diff --git a/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt index 9d1627e78..276dca4a5 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/activity/AuthenticationActivityTest.kt @@ -123,16 +123,11 @@ class AuthenticationActivityTest { } @Test - fun stringValidationEmptyUsername() { + fun stringValidationEmptyFields() { onView(withId(R.id.createAcc)).perform(click()) onView(withId(R.id.authentication_status)).check(matches(withText("Empty email or password"))) } - @Test - fun stringValidationEmptyUPassword() { - onView(withId(R.id.createAcc)).perform(click()) - onView(withId(R.id.authentication_status)).check(matches(withText("Empty email or password"))) - } @Test fun returnToMain() { @@ -143,8 +138,8 @@ class AuthenticationActivityTest { @Test fun stringValidationWrongEmail() { - val username = "john" - val password = "password" + val username = "j" + val password = "passwo" onView(withId(R.id.username)).perform(ViewActions.typeText(username), closeSoftKeyboard()) onView(withId(R.id.password)).perform(ViewActions.typeText(password), closeSoftKeyboard()) @@ -155,8 +150,8 @@ class AuthenticationActivityTest { @Test fun stringValidationShorPassword() { - val username = "john@test.com" - val password = "12345" + val username = "u@u.c" + val password = "1" onView(withId(R.id.username)).perform(ViewActions.typeText(username), closeSoftKeyboard()) onView(withId(R.id.password)).perform(ViewActions.typeText(password), closeSoftKeyboard()) @@ -168,8 +163,8 @@ class AuthenticationActivityTest { @Test fun logInCorrect() { - val username = "mockUsername@test.com" - val password = "password" + val username = "u@u.c" + val password = "passwo" val mockTask = createMockTask(true) val mockUser = createMockUser(username) @@ -186,8 +181,8 @@ class AuthenticationActivityTest { @Test fun createAccountCorrect() { - val username = "user@user.com" - val password = "password" + val username = "u@u.c" + val password = "passwo" TestMode.setTest() diff --git a/app/src/androidTest/java/ch/sdp/vibester/activity/BuzzerSetupActivityTest.kt b/app/src/androidTest/java/ch/sdp/vibester/activity/BuzzerSetupActivityTest.kt index af4a75430..af904074d 100644 --- a/app/src/androidTest/java/ch/sdp/vibester/activity/BuzzerSetupActivityTest.kt +++ b/app/src/androidTest/java/ch/sdp/vibester/activity/BuzzerSetupActivityTest.kt @@ -37,10 +37,11 @@ class BuzzerSetupActivityTest { @get:Rule(order = 1) val activityRule = ActivityScenarioRule(BuzzerSetupActivity::class.java) - val mockArray = arrayOf("Player1", "Player2", "Player3", "Player4") + val mockArray = arrayOf("1", "2", "3", "4") val editTextIdArray = arrayOf(R.id.namePlayer1, R.id.namePlayer2, R.id.namePlayer3, R.id.namePlayer4) - /** helper function used in tests + /** + * helper function used in tests * @param n: number of names to enter */ private fun enterNames(n: Int) { @@ -84,16 +85,17 @@ class BuzzerSetupActivityTest { return gameManager } - @Test - fun checkDefaultSelect() { - onView(withId(R.id.nb_player_spinner)).check(matches(withSpinnerText("One"))) - } @Test - fun textToNumberWrong(){ + fun variousDefaultStateTest(){ var res:Int = 0 val intent = Intent(ApplicationProvider.getApplicationContext(), BuzzerSetupActivity::class.java) val scn: ActivityScenario = ActivityScenario.launch(intent) + + //Check default selection + onView(withId(R.id.nb_player_spinner)).check(matches(withSpinnerText("One"))) + + //Wrong Text to Number scn.onActivity { activity -> res = activity.textToNumber("Test") } @@ -123,47 +125,7 @@ class BuzzerSetupActivityTest { assertEquals(4, res) } - @Test - fun checkCustomSelectOne() { - onView(withId(R.id.nb_player_spinner)).perform(click()) - onData(Matchers.anything()).atPosition(0).perform(scrollTo(),click()) - onView(withId(R.id.nb_player_spinner)).check(matches(withSpinnerText("One"))) - } - - @Test - fun checkCustomSelectTwo() { - onView(withId(R.id.nb_player_spinner)).perform(click()) - onData(Matchers.anything()).atPosition(1).perform(scrollTo(),click()) - onView(withId(R.id.nb_player_spinner)).check(matches(withSpinnerText("Two"))) - } - @Test - fun checkCustomSelectThree() { - onView(withId(R.id.nb_player_spinner)).perform(click()) - onData(Matchers.anything()).atPosition(2).perform(scrollTo(),click()) - onView(withId(R.id.nb_player_spinner)).check(matches(withSpinnerText("Three"))) - } - - @Test - fun checkCustomSelectFour() { - onView(withId(R.id.nb_player_spinner)).perform(click()) - onData(Matchers.anything()).atPosition(3).perform(scrollTo(),click()) - onView(withId(R.id.nb_player_spinner)).check(matches(withSpinnerText("Four"))) - } -/* - @Test - fun checkNoIntentIfMissingName() { - val intent = Intent(ApplicationProvider.getApplicationContext(), BuzzerSetupActivity::class.java) - intent.putExtra("gameManager", setGameManager()) - val scn: ActivityScenario = ActivityScenario.launch(intent) - onView(withId(R.id.missingNameAlert)).check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))) - onView(withId(R.id.nb_players_selected)).perform(click()) - onView(withId(R.id.missingNameAlert)).check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - onView(withId(R.id.missingNameOk)).perform(click()) - onView(withId(R.id.missingNameAlert)).check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))) - - } -*/ @Test fun checkIntentOnProceedOne() { val intent = Intent(ApplicationProvider.getApplicationContext(), BuzzerSetupActivity::class.java)