From d384ae9e6c263265d0a777d9fa529f5688ea24ff Mon Sep 17 00:00:00 2001 From: NikM3 <nikolas.a.melendez@gmail.com> Date: Fri, 21 Apr 2023 17:08:04 -0400 Subject: [PATCH 1/2] Registration and Home behavioral test --- .../com/symphony/mrfit/ui/HomeActivityTest.kt | 77 +++++++++++++++++++ .../symphony/mrfit/ui/RegisterActivityTest.kt | 56 ++++++++++++++ app/src/main/res/layout/activity_home.xml | 8 +- app/src/main/res/layout/activity_register.xml | 5 +- app/src/main/res/layout/card_goal.xml | 6 +- app/src/main/res/layout/card_history.xml | 8 +- app/src/main/res/layout/card_history2.xml | 6 +- .../main/res/layout/popup_new_exercise.xml | 8 +- 8 files changed, 154 insertions(+), 20 deletions(-) create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt new file mode 100644 index 0000000..816b1ab --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt @@ -0,0 +1,77 @@ +/* + * Created by Team Symphony on 4/21/23, 5:08 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 5:03 PM + */ + +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.hamcrest.Matchers.not +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class HomeActivityTest { + + @get:Rule + var activityScenarioRule = activityScenarioRule<HomeActivity>() + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_homeActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the components are visible + */ + @Test + fun checkViewVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.homeScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.userLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.homeProfilePicture)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.homeWelcomeTextView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.homeNameTextView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + Espresso.onView(ViewMatchers.withId(R.id.homeScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.settingsCog)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.scheduleButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.pastWorkout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.workoutButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.historyList)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner)) + .check(ViewAssertions.matches(not(ViewMatchers.isDisplayed()))) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt new file mode 100644 index 0000000..b7ffa8d --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt @@ -0,0 +1,56 @@ +/* + * Created by Team Symphony on 4/21/23, 5:08 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 4:12 PM + */ + +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class RegisterActivityTest { + + @get:Rule + var activityScenarioRule = activityScenarioRule<RegisterActivity>() + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_registerActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the components are visible + */ + @Test + fun checkViewVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.registerEmail)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.registerPassword)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.confirmPassword)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.registerButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.toLoginTextView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 295a307..f8932ab 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 4/21/23, 3:22 PM + ~ Created by Team Symphony on 4/21/23, 5:08 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/21/23, 3:17 PM + ~ Last modified 4/21/23, 4:39 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" @@ -49,7 +49,7 @@ android:orientation="vertical"> <TextView - android:id="@+id/templateNameTextView" + android:id="@+id/homeWelcomeTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/welcome" @@ -67,7 +67,7 @@ </LinearLayout> <ImageView - android:id="@+id/imageView" + android:id="@+id/settingsCog" android:layout_width="30dp" android:layout_height="30dp" android:layout_margin="5dp" diff --git a/app/src/main/res/layout/activity_register.xml b/app/src/main/res/layout/activity_register.xml index f09f774..1484b7c 100644 --- a/app/src/main/res/layout/activity_register.xml +++ b/app/src/main/res/layout/activity_register.xml @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 4/7/23, 7:13 PM + ~ Created by Team Symphony on 4/21/23, 5:08 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/7/23, 6:43 PM + ~ Last modified 4/21/23, 4:12 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/layout_registerActivity" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.RegisterActivity"> diff --git a/app/src/main/res/layout/card_goal.xml b/app/src/main/res/layout/card_goal.xml index 19f701f..8b5eb3a 100644 --- a/app/src/main/res/layout/card_goal.xml +++ b/app/src/main/res/layout/card_goal.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?><!-- - ~ Created by Team Symphony on 4/2/23, 3:50 AM + ~ Created by Team Symphony on 4/21/23, 5:08 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/2/23, 1:29 AM + ~ Last modified 4/21/23, 5:00 PM --> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" @@ -24,7 +24,7 @@ will add padding in API v21+ as well to have the same measurements with previous <LinearLayout android:layout_width="match_parent" - android:layout_height="70dp" + android:layout_height="wrap_content" android:gravity="center" android:padding="10dp"> diff --git a/app/src/main/res/layout/card_history.xml b/app/src/main/res/layout/card_history.xml index 4310e13..ce212b3 100644 --- a/app/src/main/res/layout/card_history.xml +++ b/app/src/main/res/layout/card_history.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?><!-- - ~ Created by Team Symphony on 4/1/23, 4:23 AM + ~ Created by Team Symphony on 4/21/23, 5:08 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/1/23, 4:20 AM + ~ Last modified 4/21/23, 5:00 PM --> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" @@ -25,7 +25,7 @@ will add padding in API v21+ as well to have the same measurements with previous <LinearLayout android:layout_width="match_parent" - android:layout_height="70dp" + android:layout_height="wrap_content" android:background="@drawable/border_thick" android:gravity="center"> @@ -42,7 +42,7 @@ will add padding in API v21+ as well to have the same measurements with previous <LinearLayout android:layout_width="wrap_content" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_weight="1" android:gravity="right" android:orientation="vertical" diff --git a/app/src/main/res/layout/card_history2.xml b/app/src/main/res/layout/card_history2.xml index b601639..0f3e0fe 100644 --- a/app/src/main/res/layout/card_history2.xml +++ b/app/src/main/res/layout/card_history2.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?><!-- - ~ Created by Team Symphony on 4/2/23, 3:50 AM + ~ Created by Team Symphony on 4/21/23, 5:08 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/2/23, 1:29 AM + ~ Last modified 4/21/23, 5:00 PM --> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" @@ -24,7 +24,7 @@ will add padding in API v21+ as well to have the same measurements with previous <LinearLayout android:layout_width="match_parent" - android:layout_height="70dp" + android:layout_height="wrap_content" android:gravity="center" android:padding="10dp"> diff --git a/app/src/main/res/layout/popup_new_exercise.xml b/app/src/main/res/layout/popup_new_exercise.xml index 6b6e2d8..6958cbc 100644 --- a/app/src/main/res/layout/popup_new_exercise.xml +++ b/app/src/main/res/layout/popup_new_exercise.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?><!-- - ~ Created by Team Symphony on 4/20/23, 1:04 AM + ~ Created by Team Symphony on 4/21/23, 5:08 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/20/23, 1:04 AM + ~ Last modified 4/21/23, 5:00 PM --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" @@ -54,7 +54,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_tags" - android:inputType="textMultiLine|text" /> + android:inputType="textLongMessage|text" /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.textfield.TextInputLayout @@ -67,7 +67,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_description" - android:inputType="textLongMessage|textMultiLine|text" /> + android:inputType="textLongMessage|text" /> </com.google.android.material.textfield.TextInputLayout> <TextView From 490e995c0fede4c8f065aa584035e3df7888d80d Mon Sep 17 00:00:00 2001 From: NikM3 <nikolas.a.melendez@gmail.com> Date: Fri, 21 Apr 2023 22:19:01 -0400 Subject: [PATCH 2/2] A bunch of basic behavioral tests for #75 --- app/build.gradle | 29 +++--- .../com/symphony/mrfit/ui/ExerciseTest.kt | 69 +++++++++++++ .../com/symphony/mrfit/ui/HomeActivityTest.kt | 12 ++- .../mrfit/ui/TemplateSelectionActivityTest.kt | 60 +++++++++++ .../mrfit/ui/UserProfileActivityTest.kt | 99 +++++++++++++++++++ .../mrfit/ui/WorkoutRoutineActivityTest.kt | 92 +++++++++++++++++ .../mrfit/ui/WorkoutTemplateActivityTest.kt | 85 ++++++++++++++++ .../mrfit/ui/WorkoutRoutineActivity.kt | 6 +- app/src/main/res/layout/activity_exercise.xml | 6 +- .../res/layout/activity_routine_selection.xml | 5 +- .../main/res/layout/activity_user_profile.xml | 10 +- .../res/layout/activity_workout_routine.xml | 5 +- .../res/layout/activity_workout_template.xml | 23 ++--- 13 files changed, 461 insertions(+), 40 deletions(-) create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/ExerciseTest.kt create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/TemplateSelectionActivityTest.kt create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutRoutineActivityTest.kt create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutTemplateActivityTest.kt diff --git a/app/build.gradle b/app/build.gradle index 2854a2e..04ce123 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,22 +42,23 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.core:core-ktx:1.10.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'com.google.firebase:firebase-database-ktx:20.1.0' - implementation 'com.google.firebase:firebase-database:20.1.0' + implementation 'com.google.firebase:firebase-database-ktx:20.2.0' + implementation 'com.google.firebase:firebase-database:20.2.0' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.0" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.0" + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1' implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' // Testing dependencies + implementation 'androidx.arch.core:core-testing:2.2.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.junit.jupiter:junit-jupiter' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test:runner:1.5.2' @@ -66,13 +67,17 @@ dependencies { androidTestImplementation 'androidx.test:core-ktx:1.5.0' androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5' + // https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy + implementation 'net.bytebuddy:byte-buddy-android:1.14.4' + // Optional -- Mockito framework - testImplementation 'org.mockito:mockito-core:5.0.0' + testImplementation 'org.mockito:mockito-core:5.3.1' + testImplementation 'org.mockito:mockito-android:5.3.1' testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0' - testImplementation 'io.mockk:mockk:1.13.4' + testImplementation 'io.mockk:mockk:1.13.5' // Import the BoM for the Firebase platform - implementation platform('com.google.firebase:firebase-bom:31.1.0') + implementation platform('com.google.firebase:firebase-bom:31.5.0') // Add the dependency for the Firebase library // When using the BoM, you don't specify versions in Firebase library dependencies @@ -95,11 +100,11 @@ dependencies { implementation 'com.firebaseui:firebase-ui-storage:8.0.2' // Also add the dependency for the Google Play services library and specify its version - implementation 'com.google.android.gms:play-services-auth:20.4.1' + implementation 'com.google.android.gms:play-services-auth:20.5.0' // Add the dependency for Glide - implementation 'com.github.bumptech.glide:glide:4.15.0' - kapt 'com.github.bumptech.glide:compiler:4.15.0' + implementation 'com.github.bumptech.glide:glide:4.15.1' + kapt 'com.github.bumptech.glide:compiler:4.15.1' // Konfetti by https://github.com/DanielMartinus/Konfetti implementation 'nl.dionsegijn:konfetti-xml:2.0.2' diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/ExerciseTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/ExerciseTest.kt new file mode 100644 index 0000000..eeeef0e --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/ExerciseTest.kt @@ -0,0 +1,69 @@ +/* + * Created by Team Symphony on 4/21/23, 10:18 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 10:18 PM + */ + +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.hamcrest.Matchers +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class ExerciseTest { + + @Before + fun setUp() { + } + + @get:Rule + var activityScenarioRule = activityScenarioRule<ExerciseActivity>() + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_exerciseSelectionActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the appropriate components are visible + */ + @Test + fun checkViewVisibility() { + Thread.sleep(500) + Espresso.onView(ViewMatchers.withId(R.id.exerciseScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.exerciseListView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.exerciseSearchTextView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.exerciseSearchEditText)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.exerciseSearchButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.button2)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt index 816b1ab..f6576e3 100644 --- a/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/21/23, 5:08 PM + * Created by Team Symphony on 4/21/23, 10:18 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/21/23, 5:03 PM + * Last modified 4/21/23, 10:18 PM */ package com.symphony.mrfit.ui @@ -14,6 +14,7 @@ import androidx.test.filters.LargeTest import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner import com.symphony.mrfit.R import org.hamcrest.Matchers.not +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -22,6 +23,10 @@ import org.junit.runner.RunWith @LargeTest class HomeActivityTest { + @Before + fun setUp() { + } + @get:Rule var activityScenarioRule = activityScenarioRule<HomeActivity>() @@ -35,10 +40,11 @@ class HomeActivityTest { } /** - * Test if all the components are visible + * Test if all the appropriate components are visible */ @Test fun checkViewVisibility() { + Thread.sleep(1000) Espresso.onView(ViewMatchers.withId(R.id.homeScreenView)) .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/TemplateSelectionActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/TemplateSelectionActivityTest.kt new file mode 100644 index 0000000..b63420f --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/TemplateSelectionActivityTest.kt @@ -0,0 +1,60 @@ +/* + * Created by Team Symphony on 4/21/23, 10:18 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 9:24 PM + */ + +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.hamcrest.Matchers +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class TemplateSelectionActivityTest { + + @Before + fun setUp() { + } + + @get:Rule + var activityScenarioRule = activityScenarioRule<RoutineSelectionActivity>() + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_selectionActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the appropriate components are visible + */ + @Test + fun checkViewVisibility() { + Thread.sleep(500) + Espresso.onView(ViewMatchers.withId(R.id.selectionScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.routineListView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.newWorkoutButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt new file mode 100644 index 0000000..851d757 --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/UserProfileActivityTest.kt @@ -0,0 +1,99 @@ +/* + * Created by Team Symphony on 4/21/23, 10:18 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 8:55 PM + */ + +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.hamcrest.Matchers +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class UserProfileActivityTest { + + @Before + fun setUp() { + } + + @get:Rule + var activityScenarioRule = activityScenarioRule<UserProfileActivity>() + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_profileActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the appropriate components are visible + */ + @Test + fun checkViewVisibility() { + Thread.sleep(500) + Espresso.onView(ViewMatchers.withId(R.id.profileScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.profilePicture)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.profileNameTextView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.editProfileButton)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + + Espresso.onView(ViewMatchers.withId(R.id.heightLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.weightLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.ageLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.stuffLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.goalsButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.notificationsButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.historyButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.customExercisesButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.settingLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.notificationToggle)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + + Espresso.onView(ViewMatchers.withId(R.id.logoutButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.deleteButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutRoutineActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutRoutineActivityTest.kt new file mode 100644 index 0000000..317caf6 --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutRoutineActivityTest.kt @@ -0,0 +1,92 @@ +/* + * Created by Team Symphony on 4/21/23, 10:18 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 10:18 PM + */ + +package com.symphony.mrfit.ui + +import android.content.Intent +import androidx.test.core.app.ApplicationProvider +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.hamcrest.Matchers +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class WorkoutRoutineActivityTest { + + @Before + fun setUp() { + } + + @get:Rule + var activityScenarioRule = activityScenarioRule<WorkoutRoutineActivity>( + intent = Intent( + ApplicationProvider.getApplicationContext(), + WorkoutRoutineActivity::class.java + ) + .putExtra(WorkoutTemplateActivity.EXTRA_IDENTITY, "test") + ) + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_workoutBuilderActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the appropriate components are visible + */ + @Test + fun checkViewVisibility() { + Thread.sleep(1000) + Espresso.onView(ViewMatchers.withId(R.id.routineScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.headerLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.routineNameEditText)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.workoutPlaylistEditText)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.openPlaylistButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.workoutListView)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + + Espresso.onView(ViewMatchers.withId(R.id.routineScreenButtons)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.startWorkoutButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.newExerciseButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.saveWorkoutButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.deleteWorkoutButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner)) + .check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed()))) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutTemplateActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutTemplateActivityTest.kt new file mode 100644 index 0000000..e96a27b --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/WorkoutTemplateActivityTest.kt @@ -0,0 +1,85 @@ +/* + * Created by Team Symphony on 4/21/23, 10:18 PM + * Copyright (c) 2023 . All rights reserved. + * Last modified 4/21/23, 10:18 PM + */ + +package com.symphony.mrfit.ui + +import android.content.Intent +import androidx.test.core.app.ApplicationProvider +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.filters.LargeTest +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import com.symphony.mrfit.R +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4ClassRunner::class) +@LargeTest +class WorkoutTemplateActivityTest { + + @Before + fun setUp() { + } + + @get:Rule + var activityScenarioRule = activityScenarioRule<WorkoutTemplateActivity>( + intent = Intent( + ApplicationProvider.getApplicationContext(), + WorkoutTemplateActivity::class.java + ) + .putExtra(WorkoutRoutineActivity.EXTRA_ROUTINE, "test") + .putExtra(WorkoutTemplateActivity.EXTRA_IDENTITY, "test") + .putExtra(WorkoutTemplateActivity.EXTRA_EXERCISE, "test") + .putExtra(WorkoutTemplateActivity.EXTRA_LIST, ArrayList<String>()) + ) + + /** + * Test if the activity is displayed and visible to user + */ + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_exerciseBuilderActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + /** + * Test if all the appropriate components are visible + */ + @Test + fun checkViewVisibility() { + Thread.sleep(500) + Espresso.onView(ViewMatchers.withId(R.id.templateScreenView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.exerciseCardView)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.editDuration)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.editDistance)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.repsAndSetsLayout)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.editReps)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.editSets)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.deleteTemplateButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.saveTemplateButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt b/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt index 7fc296b..51fd8bb 100644 --- a/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt +++ b/app/src/main/java/com/symphony/mrfit/ui/WorkoutRoutineActivity.kt @@ -1,7 +1,7 @@ /* - * Created by Team Symphony on 4/20/23, 2:11 AM + * Created by Team Symphony on 4/21/23, 10:18 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/20/23, 2:08 AM + * Last modified 4/21/23, 9:57 PM */ package com.symphony.mrfit.ui @@ -81,7 +81,6 @@ class WorkoutRoutineActivity : AppCompatActivity() { placeholderText.visibility = View.VISIBLE workoutList.visibility = View.GONE - spinner.visibility = View.VISIBLE /** * Retrieve the extras passed to this intent @@ -109,6 +108,7 @@ class WorkoutRoutineActivity : AppCompatActivity() { routinePlaylist.setText(BLANK) } if (routine.workoutList != null) { + spinner.visibility = View.VISIBLE placeholderText.visibility = View.GONE workoutList.visibility = View.VISIBLE passedList = routine.workoutList diff --git a/app/src/main/res/layout/activity_exercise.xml b/app/src/main/res/layout/activity_exercise.xml index 5a040ec..290e077 100644 --- a/app/src/main/res/layout/activity_exercise.xml +++ b/app/src/main/res/layout/activity_exercise.xml @@ -1,19 +1,21 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 4/7/23, 7:13 PM + ~ Created by Team Symphony on 4/21/23, 10:18 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/7/23, 7:12 PM + ~ Last modified 4/21/23, 10:16 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/layout_exerciseSelectionActivity" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.ExerciseActivity"> <LinearLayout + android:id="@+id/exerciseScreenView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" diff --git a/app/src/main/res/layout/activity_routine_selection.xml b/app/src/main/res/layout/activity_routine_selection.xml index ec3be1f..b682128 100644 --- a/app/src/main/res/layout/activity_routine_selection.xml +++ b/app/src/main/res/layout/activity_routine_selection.xml @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 2/24/23, 11:21 PM + ~ Created by Team Symphony on 4/21/23, 10:18 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 2/24/23, 11:20 PM + ~ Last modified 4/21/23, 9:24 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/layout_selectionActivity" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.RoutineSelectionActivity"> diff --git a/app/src/main/res/layout/activity_user_profile.xml b/app/src/main/res/layout/activity_user_profile.xml index f98d3de..a284916 100644 --- a/app/src/main/res/layout/activity_user_profile.xml +++ b/app/src/main/res/layout/activity_user_profile.xml @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 4/19/23, 5:18 PM + ~ Created by Team Symphony on 4/21/23, 10:18 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/19/23, 5:06 PM + ~ Last modified 4/21/23, 8:40 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/layout_profileActivity" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.UserProfileActivity"> @@ -15,7 +16,9 @@ <ScrollView android:id="@+id/profileScreenView" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> <LinearLayout android:layout_width="match_parent" @@ -208,6 +211,7 @@ android:text="@string/label_settings" /> <LinearLayout + android:id="@+id/notificationToggle" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" diff --git a/app/src/main/res/layout/activity_workout_routine.xml b/app/src/main/res/layout/activity_workout_routine.xml index 1a09085..a16f4d9 100644 --- a/app/src/main/res/layout/activity_workout_routine.xml +++ b/app/src/main/res/layout/activity_workout_routine.xml @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 4/2/23, 1:04 AM + ~ Created by Team Symphony on 4/21/23, 10:18 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/2/23, 1:01 AM + ~ Last modified 4/21/23, 9:24 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/layout_workoutBuilderActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" diff --git a/app/src/main/res/layout/activity_workout_template.xml b/app/src/main/res/layout/activity_workout_template.xml index 5f9fc14..ce8a588 100644 --- a/app/src/main/res/layout/activity_workout_template.xml +++ b/app/src/main/res/layout/activity_workout_template.xml @@ -1,27 +1,24 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Created by Team Symphony on 4/19/23, 4:10 PM + ~ Created by Team Symphony on 4/21/23, 10:18 PM ~ Copyright (c) 2023 . All rights reserved. - ~ Last modified 4/19/23, 4:07 PM + ~ Last modified 4/21/23, 10:16 PM --> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/layout_exerciseBuilderActivity" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".data.model.Workout"> <LinearLayout - android:layout_width="380dp" - android:layout_height="699dp" - android:layout_marginStart="17dp" - android:layout_marginTop="17dp" - android:layout_marginEnd="14dp" - android:layout_marginBottom="15dp" + android:id="@+id/templateScreenView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_margin="15dp" android:orientation="vertical" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -33,8 +30,8 @@ android:visibility="visible" /> <com.google.android.material.textfield.TextInputLayout - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense" android:id="@+id/durationLayout" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"> @@ -84,8 +81,8 @@ android:layout_height="wrap_content" android:layout_marginEnd="5dp" android:layout_weight="1" - android:hint="@string/hint_reps" android:digits="0123456789." + android:hint="@string/hint_reps" android:inputType="numberDecimal" android:maxLength="4" android:visibility="visible" /> @@ -105,8 +102,8 @@ android:layout_height="wrap_content" android:layout_marginStart="5dp" android:layout_weight="1" - android:hint="@string/hint_sets" android:digits="0123456789." + android:hint="@string/hint_sets" android:inputType="numberDecimal" android:maxLength="4" /> </com.google.android.material.textfield.TextInputLayout>