Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelchassot committed Nov 16, 2018
1 parent 63b7af3 commit e0bed1c
Showing 1 changed file with 26 additions and 1 deletion.
Expand Up @@ -11,13 +11,17 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.closeSoftKeyboard;
import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.clearText;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.scrollTo;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;


import static ch.epfl.swissteam.services.TestUtils.sleep;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.instanceOf;
Expand All @@ -33,6 +37,9 @@ public class ServicesFragmentTest {
@Before
public void initialize() {
LocationManager.get().setMock();
User testUser = TestUtils.getTestUser();
testUser.addToDB(DBUtility.get().getDb_());
GoogleSignInSingleton.putUniqueID(TestUtils.M_GOOGLE_ID);
}

@After
Expand All @@ -45,6 +52,24 @@ public void openFragment() {
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.button_maindrawer_services));
onView(withId(R.id.services_spinner)).perform(scrollTo()).perform(click());
//onData(allOf(is(instanceOf(Categories.class)), is(Categories.HOUSE))).perform(scrollTo()).perform(click());
}

@Test
public void clickSearchWithoutKeyWords(){
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.button_maindrawer_services));
sleep(1000);
onView(withId(R.id.button_services_search)).perform(click());
}

@Test
public void clickSearchWithKeywords(){
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.button_maindrawer_services));
sleep(1000);
onView(withId(R.id.edittext_services_keywordsinput)).perform(clearText()).perform(typeText("Python"));
closeSoftKeyboard();
sleep(1000);
onView(withId(R.id.button_services_search)).perform(click());
}
}

0 comments on commit e0bed1c

Please sign in to comment.