Skip to content

Commit a0387fc

Browse files
authored
Add Proguard Files to Smoke Tests (#572)
This change adds the necessary proguard files and a configuration block for release builds. However, this change does not yet enable testing against the release build.
1 parent 4b150b8 commit a0387fc

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

smoke-tests/build.gradle

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ android {
3939
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4040
}
4141

42+
buildTypes {
43+
release {
44+
minifyEnabled true
45+
shrinkResources true
46+
signingConfig signingConfigs.debug
47+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "smoke-test-rules.pro"
48+
testProguardFiles "infrastructure-rules.pro"
49+
}
50+
}
51+
4252
flavorDimensions "systemUnderTest"
4353

4454
// TODO(allisonbm92): Switch to the default flavor.
@@ -58,12 +68,11 @@ apply from: "configure.gradle"
5868

5969
dependencies {
6070
// Common
61-
api "androidx.test:runner:1.2.0"
62-
api "com.google.truth:truth:0.45"
63-
api "junit:junit:4.12"
64-
6571
implementation "androidx.test:rules:1.2.0"
72+
implementation "androidx.test:runner:1.2.0"
6673
implementation "com.google.firebase:firebase-common"
74+
implementation "com.google.truth:truth:0.44"
75+
implementation "junit:junit:4.12"
6776

6877
// All
6978
combinedImplementation "com.google.firebase:firebase-auth"
@@ -73,6 +82,10 @@ dependencies {
7382
// combinedImplementation "com.google.firebase:firebase-inappmessaging"
7483
combinedImplementation "com.google.firebase:firebase-config"
7584
combinedImplementation "com.google.firebase:firebase-storage"
85+
86+
androidTestImplementation "androidx.test:core:1.2.0"
87+
androidTestImplementation "androidx.test:runner:1.2.0"
88+
androidTestImplementation "junit:junit:4.12"
7689
}
7790

7891
clean.doLast {

smoke-tests/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
android.enableJetifier=true
15+
android.enableR8=true
1616
android.useAndroidX=true

smoke-tests/infrastructure-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-dontobfuscate
2+
-dontoptimize
3+
-dontshrink

smoke-tests/smoke-test-rules.pro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-optimizationpasses 3
2+
-keepattributes SourceFile, LineNumberTable, *Annotation*
3+
4+
-keep @org.junit.runner.RunWith class *
5+
-keep class androidx.test.**
6+
-keep class org.junit.**
7+
8+
-keepclassmembers @org.junit.runner.RunWith class * {
9+
public <methods>;
10+
public <fields>;
11+
}
12+
13+
-keepclassmembers class androidx.test.** {
14+
public <methods>;
15+
}
16+
17+
-keepclassmembers class org.junit.** {
18+
protected <methods>;
19+
public <methods>;
20+
}
21+
22+
-dontwarn android.**
23+
-dontwarn okio.**

smoke-tests/src/androidTest/java/com/google/firebase/testing/common/SmokeTestSuite.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import android.content.Context;
1818
import android.content.pm.ApplicationInfo;
1919
import android.content.pm.PackageManager;
20-
import androidx.test.InstrumentationRegistry;
20+
import androidx.test.core.app.ApplicationProvider;
2121
import java.util.ArrayList;
2222
import java.util.Arrays;
2323
import java.util.List;
@@ -69,7 +69,7 @@ protected void runChild(Runner runner, RunNotifier notifier) {
6969
}
7070

7171
private static List<Class<?>> getTestClasses() throws InitializationError {
72-
Context ctx = InstrumentationRegistry.getTargetContext();
72+
Context ctx = ApplicationProvider.getApplicationContext();
7373
return getTestClasses(ctx);
7474
}
7575

0 commit comments

Comments
 (0)