-
-
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.
Extend assertNotExist with a new implementation using a viewMatcher a…
…s a param (#479) * Rename .java to .kt * Add assertNotExist with view mather implementation * Add assertExist ,javadoc and update README Co-authored-by: Quentin MOUTY <[email protected]>
- Loading branch information
1 parent
bce5f90
commit 602f148
Showing
5 changed files
with
149 additions
and
44 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
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
30 changes: 0 additions & 30 deletions
30
...com/adevinta/android/barista/sample/RecyclerViewWithDifferentDataInsideViewPagerTest.java
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
...a/com/adevinta/android/barista/sample/RecyclerViewWithDifferentDataInsideViewPagerTest.kt
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,91 @@ | ||
package com.adevinta.android.barista.sample | ||
|
||
import android.view.View | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.assertion.ViewAssertions | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import com.adevinta.android.barista.assertion.BaristaListAssertions.assertDisplayedAtPosition | ||
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions | ||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions | ||
import com.adevinta.android.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerBack | ||
import com.adevinta.android.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerForward | ||
import com.adevinta.android.barista.internal.matcher.withCompatText | ||
import junit.framework.AssertionFailedError | ||
import org.hamcrest.CoreMatchers | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.core.AllOf.allOf | ||
import org.junit.Assert | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class RecyclerViewWithDifferentDataInsideViewPagerTest { | ||
@Rule | ||
var activityRule = ActivityScenarioRule( | ||
RecyclerViewsWithDifferentDataInsideViewPagerActivity::class.java | ||
) | ||
|
||
@Test | ||
fun checkClickRecyclerViewItem() { | ||
swipeViewPagerForward(R.id.pager) | ||
BaristaSleepInteractions.sleep(500) | ||
assertDisplayedAtPosition(R.id.recycler, 1, "Marionberry") | ||
swipeViewPagerBack(R.id.pager) | ||
BaristaSleepInteractions.sleep(500) | ||
assertDisplayedAtPosition(R.id.recycler, 0, R.id.textview, "Apple") | ||
} | ||
|
||
@Test | ||
fun assertExistingView() { | ||
BaristaVisibilityAssertions.assertDisplayed("Apple") | ||
BaristaVisibilityAssertions.assertExist( | ||
allOf( | ||
withCompatText("Apple"), | ||
withId(R.id.textview) | ||
) | ||
) | ||
BaristaVisibilityAssertions.assertExist("Apple") | ||
BaristaVisibilityAssertions.assertExist(R.id.pager) | ||
|
||
swipeViewPagerForward(R.id.pager) | ||
BaristaSleepInteractions.sleep(500) | ||
BaristaVisibilityAssertions.assertNotDisplayed("Apple") | ||
BaristaVisibilityAssertions.assertExist( | ||
allOf( | ||
withCompatText("Apple"), | ||
withId(R.id.textview) | ||
) | ||
) | ||
BaristaVisibilityAssertions.assertExist(R.id.pager) | ||
|
||
} | ||
|
||
@Test | ||
fun assertNotExistingView() { | ||
swipeViewPagerForward(R.id.pager) | ||
BaristaSleepInteractions.sleep(500) | ||
try { | ||
BaristaVisibilityAssertions.assertNotExist("Apple") | ||
Assert.assertFalse(false) | ||
} catch (error: AssertionFailedError) { | ||
Assert.assertTrue(true) | ||
} | ||
Espresso.onView(withCompatText("Apple")) | ||
.check(ViewAssertions.matches(withEffectiveVisibility(Visibility.VISIBLE))) | ||
|
||
val displayedRecyclerView: Matcher<View> = | ||
allOf(withId(R.id.recycler), isDisplayed()) | ||
|
||
BaristaVisibilityAssertions.assertNotExist( | ||
CoreMatchers.allOf( | ||
withText("Apple"), | ||
isDescendantOfA(displayedRecyclerView) | ||
) | ||
) | ||
|
||
assertDisplayedAtPosition(R.id.recycler, 1, "Marionberry") | ||
swipeViewPagerBack(R.id.pager) | ||
BaristaSleepInteractions.sleep(500) | ||
assertDisplayedAtPosition(R.id.recycler, 0, R.id.textview, "Apple") | ||
} | ||
} |