Skip to content

Commit

Permalink
Merge pull request #39 from EmsadS/develop
Browse files Browse the repository at this point in the history
TL-010 Fixed all tests and added small fixes
  • Loading branch information
Irma1997 authored Jun 10, 2021
2 parents f114fe8 + 4002d04 commit 11ee2d0
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 117 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,18 @@ class FilterActivityTest : TestCase() {
// check if the recycler view is visible
onView(withId(R.id.filterRecyclerView)).check(matches(isDisplayed()))

Thread.sleep(1500);
assertTrue(activityFilter.activity.subjectAdapter.getSubjects().size > 0)

// test select subject
onView(withId(R.id.filterRecyclerView)).perform(actionOnItemAtPosition<RecyclerViewAdapter.ViewHolder>(4, click()))
onView(withId(R.id.filterRecyclerView)).perform(actionOnItemAtPosition<RecyclerViewAdapter.ViewHolder>(0, click()))

assertTrue(activityFilter.activity.subjectAdapter.getSubjects()[4].isSelected)
assertTrue(activityFilter.activity.subjectAdapter.getSubjects()[0].isSelected)

//test unselect subject
onView(withId(R.id.filterRecyclerView)).perform(actionOnItemAtPosition<RecyclerViewAdapter.ViewHolder>(4, click()))
onView(withId(R.id.filterRecyclerView)).perform(actionOnItemAtPosition<RecyclerViewAdapter.ViewHolder>(0, click()))

assertFalse(activityFilter.activity.subjectAdapter.getSubjects()[4].isSelected)
assertFalse(activityFilter.activity.subjectAdapter.getSubjects()[0].isSelected)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class LoginRegisterTest {

@Test
fun validLogin() {
activityLogin.launchActivity(Intent())
// Type text and then press the button.
onView(withId(R.id.input_username_login))
.perform(typeText(validEmailToBetyped), closeSoftKeyboard())
Expand All @@ -107,6 +108,7 @@ class LoginRegisterTest {

@Test
fun invalidEmailLogin() {
activityLogin.launchActivity(Intent())
// Type text and then press the button.
onView(withId(R.id.input_username_login))
.perform(typeText(invalidEmailToBetyped), closeSoftKeyboard())
Expand All @@ -121,6 +123,7 @@ class LoginRegisterTest {

@Test
fun invalidPWLogin() {
activityLogin.launchActivity(Intent())
// Type text and then press the button.
onView(withId(R.id.input_username_login))
.perform(typeText(validEmailToBetyped), closeSoftKeyboard())
Expand All @@ -136,7 +139,7 @@ class LoginRegisterTest {
@Test
fun gotoRegisterclick() {

activityRegister.launchActivity(Intent())
activityLogin.launchActivity(Intent())
onView(withId(R.id.txt_gotoRegister)).perform(click())

// check
Expand Down Expand Up @@ -188,6 +191,7 @@ class LoginRegisterTest {

@Test
fun validRegister() {
activityLogin.launchActivity(Intent())
onView(withId(R.id.txt_gotoRegister)).perform(click())
// Type text and then press the button.
onView(withId(R.id.username_reg))
Expand All @@ -211,7 +215,10 @@ class LoginRegisterTest {

@Test
fun invalidRegister() {
activityLogin.launchActivity(Intent())
onView(withId(R.id.txt_gotoRegister)).perform(click())


// Type text and then press the button.
onView(withId(R.id.username_reg))
.perform(typeText(validEmailToBeregistered), closeSoftKeyboard())
Expand All @@ -234,6 +241,7 @@ class LoginRegisterTest {

@Test
fun invalidRegisterOnInvalidEmail() {
activityLogin.launchActivity(Intent())
onView(withId(R.id.txt_gotoRegister)).perform(click())
// Type text and then press the button.
onView(withId(R.id.username_reg))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class NewTutorActivityTest : TestCase(){
true,
false)

var activityMain: ActivityTestRule<MainActivity> = ActivityTestRule<MainActivity>(
MainActivity::class.java,
true,
false)

var ruleSwitchToNewTutor =
ActivityTestRule(NewTutor::class.java, true, false)

@Before
fun initIntent() {
Intents.init()
Expand All @@ -38,6 +46,30 @@ class NewTutorActivityTest : TestCase(){

@Test
fun uiTest() {
activityNewTutor.launchActivity(Intent())
Espresso.onView(ViewMatchers.withId(R.id.newTutorRecyclerView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Espresso.onView(ViewMatchers.withId(R.id.btnApply))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Espresso.onView(ViewMatchers.withId(R.id.phoneNum))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Espresso.onView(ViewMatchers.withId(R.id.btn_change_lang_new_tutor))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Espresso.onView(ViewMatchers.withId(R.id.townAutocomplete_fragment))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

@Test
fun toNewTutorActivity()
{
activityMain.launchActivity(Intent())
Espresso.onView(ViewMatchers.withId(R.id.btn_new_tutor))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Espresso.onView(ViewMatchers.withId(R.id.btn_new_tutor)).perform(ViewActions.click())

// Check that only once run
ruleSwitchToNewTutor.launchActivity(Intent())
Intents.intended(IntentMatchers.hasComponent(MainActivity::class.java.name))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ class TownSelectionTest {
private lateinit var validCity: String


@get:Rule
var townSelection: ActivityScenarioRule<TownSelection>
= ActivityScenarioRule(TownSelection::class.java)
var ruleFromMainTownSelection =
ActivityTestRule(MainActivity::class.java, true, false)
var activityMain: ActivityTestRule<MainActivity> = ActivityTestRule<MainActivity>(
MainActivity::class.java,
true,
false)

var activityTownSelection: ActivityTestRule<TownSelection> = ActivityTestRule<TownSelection>(
TownSelection::class.java,
true,
false)

var ruleSwitchToTownSel =
ActivityTestRule(TownSelection::class.java, true, false)

@Before
fun init() {
Expand All @@ -50,12 +57,19 @@ class TownSelectionTest {
validCity = "Graz"
}

@After
fun tearDown() {
Intents.release()
}

@Test
/*fun getToTownSelection(){
fun getToTownSelection(){
activityMain.launchActivity(Intent())
onView(withId(R.id.btnTownSelection)).perform(click())
ruleFromMainTownSelection.launchActivity(Intent())
// check
ruleSwitchToTownSel.launchActivity(Intent())
intended(hasComponent(TownSelection::class.java.name), times(2))
}*/
}

fun checkIfPopUpAppears()
{
Expand All @@ -64,9 +78,12 @@ class TownSelectionTest {
java.util.concurrent.TimeUnit.SECONDS.sleep(2)
}

/*@Test
@Test
fun typeCity(){ //some problem with the test
// Type text
activityTownSelection.launchActivity(Intent())
/*
onView(withId(R.id.autocomplete_fragment)).perform(typeText("Salzburg"), closeSoftKeyboard())
onView(withId(R.id.autocomplete_fragment))
.perform(click())
java.util.concurrent.TimeUnit.SECONDS.sleep(2)
Expand All @@ -77,14 +94,10 @@ class TownSelectionTest {
// Check that the text was changed.
onView(withId(R.id.autocomplete_fragment))
.check(matches(withText(validCity)))
}*/
/*@Test
fun cityTest()
{
onPlaceSelected()
}*/



*/
onView(withId(R.id.autocomplete_fragment)).check(matches(isDisplayed()))
onView(withId(R.id.textView3)).check(matches(isDisplayed()))
onView(withId(R.id.btn_change_lang_town_selection)).check(matches(isDisplayed()))
onView(withId(R.id.btnTownDone)).check(matches(isDisplayed()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.rule.ActivityTestRule
import com.example.tutorly.database.LvlOfKnowledge
import com.example.tutorly.database.Tutor
import junit.framework.TestCase
import org.junit.After
import org.junit.Before
Expand All @@ -30,7 +32,10 @@ class TutorProfileTest : TestCase() {
Intents.init()

// change activity
val intent = Intent()
val tempTutor = Tutor("testId", "testName", "testLastname", "testEmail", hashMapOf(
"German" to LvlOfKnowledge.University, "Physics" to LvlOfKnowledge.School), "12345", "Graz")

val intent = Intent().putExtra("Tutor", tempTutor)
tutorProfileActivity.launchActivity(intent)
}

Expand Down Expand Up @@ -80,11 +85,11 @@ class TutorProfileTest : TestCase() {
Espresso.onView(ViewMatchers.withId(R.id.txtTutorName))
.check(ViewAssertions.matches(ViewMatchers.withText("Name: ${TutorProfile.tutorName}")))
Espresso.onView(ViewMatchers.withId(R.id.txtTutorAge))
.check(ViewAssertions.matches(ViewMatchers.withText("Age: ${TutorProfile.tutorAge}")))
.check(ViewAssertions.matches(ViewMatchers.withText("Surname: ${TutorProfile.tutorSurnamne}")))
Espresso.onView(ViewMatchers.withId(R.id.txtTutorGender))
.check(ViewAssertions.matches(ViewMatchers.withText("Gender: ${TutorProfile.tutorGender}")))
.check(ViewAssertions.matches(ViewMatchers.withText("Phone: ${TutorProfile.tutorPhone}")))
Espresso.onView(ViewMatchers.withId(R.id.txtTutorMail))
.check(ViewAssertions.matches(ViewMatchers.withText("E-Mail: ${TutorProfile.tutorMail}")))
.check(ViewAssertions.matches(ViewMatchers.withText("Email: ${TutorProfile.tutorMail}")))
}

@Test
Expand Down
Loading

0 comments on commit 11ee2d0

Please sign in to comment.