Skip to content

Commit 988669b

Browse files
committed
Resolve strict mode violations in firebase-messaging
1 parent 39930de commit 988669b

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

firebase-messaging/firebase-messaging.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,13 @@ dependencies {
133133
testImplementation 'androidx.test.ext:truth:1.4.0'
134134
testImplementation 'androidx.test.services:test-services:1.2.0'
135135
testImplementation 'androidx.core:core:1.6.0'
136+
137+
androidTestImplementation project(':integ-testing')
138+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
139+
androidTestImplementation 'androidx.test:runner:1.2.0'
140+
androidTestImplementation "com.google.truth:truth:$googleTruthVersion"
141+
androidTestImplementation 'junit:junit:4.12'
142+
androidTestImplementation "androidx.annotation:annotation:1.0.0"
143+
androidTestImplementation 'org.mockito:mockito-core:2.25.0'
144+
androidTestImplementation 'org.mockito:mockito-inline:2.25.0'
136145
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2019 Google LLC -->
3+
<!-- -->
4+
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
5+
<!-- you may not use this file except in compliance with the License. -->
6+
<!-- You may obtain a copy of the License at -->
7+
<!-- -->
8+
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
9+
<!-- -->
10+
<!-- Unless required by applicable law or agreed to in writing, software -->
11+
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
12+
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
13+
<!-- See the License for the specific language governing permissions and -->
14+
<!-- limitations under the License. -->
15+
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
package="com.google.firebase.installations">
18+
19+
<application>
20+
<uses-library android:name="android.test.runner"/>
21+
</application>
22+
23+
<instrumentation
24+
android:name="androidx.test.runner.AndroidJUnitRunner"
25+
android:targetPackage="com.google.firebase.messaging" />
26+
</manifest>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.messaging;
16+
17+
import androidx.test.core.app.ApplicationProvider;
18+
import androidx.test.ext.junit.runners.AndroidJUnit4;
19+
import com.google.firebase.FirebaseApp;
20+
import com.google.firebase.FirebaseOptions.Builder;
21+
import com.google.firebase.testing.integ.StrictModeRule;
22+
import org.junit.Rule;
23+
import org.junit.Test;
24+
import org.junit.runner.RunWith;
25+
26+
@RunWith(AndroidJUnit4.class)
27+
public class StrictModeTest {
28+
29+
@Rule public StrictModeRule strictMode = new StrictModeRule();
30+
31+
@Test
32+
public void initializingFirebaseMessaging_shouldNotViolateStrictMode() {
33+
strictMode.runOnMainThread(
34+
() -> {
35+
FirebaseApp app =
36+
FirebaseApp.initializeApp(
37+
ApplicationProvider.getApplicationContext(),
38+
new Builder()
39+
.setApiKey("api")
40+
.setProjectId("123")
41+
.setApplicationId("appId")
42+
.build(),
43+
"hello");
44+
app.get(FirebaseMessaging.class);
45+
});
46+
}
47+
}

0 commit comments

Comments
 (0)