New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Screenshots Automation] Fix locales switching #6834
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
661c920
Check if selected site exists before accessing in MoreMenuRepository
hichamboushaba 491fbc3
Remove the locales list hack
hichamboushaba 57b6aeb
Fix initialization of LocaleTestRule
hichamboushaba 4e88778
Improve detection of test environment
hichamboushaba b0b7d01
Make sure LeakCanary is not initialized for test/androidTest builds
hichamboushaba File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<manifest package="com.woocommerce.android" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.woocommerce.android"> | ||
|
||
<!-- Allows unlocking your device and activating its screen so UI tests can succeed --> | ||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/> | ||
<uses-permission android:name="android.permission.WAKE_LOCK"/> | ||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
|
||
<!-- Allows for storing and retrieving screenshots --> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" /> | ||
<uses-permission | ||
android:name="android.permission.WRITE_EXTERNAL_STORAGE" | ||
android:maxSdkVersion="28" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
|
||
<!-- Allows changing locales --> | ||
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" tools:ignore="ProtectedPermissions" /> | ||
<uses-permission | ||
android:name="android.permission.CHANGE_CONFIGURATION" | ||
tools:ignore="ProtectedPermissions" /> | ||
|
||
<!-- Clean the status bar for screenshots automation | ||
See https://docs.fastlane.tools/actions/screengrab/#clean-status-bar --> | ||
<!-- Indicates the use of the clean status bar feature --> | ||
<uses-feature android:name="tools.fastlane.screengrab.cleanstatusbar" /> | ||
<!-- Allows for changing the status bar --> | ||
<uses-permission android:name="android.permission.DUMP" tools:ignore="ProtectedPermissions" /> | ||
<uses-permission | ||
android:name="android.permission.DUMP" | ||
tools:ignore="ProtectedPermissions" /> | ||
|
||
<application | ||
android:name=".WooCommerceDebug" | ||
tools:replace="android:name" /> | ||
tools:replace="android:name"> | ||
<provider | ||
android:name=".LeakCanaryInstaller" | ||
android:authorities="${applicationId}.leakcanary-installer" | ||
android:exported="false" /> | ||
</application> | ||
|
||
</manifest> |
42 changes: 42 additions & 0 deletions
42
WooCommerce/src/debug/kotlin/com.woocommerce.android/LeakCanaryInstaller.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,42 @@ | ||
package com.woocommerce.android | ||
|
||
import android.app.Application | ||
import android.content.ContentProvider | ||
import android.content.ContentValues | ||
import android.database.Cursor | ||
import android.net.Uri | ||
import com.woocommerce.android.util.PackageUtils | ||
import com.woocommerce.android.util.WooLog | ||
import leakcanary.AppWatcher | ||
|
||
internal class LeakCanaryInstaller : ContentProvider() { | ||
override fun onCreate(): Boolean { | ||
if (!PackageUtils.isTesting()) { | ||
WooLog.v(WooLog.T.DEVICE, "Installing LeakCanary") | ||
val application = context!!.applicationContext as Application | ||
AppWatcher.manualInstall(application) | ||
} | ||
return true | ||
} | ||
|
||
override fun query( | ||
uri: Uri, | ||
projectionArg: Array<String>?, | ||
selection: String?, | ||
selectionArgs: Array<String>?, | ||
sortOrder: String? | ||
): Cursor? = null | ||
|
||
override fun getType(uri: Uri): String? = null | ||
|
||
override fun insert(uri: Uri, contentValues: ContentValues?): Uri? = null | ||
|
||
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0 | ||
|
||
override fun update( | ||
uri: Uri, | ||
values: ContentValues?, | ||
selection: String?, | ||
selectionArgs: Array<out String>? | ||
): 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ object PackageUtils { | |
fun isTesting(): Boolean { | ||
if (isTesting == null) { | ||
isTesting = try { | ||
Class.forName("com.woocommerce.android.viewmodel.BaseUnitTest") | ||
Class.forName("org.junit.Test") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this change, this function detects both UI tests and unit tests. |
||
true | ||
} catch (e: ClassNotFoundException) { | ||
false | ||
|
@@ -29,15 +29,6 @@ object PackageUtils { | |
return isTesting!! | ||
} | ||
|
||
fun isUITesting(): Boolean { | ||
return try { | ||
Class.forName("com.woocommerce.android.helpers.TestBase") | ||
true | ||
} catch (e: ClassNotFoundException) { | ||
false | ||
} | ||
} | ||
|
||
fun isBetaBuild(context: Context): Boolean { | ||
val versionName = getVersionName(context).toLowerCase(Locale.ROOT) | ||
return (versionName.contains("beta") || versionName.contains("rc")) | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the same logic as
leak-canary
's default artifact in using aContentProvider
for the initialization, the change is that we can have custom logic for the initialization now.