Skip to content

Commit

Permalink
Merge branch 'NicoleCalderon' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
NikM3 committed Apr 23, 2023
2 parents 0708bda + 6f20a62 commit ce019f9
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For both types of tests, start by going into *Run* > *Edit Configurations*

For unit tests, create a new JUnit4 test. For the module select `MrFit.app.unitTest`, and then select the class of the unit test you want to run.

To run behavioral tests, create a new Android Instrumented Test pointed at `MrFit.app.androidTest`, then run this new configuration.
To run behavioral tests, ![](../../AppData/Local/Temp/profilepicturev2.jpg)create a new Android Instrumented Test pointed at `MrFit.app.androidTest`, then run this new configuration.

# Authors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,35 @@

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.Rule
import org.junit.Test

class GoalsActivityTest {
@get:Rule
var activityScenarioRule = activityScenarioRule<GoalsActivity>()

//TODO
//TODO: added simple tests, worked on mine but check if needs more
//tests if the activity is displayed and visible to user
@Test
fun checkActivityVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.layout_goalsActivity))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

//tests if components are visible
@Test
fun checkViewVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.goalsTitleTextView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.goalsList))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

}
}

Original file line number Diff line number Diff line change
@@ -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()))
}*/
}
Original file line number Diff line number Diff line change
@@ -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<PostWorkoutActivity>()

//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()))*/

}
}
Original file line number Diff line number Diff line change
@@ -1,57 +1,48 @@
/*
* Created by Team Symphony on 4/22/23, 6:21 AM
* Copyright (c) 2023 . All rights reserved.
* Last modified 4/22/23, 6:05 AM
*/

package com.symphony.mrfit.ui

import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
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 androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.symphony.mrfit.R
import org.junit.Assert.*
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
*/


/*tests if register works*/
@Test
fun checkActivityVisibility() {
Espresso.onView(withId(R.id.layout_registerActivity))
.check(matches(isDisplayed()))
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())
}

/**
* Test if all the components are visible
*/
/*tests if empty email/pass gives error*/
@Test
fun checkViewVisibility() {
Espresso.onView(withId(R.id.registerEmail))
.check(matches(isDisplayed()))

Espresso.onView(withId(R.id.registerPassword))
.check(matches(isDisplayed()))

Espresso.onView(withId(R.id.confirmPassword))
.check(matches(isDisplayed()))
fun checkInvalidRegister() {
onView(withId(R.id.registerEmail))
.perform(ViewActions.typeText(TEST_EMAIL))
}

Espresso.onView(withId(R.id.registerButton))
.check(matches(isDisplayed()))
companion object {

Espresso.onView(withId(R.id.toLoginTextView))
.check(matches(isDisplayed()))
const val REAL_EMAIL = "[email protected]"
const val REAL_PASS = "abcd1234"
const val TEST_EMAIL = ""
const val TEST_PASS = ""
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_notifActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_post_workout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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_postWorkoutActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.PostWorkoutActivity">
Expand Down

0 comments on commit ce019f9

Please sign in to comment.