Skip to content

Commit 9b2c63a

Browse files
committed
Merge branch 'master' into vk.jetpack_migration
2 parents 1af106a + d12b0d7 commit 9b2c63a

33 files changed

+92
-92
lines changed

firebase-firestore/firebase-firestore.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ dependencies {
117117
}
118118

119119
testImplementation 'junit:junit:4.12'
120+
testImplementation 'androidx.test:core:1.2.0'
120121
testImplementation 'org.mockito:mockito-core:2.25.0'
121122
testImplementation "org.robolectric:robolectric:$robolectricVersion"
122123
testImplementation "com.google.truth:truth:$googleTruthVersion"
@@ -133,9 +134,9 @@ dependencies {
133134

134135
gradle.projectsEvaluated {
135136
tasks.withType(JavaCompile) {
136-
// TODO(rsgowman): Also add "-Xlint:unchecked". But currently that
137+
// TODO(wuandy): Also add "-Xlint:unchecked". But currently that
137138
// enables 100+ warnings due to our generated source code.
138-
options.compilerArgs << "-Xlint:deprecation"
139+
options.compilerArgs << "-Xlint:deprecation" << "-Werror"
139140
}
140141
}
141142

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ArrayTransformsServerApplicationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
2121
import static com.google.firebase.firestore.testutil.TestUtil.map;
2222
import static java.util.Arrays.asList;
23-
import static junit.framework.Assert.assertEquals;
23+
import static org.junit.Assert.assertEquals;
2424

2525
import androidx.test.runner.AndroidJUnit4;
2626
import com.google.firebase.firestore.FirebaseFirestoreException.Code;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ArrayTransformsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
1919
import static com.google.firebase.firestore.testutil.TestUtil.map;
2020
import static java.util.Arrays.asList;
21-
import static junit.framework.Assert.assertEquals;
22-
import static junit.framework.Assert.assertFalse;
21+
import static org.junit.Assert.assertEquals;
22+
import static org.junit.Assert.assertFalse;
2323

2424
import androidx.test.runner.AndroidJUnit4;
2525
import com.google.firebase.firestore.testutil.EventAccumulator;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/CursorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.writeAllDocs;
2424
import static com.google.firebase.firestore.testutil.TestUtil.map;
2525
import static java.util.Arrays.asList;
26-
import static junit.framework.Assert.assertEquals;
27-
import static junit.framework.Assert.assertTrue;
26+
import static org.junit.Assert.assertEquals;
27+
import static org.junit.Assert.assertTrue;
2828

2929
import androidx.test.runner.AndroidJUnit4;
3030
import com.google.firebase.Timestamp;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FieldsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
2323
import static com.google.firebase.firestore.testutil.TestUtil.map;
2424
import static com.google.firebase.firestore.util.Util.autoId;
25-
import static junit.framework.Assert.assertEquals;
26-
import static junit.framework.Assert.assertNull;
25+
import static org.junit.Assert.assertEquals;
26+
import static org.junit.Assert.assertNull;
2727

2828
import androidx.test.runner.AndroidJUnit4;
2929
import com.google.android.gms.tasks.Task;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FirestoreTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForOnlineSnapshot;
2727
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
2828
import static com.google.firebase.firestore.testutil.TestUtil.map;
29-
import static junit.framework.Assert.assertEquals;
30-
import static junit.framework.Assert.assertFalse;
31-
import static junit.framework.Assert.assertNotNull;
32-
import static junit.framework.Assert.assertNull;
33-
import static junit.framework.Assert.assertSame;
34-
import static junit.framework.Assert.assertTrue;
35-
import static junit.framework.Assert.fail;
29+
import static org.junit.Assert.assertEquals;
30+
import static org.junit.Assert.assertFalse;
3631
import static org.junit.Assert.assertNotEquals;
32+
import static org.junit.Assert.assertNotNull;
33+
import static org.junit.Assert.assertNull;
34+
import static org.junit.Assert.assertSame;
35+
import static org.junit.Assert.assertTrue;
36+
import static org.junit.Assert.fail;
3737

3838
import androidx.test.runner.AndroidJUnit4;
3939
import com.google.android.gms.tasks.Task;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ListenerRegistrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
1818
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
1919
import static com.google.firebase.firestore.testutil.TestUtil.map;
20-
import static junit.framework.Assert.assertEquals;
21-
import static junit.framework.Assert.assertNull;
20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertNull;
2222

2323
import android.app.Activity;
2424
import androidx.fragment.app.FragmentActivity;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/NumericTransformsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testDocument;
1818
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
1919
import static com.google.firebase.firestore.testutil.TestUtil.map;
20-
import static junit.framework.Assert.assertEquals;
21-
import static junit.framework.Assert.assertFalse;
20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertFalse;
2222

2323
import androidx.test.runner.AndroidJUnit4;
2424
import com.google.android.gms.tasks.Tasks;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/POJOTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
2020
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
2121
import static com.google.firebase.firestore.testutil.TestUtil.map;
22-
import static junit.framework.Assert.assertEquals;
22+
import static org.junit.Assert.assertEquals;
2323

2424
import androidx.test.runner.AndroidJUnit4;
2525
import com.google.android.gms.tasks.Task;
@@ -38,7 +38,7 @@
3838

3939
@RunWith(AndroidJUnit4.class)
4040
public class POJOTest {
41-
public static class POJO {
41+
public static final class POJO {
4242

4343
double number;
4444
String str;
@@ -123,7 +123,7 @@ public boolean equals(Object o) {
123123
if (this == o) {
124124
return true;
125125
}
126-
if (o == null || getClass() != o.getClass()) {
126+
if (o == null || !(o instanceof POJO)) {
127127
return false;
128128
}
129129

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static com.google.firebase.firestore.testutil.TestUtil.map;
2424
import static java.util.Arrays.asList;
2525
import static java.util.Collections.singletonList;
26-
import static junit.framework.Assert.assertEquals;
26+
import static org.junit.Assert.assertEquals;
2727
import static org.junit.Assert.assertFalse;
2828
import static org.junit.Assert.assertNull;
2929
import static org.junit.Assert.assertTrue;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ServerTimestampTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
2020
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
2121
import static com.google.firebase.firestore.testutil.TestUtil.map;
22-
import static junit.framework.Assert.assertEquals;
23-
import static junit.framework.Assert.assertFalse;
24-
import static junit.framework.Assert.assertNotNull;
25-
import static junit.framework.Assert.assertNull;
26-
import static junit.framework.Assert.assertTrue;
27-
import static junit.framework.Assert.fail;
22+
import static org.junit.Assert.assertEquals;
23+
import static org.junit.Assert.assertFalse;
24+
import static org.junit.Assert.assertNotNull;
25+
import static org.junit.Assert.assertNull;
26+
import static org.junit.Assert.assertTrue;
27+
import static org.junit.Assert.fail;
2828

2929
import androidx.test.runner.AndroidJUnit4;
3030
import com.google.android.gms.tasks.Task;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/SmokeTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
1818
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
1919
import static com.google.firebase.firestore.testutil.TestUtil.map;
20-
import static junit.framework.Assert.assertEquals;
21-
import static junit.framework.Assert.assertFalse;
22-
import static junit.framework.Assert.assertTrue;
20+
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertFalse;
22+
import static org.junit.Assert.assertTrue;
2323

2424
import androidx.test.runner.AndroidJUnit4;
2525
import com.google.android.gms.tasks.Task;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/SourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
2323
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
2424
import static com.google.firebase.firestore.testutil.TestUtil.map;
25-
import static junit.framework.Assert.assertNull;
2625
import static org.junit.Assert.assertEquals;
2726
import static org.junit.Assert.assertFalse;
27+
import static org.junit.Assert.assertNull;
2828
import static org.junit.Assert.assertTrue;
2929

3030
import androidx.test.runner.AndroidJUnit4;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/TransactionTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
1919
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
2020
import static com.google.firebase.firestore.testutil.TestUtil.map;
21-
import static junit.framework.Assert.assertEquals;
22-
import static junit.framework.Assert.assertFalse;
23-
import static junit.framework.Assert.assertNotNull;
24-
import static junit.framework.Assert.assertTrue;
25-
import static junit.framework.Assert.fail;
21+
import static org.junit.Assert.assertEquals;
22+
import static org.junit.Assert.assertFalse;
23+
import static org.junit.Assert.assertNotNull;
24+
import static org.junit.Assert.assertTrue;
25+
import static org.junit.Assert.fail;
2626

2727
import androidx.test.runner.AndroidJUnit4;
2828
import com.google.android.gms.tasks.Task;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/WriteBatchTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
2323
import static com.google.firebase.firestore.testutil.TestUtil.map;
2424
import static java.util.Arrays.asList;
25-
import static junit.framework.Assert.assertEquals;
26-
import static junit.framework.Assert.assertFalse;
27-
import static junit.framework.Assert.assertNotNull;
28-
import static junit.framework.Assert.assertTrue;
25+
import static org.junit.Assert.assertEquals;
26+
import static org.junit.Assert.assertFalse;
27+
import static org.junit.Assert.assertNotNull;
28+
import static org.junit.Assert.assertTrue;
2929

3030
import androidx.test.runner.AndroidJUnit4;
3131
import com.google.firebase.Timestamp;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/remote/RemoteStoreTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,24 @@ public void testRemoteStoreStreamStopsWhenNetworkUnreachable() {
4848
Semaphore networkChangeSemaphore = new Semaphore(0);
4949
RemoteStore.RemoteStoreCallback callback =
5050
new RemoteStore.RemoteStoreCallback() {
51+
@Override
5152
public void handleRemoteEvent(RemoteEvent remoteEvent) {}
5253

54+
@Override
5355
public void handleRejectedListen(int targetId, Status error) {}
5456

57+
@Override
5558
public void handleSuccessfulWrite(MutationBatchResult successfulWrite) {}
5659

60+
@Override
5761
public void handleRejectedWrite(int batchId, Status error) {}
5862

63+
@Override
5964
public void handleOnlineStateChange(OnlineState onlineState) {
6065
networkChangeSemaphore.release();
6166
}
6267

68+
@Override
6369
public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
6470
return null;
6571
}
@@ -90,7 +96,7 @@ private void drain(AsyncQueue testQueue) {
9096
waitFor(testQueue.enqueue(() -> {}));
9197
}
9298

93-
class FakeConnectivityMonitor implements ConnectivityMonitor {
99+
static class FakeConnectivityMonitor implements ConnectivityMonitor {
94100
private Consumer<NetworkStatus> callback = null;
95101

96102
@Override

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java

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

1717
import static com.google.firebase.firestore.testutil.TestUtil.map;
1818
import static com.google.firebase.firestore.util.Util.autoId;
19-
import static junit.framework.Assert.assertNull;
19+
import static org.junit.Assert.assertNull;
2020

2121
import android.content.Context;
2222
import android.net.SSLCertificateSocketFactory;

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/AndroidConnectivityMonitor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public void run() {
8484
};
8585
} else {
8686
NetworkReceiver networkReceiver = new NetworkReceiver();
87+
@SuppressWarnings("deprecation")
8788
IntentFilter networkIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
8889
context.registerReceiver(networkReceiver, networkIntentFilter);
8990
unregisterRunnable =

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/FirestoreCallCredentials.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import com.google.firebase.firestore.auth.CredentialsProvider;
1919
import com.google.firebase.firestore.util.Logger;
2020
import com.google.firebase.internal.api.FirebaseNoSignedInUserException;
21-
import io.grpc.CallCredentials2;
21+
import io.grpc.CallCredentials;
2222
import io.grpc.Metadata;
2323
import io.grpc.Status;
2424
import java.util.concurrent.Executor;
2525

2626
/** CallCredentials that applies any authorization headers. */
27-
final class FirestoreCallCredentials extends CallCredentials2 {
27+
final class FirestoreCallCredentials extends CallCredentials {
2828

2929
private static final String LOG_TAG = "FirestoreCallCredentials";
3030

firebase-firestore/src/test/java/com/google/firebase/firestore/FirestoreRegistrarTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21+
import androidx.test.core.app.ApplicationProvider;
2122
import com.google.firebase.FirebaseApp;
2223
import com.google.firebase.FirebaseOptions;
2324
import com.google.firebase.platforminfo.UserAgentPublisher;
2425
import org.junit.Ignore;
2526
import org.junit.Test;
2627
import org.junit.runner.RunWith;
2728
import org.robolectric.RobolectricTestRunner;
28-
import org.robolectric.RuntimeEnvironment;
2929

3030
@RunWith(RobolectricTestRunner.class)
3131
public class FirestoreRegistrarTest {
@@ -35,7 +35,7 @@ public class FirestoreRegistrarTest {
3535
public void storageRegistrar_getComponents_publishesLibVersionComponent() {
3636
FirebaseApp app =
3737
FirebaseApp.initializeApp(
38-
RuntimeEnvironment.application.getApplicationContext(),
38+
ApplicationProvider.getApplicationContext(),
3939
new FirebaseOptions.Builder()
4040
.setProjectId("projectId")
4141
.setApplicationId("1:196403931065:android:60949756fbe381ea")

firebase-firestore/src/test/java/com/google/firebase/firestore/local/EncodedPathTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.database.Cursor;
2626
import android.database.sqlite.SQLiteDatabase;
2727
import android.database.sqlite.SQLiteOpenHelper;
28+
import androidx.test.core.app.ApplicationProvider;
2829
import com.google.firebase.firestore.model.ResourcePath;
2930
import java.util.ArrayList;
3031
import java.util.List;
@@ -33,7 +34,6 @@
3334
import org.junit.Test;
3435
import org.junit.runner.RunWith;
3536
import org.robolectric.RobolectricTestRunner;
36-
import org.robolectric.RuntimeEnvironment;
3737
import org.robolectric.annotation.Config;
3838

3939
@RunWith(RobolectricTestRunner.class)
@@ -42,7 +42,7 @@ public class EncodedPathTest {
4242

4343
static class OpenHelper extends SQLiteOpenHelper {
4444
OpenHelper() {
45-
super(RuntimeEnvironment.application, "test", null, 1);
45+
super(ApplicationProvider.getApplicationContext(), "test", null, 1);
4646
}
4747

4848
@Override

firebase-firestore/src/test/java/com/google/firebase/firestore/local/PersistenceTestHelpers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
package com.google.firebase.firestore.local;
1616

1717
import android.content.Context;
18+
import androidx.test.core.app.ApplicationProvider;
1819
import com.google.firebase.firestore.model.DatabaseId;
1920
import com.google.firebase.firestore.remote.RemoteSerializer;
20-
import org.robolectric.RuntimeEnvironment;
2121

2222
public final class PersistenceTestHelpers {
2323

@@ -32,7 +32,7 @@ public static SQLitePersistence openSQLitePersistence(
3232
String name, LruGarbageCollector.Params params) {
3333
DatabaseId databaseId = DatabaseId.forProject("projectId");
3434
LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
35-
Context context = RuntimeEnvironment.application;
35+
Context context = ApplicationProvider.getApplicationContext();
3636
SQLitePersistence persistence =
3737
new SQLitePersistence(context, name, databaseId, serializer, params);
3838
persistence.start();

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.database.Cursor;
2828
import android.database.sqlite.SQLiteDatabase;
2929
import android.database.sqlite.SQLiteOpenHelper;
30+
import androidx.test.core.app.ApplicationProvider;
3031
import com.google.firebase.firestore.model.DatabaseId;
3132
import com.google.firebase.firestore.model.ResourcePath;
3233
import com.google.firebase.firestore.proto.WriteBatch;
@@ -43,7 +44,6 @@
4344
import org.junit.Test;
4445
import org.junit.runner.RunWith;
4546
import org.robolectric.RobolectricTestRunner;
46-
import org.robolectric.RuntimeEnvironment;
4747
import org.robolectric.annotation.Config;
4848

4949
/** Tests migrations in SQLiteSchema. */
@@ -59,7 +59,7 @@ public class SQLiteSchemaTest {
5959
@Before
6060
public void setUp() {
6161
SQLiteOpenHelper opener =
62-
new SQLiteOpenHelper(RuntimeEnvironment.application, "foo", null, 1) {
62+
new SQLiteOpenHelper(ApplicationProvider.getApplicationContext(), "foo", null, 1) {
6363
@Override
6464
public void onCreate(SQLiteDatabase db) {}
6565

0 commit comments

Comments
 (0)