forked from feelfreelinux/WykopMobilny
-
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.
Merge pull request feelfreelinux#165 from otwarty-wykop-mobilny/2fa
- Loading branch information
Showing
64 changed files
with
908 additions
and
105 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
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
55 changes: 55 additions & 0 deletions
55
app/src/androidTest/java/io/github/wykopmobilny/utils/Utils.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,55 @@ | ||
package io.github.wykopmobilny.utils | ||
|
||
import androidx.test.espresso.NoMatchingViewException | ||
import androidx.test.espresso.ViewAssertion | ||
import androidx.test.espresso.ViewInteraction | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.util.HumanReadables | ||
import junit.framework.AssertionFailedError | ||
import java.util.concurrent.TimeoutException | ||
|
||
internal fun ViewInteraction.waitVisible(timeout: Long = 2000L): ViewInteraction { | ||
val startTime = System.currentTimeMillis() | ||
val endTime = startTime + timeout | ||
|
||
do { | ||
try { | ||
check(matches(isDisplayed())) | ||
return this | ||
} catch (e: AssertionFailedError) { | ||
Thread.sleep(50) | ||
} catch (e: NoMatchingViewException) { | ||
Thread.sleep(50) | ||
} | ||
} while (System.currentTimeMillis() < endTime) | ||
|
||
throw TimeoutException() | ||
} | ||
|
||
internal fun ViewInteraction.waitNotVisible(timeout: Long = 2000L): ViewInteraction { | ||
val startTime = System.currentTimeMillis() | ||
val endTime = startTime + timeout | ||
|
||
do { | ||
try { | ||
check(isNotDisplayed()) | ||
return this | ||
} catch (e: AssertionFailedError) { | ||
Thread.sleep(50) | ||
} catch (e: NoMatchingViewException) { | ||
Thread.sleep(50) | ||
} | ||
} while (System.currentTimeMillis() < endTime) | ||
|
||
throw TimeoutException() | ||
} | ||
|
||
fun isNotDisplayed() = ViewAssertion { view, _ -> | ||
if (isDisplayed().matches(view)) { | ||
throw AssertionError( | ||
"View is present in the hierarchy and Displayed: " + | ||
HumanReadables.describe(view), | ||
) | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"data": [] | ||
} |
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
Oops, something went wrong.