Skip to content

Commit bd24bfe

Browse files
Merge
2 parents a2fba58 + c5afc57 commit bd24bfe

File tree

9 files changed

+493
-245
lines changed

9 files changed

+493
-245
lines changed

firebase-abt/firebase-abt.gradle

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

1515
plugins {
1616
id 'firebase-library'
17-
id 'com.google.protobuf'
1817
}
1918

2019
firebaseLibrary {
2120
testLab.enabled = false
2221
publishSources = true
2322
}
2423

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-
4724
android {
4825

4926
lintOptions {
5027
abortOnError false
5128
}
5229
sourceSets {
5330
main {
54-
proto {
55-
srcDir 'src/proto'
31+
java {
32+
}
33+
}
34+
test {
35+
java {
5636
}
57-
58-
resources {
59-
srcDir 'src/proto/com/google/protos'
60-
}
6137
}
6238
}
6339

@@ -85,7 +61,6 @@ dependencies {
8561
implementation ('com.google.firebase:firebase-measurement-connector:18.0.0') {
8662
exclude group: "com.google.firebase", module: "firebase-common"
8763
}
88-
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
8964
testImplementation 'org.mockito:mockito-core:2.25.0'
9065
testImplementation 'com.google.truth:truth:0.44'
9166
testImplementation 'junit:junit:4.13-beta-2'

firebase-config/firebase-config.gradle

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

53+
firebaseLibrary {
54+
testLab.enabled = true
55+
publishSources = true
56+
}
57+
5358
android {
5459
compileSdkVersion project.targetSdkVersion
5560
defaultConfig {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
syntax = "proto3";
16+
package developers.mobile.abt;
17+
18+
option java_outer_classname = "FirebaseAbt";
19+
20+
// A lighter version of ExperimentPayload that describes an experiment
21+
// by only its experimentId. To be used when we don't need
22+
// to know all the details about the experiment, such as when sending a
23+
// list of all ongoing experiments.
24+
message ExperimentLite {
25+
// A string of max length 22 characters.
26+
// Format: _exp_<origin prefix>_<experiment_id>
27+
// Required field.
28+
string experiment_id = 1;
29+
}
30+
31+
// ABT Payload for Firebase Namespace.
32+
message ExperimentPayload {
33+
// A string of max length 22 characters.
34+
// Format: _exp_<origin prefix>_<experiment_id>
35+
// This is referred to as the tracking id and is different from the
36+
// experiment id which is used internally by ABT.
37+
// Required field.
38+
string experiment_id = 1;
39+
40+
// A string which has numbers from 0-10.
41+
// Required field.
42+
string variant_id = 2;
43+
44+
// Epoch time in milliseconds when the experiment was started; > 0.
45+
// Required field.
46+
int64 experiment_start_time_millis = 3;
47+
48+
// The Scion event that causes the experiment to transition to ON state.
49+
string trigger_event = 4;
50+
51+
// Duration in milliseconds that the experiment can stay in STANDBY state.
52+
// Valid range is from 1ms to 6 months (current max defined by Scion).
53+
// If the value is outside this range the setExperiment call on the client
54+
// will fail.
55+
// Required field
56+
int64 trigger_timeout_millis = 5;
57+
58+
// Duration in milliseconds that the experiment can stay in ON state (an
59+
// experiment becomes ON when it has been triggered, or when it has no
60+
// trigger event).
61+
// Corresponds to the attribution time in the ABT UI.
62+
// Valid range is from 1ms to 6 months (current max defined by Scion).
63+
// If the value is outside this range the setExperiment call on the client
64+
// will fail.
65+
// Required field
66+
int64 time_to_live_millis = 6;
67+
68+
// The event logged when impact service sets the experiment.
69+
// Max length = 32 chars
70+
string set_event_to_log = 7;
71+
72+
// The event logged when an experiment goes to the ON state.
73+
// Max length = 32 chars
74+
string activate_event_to_log = 8;
75+
76+
// The event logged when an experiment is cleared.
77+
// Max length = 32 chars
78+
string clear_event_to_log = 9;
79+
80+
// The event logged when an experiment times out after trigger_timeout_millis
81+
// milliseconds.
82+
// Max length = 32 chars
83+
string timeout_event_to_log = 10;
84+
85+
// The event logged when an experiment times out after time_to_live_millis
86+
// milliseconds.
87+
// Max length = 32 chars
88+
string ttl_expiry_event_to_log = 11;
89+
90+
// Policy to use when there are more experiments than the Scion client can
91+
// support on a single App for a single service.
92+
// As of October 2016, we allow 3 experiments per instance per service
93+
// (i.e. 3 each for Config and Notifications).
94+
enum ExperimentOverflowPolicy {
95+
POLICY_UNSPECIFIED = 0;
96+
// Discard oldest experiments (by experiment_start_time) first.
97+
DISCARD_OLDEST = 1;
98+
// Ignore newest experiments first.
99+
IGNORE_NEWEST = 2;
100+
}
101+
// The overflow policy enum for this experiment payload.
102+
ExperimentOverflowPolicy overflow_policy = 12;
103+
104+
// A list of all other ongoing (started, and not yet stopped) experiments
105+
// at the time this experiment was started.
106+
// Does not include this experiment; only the others.
107+
repeated ExperimentLite ongoing_experiments = 13;
108+
}
109+

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

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

1515
package com.google.firebase.firestore;
1616

17-
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
1817
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToIds;
1918
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.querySnapshotToValues;
2019
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollection;
@@ -39,7 +38,7 @@
3938
import java.util.Map;
4039
import java.util.concurrent.Semaphore;
4140
import org.junit.After;
42-
import org.junit.Assume;
41+
import org.junit.Ignore;
4342
import org.junit.Test;
4443
import org.junit.runner.RunWith;
4544

@@ -429,33 +428,33 @@ public void testQueriesCanUseArrayContainsFilters() {
429428
// much of anything else interesting to test.
430429
}
431430

432-
// TODO(in-queries): Re-enable in prod once feature lands in backend.
431+
// TODO(in-queries): Re-enable once emulator support is added to travis.
433432
@Test
433+
@Ignore
434434
public void testQueriesCanUseInFilters() {
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));
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));
442441
CollectionReference collection =
443442
testCollectionWithDocs(
444443
map("a", docA, "b", docB, "c", docC, "d", docD, "e", docE, "f", docF));
445444

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

450449
// With objects.
451-
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500L))).get());
450+
snapshot = waitFor(collection.whereIn("zip", asList(map("code", 500))).get());
452451
assertEquals(asList(docF), querySnapshotToValues(snapshot));
453452
}
454453

455-
// TODO(in-queries): Re-enable in prod once feature lands in backend.
454+
// TODO(in-queries): Re-enable once emulator support is added to travis.
456455
@Test
456+
@Ignore
457457
public void testQueriesCanUseArrayContainsAnyFilters() {
458-
Assume.assumeTrue(isRunningAgainstEmulator());
459458
Map<String, Object> docA = map("array", asList(42L));
460459
Map<String, Object> docB = map("array", asList("a", 42L, "c"));
461460
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: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,11 @@ 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+
704709
reason =
705710
"Invalid query. When querying a collection group by FieldPath.documentId(), the value "
706711
+ "provided must result in a valid document path, but 'foo' is not because it has "
@@ -721,38 +726,6 @@ public void queriesFilteredByDocumentIDMustUseStringsOrDocumentReferences() {
721726
() -> collection.whereArrayContainsAny(FieldPath.documentId(), asList(1, 2)), reason);
722727
}
723728

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-
756729
// Helpers
757730

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

0 commit comments

Comments
 (0)