aboutsummaryrefslogtreecommitdiff
path: root/javatests/artifacts/hilt-android
diff options
context:
space:
mode:
Diffstat (limited to 'javatests/artifacts/hilt-android')
-rw-r--r--javatests/artifacts/hilt-android/gradleConfigCache/app/build.gradle4
-rw-r--r--javatests/artifacts/hilt-android/gradleConfigCache/build.gradle16
-rw-r--r--javatests/artifacts/hilt-android/simple/app/build.gradle1
-rw-r--r--javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/CustomTestApplicationTest.java66
-rw-r--r--javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/SimpleEmulatorTestRunner.java5
-rw-r--r--javatests/artifacts/hilt-android/simple/app/src/sharedTest/java/dagger/hilt/android/simple/BaseTestApplication.java68
-rw-r--r--javatests/artifacts/hilt-android/simple/app/src/test/java/dagger/hilt/android/simple/CustomTestApplicationTest.java72
-rw-r--r--javatests/artifacts/hilt-android/simple/build.gradle16
-rw-r--r--javatests/artifacts/hilt-android/simpleKotlin/build.gradle13
9 files changed, 3 insertions, 258 deletions
diff --git a/javatests/artifacts/hilt-android/gradleConfigCache/app/build.gradle b/javatests/artifacts/hilt-android/gradleConfigCache/app/build.gradle
index 4f21d0a38..43ccd1d55 100644
--- a/javatests/artifacts/hilt-android/gradleConfigCache/app/build.gradle
+++ b/javatests/artifacts/hilt-android/gradleConfigCache/app/build.gradle
@@ -38,9 +38,6 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
- lintOptions {
- checkReleaseBuilds = false
- }
testOptions {
unitTests.includeAndroidResources = true
}
@@ -48,7 +45,6 @@ android {
hilt {
enableTransformForLocalTests = true
- enableExperimentalClasspathAggregation = true
}
dependencies {
diff --git a/javatests/artifacts/hilt-android/gradleConfigCache/build.gradle b/javatests/artifacts/hilt-android/gradleConfigCache/build.gradle
index de0566c5d..3b0cddeb4 100644
--- a/javatests/artifacts/hilt-android/gradleConfigCache/build.gradle
+++ b/javatests/artifacts/hilt-android/gradleConfigCache/build.gradle
@@ -38,20 +38,4 @@ allprojects {
mavenCentral()
mavenLocal()
}
- // TODO(bcorso): Consider organizing all projects under a single project
- // that share a build.gradle configuration to reduce the copy-paste.
- // Local tests: Adds logs for individual local tests
- tasks.withType(Test) {
- testLogging {
- exceptionFormat "full"
- showCauses true
- showExceptions true
- showStackTraces true
- showStandardStreams true
- events = ["passed", "skipped", "failed", "standardOut", "standardError"]
- }
- }
}
-
-// Instrumentation tests: Combines test reports for all modules
-apply plugin: 'android-reporting' \ No newline at end of file
diff --git a/javatests/artifacts/hilt-android/simple/app/build.gradle b/javatests/artifacts/hilt-android/simple/app/build.gradle
index 1d76ec26c..98b79e188 100644
--- a/javatests/artifacts/hilt-android/simple/app/build.gradle
+++ b/javatests/artifacts/hilt-android/simple/app/build.gradle
@@ -97,6 +97,7 @@ dependencies {
// To help us catch version skew related issues in hilt extensions.
// TODO(bcorso): Add examples testing the actual API.
+ implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01'
implementation 'androidx.hilt:hilt-work:1.0.0-alpha01'
annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0-alpha01'
testAnnotationProcessor 'androidx.hilt:hilt-compiler:1.0.0-alpha01'
diff --git a/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/CustomTestApplicationTest.java b/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/CustomTestApplicationTest.java
deleted file mode 100644
index de2e37aef..000000000
--- a/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/CustomTestApplicationTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2021 The Dagger Authors.
- *
- * 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 dagger.hilt.android.simple;
-
-import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import dagger.hilt.android.simple.BaseTestApplication.Foo;
-import dagger.hilt.android.testing.HiltAndroidRule;
-import dagger.hilt.android.testing.HiltAndroidTest;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/** Tests {@link dagger.hilt.android.testing.CustomTestApplication}. */
-@HiltAndroidTest
-@RunWith(AndroidJUnit4.class)
-public final class CustomTestApplicationTest {
- @Rule public HiltAndroidRule rule = new HiltAndroidRule(this);
-
- @Test
- public void testApplicationBaseClass() throws Exception {
- assertThat((Context) getApplicationContext()).isInstanceOf(BaseTestApplication.class);
- }
-
- @Test
- public void testEarlyEntryPoint() throws Exception {
- BaseTestApplication app = (BaseTestApplication) getApplicationContext();
-
- // Assert that all scoped Foo instances from EarlyEntryPoint are equal
- Foo earlyFoo = app.earlyFoo();
- Foo lazyEarlyFoo1 = app.lazyEarlyFoo();
- Foo lazyEarlyFoo2 = app.lazyEarlyFoo();
- assertThat(earlyFoo).isNotNull();
- assertThat(lazyEarlyFoo1).isNotNull();
- assertThat(lazyEarlyFoo2).isNotNull();
- assertThat(earlyFoo).isEqualTo(lazyEarlyFoo1);
- assertThat(earlyFoo).isEqualTo(lazyEarlyFoo2);
-
- // Assert that all scoped Foo instances from EntryPoint are equal
- Foo lazyFoo1 = app.lazyFoo();
- Foo lazyFoo2 = app.lazyFoo();
- assertThat(lazyFoo1).isNotNull();
- assertThat(lazyFoo2).isNotNull();
- assertThat(lazyFoo1).isEqualTo(lazyFoo2);
-
- // Assert that scoped Foo instances from EarlyEntryPoint and EntryPoint are not equal
- assertThat(earlyFoo).isNotEqualTo(lazyFoo1);
- }
-}
diff --git a/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/SimpleEmulatorTestRunner.java b/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/SimpleEmulatorTestRunner.java
index 8d4913b35..6ee721c84 100644
--- a/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/SimpleEmulatorTestRunner.java
+++ b/javatests/artifacts/hilt-android/simple/app/src/androidTest/java/dagger/hilt/android/simple/SimpleEmulatorTestRunner.java
@@ -19,15 +19,14 @@ package dagger.hilt.android.simple;
import android.app.Application;
import android.content.Context;
import androidx.test.runner.AndroidJUnitRunner;
-import dagger.hilt.android.testing.CustomTestApplication;
+import dagger.hilt.android.testing.HiltTestApplication;
/** A custom runner to setup the emulator application class for tests. */
-@CustomTestApplication(BaseTestApplication.class)
public final class SimpleEmulatorTestRunner extends AndroidJUnitRunner {
@Override
public Application newApplication(ClassLoader cl, String className, Context context)
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
- return super.newApplication(cl, SimpleEmulatorTestRunner_Application.class.getName(), context);
+ return super.newApplication(cl, HiltTestApplication.class.getName(), context);
}
}
diff --git a/javatests/artifacts/hilt-android/simple/app/src/sharedTest/java/dagger/hilt/android/simple/BaseTestApplication.java b/javatests/artifacts/hilt-android/simple/app/src/sharedTest/java/dagger/hilt/android/simple/BaseTestApplication.java
deleted file mode 100644
index 7af0cb39e..000000000
--- a/javatests/artifacts/hilt-android/simple/app/src/sharedTest/java/dagger/hilt/android/simple/BaseTestApplication.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2021 The Dagger Authors.
- *
- * 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 dagger.hilt.android.simple;
-
-import android.app.Application;
-import dagger.hilt.EntryPoint;
-import dagger.hilt.EntryPoints;
-import dagger.hilt.InstallIn;
-import dagger.hilt.android.EarlyEntryPoint;
-import dagger.hilt.android.EarlyEntryPoints;
-import dagger.hilt.components.SingletonComponent;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-/** A custom application used to test @EarlyEntryPoint */
-public class BaseTestApplication extends Application {
- @EarlyEntryPoint
- @InstallIn(SingletonComponent.class)
- interface EarlyFooEntryPoint {
- Foo earlyFoo();
- }
-
- @EntryPoint
- @InstallIn(SingletonComponent.class)
- interface FooEntryPoint {
- Foo lazyFoo();
- }
-
- @Singleton
- public static final class Foo {
- @Inject
- Foo() {}
- }
-
- private Foo earlyFoo;
-
- @Override
- public void onCreate() {
- super.onCreate();
- earlyFoo = EarlyEntryPoints.get(this, EarlyFooEntryPoint.class).earlyFoo();
- }
-
- public Foo earlyFoo() {
- return earlyFoo;
- }
-
- public Foo lazyEarlyFoo() {
- return EarlyEntryPoints.get(this, EarlyFooEntryPoint.class).earlyFoo();
- }
-
- public Foo lazyFoo() {
- return EntryPoints.get(this, FooEntryPoint.class).lazyFoo();
- }
-}
diff --git a/javatests/artifacts/hilt-android/simple/app/src/test/java/dagger/hilt/android/simple/CustomTestApplicationTest.java b/javatests/artifacts/hilt-android/simple/app/src/test/java/dagger/hilt/android/simple/CustomTestApplicationTest.java
deleted file mode 100644
index 8c7f73f27..000000000
--- a/javatests/artifacts/hilt-android/simple/app/src/test/java/dagger/hilt/android/simple/CustomTestApplicationTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2021 The Dagger Authors.
- *
- * 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 dagger.hilt.android.simple;
-
-import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.os.Build;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import dagger.hilt.android.simple.BaseTestApplication.Foo;
-import dagger.hilt.android.testing.CustomTestApplication;
-import dagger.hilt.android.testing.HiltAndroidRule;
-import dagger.hilt.android.testing.HiltAndroidTest;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
-
-/** Tests {@link dagger.hilt.android.testing.CustomTestApplication}. */
-@CustomTestApplication(BaseTestApplication.class)
-@HiltAndroidTest
-@RunWith(AndroidJUnit4.class)
-// Robolectric requires Java9 to run API 29 and above, so use API 28 instead
-@Config(sdk = Build.VERSION_CODES.P, application = CustomTestApplicationTest_Application.class)
-public final class CustomTestApplicationTest {
- @Rule public HiltAndroidRule rule = new HiltAndroidRule(this);
-
- @Test
- public void testApplicationBaseClass() throws Exception {
- assertThat((Context) getApplicationContext()).isInstanceOf(BaseTestApplication.class);
- }
-
- @Test
- public void testEarlyEntryPoint() throws Exception {
- BaseTestApplication app = (BaseTestApplication) getApplicationContext();
-
- // Assert that all scoped Foo instances from EarlyEntryPoint are equal
- Foo earlyFoo = app.earlyFoo();
- Foo lazyEarlyFoo1 = app.lazyEarlyFoo();
- Foo lazyEarlyFoo2 = app.lazyEarlyFoo();
- assertThat(earlyFoo).isNotNull();
- assertThat(lazyEarlyFoo1).isNotNull();
- assertThat(lazyEarlyFoo2).isNotNull();
- assertThat(earlyFoo).isEqualTo(lazyEarlyFoo1);
- assertThat(earlyFoo).isEqualTo(lazyEarlyFoo2);
-
- // Assert that all scoped Foo instances from EntryPoint are equal
- Foo lazyFoo1 = app.lazyFoo();
- Foo lazyFoo2 = app.lazyFoo();
- assertThat(lazyFoo1).isNotNull();
- assertThat(lazyFoo2).isNotNull();
- assertThat(lazyFoo1).isEqualTo(lazyFoo2);
-
- // Assert that scoped Foo instances from EarlyEntryPoint and EntryPoint are not equal
- assertThat(earlyFoo).isNotEqualTo(lazyFoo1);
- }
-}
diff --git a/javatests/artifacts/hilt-android/simple/build.gradle b/javatests/artifacts/hilt-android/simple/build.gradle
index 59336bcbf..770fabd31 100644
--- a/javatests/artifacts/hilt-android/simple/build.gradle
+++ b/javatests/artifacts/hilt-android/simple/build.gradle
@@ -39,20 +39,4 @@ allprojects {
mavenCentral()
mavenLocal()
}
- // TODO(bcorso): Consider organizing all projects under a single project
- // that share a build.gradle configuration to reduce the copy-paste.
- // Local tests: Adds logs for individual local tests
- tasks.withType(Test) {
- testLogging {
- exceptionFormat "full"
- showCauses true
- showExceptions true
- showStackTraces true
- showStandardStreams true
- events = ["passed", "skipped", "failed", "standardOut", "standardError"]
- }
- }
}
-
-// Instrumentation tests: Combines test reports for all modules
-apply plugin: 'android-reporting'
diff --git a/javatests/artifacts/hilt-android/simpleKotlin/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/build.gradle
index e7eb9b252..d59447608 100644
--- a/javatests/artifacts/hilt-android/simpleKotlin/build.gradle
+++ b/javatests/artifacts/hilt-android/simpleKotlin/build.gradle
@@ -38,17 +38,4 @@ allprojects {
mavenCentral()
mavenLocal()
}
- // TODO(bcorso): Consider organizing all projects under a single project
- // that share a build.gradle configuration to reduce the copy-paste.
- // Local tests: Adds logs for individual local tests
- tasks.withType(Test) {
- testLogging {
- exceptionFormat "full"
- showCauses true
- showExceptions true
- showStackTraces true
- showStandardStreams true
- events = ["passed", "skipped", "failed", "standardOut", "standardError"]
- }
- }
}