-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Locale-specific test more reliable by deactivating LeakCanary an…
…d by granting CHANGE_CONFIGURATION permission before running LocaleTestRule
- Loading branch information
1 parent
4f060bb
commit 1bf680c
Showing
7 changed files
with
78 additions
and
80 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
24 changes: 4 additions & 20 deletions
24
myExpenses/src/androidTest/java/org/totschnig/myexpenses/test/screenshots/ArabTest.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,29 +1,13 @@ | ||
package org.totschnig.myexpenses.test.screenshots | ||
|
||
import android.Manifest | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.rule.GrantPermissionRule | ||
import org.junit.Rule | ||
import androidx.test.filters.LargeTest | ||
import org.junit.Test | ||
import tools.fastlane.screengrab.locale.LocaleTestRule | ||
|
||
class ArabTest: TestMain() { | ||
|
||
@get:Rule | ||
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant( | ||
Manifest.permission.WRITE_CALENDAR, Manifest.permission.READ_CALENDAR | ||
) | ||
|
||
@Rule | ||
@JvmField | ||
val localeTestRule = LocaleTestRule(locale) | ||
@LargeTest | ||
class ArabTest: TestMain("ar-SA") { | ||
|
||
@Test | ||
fun runArab() { | ||
runScenario("1", locale) | ||
} | ||
|
||
companion object { | ||
const val locale = "ar-SA" | ||
runScenario("1") | ||
} | ||
} |
22 changes: 4 additions & 18 deletions
22
myExpenses/src/androidTest/java/org/totschnig/myexpenses/test/screenshots/JapaneseTest.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,28 +1,14 @@ | ||
package org.totschnig.myexpenses.test.screenshots | ||
|
||
import android.Manifest | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.rule.GrantPermissionRule | ||
import org.junit.Rule | ||
import androidx.test.filters.LargeTest | ||
import org.junit.Test | ||
import tools.fastlane.screengrab.locale.LocaleTestRule | ||
|
||
class JapaneseTest: TestMain() { | ||
@get:Rule | ||
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant( | ||
Manifest.permission.WRITE_CALENDAR, Manifest.permission.READ_CALENDAR | ||
) | ||
|
||
@Rule | ||
@JvmField | ||
val localeTestRule = LocaleTestRule(locale) | ||
@LargeTest | ||
class JapaneseTest: TestMain("ja-JP") { | ||
|
||
@Test | ||
fun runJapanese() { | ||
runScenario("1", locale) | ||
} | ||
|
||
companion object { | ||
const val locale = "ja-JP" | ||
runScenario("1") | ||
} | ||
} |
21 changes: 9 additions & 12 deletions
21
myExpenses/src/androidTest/java/org/totschnig/myexpenses/test/screenshots/ScreenGrabTest.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,32 +1,29 @@ | ||
package org.totschnig.myexpenses.test.screenshots | ||
|
||
import android.Manifest | ||
import androidx.test.filters.LargeTest | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.rule.GrantPermissionRule | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import tools.fastlane.screengrab.locale.LocaleTestRule | ||
import tools.fastlane.screengrab.locale.LocaleUtil | ||
|
||
/** | ||
* When not run from ScreenGrab, it runs with device locale | ||
*/ | ||
class ScreenGrabTest: TestMain() { | ||
|
||
@get:Rule | ||
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant( | ||
Manifest.permission.WRITE_CALENDAR, Manifest.permission.READ_CALENDAR | ||
) | ||
@LargeTest | ||
class ScreenGrabTest: TestMain(null) { | ||
|
||
@Rule | ||
@JvmField | ||
val localeTestRule = LocaleTestRule() | ||
|
||
override val shouldTakeScreenShot = true | ||
override val shouldTakeScreenShot = getInstrumentationArgument("screenshots", "1") == "true" | ||
|
||
@Test | ||
fun mkScreenshots() { | ||
val scenario = InstrumentationRegistry.getArguments().getString("scenario", "1") | ||
runScenario(scenario, LocaleUtil.getTestLocale()) | ||
val scenario = getInstrumentationArgument("scenario", "1") | ||
runScenario(scenario) | ||
} | ||
|
||
private fun getInstrumentationArgument(key: String, @Suppress("SameParameterValue") defaultValue: String) = | ||
InstrumentationRegistry.getArguments().getString(key, defaultValue) | ||
} |
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