diff --git a/WooCommerce/build.gradle b/WooCommerce/build.gradle index 24cd24eb16d..11b3cf29288 100644 --- a/WooCommerce/build.gradle +++ b/WooCommerce/build.gradle @@ -263,7 +263,7 @@ dependencies { // See https://github.com/wordpress-mobile/WordPress-FluxC-Android/issues/919 exclude group: 'com.squareup.okhttp3' } - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' + debugImplementation 'com.squareup.leakcanary:leakcanary-android-core:2.9.1' // Dependencies for local unit tests testImplementation "junit:junit:$jUnitVersion" diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/screenshots/ScreenshotTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/screenshots/ScreenshotTest.kt index 304b5a59d88..e218927355a 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/screenshots/ScreenshotTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/screenshots/ScreenshotTest.kt @@ -40,11 +40,11 @@ class ScreenshotTest : TestBase() { val composeTestRule = createComposeRule() @get:Rule(order = 3) - var activityRule = ActivityTestRule(MainActivity::class.java) - - @Rule @JvmField val localeTestRule = LocaleTestRule() + @get:Rule(order = 4) + var activityRule = ActivityTestRule(MainActivity::class.java) + @Before fun setUp() { CleanStatusBar.enableWithDefaults() diff --git a/WooCommerce/src/debug/AndroidManifest.xml b/WooCommerce/src/debug/AndroidManifest.xml index 5ca4765fb2a..7270cef6d1e 100644 --- a/WooCommerce/src/debug/AndroidManifest.xml +++ b/WooCommerce/src/debug/AndroidManifest.xml @@ -1,29 +1,40 @@ - + - - + + - + - + - + + tools:replace="android:name"> + + diff --git a/WooCommerce/src/debug/kotlin/com.woocommerce.android/LeakCanaryInstaller.kt b/WooCommerce/src/debug/kotlin/com.woocommerce.android/LeakCanaryInstaller.kt new file mode 100644 index 00000000000..d1656c793d9 --- /dev/null +++ b/WooCommerce/src/debug/kotlin/com.woocommerce.android/LeakCanaryInstaller.kt @@ -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?, + selection: String?, + selectionArgs: Array?, + 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?): Int = 0 + + override fun update( + uri: Uri, + values: ContentValues?, + selection: String?, + selectionArgs: Array? + ): Int = 0 +} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/support/ZendeskHelper.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/support/ZendeskHelper.kt index 655bb2425a5..8666e1cb408 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/support/ZendeskHelper.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/support/ZendeskHelper.kt @@ -90,7 +90,7 @@ class ZendeskHelper( enableLogs: Boolean = BuildConfig.DEBUG ) { if (isZendeskEnabled) { - if (PackageUtils.isUITesting()) return + if (PackageUtils.isTesting()) return else error("Zendesk shouldn't be initialized more than once!") } if (zendeskUrl.isEmpty() || applicationId.isEmpty() || oauthClientId.isEmpty()) { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/domain/MoreMenuRepository.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/domain/MoreMenuRepository.kt index c5cda8a509d..74161a0f015 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/domain/MoreMenuRepository.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/domain/MoreMenuRepository.kt @@ -24,7 +24,7 @@ class MoreMenuRepository @Inject constructor( suspend fun isInboxEnabled(): Boolean = withContext(Dispatchers.IO) { - if (!FeatureFlag.MORE_MENU_INBOX.isEnabled()) return@withContext false + if (!selectedSite.exists() || !FeatureFlag.MORE_MENU_INBOX.isEnabled()) return@withContext false val currentWooCoreVersion = wooCommerceStore.getSitePlugin(selectedSite.get(), WOO_CORE)?.version ?: "0.0" diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/PackageUtils.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/PackageUtils.kt index a2b42000e88..b2c7539c6b8 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/PackageUtils.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/PackageUtils.kt @@ -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") 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")) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 998abb4e1a0..651d75f654e 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -613,11 +613,6 @@ platform :android do map { |locale| locale[:google_play] } end - # Override the locales array with one locale until - # https://github.com/fastlane/fastlane/issues/19521 - # is fixed: - locales = ["en-EN"] - UI.message("Attempting screenshots for locales: #{locales}") screenshot_options = {