Skip to content

Commit 23d7ff3

Browse files
committed
Add Remote Config smoke tests.
1 parent 8eb2e7e commit 23d7ff3

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

smoke-tests/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ android {
6767
combined {
6868
java.srcDirs = [
6969
"src/combined/java",
70-
"src/database/java",
71-
"src/firestore/java",
72-
"src/functions/java",
73-
"src/storage/java",
70+
"src/database/java",
71+
"src/firestore/java",
72+
"src/functions/java",
73+
"src/remoteConfig/java",
74+
"src/storage/java",
7475
]
7576
}
7677
}
@@ -103,6 +104,7 @@ dependencies {
103104
combinedImplementation "com.google.firebase:firebase-database"
104105
combinedImplementation "com.google.firebase:firebase-firestore"
105106
combinedImplementation "com.google.firebase:firebase-functions"
107+
combinedImplementation "com.google.firebase:firebase-config"
106108
combinedImplementation "com.google.firebase:firebase-storage"
107109

108110
// Database

smoke-tests/configure.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
def configurePlatform() {
17-
def bom = "com.google.firebase:firebase-bom:18.1.0"
17+
def bom = "com.google.firebase:firebase-bom:20.0.0"
1818
if (project.hasProperty("firebase-bom")) {
1919
bom = project.getProperty("firebase-bom")
2020
}

smoke-tests/src/combined/java/com/google/firebase/testing/combined/AllTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.google.firebase.testing.database.DatabaseTest;
1818
import com.google.firebase.testing.firestore.FirestoreTest;
1919
import com.google.firebase.testing.functions.FunctionsTest;
20+
import com.google.firebase.testing.remoteconfig.RemoteConfigTest;
2021
import com.google.firebase.testing.storage.StorageTest;
2122
import org.junit.runner.RunWith;
2223
import org.junit.runners.Suite;
@@ -25,5 +26,11 @@
2526
* A test suite combining the individual product flavors.
2627
*/
2728
@RunWith(Suite.class)
28-
@Suite.SuiteClasses({DatabaseTest.class, FirestoreTest.class, FunctionsTest.class, StorageTest.class})
29+
@Suite.SuiteClasses({
30+
DatabaseTest.class,
31+
FirestoreTest.class,
32+
FunctionsTest.class,
33+
RemoteConfigTest.class,
34+
StorageTest.class,
35+
})
2936
public final class AllTests {}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2018 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.testing.remoteconfig;
16+
17+
import static com.google.common.truth.Truth.assertThat;
18+
import static com.google.firebase.testing.common.Tasks2.waitForSuccess;
19+
20+
import android.app.Activity;
21+
import androidx.test.rule.ActivityTestRule;
22+
import androidx.test.runner.AndroidJUnit4;
23+
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
24+
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
25+
import org.junit.Before;
26+
import org.junit.Rule;
27+
import org.junit.Test;
28+
import org.junit.runner.RunWith;
29+
30+
@RunWith(AndroidJUnit4.class)
31+
public final class RemoteConfigTest {
32+
33+
private static final String MODEL_NAME = "Acura/Honda+Mercedes-Benz";
34+
private static final boolean COLOR_IS_RED = true;
35+
36+
@Rule public final ActivityTestRule<Activity> activity = new ActivityTestRule<>(Activity.class);
37+
38+
@Before
39+
public void prepareRemoteConfig() throws Exception {
40+
FirebaseRemoteConfig frc = FirebaseRemoteConfig.getInstance();
41+
42+
waitForSuccess(frc.fetch());
43+
waitForSuccess(frc.activate());
44+
}
45+
46+
@Test
47+
public void getBooleanConvertsValueSetInConsole() {
48+
FirebaseRemoteConfig frc = FirebaseRemoteConfig.getInstance();
49+
50+
assertThat(frc.getBoolean("COLOR_IS_RED")).isEqualTo(COLOR_IS_RED);
51+
}
52+
53+
@Test
54+
public void getStringReturnsValueSetInConsole() {
55+
FirebaseRemoteConfig frc = FirebaseRemoteConfig.getInstance();
56+
57+
assertThat(frc.getString("MODEL_NAME")).isEqualTo(MODEL_NAME);
58+
}
59+
60+
@Test
61+
public void getValueNotSetInConsoleYieldsStaticSource() {
62+
FirebaseRemoteConfig frc = FirebaseRemoteConfig.getInstance();
63+
FirebaseRemoteConfigValue value = frc.getValue("GOOBER_GOOBER");
64+
65+
assertThat(value.getSource()).isEqualTo(FirebaseRemoteConfig.VALUE_SOURCE_STATIC);
66+
}
67+
}

0 commit comments

Comments
 (0)