Skip to content

Commit 07121a2

Browse files
authored
[Smoke-tests] Add Dynamic Links to smoke tests. (#801)
This commit adds two dynamic links tests.
1 parent 6418e58 commit 07121a2

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

smoke-tests/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ dependencies {
7979
combinedImplementation "com.google.firebase:firebase-analytics"
8080
combinedImplementation "com.google.firebase:firebase-auth"
8181
combinedImplementation "com.google.firebase:firebase-database"
82+
combinedImplementation "com.google.firebase:firebase-dynamic-links"
8283
combinedImplementation "com.google.firebase:firebase-firestore"
8384
combinedImplementation "com.google.firebase:firebase-functions"
8485
combinedImplementation "com.google.firebase:firebase-inappmessaging"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.firebase.testing.combined;
1616

1717
import com.google.firebase.testing.database.DatabaseTest;
18+
import com.google.firebase.testing.dynamiclinks.DynamicLinksTest;
1819
import com.google.firebase.testing.firestore.FirestoreTest;
1920
import com.google.firebase.testing.functions.FunctionsTest;
2021
import com.google.firebase.testing.inappmessaging.InappMessagingTest;
@@ -29,6 +30,7 @@
2930
@RunWith(Suite.class)
3031
@Suite.SuiteClasses({
3132
DatabaseTest.class,
33+
DynamicLinksTest.class,
3234
FirestoreTest.class,
3335
FunctionsTest.class,
3436
InappMessagingTest.class,
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.dynamiclinks;
16+
17+
import static com.google.common.truth.Truth.assertThat;
18+
19+
import android.app.Activity;
20+
import android.net.Uri;
21+
import androidx.test.rule.ActivityTestRule;
22+
import androidx.test.runner.AndroidJUnit4;
23+
import com.google.android.gms.tasks.Task;
24+
import com.google.firebase.dynamiclinks.DynamicLink;
25+
import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
26+
import com.google.firebase.testing.common.Tasks2;
27+
import org.junit.Rule;
28+
import org.junit.Test;
29+
import org.junit.runner.RunWith;
30+
31+
@RunWith(AndroidJUnit4.class)
32+
public final class DynamicLinksTest {
33+
34+
@Rule public final ActivityTestRule<Activity> activity = new ActivityTestRule<>(Activity.class);
35+
36+
@Test
37+
public void buildDynamicLink_UriContainsCorrectComponents() throws Exception {
38+
FirebaseDynamicLinks dl = FirebaseDynamicLinks.getInstance();
39+
Uri uri = Uri.parse("http://www.example.com");
40+
41+
DynamicLink link =
42+
dl.createDynamicLink()
43+
.setLink(uri)
44+
.setDomainUriPrefix("http://example.page.link")
45+
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
46+
.buildDynamicLink();
47+
Uri actual = link.getUri();
48+
String[] query = actual.getQuery().split("&");
49+
50+
assertThat(actual.getScheme()).isEqualTo("http");
51+
assertThat(actual.getHost()).isEqualTo("example.page.link");
52+
assertThat(query)
53+
.asList()
54+
.containsAtLeast("apn=com.google.firebase.testing.combined", "link=http://www.example.com");
55+
}
56+
57+
@Test
58+
public void getDynamicLink_NonLinkReturnsNull() throws Exception {
59+
FirebaseDynamicLinks dl = FirebaseDynamicLinks.getInstance();
60+
Uri uri = Uri.parse("http://www.example.com");
61+
62+
Task<?> task = dl.getDynamicLink(uri);
63+
Object actual = Tasks2.waitForSuccess(task);
64+
65+
assertThat(actual).isNull();
66+
}
67+
}

0 commit comments

Comments
 (0)