summaryrefslogtreecommitdiff
path: root/java/tests
diff options
context:
space:
mode:
author Mark Renouf <mrenouf@google.com> 2023-08-28 15:12:19 -0400
committer Mark Renouf <mrenouf@google.com> 2023-08-30 16:37:55 -0400
commitb45704b2e6810a85fe594855a9e9a307b5fd43fe (patch)
tree011c436fba32523a0915c156d7fbd296cae66a47 /java/tests
parent08ce30f8ec4fb0dfbd3b544bbcb79d404c8d9bf2 (diff)
Revert "Creates application-level and activity-level dagger graphs"
This reverts commit 114b886b4aaf3341b4072f184c96cc71d4763f76. and dependent commit 35a34bcaf236597703208cf0472cb268b42abb1c. Change-Id: Ied8c43ed7c596624e045cb8e7b4e7f1c9ba66c58
Diffstat (limited to 'java/tests')
-rw-r--r--java/tests/Android.bp1
-rw-r--r--java/tests/AndroidManifest.xml8
-rw-r--r--java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java8
-rw-r--r--java/tests/src/com/android/intentresolver/ResolverWrapperActivity.java3
-rw-r--r--java/tests/src/com/android/intentresolver/TestApplication.kt7
-rw-r--r--java/tests/src/com/android/intentresolver/dagger/TestActivityBinderModule.kt40
-rw-r--r--java/tests/src/com/android/intentresolver/dagger/TestActivityComponent.kt30
-rw-r--r--java/tests/src/com/android/intentresolver/dagger/TestApplicationComponent.kt34
-rw-r--r--java/tests/src/com/android/intentresolver/dagger/TestApplicationModule.kt38
-rw-r--r--java/tests/src/com/android/intentresolver/dagger/TestViewModelComponent.kt29
-rw-r--r--java/tests/src/com/android/intentresolver/dagger/TestViewModelModule.kt6
11 files changed, 6 insertions, 198 deletions
diff --git a/java/tests/Android.bp b/java/tests/Android.bp
index 3936b38e..90c7fb7a 100644
--- a/java/tests/Android.bp
+++ b/java/tests/Android.bp
@@ -20,6 +20,7 @@ android_test {
static_libs: [
"IntentResolver-core",
"androidx.test.core",
+ "androidx.test.rules",
"androidx.test.ext.junit",
"androidx.test.ext.truth",
"androidx.test.espresso.contrib",
diff --git a/java/tests/AndroidManifest.xml b/java/tests/AndroidManifest.xml
index 9f8dd41c..05830c4c 100644
--- a/java/tests/AndroidManifest.xml
+++ b/java/tests/AndroidManifest.xml
@@ -15,8 +15,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="com.android.intentresolver.tests">
+ package="com.android.intentresolver.tests">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
@@ -26,10 +25,7 @@
<uses-permission android:name="android.permission.WRITE_DEVICE_CONFIG"/>
<uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
- <application
- android:name="com.android.intentresolver.TestApplication"
- tools:replace="android:appComponentFactory"
- android:appComponentFactory="com.android.intentresolver.dagger.InjectedAppComponentFactory">
+ <application android:name="com.android.intentresolver.TestApplication">
<uses-library android:name="android.test.runner" />
<activity android:name="com.android.intentresolver.ChooserWrapperActivity" />
<activity android:name="com.android.intentresolver.ResolverWrapperActivity" />
diff --git a/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java b/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java
index 49305a6c..8608cf72 100644
--- a/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java
+++ b/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java
@@ -37,7 +37,6 @@ import androidx.lifecycle.ViewModelProvider;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.CrossProfileIntentsChecker;
import com.android.intentresolver.chooser.DisplayResolveInfo;
import com.android.intentresolver.chooser.TargetInfo;
-import com.android.intentresolver.dagger.TestViewModelComponent;
import com.android.intentresolver.flags.FeatureFlagRepository;
import com.android.intentresolver.grid.ChooserGridAdapter;
import com.android.intentresolver.icons.TargetDataLoader;
@@ -48,8 +47,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import java.util.List;
import java.util.function.Consumer;
-import javax.inject.Inject;
-
/**
* Simple wrapper around chooser activity to be able to initiate it under test. For more
* information, see {@code com.android.internal.app.ChooserWrapperActivity}.
@@ -59,11 +56,6 @@ public class ChooserWrapperActivity
static final ChooserActivityOverrideData sOverrides = ChooserActivityOverrideData.getInstance();
private UsageStatsManager mUsm;
- @Inject
- public ChooserWrapperActivity(TestViewModelComponent.Builder builder) {
- super(builder);
- }
-
// ResolverActivity (the base class of ChooserActivity) inspects the launched-from UID at
// onCreate and needs to see some non-negative value in the test.
@Override
diff --git a/java/tests/src/com/android/intentresolver/ResolverWrapperActivity.java b/java/tests/src/com/android/intentresolver/ResolverWrapperActivity.java
index 11e7dffd..401ede26 100644
--- a/java/tests/src/com/android/intentresolver/ResolverWrapperActivity.java
+++ b/java/tests/src/com/android/intentresolver/ResolverWrapperActivity.java
@@ -44,8 +44,6 @@ import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
-import javax.inject.Inject;
-
/*
* Simple wrapper around chooser activity to be able to initiate it under test
*/
@@ -55,7 +53,6 @@ public class ResolverWrapperActivity extends ResolverActivity {
private final CountingIdlingResource mLabelIdlingResource =
new CountingIdlingResource("LoadLabelTask");
- @Inject
public ResolverWrapperActivity() {
super(/* isIntentPicker= */ true);
}
diff --git a/java/tests/src/com/android/intentresolver/TestApplication.kt b/java/tests/src/com/android/intentresolver/TestApplication.kt
index 4f5aefb9..849cfbab 100644
--- a/java/tests/src/com/android/intentresolver/TestApplication.kt
+++ b/java/tests/src/com/android/intentresolver/TestApplication.kt
@@ -16,13 +16,12 @@
package com.android.intentresolver
+import android.app.Application
import android.content.Context
import android.os.UserHandle
-import com.android.intentresolver.dagger.DaggerTestApplicationComponent
-class TestApplication : IntentResolverApplication() {
- override fun createApplicationComponentBuilder() = DaggerTestApplicationComponent.builder()
+class TestApplication : Application() {
// return the current context as a work profile doesn't really exist in these tests
override fun createContextAsUser(user: UserHandle, flags: Int): Context = this
-}
+} \ No newline at end of file
diff --git a/java/tests/src/com/android/intentresolver/dagger/TestActivityBinderModule.kt b/java/tests/src/com/android/intentresolver/dagger/TestActivityBinderModule.kt
deleted file mode 100644
index c08bc3b2..00000000
--- a/java/tests/src/com/android/intentresolver/dagger/TestActivityBinderModule.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.intentresolver.dagger
-
-import android.app.Activity
-import com.android.intentresolver.ChooserWrapperActivity
-import com.android.intentresolver.ResolverWrapperActivity
-import dagger.Binds
-import dagger.Module
-import dagger.multibindings.ClassKey
-import dagger.multibindings.IntoMap
-
-@Module
-interface TestActivityBinderModule {
- @Binds
- @IntoMap
- @ClassKey(ResolverWrapperActivity::class)
- @ActivityScope
- fun resolverWrapperActivity(activity: ResolverWrapperActivity): Activity
-
- @Binds
- @IntoMap
- @ClassKey(ChooserWrapperActivity::class)
- @ActivityScope
- fun chooserWrapperActivity(activity: ChooserWrapperActivity): Activity
-}
diff --git a/java/tests/src/com/android/intentresolver/dagger/TestActivityComponent.kt b/java/tests/src/com/android/intentresolver/dagger/TestActivityComponent.kt
deleted file mode 100644
index 4416c852..00000000
--- a/java/tests/src/com/android/intentresolver/dagger/TestActivityComponent.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.intentresolver.dagger
-
-import dagger.Subcomponent
-
-@ActivityScope
-@Subcomponent(
- modules = [ActivityModule::class, ActivityBinderModule::class, TestActivityBinderModule::class]
-)
-interface TestActivityComponent : ActivityComponent {
- @Subcomponent.Factory
- interface Factory : ActivityComponent.Factory {
- override fun create(): TestActivityComponent
- }
-}
diff --git a/java/tests/src/com/android/intentresolver/dagger/TestApplicationComponent.kt b/java/tests/src/com/android/intentresolver/dagger/TestApplicationComponent.kt
deleted file mode 100644
index 224c46c6..00000000
--- a/java/tests/src/com/android/intentresolver/dagger/TestApplicationComponent.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.intentresolver.dagger
-
-import android.app.Application
-import dagger.BindsInstance
-import dagger.Component
-import javax.inject.Singleton
-
-@Singleton
-@Component(modules = [TestApplicationModule::class])
-interface TestApplicationComponent : ApplicationComponent {
- @Component.Builder
- interface Builder : ApplicationComponent.Builder {
- @BindsInstance
- override fun application(application: Application): TestApplicationComponent.Builder
-
- override fun build(): TestApplicationComponent
- }
-}
diff --git a/java/tests/src/com/android/intentresolver/dagger/TestApplicationModule.kt b/java/tests/src/com/android/intentresolver/dagger/TestApplicationModule.kt
deleted file mode 100644
index 714748d2..00000000
--- a/java/tests/src/com/android/intentresolver/dagger/TestApplicationModule.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.intentresolver.dagger
-
-import dagger.Binds
-import dagger.Module
-import javax.inject.Singleton
-
-@Module(
- subcomponents = [TestActivityComponent::class, TestViewModelComponent::class],
- includes = [ReceiverBinderModule::class, CoroutinesModule::class]
-)
-interface TestApplicationModule : ApplicationModule {
-
- /** Required to support field injection of [InjectedAppComponentFactory] */
- @Binds
- @Singleton
- fun activityComponent(component: TestActivityComponent.Factory): ActivityComponent.Factory
-
- /** Required to support injection into Activity instances */
- @Binds
- @Singleton
- fun viewModelComponent(component: TestViewModelComponent.Builder): ViewModelComponent.Builder
-}
diff --git a/java/tests/src/com/android/intentresolver/dagger/TestViewModelComponent.kt b/java/tests/src/com/android/intentresolver/dagger/TestViewModelComponent.kt
deleted file mode 100644
index 539b3f36..00000000
--- a/java/tests/src/com/android/intentresolver/dagger/TestViewModelComponent.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.intentresolver.dagger
-
-import dagger.Subcomponent
-
-/** A ViewModelComponent for tests which replaces ViewModelModule -> TestViewModelModule */
-@ViewModelScope
-@Subcomponent(modules = [TestViewModelModule::class, ViewModelBinderModule::class])
-interface TestViewModelComponent : ViewModelComponent {
- @Subcomponent.Builder
- interface Builder : ViewModelComponent.Builder {
- override fun build(): TestViewModelComponent
- }
-}
diff --git a/java/tests/src/com/android/intentresolver/dagger/TestViewModelModule.kt b/java/tests/src/com/android/intentresolver/dagger/TestViewModelModule.kt
deleted file mode 100644
index 28f4fa73..00000000
--- a/java/tests/src/com/android/intentresolver/dagger/TestViewModelModule.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.android.intentresolver.dagger
-
-import dagger.Module
-
-/** Provides bindings shared among components within [@ViewModelScope][ViewModelScope]. */
-@Module abstract class TestViewModelModule