-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:QAutomatron/kopi
# Conflicts: # build.gradle
- Loading branch information
Showing
5 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
10 changes: 6 additions & 4 deletions
10
library/src/main/java/com/qautomatron/kopi/library/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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package com.qautomatron.kopi.library | ||
|
||
import android.app.Instrumentation | ||
import android.content.Context | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
|
||
val instrumentation: Instrumentation | ||
get() = InstrumentationRegistry.getInstrumentation() | ||
|
||
val appContext: Context | ||
get() = InstrumentationRegistry.getInstrumentation().targetContext | ||
get() = instrumentation.targetContext | ||
|
||
/** | ||
* Return string from resources | ||
*/ | ||
fun resourceToString(resource: Int, vararg a: Any): String { | ||
return appContext.getString(resource, *a) | ||
} | ||
fun resourceToString(resource: Int, vararg a: Any): String = appContext.getString(resource, *a) |
32 changes: 32 additions & 0 deletions
32
library/src/main/java/com/qautomatron/kopi/library/rule/DisableAnimationsRule.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,32 @@ | ||
package com.qautomatron.kopi.library.rule | ||
|
||
import androidx.test.uiautomator.UiDevice | ||
import com.qautomatron.kopi.library.instrumentation | ||
import org.junit.rules.TestWatcher | ||
import org.junit.runner.Description | ||
|
||
|
||
class DisableAnimationsRule : TestWatcher() { | ||
|
||
override fun starting(description: Description) = disableAnimations() | ||
|
||
override fun finished(description: Description) = enableAnimations() | ||
|
||
private fun disableAnimations() { | ||
UiDevice.getInstance(instrumentation) | ||
.executeShellCommand("settings put global transition_animation_scale 0") | ||
UiDevice.getInstance(instrumentation) | ||
.executeShellCommand("settings put global window_animation_scale 0") | ||
UiDevice.getInstance(instrumentation) | ||
.executeShellCommand("settings put global animator_duration_scale 0") | ||
} | ||
|
||
private fun enableAnimations() { | ||
UiDevice.getInstance(instrumentation) | ||
.executeShellCommand("settings put global transition_animation_scale 1") | ||
UiDevice.getInstance(instrumentation) | ||
.executeShellCommand("settings put global window_animation_scale 1") | ||
UiDevice.getInstance(instrumentation) | ||
.executeShellCommand("settings put global animator_duration_scale 1") | ||
} | ||
} |
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