Skip to content

Add '-Werror' for main build and suppress one deprecation warning #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions firebase-firestore/firebase-firestore.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ dependencies {
}

testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test:core:1.2.0'
testImplementation 'org.mockito:mockito-core:2.21.0'
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation "com.google.truth:truth:$googleTruthVersion"
Expand All @@ -134,9 +135,9 @@ dependencies {

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
// TODO(rsgowman): Also add "-Xlint:unchecked". But currently that
// TODO(wuandy): Also add "-Xlint:unchecked". But currently that
// enables 100+ warnings due to our generated source code.
options.compilerArgs << "-Xlint:deprecation"
options.compilerArgs << "-Xlint:deprecation" << "-Werror"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;

import android.support.test.runner.AndroidJUnit4;
import com.google.firebase.firestore.FirebaseFirestoreException.Code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import android.support.test.runner.AndroidJUnit4;
import com.google.firebase.firestore.testutil.EventAccumulator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.writeAllDocs;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.support.test.runner.AndroidJUnit4;
import com.google.firebase.Timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static com.google.firebase.firestore.util.Util.autoId;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForOnlineSnapshot;
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertSame;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import android.app.Activity;
import android.support.test.rule.ActivityTestRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testDocument;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Task;
Expand All @@ -38,7 +38,7 @@

@RunWith(AndroidJUnit4.class)
public class POJOTest {
public static class POJO {
public static final class POJO {

double number;
String str;
Expand Down Expand Up @@ -123,7 +123,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (o == null || !(o instanceof POJO)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.support.test.runner.AndroidJUnit4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import android.support.test.runner.AndroidJUnit4;
import com.google.android.gms.tasks.Task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitForException;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import android.support.test.runner.AndroidJUnit4;
import com.google.firebase.Timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@ public void testRemoteStoreStreamStopsWhenNetworkUnreachable() {
Semaphore networkChangeSemaphore = new Semaphore(0);
RemoteStore.RemoteStoreCallback callback =
new RemoteStore.RemoteStoreCallback() {
@Override
public void handleRemoteEvent(RemoteEvent remoteEvent) {}

@Override
public void handleRejectedListen(int targetId, Status error) {}

@Override
public void handleSuccessfulWrite(MutationBatchResult successfulWrite) {}

@Override
public void handleRejectedWrite(int batchId, Status error) {}

@Override
public void handleOnlineStateChange(OnlineState onlineState) {
networkChangeSemaphore.release();
}

@Override
public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
return null;
}
Expand Down Expand Up @@ -90,7 +96,7 @@ private void drain(AsyncQueue testQueue) {
waitFor(testQueue.enqueue(() -> {}));
}

class FakeConnectivityMonitor implements ConnectivityMonitor {
static class FakeConnectivityMonitor implements ConnectivityMonitor {
private Consumer<NetworkStatus> callback = null;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static com.google.firebase.firestore.testutil.TestUtil.map;
import static com.google.firebase.firestore.util.Util.autoId;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertNull;

import android.content.Context;
import android.net.SSLCertificateSocketFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void run() {
};
} else {
NetworkReceiver networkReceiver = new NetworkReceiver();
@SuppressWarnings("deprecation")
IntentFilter networkIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
context.registerReceiver(networkReceiver, networkIntentFilter);
unregisterRunnable =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import com.google.firebase.firestore.auth.CredentialsProvider;
import com.google.firebase.firestore.util.Logger;
import com.google.firebase.internal.api.FirebaseNoSignedInUserException;
import io.grpc.CallCredentials2;
import io.grpc.CallCredentials;
import io.grpc.Metadata;
import io.grpc.Status;
import java.util.concurrent.Executor;

/** CallCredentials that applies any authorization headers. */
final class FirestoreCallCredentials extends CallCredentials2 {
final class FirestoreCallCredentials extends CallCredentials {

private static final String LOG_TAG = "FirestoreCallCredentials";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

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

import androidx.test.core.app.ApplicationProvider;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.platforminfo.UserAgentPublisher;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

@RunWith(RobolectricTestRunner.class)
public class FirestoreRegistrarTest {
Expand All @@ -35,7 +35,7 @@ public class FirestoreRegistrarTest {
public void storageRegistrar_getComponents_publishesLibVersionComponent() {
FirebaseApp app =
FirebaseApp.initializeApp(
RuntimeEnvironment.application.getApplicationContext(),
ApplicationProvider.getApplicationContext(),
new FirebaseOptions.Builder()
.setProjectId("projectId")
.setApplicationId("1:196403931065:android:60949756fbe381ea")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.test.core.app.ApplicationProvider;
import com.google.firebase.firestore.model.ResourcePath;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -33,7 +34,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
Expand All @@ -42,7 +42,7 @@ public class EncodedPathTest {

static class OpenHelper extends SQLiteOpenHelper {
OpenHelper() {
super(RuntimeEnvironment.application, "test", null, 1);
super(ApplicationProvider.getApplicationContext(), "test", null, 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package com.google.firebase.firestore.local;

import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import com.google.firebase.firestore.model.DatabaseId;
import com.google.firebase.firestore.remote.RemoteSerializer;
import org.robolectric.RuntimeEnvironment;

public final class PersistenceTestHelpers {

Expand All @@ -32,7 +32,7 @@ public static SQLitePersistence openSQLitePersistence(
String name, LruGarbageCollector.Params params) {
DatabaseId databaseId = DatabaseId.forProject("projectId");
LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
Context context = RuntimeEnvironment.application;
Context context = ApplicationProvider.getApplicationContext();
SQLitePersistence persistence =
new SQLitePersistence(context, name, databaseId, serializer, params);
persistence.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.test.core.app.ApplicationProvider;
import com.google.firebase.firestore.model.DatabaseId;
import com.google.firebase.firestore.model.ResourcePath;
import com.google.firebase.firestore.proto.WriteBatch;
Expand All @@ -43,7 +44,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

/** Tests migrations in SQLiteSchema. */
Expand All @@ -59,7 +59,7 @@ public class SQLiteSchemaTest {
@Before
public void setUp() {
SQLiteOpenHelper opener =
new SQLiteOpenHelper(RuntimeEnvironment.application, "foo", null, 1) {
new SQLiteOpenHelper(ApplicationProvider.getApplicationContext(), "foo", null, 1) {
@Override
public void onCreate(SQLiteDatabase db) {}

Expand Down
Loading