[#1129] Fix failing Test Robo Debug

* [#1129] Fix failing Test Robo Debug

Closes #1129

* Changelog update

* Specify main-debug folder

* [#1129] Separate version flags

- Separate debuggable and run under a test service flags
- As we now have more flexibility in requesting the flags in runtime
This commit is contained in:
Honza Rychnovský 2023-12-19 11:03:28 +01:00 committed by GitHub
parent 4cf608b733
commit 4e3bea2c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 114 additions and 12 deletions

View File

@ -11,6 +11,8 @@ directly impact users rather than highlighting other key architectural updates.*
### Changed
- Home screen navigation switched from the Side menu to the Bottom Navigation Tabs menu
- Re-enabled the possibility of installing different Zashi application build types on the same device simultaneously
(i.e., Mainnet, Testnet, Production, Debug)
## [0.2.0 (505)] - 2023-12-11

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name="co.electriccoin.zcash.app.ZcashApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher_square"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name">
<provider
android:name="co.electriccoin.zcash.ui.screen.exportdata.util.ShareFileProvider"
android:authorities="co.electriccoin.zcash.provider.testnet"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/share_file_provider_paths" />
</provider>
</application>
</manifest>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name="co.electriccoin.zcash.app.ZcashApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher_square"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name">
<provider
android:name="co.electriccoin.zcash.ui.screen.exportdata.util.ShareFileProvider"
android:authorities="co.electriccoin.zcash.debug.provider.testnet"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/share_file_provider_paths" />
</provider>
</application>
</manifest>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Overlay from sdk-ext-lib. -->
<bool name="zcash_is_testnet">true</bool>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View File

@ -4,6 +4,7 @@ import androidx.test.filters.SmallTest
import co.electriccoin.zcash.ui.test.getAppContext
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
@ -15,6 +16,7 @@ class VersionInfoTest {
// We expect some VersionInfo object parameters to be empty during the testing
// isDebuggable is not tested as it's not static during UI testing in CI or locally
assertFalse(versionInfo.isTestnet)
assertEquals("null", versionInfo.versionName)
assertEquals(0, versionInfo.versionCode)
assertNotEquals(versionInfo.gitSha, "")

View File

@ -13,6 +13,8 @@ data class VersionInfo(
val versionName: String,
val versionCode: Long,
val isDebuggable: Boolean,
val isRunningUnderTestService: Boolean,
val isTestnet: Boolean,
val gitSha: String,
val gitCommitCount: Long
) {
@ -26,11 +28,12 @@ data class VersionInfo(
versionName = packageInfo.versionName ?: "null",
// Should only be 0 during tests
versionCode = packageInfo.versionCodeCompat,
isDebuggable = (
(0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) &&
!FirebaseTestLabUtil.isFirebaseTestLab(context.applicationContext) &&
!EmulatorWtfUtil.isEmulatorWtf(context.applicationContext)
isDebuggable = (0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE),
isRunningUnderTestService = (
FirebaseTestLabUtil.isFirebaseTestLab(context.applicationContext) ||
EmulatorWtfUtil.isEmulatorWtf(context.applicationContext)
),
isTestnet = context.resources.getBoolean(cash.z.ecc.sdk.ext.R.bool.zcash_is_testnet),
gitSha = gitSha,
gitCommitCount = gitCommitCount.toLong()
)

View File

@ -8,19 +8,26 @@ object VersionInfoFixture {
const val VERSION_NAME = "1.0.0"
const val VERSION_CODE = 1L
const val IS_DEBUGGABLE = false
const val IS_TESTNET = false
const val IS_RUNNING_UNDER_TEST_SERVICE = false
const val GIT_SHA = "635dac0eb9ddc2bc6da5177f0dd495d8b76af4dc"
const val GIT_COMMIT_COUNT = 1L
@Suppress("LongParameterList")
fun new(
versionName: String = VERSION_NAME,
versionCode: Long = VERSION_CODE,
isDebuggable: Boolean = IS_DEBUGGABLE,
isRunningUnderTestService: Boolean = IS_RUNNING_UNDER_TEST_SERVICE,
isTestnet: Boolean = IS_TESTNET,
gitSha: String = GIT_SHA,
gitCommitCount: Long = GIT_COMMIT_COUNT
) = VersionInfo(
versionName,
versionCode,
isDebuggable,
isRunningUnderTestService,
isTestnet,
gitSha,
gitCommitCount
)

View File

@ -97,7 +97,7 @@ private fun AboutTopAppBar(
backContentDescriptionText = stringResource(R.string.about_back_content_description),
onBack = onBack,
regularActions = {
if (versionInfo.isDebuggable) {
if (versionInfo.isDebuggable && !versionInfo.isRunningUnderTestService) {
DebugMenu(versionInfo, configInfo)
}
}

View File

@ -17,6 +17,9 @@ object FileShareUtil {
const val ZASHI_INTERNAL_DATA_AUTHORITY = "co.electriccoin.zcash.provider" // NON-NLS
const val ZASHI_INTERNAL_DATA_AUTHORITY_DEBUG = "co.electriccoin.zcash.debug.provider" // NON-NLS
const val ZASHI_INTERNAL_DATA_AUTHORITY_TESTNET = "co.electriccoin.zcash.provider.testnet" // NON-NLS
const val ZASHI_INTERNAL_DATA_AUTHORITY_TESTNET_DEBUG = "co.electriccoin.zcash.debug.provider.testnet" // NON-NLS
/**
* Returns a new share internal app data intent with necessary permission granted exclusively to the data file.
*
@ -32,11 +35,7 @@ object FileShareUtil {
val fileUri =
FileProvider.getUriForFile(
context,
if (versionInfo.isDebuggable) {
ZASHI_INTERNAL_DATA_AUTHORITY_DEBUG
} else {
ZASHI_INTERNAL_DATA_AUTHORITY
},
getAuthorityByVersionInfo(versionInfo),
File(dataFilePath)
)
@ -60,4 +59,19 @@ object FileShareUtil {
return shareDataIntent
}
private fun getAuthorityByVersionInfo(versionInfo: VersionInfo) =
if (versionInfo.isTestnet) {
if (versionInfo.isDebuggable) {
ZASHI_INTERNAL_DATA_AUTHORITY_TESTNET_DEBUG
} else {
ZASHI_INTERNAL_DATA_AUTHORITY_TESTNET
}
} else {
if (versionInfo.isDebuggable) {
ZASHI_INTERNAL_DATA_AUTHORITY_DEBUG
} else {
ZASHI_INTERNAL_DATA_AUTHORITY
}
}
}

View File

@ -77,7 +77,7 @@ internal fun WrapOnboarding(activity: ComponentActivity) {
ShortOnboarding(
showWelcomeAnim = showWelcomeAnimation,
isDebugMenuEnabled = versionInfo.isDebuggable,
isDebugMenuEnabled = versionInfo.isDebuggable && !versionInfo.isRunningUnderTestService,
onImportWallet = onImportWallet,
onCreateWallet = onCreateWallet,
onFixtureWallet = onFixtureWallet

View File

@ -77,7 +77,7 @@ private fun WrapSettings(
} else {
Settings(
TroubleshootingParameters(
isEnabled = versionInfo.isDebuggable,
isEnabled = versionInfo.isDebuggable && !versionInfo.isRunningUnderTestService,
isBackgroundSyncEnabled = isBackgroundSyncEnabled,
isKeepScreenOnDuringSyncEnabled = isKeepScreenOnWhileSyncing,
isAnalyticsEnabled = isAnalyticsEnabled,