From 6f20a6258bf1f1526cadbb12bdead9f8d7cf2046 Mon Sep 17 00:00:00 2001 From: nicolekaate Date: Sat, 22 Apr 2023 19:43:42 -0400 Subject: [PATCH] basic unit tests #75 --- .../mrfit/ui/NotificationActivityTest.kt | 45 +++++++++++++++++++ .../mrfit/ui/PostWorkoutActivityTest.kt | 41 +++++++++++++++++ .../symphony/mrfit/ui/RegisterActivityTest.kt | 2 + .../main/res/layout/activity_notification.xml | 1 + .../main/res/layout/activity_post_workout.xml | 1 + 5 files changed, 90 insertions(+) create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/NotificationActivityTest.kt create mode 100644 app/src/androidTest/java/com/symphony/mrfit/ui/PostWorkoutActivityTest.kt diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/NotificationActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/NotificationActivityTest.kt new file mode 100644 index 0000000..f5eff35 --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/NotificationActivityTest.kt @@ -0,0 +1,45 @@ +package com.symphony.mrfit.ui + +import androidx.test.espresso.Espresso +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import com.symphony.mrfit.R +import org.junit.Assert.* + +import org.junit.Test +import org.mockito.Mockito; +import org.mockito.Mockito.`when` + + +class NotificationActivityTest { + + //TODO: cant figure out tests for notif activity + + /*@Test + fun getHasNotificationPermissionGranted() { + + } + + @Test + fun setHasNotificationPermissionGranted() { + + }*/ + + //tests if the activity is displayed and visible to user + /*@Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_notifActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + //tests if date picker and time picker are visible + @Test + fun checkViewVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.datePicker)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.timePicker)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + }*/ +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/symphony/mrfit/ui/PostWorkoutActivityTest.kt b/app/src/androidTest/java/com/symphony/mrfit/ui/PostWorkoutActivityTest.kt new file mode 100644 index 0000000..3e355c6 --- /dev/null +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/PostWorkoutActivityTest.kt @@ -0,0 +1,41 @@ +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 com.symphony.mrfit.R +import org.junit.Assert.* +import org.junit.Rule + +import org.junit.Test + +class PostWorkoutActivityTest { + + @get:Rule + var activityScenarioRule = activityScenarioRule() + + //tests if the activity is displayed and visible to user + @Test + fun checkActivityVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.layout_postWorkoutActivity)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } + + //tests if components are visible + @Test + fun checkViewVisibility() { + Espresso.onView(ViewMatchers.withId(R.id.postWorkoutTitle)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.postWorkoutTime)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + /*Espresso.onView(ViewMatchers.withId(R.id.gotoGoalsButton)) + .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + + Espresso.onView(ViewMatchers.withId(R.id.returnHomeButton)) + .check(ViewAssertions.matches(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 index 674ca5f..7b20abc 100644 --- a/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt +++ b/app/src/androidTest/java/com/symphony/mrfit/ui/RegisterActivityTest.kt @@ -18,6 +18,8 @@ class RegisterActivityTest { @get:Rule var activityScenarioRule = activityScenarioRule() + + /*tests if register works*/ @Test fun checkValidRegister() { diff --git a/app/src/main/res/layout/activity_notification.xml b/app/src/main/res/layout/activity_notification.xml index fab5cbd..4b54fcf 100644 --- a/app/src/main/res/layout/activity_notification.xml +++ b/app/src/main/res/layout/activity_notification.xml @@ -8,6 +8,7 @@