From d384ae9e6c263265d0a777d9fa529f5688ea24ff Mon Sep 17 00:00:00 2001 From: NikM3 Date: Fri, 21 Apr 2023 17:08:04 -0400 Subject: [PATCH 01/18] 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() + + /** + * 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() + + /** + * 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 @@ 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 @@ 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 @@ @@ -42,7 +42,7 @@ will add padding in API v21+ as well to have the same measurements with previous 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 @@ + android:inputType="textLongMessage|text" /> + android:inputType="textLongMessage|text" /> Date: Fri, 21 Apr 2023 19:39:31 -0400 Subject: [PATCH 02/18] unit test for register user #75 --- .../symphony/mrfit/ui/RegisterActivityTest.kt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt 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..674ca5f --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt @@ -0,0 +1,46 @@ +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.ext.junit.rules.activityScenarioRule +import com.symphony.mrfit.R +import org.junit.Assert.* +import org.junit.Rule + +import org.junit.Test + +class RegisterActivityTest { + + @get:Rule + var activityScenarioRule = activityScenarioRule() + + /*tests if register works*/ + @Test + fun checkValidRegister() { + onView(withId(R.id.registerEmail)) + .perform(ViewActions.typeText(REAL_EMAIL)) + onView(withId(R.id.registerPassword)) + .perform(ViewActions.typeText(LoginActivityTest.REAL_PASS), ViewActions.closeSoftKeyboard()) + onView(withId(R.id.registerButton)) + .perform(ViewActions.click()) + } + + /*tests if empty email/pass gives error*/ + @Test + fun checkInvalidRegister() { + onView(withId(R.id.registerEmail)) + .perform(ViewActions.typeText(TEST_EMAIL)) + } + + companion object { + + const val REAL_EMAIL = "testregister@symphony.com" + const val REAL_PASS = "abcd1234" + const val TEST_EMAIL = "" + const val TEST_PASS = "" + } +} \ No newline at end of file From 490e995c0fede4c8f065aa584035e3df7888d80d Mon Sep 17 00:00:00 2001 From: NikM3 Date: Fri, 21 Apr 2023 22:19:01 -0400 Subject: [PATCH 03/18] 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() + + /** + * 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() @@ -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() + + /** + * 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() + + /** + * 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( + 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( + 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()) + ) + + /** + * 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 @@ 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 @@ @@ -15,7 +16,9 @@ + android:layout_height="match_parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> @@ -33,8 +30,8 @@ android:visibility="visible" /> @@ -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" /> From 0f153591bb949dd6b8e1f5f06ad89d34f9ac0f51 Mon Sep 17 00:00:00 2001 From: NikM3 Date: Fri, 21 Apr 2023 22:36:54 -0400 Subject: [PATCH 04/18] Minor UI fixes --- .../symphony/mrfit/ui/CurrentWorkoutActivity.kt | 9 ++++----- .../symphony/mrfit/ui/WorkoutRoutineActivity.kt | 16 +++++++++------- .../main/res/layout/activity_post_workout.xml | 5 ++--- .../res/layout/activity_workout_routine.xml | 17 +++++++++++------ app/src/main/res/layout/card_history.xml | 6 ++---- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/symphony/mrfit/ui/CurrentWorkoutActivity.kt b/app/src/main/java/com/symphony/mrfit/ui/CurrentWorkoutActivity.kt index e81a7f1..3a8bb0d 100644 --- a/app/src/main/java/com/symphony/mrfit/ui/CurrentWorkoutActivity.kt +++ b/app/src/main/java/com/symphony/mrfit/ui/CurrentWorkoutActivity.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:36 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/20/23, 2:11 AM + * Last modified 4/21/23, 10:36 PM */ package com.symphony.mrfit.ui @@ -134,16 +134,15 @@ class CurrentWorkoutActivity : AppCompatActivity() { .inflate(R.layout.activity_post_workout, null, false) materialDialog.setView(dialogView) - .setTitle("Post Exercise") val text = dialogView.findViewById(R.id.postWorkoutTime) val startTime = SimpleDateFormat( - "'You started this workout at' hh:mm a", + "'You started this workout at 'hh:mm a", Locale.getDefault() ) .format(Date().time - timeSpent) val endTime = SimpleDateFormat( - "' and finished at ' hh:mm a", + "' and finished at 'hh:mm a", Locale.getDefault() ) .format(Date()) 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 51fd8bb..f879436 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/21/23, 10:18 PM + * Created by Team Symphony on 4/21/23, 10:36 PM * Copyright (c) 2023 . All rights reserved. - * Last modified 4/21/23, 9:57 PM + * Last modified 4/21/23, 10:26 PM */ package com.symphony.mrfit.ui @@ -108,11 +108,13 @@ 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 - exerciseViewModel.getWorkouts(routine.workoutList) + if (routine.workoutList.isNotEmpty()) { + spinner.visibility = View.VISIBLE + placeholderText.visibility = View.GONE + workoutList.visibility = View.VISIBLE + passedList = routine.workoutList + exerciseViewModel.getWorkouts(routine.workoutList) + } } }) exerciseViewModel.workoutList.observe(this, Observer { diff --git a/app/src/main/res/layout/activity_post_workout.xml b/app/src/main/res/layout/activity_post_workout.xml index d34401a..a1f27bd 100644 --- a/app/src/main/res/layout/activity_post_workout.xml +++ b/app/src/main/res/layout/activity_post_workout.xml @@ -1,8 +1,8 @@ + android:textAlignment="center" + android:textColor="@color/black" + android:textColorHint="@color/black" /> + android:layout_weight="1" + android:textColorHint="@color/material_dynamic_neutral40"> + android:hint="@string/workout_playlist" + android:textColor="@color/black" + android:textColorHint="@color/black" />