Skip to content

Commit a79cae2

Browse files
committed
Merge branch 'master' of github.com:firebase/firebase-android-sdk into floc-master
2 parents 0a794dc + a0387fc commit a79cae2

File tree

14 files changed

+336
-161
lines changed

14 files changed

+336
-161
lines changed

firebase-abt/firebase-abt.gradle

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,50 @@
1414

1515
plugins {
1616
id 'firebase-library'
17+
id 'com.google.protobuf'
1718
}
1819

1920
firebaseLibrary {
2021
testLab.enabled = false
2122
publishSources = true
2223
}
2324

25+
// TODO(issue/568): Remove this once legacy logic is removed from Remote Config.
26+
protobuf {
27+
protoc {
28+
artifact = 'com.google.protobuf:protoc:3.4.0'
29+
}
30+
plugins {
31+
javalite {
32+
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
33+
}
34+
}
35+
generateProtoTasks {
36+
all().each { task ->
37+
task.builtins {
38+
remove java
39+
}
40+
task.plugins {
41+
javalite {}
42+
}
43+
}
44+
}
45+
}
46+
2447
android {
2548

2649
lintOptions {
2750
abortOnError false
2851
}
2952
sourceSets {
3053
main {
31-
java {
32-
}
33-
}
34-
test {
35-
java {
54+
proto {
55+
srcDir 'src/proto'
3656
}
57+
58+
resources {
59+
srcDir 'src/proto/com/google/protos'
60+
}
3761
}
3862
}
3963

@@ -61,6 +85,7 @@ dependencies {
6185
implementation ('com.google.firebase:firebase-measurement-connector:18.0.0') {
6286
exclude group: "com.google.firebase", module: "firebase-common"
6387
}
88+
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
6489
testImplementation 'org.mockito:mockito-core:2.25.0'
6590
testImplementation 'com.google.truth:truth:0.44'
6691
testImplementation 'junit:junit:4.13-beta-2'

firebase-config/firebase-config.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ protobuf {
5050
}
5151
}
5252

53-
firebaseLibrary {
54-
testLab.enabled = true
55-
publishSources = true
56-
}
57-
5853
android {
5954
compileSdkVersion project.targetSdkVersion
6055
defaultConfig {

firebase-firestore/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,33 @@ the source root.
4141
Make sure you have created a Firestore instance for your project, before
4242
you proceed.
4343

44-
### Run on Local Emulator
44+
By default, integration tests run against the Firestore emulator.
45+
46+
### Setting up the Firestore Emulator
47+
48+
The integration tests require that the Firestore emulator is running on port
49+
8080, which is default when running it via CLI.
50+
51+
* [Install the Firebase CLI](https://firebase.google.com/docs/cli/).
52+
```
53+
npm install -g firebase-tools
54+
```
55+
* [Install the Firestore
56+
emulator](https://firebase.google.com/docs/firestore/security/test-rules-emulator#install_the_emulator).
57+
```
58+
firebase setup:emulators:firestore
59+
```
60+
* Run the emulator
61+
```
62+
firebase serve --only firestore
63+
```
64+
* Select the `Firestore Integration Tests (Firestore Emulator)` run
65+
configuration to run all integration tests.
66+
67+
To run the integration tests against prod, select `FirestoreProdIntegrationTest`
68+
run configuration.
69+
70+
### Run on Local Android Emulator
4571
4672
Then simply run:
4773
```bash

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.firestore;
1616

17+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
1718
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToIds;
1819
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToValues;
1920
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
@@ -38,7 +39,7 @@
3839
import java.util.Map;
3940
import java.util.concurrent.Semaphore;
4041
import org.junit.After;
41-
import org.junit.Ignore;
42+
import org.junit.Assume;
4243
import org.junit.Test;
4344
import org.junit.runner.RunWith;
4445

@@ -428,33 +429,33 @@ public void testQueriesCanUseArrayContainsFilters() {
428429
// much of anything else interesting to test.
429430
}
430431

431-
// TODO(in-queries): Re-enable once emulator support is added to travis.
432+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
432433
@Test
433-
@Ignore
434434
public void testQueriesCanUseInFilters() {
435-
Map<String, Object> docA = map("zip", 98101);
436-
Map<String, Object> docB = map("zip", 91102);
437-
Map<String, Object> docC = map("zip", 98103);
438-
Map<String, Object> docD = map("zip", asList(98101));
439-
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101)));
440-
Map<String, Object> docF = map("zip", map("code", 500));
435+
Assume.assumeTrue(isRunningAgainstEmulator());
436+
Map<String, Object> docA = map("zip", 98101L);
437+
Map<String, Object> docB = map("zip", 91102L);
438+
Map<String, Object> docC = map("zip", 98103L);
439+
Map<String, Object> docD = map("zip", asList(98101L));
440+
Map<String, Object> docE = map("zip", asList("98101", map("zip", 98101L)));
441+
Map<String, Object> docF = map("zip", map("code", 500L));
441442
CollectionReference collection =
442443
testCollectionWithDocs(
443444
map("a", docA, "b", docB, "c", docC, "d", docD, "e", docE, "f", docF));
444445

445446
// Search for zips matching [98101, 98103].
446-
QuerySnapshot snapshot = waitFor(collection.whereIn("zip", asList(98101, 98103)).get());
447+
QuerySnapshot snapshot = waitFor(collection.whereIn("zip", asList(98101L, 98103L)).get());
447448
assertEquals(asList(docA, docC), querySnapshotToValues(snapshot));
448449

449450
// With objects.
450-
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500))).get());
451+
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500L))).get());
451452
assertEquals(asList(docF), querySnapshotToValues(snapshot));
452453
}
453454

454-
// TODO(in-queries): Re-enable once emulator support is added to travis.
455+
// TODO(in-queries): Re-enable in prod once feature lands in backend.
455456
@Test
456-
@Ignore
457457
public void testQueriesCanUseArrayContainsAnyFilters() {
458+
Assume.assumeTrue(isRunningAgainstEmulator());
458459
Map<String, Object> docA = map("array", asList(42L));
459460
Map<String, Object> docB = map("array", asList("a", 42L, "c"));
460461
Map<String, Object> docC = map("array", asList(41.999, "42", map("a", asList(42))));

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

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,6 @@ public void queriesFilteredByDocumentIDMustUseStringsOrDocumentReferences() {
701701
+ "a valid String or DocumentReference, but it was of type: java.lang.Integer";
702702
expectError(() -> collection.whereGreaterThanOrEqualTo(FieldPath.documentId(), 1), reason);
703703

704-
reason =
705-
"Invalid query. When querying with FieldPath.documentId() you must provide "
706-
+ "a valid String or DocumentReference, but it was of type: java.util.Arrays$ArrayList";
707-
expectError(() -> collection.whereIn(FieldPath.documentId(), asList(1, 2)), reason);
708-
709704
reason =
710705
"Invalid query. When querying a collection group by FieldPath.documentId(), the value "
711706
+ "provided must result in a valid document path, but 'foo' is not because it has "
@@ -726,6 +721,38 @@ public void queriesFilteredByDocumentIDMustUseStringsOrDocumentReferences() {
726721
() -> collection.whereArrayContainsAny(FieldPath.documentId(), asList(1, 2)), reason);
727722
}
728723

724+
@Test
725+
public void queriesUsingInAndDocumentIdMustHaveProperDocumentReferencesInArray() {
726+
CollectionReference collection = testCollection();
727+
collection.whereIn(FieldPath.documentId(), asList(collection.getPath()));
728+
729+
String reason =
730+
"Invalid query. When querying with FieldPath.documentId() you must provide "
731+
+ "a valid document ID, but it was an empty string.";
732+
expectError(() -> collection.whereIn(FieldPath.documentId(), asList("")), reason);
733+
734+
reason =
735+
"Invalid query. When querying a collection by FieldPath.documentId() you must provide "
736+
+ "a plain document ID, but 'foo/bar/baz' contains a '/' character.";
737+
expectError(() -> collection.whereIn(FieldPath.documentId(), asList("foo/bar/baz")), reason);
738+
739+
reason =
740+
"Invalid query. When querying with FieldPath.documentId() you must provide "
741+
+ "a valid String or DocumentReference, but it was of type: java.lang.Integer";
742+
expectError(() -> collection.whereIn(FieldPath.documentId(), asList(1, 2)), reason);
743+
744+
reason =
745+
"Invalid query. When querying a collection group by FieldPath.documentId(), the value "
746+
+ "provided must result in a valid document path, but 'foo' is not because it has "
747+
+ "an odd number of segments (1).";
748+
expectError(
749+
() ->
750+
testFirestore()
751+
.collectionGroup("collection")
752+
.whereIn(FieldPath.documentId(), asList("foo")),
753+
reason);
754+
}
755+
729756
// Helpers
730757

731758
/** Performs a write using each write API and makes sure it fails with the expected reason. */

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,8 @@ public static Map<String, Object> toDataMap(QuerySnapshot qrySnap) {
422422
}
423423
return result;
424424
}
425+
426+
public static boolean isRunningAgainstEmulator() {
427+
return CONNECT_TO_EMULATOR;
428+
}
425429
}

0 commit comments

Comments
 (0)