-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lots of tests on the Barista methods
- Loading branch information
1 parent
a77faf2
commit 36c3239
Showing
18 changed files
with
375 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/build | ||
/captures | ||
.externalNativeBuild | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
library/src/main/java/com/schibsted/spain/barista/BaristaScrollActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.schibsted.spain.barista; | ||
|
||
import android.support.annotation.IdRes; | ||
import android.support.test.espresso.action.ViewActions; | ||
|
||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
|
||
public class BaristaScrollActions { | ||
|
||
public static void scrollTo(@IdRes int id) { | ||
onView(withId(id)).perform(ViewActions.scrollTo()); | ||
} | ||
|
||
public static void scrollTo(String text) { | ||
onView(withText(text)).perform(ViewActions.scrollTo()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
sample/src/androidTest/java/com/schibsted/spain/barista/sample/AssertionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.schibsted.spain.barista.BaristaAssertions.assertTextDoesNotExist; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertTextIsDisplayed; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertTextIsNotDisplayed; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertThatBackButtonClosesTheApp; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertViewDoesNotExist; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertViewIsDisabled; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertViewIsDisplayed; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertViewIsEnabled; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertViewIsNotDisplayed; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class AssertionsTest { | ||
|
||
@Rule | ||
public ActivityTestRule<SomeViewsWithDifferentVisibilitesActivity> activityRule = new ActivityTestRule<>(SomeViewsWithDifferentVisibilitesActivity.class); | ||
|
||
@Test | ||
public void checkVisibleViews() { | ||
assertViewIsDisplayed(R.id.visible_view); | ||
|
||
assertTextIsDisplayed(R.string.hello_world); | ||
assertTextIsDisplayed("Hello world!"); | ||
} | ||
|
||
@Test | ||
public void checkInvisibleViews() { | ||
assertViewIsNotDisplayed(R.id.invisible_view); | ||
assertViewIsNotDisplayed(R.id.gone_view); | ||
|
||
assertTextIsNotDisplayed(R.string.im_invisible); | ||
assertTextIsNotDisplayed("I'm invisible!"); | ||
} | ||
|
||
@Test | ||
public void checkUnexistingView() { | ||
assertTextDoesNotExist(R.string.unknown); | ||
assertTextDoesNotExist("Unknown"); | ||
} | ||
|
||
@Test | ||
public void cantFindAnIdThatDoesntExist() { | ||
assertViewDoesNotExist(R.id.view_in_another_layout); | ||
} | ||
|
||
@Test | ||
public void checkEnabledView() { | ||
assertViewIsEnabled(R.id.enabled_button); | ||
} | ||
|
||
@Test | ||
public void checkDisabledView() { | ||
assertViewIsDisabled(R.id.disabled_button); | ||
} | ||
|
||
@Test | ||
public void checkBackButton() { | ||
assertThatBackButtonClosesTheApp(); | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
sample/src/androidTest/java/com/schibsted/spain/barista/sample/BaristaSampleTest.java
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
sample/src/androidTest/java/com/schibsted/spain/barista/sample/ButtonsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.schibsted.spain.barista.BaristaAssertions.assertTextIsDisplayed; | ||
import static com.schibsted.spain.barista.BaristaClickActions.click; | ||
import static com.schibsted.spain.barista.BaristaClickActions.clickBack; | ||
import static com.schibsted.spain.barista.BaristaClickActions.clickScrollingIfNeeded; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ButtonsTest { | ||
|
||
@Rule | ||
public ActivityTestRule<FlowFirstScreen> activityRule = new ActivityTestRule<>(FlowFirstScreen.class); | ||
|
||
@Test | ||
public void checkClickById() { | ||
click(R.id.next); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
} | ||
|
||
@Test | ||
public void checkClickAndScrollIfNeededById() { | ||
clickScrollingIfNeeded(R.id.next); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
} | ||
|
||
@Test | ||
public void checkClickByText() { | ||
click("Next"); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
} | ||
|
||
@Test | ||
public void checkClickAndScrollIfNeededByText() { | ||
clickScrollingIfNeeded("Next"); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
} | ||
|
||
@Test | ||
public void checkScrollingClickById() { | ||
clickScrollingIfNeeded(R.id.really_far_away_button); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
} | ||
|
||
@Test | ||
public void checkScrollingClickByText() { | ||
clickScrollingIfNeeded("Really far away button"); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
} | ||
|
||
@Test | ||
public void checkBackButton() { | ||
click("Next"); | ||
assertTextIsDisplayed("Hi! I'm the second screen!"); | ||
clickBack(); | ||
assertTextIsDisplayed("Hi! I'm the first screen!"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
sample/src/androidTest/java/com/schibsted/spain/barista/sample/ScrollsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.schibsted.spain.barista.BaristaAssertions.assertTextIsDisplayed; | ||
import static com.schibsted.spain.barista.BaristaAssertions.assertTextIsNotDisplayed; | ||
import static com.schibsted.spain.barista.BaristaScrollActions.scrollTo; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ScrollsTest { | ||
|
||
@Rule | ||
public ActivityTestRule<FlowFirstScreen> activityRule = new ActivityTestRule<>(FlowFirstScreen.class); | ||
|
||
@Test | ||
public void checkScrollByText() { | ||
assertTextIsDisplayed("Hi! I'm the first screen!"); | ||
assertTextIsNotDisplayed("Really far away button"); | ||
|
||
scrollTo("Really far away button"); | ||
|
||
assertTextIsNotDisplayed("Hi! I'm the first screen!"); | ||
assertTextIsDisplayed("Really far away button"); | ||
} | ||
|
||
@Test | ||
public void checkScrollById() { | ||
assertTextIsDisplayed("Hi! I'm the first screen!"); | ||
assertTextIsNotDisplayed("Really far away button"); | ||
|
||
scrollTo(R.id.really_far_away_button); | ||
|
||
assertTextIsNotDisplayed("Hi! I'm the first screen!"); | ||
assertTextIsDisplayed("Really far away button"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.