This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
forked from AdevintaSpain/Barista
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add assertListNotEmpty (AdevintaSpain#288)
* Add assertListHasItems * Rename assertListHasItems to assertListNotEmpty
- Loading branch information
1 parent
fc3364a
commit 6029033
Showing
5 changed files
with
73 additions
and
0 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
22 changes: 22 additions & 0 deletions
22
...y/src/main/java/com/schibsted/spain/barista/internal/matcher/ListViewNotEmptyAssertion.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,22 @@ | ||
package com.schibsted.spain.barista.internal.matcher | ||
|
||
import android.support.test.espresso.NoMatchingViewException | ||
import android.support.test.espresso.ViewAssertion | ||
import android.view.View | ||
import android.widget.ListView | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.not | ||
|
||
class ListViewNotEmptyAssertion : ViewAssertion { | ||
|
||
override fun check(view: View?, noViewFoundException: NoMatchingViewException?) { | ||
if (noViewFoundException != null) { | ||
throw noViewFoundException | ||
} | ||
|
||
val listView = view as ListView | ||
val adapter = listView.adapter | ||
val listViewItemCount = adapter.count | ||
assertThat<Int>("List item count mismatch. ", listViewItemCount, not<Int>(0)) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...c/main/java/com/schibsted/spain/barista/internal/matcher/RecyclerViewNotEmptyAssertion.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,22 @@ | ||
package com.schibsted.spain.barista.internal.matcher | ||
|
||
import android.support.test.espresso.NoMatchingViewException | ||
import android.support.test.espresso.ViewAssertion | ||
import android.support.v7.widget.RecyclerView | ||
import android.view.View | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.not | ||
|
||
class RecyclerViewNotEmptyAssertion : ViewAssertion { | ||
|
||
override fun check(view: View?, noViewFoundException: NoMatchingViewException?) { | ||
if (noViewFoundException != null) { | ||
throw noViewFoundException | ||
} | ||
|
||
val recyclerView = view as RecyclerView | ||
val adapter = recyclerView.adapter | ||
val recyclerViewItemCount = adapter.itemCount | ||
assertThat<Int>("Recycler item count mismatch. ", recyclerViewItemCount, not<Int>(0)) | ||
} | ||
} |
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