diff --git a/app/src/androidTest/java/com/mytaxi/android_demo/AppObjects/ObjectStore.java b/app/src/androidTest/java/com/mytaxi/android_demo/AppObjects/ObjectStore.java index 1ed9491..4bcc4b0 100644 --- a/app/src/androidTest/java/com/mytaxi/android_demo/AppObjects/ObjectStore.java +++ b/app/src/androidTest/java/com/mytaxi/android_demo/AppObjects/ObjectStore.java @@ -5,6 +5,7 @@ import static android.support.test.espresso.assertion.ViewAssertions.matches; import org.hamcrest.Matcher; import android.support.test.espresso.matcher.ViewMatchers; +import static android.support.test.espresso.Espresso.onView; /* @@ -12,9 +13,13 @@ */ public class ObjectStore { - public final static Matcher tv_USERNAME = withId(R.id.edt_username); - public final static Matcher tv_PASSWORD = withId(R.id.edt_password); + public final static Matcher et_USERNAME = withId(R.id.edt_username); + public final static Matcher et_PASSWORD = withId(R.id.edt_password); public final static Matcher btn_LOGIN = withId(R.id.btn_login); + public final static Matcher left_DRAWER = withId(R.id.drawer_layout); + + public final static Matcher tv_USER_LOGGED = withId(R.id.nav_username); + } diff --git a/app/src/androidTest/java/com/mytaxi/android_demo/LoginTestTask.java b/app/src/androidTest/java/com/mytaxi/android_demo/LoginTestTask.java index 42e58c0..1927194 100644 --- a/app/src/androidTest/java/com/mytaxi/android_demo/LoginTestTask.java +++ b/app/src/androidTest/java/com/mytaxi/android_demo/LoginTestTask.java @@ -83,16 +83,16 @@ public void setUpBeforeTest(){ public void performLoginTestWithValidCredentials(){ //checking if Username input field is present & enabled before entering text - onView(ObjectStore.tv_USERNAME).check(matches(isDisplayed())); - onView(ObjectStore.tv_USERNAME).check(matches(isEnabled())); - onView(ObjectStore.tv_USERNAME).perform(click()) ; - onView(ObjectStore.tv_USERNAME).perform(typeText(Constants.USER_NAME)); // enter in username + onView(ObjectStore.et_USERNAME).check(matches(isDisplayed())); + onView(ObjectStore.et_USERNAME).check(matches(isEnabled())); + onView(ObjectStore.et_USERNAME).perform(click()) ; + onView(ObjectStore.et_USERNAME).perform(typeText(Constants.USER_NAME)); // enter in username //checking if password input field is present & enabled before entering text - onView(ObjectStore.tv_PASSWORD).check(matches(isDisplayed())); - onView(ObjectStore.tv_PASSWORD).check(matches(isEnabled())); - onView(ObjectStore.tv_PASSWORD).perform(click()) ; - onView(ObjectStore.tv_PASSWORD).perform(typeText(Constants.USER_PASSWORD), closeSoftKeyboard()); //enter in password field and close the keyboard + onView(ObjectStore.et_PASSWORD).check(matches(isDisplayed())); + onView(ObjectStore.et_PASSWORD).check(matches(isEnabled())); + onView(ObjectStore.et_PASSWORD).perform(click()) ; + onView(ObjectStore.et_PASSWORD).perform(typeText(Constants.USER_PASSWORD), closeSoftKeyboard()); //enter in password field and close the keyboard // to check if LOGIN button is displayed and can be clicked @@ -111,9 +111,9 @@ public void performLoginTestWithValidCredentials(){ @Test public void performLoginTestWithBlankValues(){ - onView(ObjectStore.tv_USERNAME).check(matches(isDisplayed())); //checking if username input field is present + onView(ObjectStore.et_USERNAME).check(matches(isDisplayed())); //checking if username input field is present - onView(ObjectStore.tv_PASSWORD).check(matches(isDisplayed())); //checking if password input field is present + onView(ObjectStore.et_PASSWORD).check(matches(isDisplayed())); //checking if password input field is present onView(ObjectStore.btn_LOGIN).check(matches(isDisplayed())).check(matches(isClickable())); // to check if LOGIN button is displayed and can be clicked onView(ObjectStore.btn_LOGIN).perform(click()) ; // click LOGIN button to submit [Although LOGIN button should be disabled unless Username & Password fields have value] @@ -135,17 +135,17 @@ public void performLoginTestWithBlankValues(){ @Test public void performLoginTestWithInValidUsername(){ //checking if Username input field is present & enabled before entering text - onView(ObjectStore.tv_USERNAME).check(matches(isDisplayed())); - onView(ObjectStore.tv_USERNAME).check(matches(isEnabled())); - onView(ObjectStore.tv_USERNAME).perform(click()) ; - onView(ObjectStore.tv_USERNAME).perform(typeText(Constants.SOME_INVALID_TEXT)); // enter in username field + onView(ObjectStore.et_USERNAME).check(matches(isDisplayed())); + onView(ObjectStore.et_USERNAME).check(matches(isEnabled())); + onView(ObjectStore.et_USERNAME).perform(click()) ; + onView(ObjectStore.et_USERNAME).perform(typeText(Constants.SOME_INVALID_TEXT)); // enter in username field //checking if password input field is present & enabled before entering text - onView(ObjectStore.tv_PASSWORD).check(matches(isDisplayed())); - onView(ObjectStore.tv_PASSWORD).check(matches(isEnabled())); - onView(ObjectStore.tv_PASSWORD).perform(click()) ; - onView(ObjectStore.tv_PASSWORD).perform(typeText(Constants.USER_PASSWORD), closeSoftKeyboard()); // enter in password field & close keyboard + onView(ObjectStore.et_PASSWORD).check(matches(isDisplayed())); + onView(ObjectStore.et_PASSWORD).check(matches(isEnabled())); + onView(ObjectStore.et_PASSWORD).perform(click()) ; + onView(ObjectStore.et_PASSWORD).perform(typeText(Constants.USER_PASSWORD), closeSoftKeyboard()); // enter in password field & close keyboard onView(ObjectStore.btn_LOGIN).check(matches(isDisplayed())).check(matches(isClickable())); // to check if LOGIN button is displayed and can be clicked onView(ObjectStore.btn_LOGIN).perform(click()) ; // click LOGIN button to submit @@ -167,17 +167,17 @@ public void performLoginTestWithInValidUsername(){ @Test public void performLoginTestWithInValidPassword(){ //checking if Username input field is present & enabled before entering text - onView(ObjectStore.tv_USERNAME).check(matches(isDisplayed())); - onView(ObjectStore.tv_USERNAME).check(matches(isEnabled())); - onView(ObjectStore.tv_USERNAME).perform(click()) ; - onView(ObjectStore.tv_USERNAME).perform(typeText(Constants.USER_NAME )); // enter in username field + onView(ObjectStore.et_USERNAME).check(matches(isDisplayed())); + onView(ObjectStore.et_USERNAME).check(matches(isEnabled())); + onView(ObjectStore.et_USERNAME).perform(click()) ; + onView(ObjectStore.et_USERNAME).perform(typeText(Constants.USER_NAME )); // enter in username field //checking if password input field is present & enabled before entering text - onView(ObjectStore.tv_PASSWORD).check(matches(isDisplayed())); - onView(ObjectStore.tv_PASSWORD).check(matches(isEnabled())); - onView(ObjectStore.tv_PASSWORD).perform(click()) ; - onView(ObjectStore.tv_PASSWORD).perform(typeText(Constants.SOME_INVALID_TEXT), closeSoftKeyboard()); // enter in password field & close keyboard + onView(ObjectStore.et_PASSWORD).check(matches(isDisplayed())); + onView(ObjectStore.et_PASSWORD).check(matches(isEnabled())); + onView(ObjectStore.et_PASSWORD).perform(click()) ; + onView(ObjectStore.et_PASSWORD).perform(typeText(Constants.SOME_INVALID_TEXT), closeSoftKeyboard()); // enter in password field & close keyboard // to check if LOGIN button is displayed and can be clicked diff --git a/app/src/androidTest/java/com/mytaxi/android_demo/SearchDriverTestTask.java b/app/src/androidTest/java/com/mytaxi/android_demo/SearchDriverTestTask.java index 57dece1..fc0999a 100644 --- a/app/src/androidTest/java/com/mytaxi/android_demo/SearchDriverTestTask.java +++ b/app/src/androidTest/java/com/mytaxi/android_demo/SearchDriverTestTask.java @@ -21,6 +21,8 @@ import org.junit.Test; import org.junit.runner.RunWith; +import static com.mytaxi.android_demo.ObjectStore; + import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard; @@ -79,26 +81,26 @@ public void setUpBeforeTest() { @Test public void performLoginAndCallSearchedDriverTest(){ //checking if Username input field is present & enabled before entering text - onView(withId(R.id.edt_username)).check(matches(isDisplayed())); - onView(withId(R.id.edt_username)).check(matches(isEnabled())); - onView(withId(R.id.edt_username)).perform(click()) ; - onView(withId(R.id.edt_username)).perform(typeText(Constants.USER_NAME)); //enter in username field + onView(ObjectStore.et_USERNAME).check(matches(isDisplayed())); + onView(ObjectStore.et_USERNAME).check(matches(isEnabled())); + onView(ObjectStore.et_USERNAME).perform(click()) ; + onView(ObjectStore.et_USERNAME).perform(typeText(Constants.USER_NAME)); //enter in username field //checking if password input field is present & enabled before entering text - onView(withId(R.id.edt_password)).check(matches(isDisplayed())); - onView(withId(R.id.edt_password)).check(matches(isEnabled())); - onView(withId(R.id.edt_password)).perform(click()) ; - onView(withId(R.id.edt_password)).perform(typeText(Constants.USER_PASSWORD), closeSoftKeyboard()); //enter in password field and close the keyboard + onView(ObjectStore.et_PASSWORD).check(matches(isDisplayed())); + onView(ObjectStore.et_PASSWORD).check(matches(isEnabled())); + onView(ObjectStore.et_PASSWORD).perform(click()) ; + onView(ObjectStore.et_PASSWORD).perform(typeText(Constants.USER_PASSWORD), closeSoftKeyboard()); //enter in password field and close the keyboard // to check if LOGIN button is displayed and can be clicked - onView(withId(R.id.btn_login)).check(matches(isDisplayed())).check(matches(isClickable())); - onView(withId(R.id.btn_login)).perform(click()) ; // click LOGIN to submit + onView(ObjectStore.btn_LOGIN).check(matches(isDisplayed())).check(matches(isClickable())); + onView(ObjectStore.btn_LOGIN).perform(click()) ; // click LOGIN to submit //Waiting for MainActivity to open up IdlingRegistry.getInstance().register(mainActivityIdlingResource); - onView(withId(R.id.drawer_layout)) + onView(ObjectStore.left_DRAWER) .check(matches(isClosed(Gravity.LEFT))) // To check Left Drawer based on that it is currently closed. .perform(DrawerActions.open()); // open drawer