Fix android instrumented tests failures

Caused by some ops in core's newly added initializers to happen before
the DI componenet was setup.
Based on https://github.com/google/dagger/issues/3356 this issue is
fixed in dagger / hilt 2.42. Such upgrade doesn't apply cleanly here,
which lead to this workaround of removing the offending core
initializers in the manifest to instead invoke them manually, so that
they won't be initialized when runnign tests (as they use
`HiltTestApplication` instead of `ProtonApplication`)
This commit is contained in:
Marino Meneghel 2022-10-03 17:37:56 +02:00
parent 9fb9f43c70
commit 71730d51df
2 changed files with 14 additions and 0 deletions

View File

@ -90,6 +90,16 @@
android:exported="false"
tools:node="merge">
<meta-data
android:name="me.proton.core.humanverification.presentation.HumanVerificationInitializer"
android:value="androidx.startup"
tools:node="remove" />
<meta-data
android:name="me.proton.core.auth.presentation.MissingScopeInitializer"
android:value="androidx.startup"
tools:node="remove" />
<!-- Disable default WorkManagerInitializer for use Hilt injection -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"

View File

@ -105,8 +105,10 @@ import ch.protonmail.android.worker.FetchContactsDataWorker;
import ch.protonmail.android.worker.FetchContactsEmailsWorker;
import dagger.hilt.android.HiltAndroidApp;
import me.proton.core.accountmanager.domain.AccountManager;
import me.proton.core.auth.presentation.MissingScopeInitializer;
import me.proton.core.crypto.validator.presentation.init.CryptoValidatorInitializer;
import me.proton.core.domain.entity.UserId;
import me.proton.core.humanverification.presentation.HumanVerificationInitializer;
import me.proton.core.util.kotlin.CoreLogger;
import studio.forface.viewstatestore.ViewStateStoreConfig;
import timber.log.Timber;
@ -226,6 +228,8 @@ public class ProtonMailApplication extends Application implements androidx.work.
appInitializer.initializeComponent(AccountStateHandlerInitializer.class);
appInitializer.initializeComponent(CryptoValidatorInitializer.class);
appInitializer.initializeComponent(SecurityManagerInitializer.class);
appInitializer.initializeComponent(HumanVerificationInitializer.class);
appInitializer.initializeComponent(MissingScopeInitializer.class);
checkForUpdateAndClearCache();
}