Skip to content

refactor: cleanup Dynamic Links example app and integration tests #5903

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
merged 4 commits into from
Apr 23, 2021
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
68 changes: 68 additions & 0 deletions .github/workflows/firebase_dynamic_links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: firebase_dynamic_links

on:
pull_request:
paths:
- "packages/firebase_dynamic_links/**"
- ".github/workflows/firebase_dynamic_links.yaml"
push:
branches:
- master
paths-ignore:
- "docs/**"
- "**.md"

env:
FLUTTERFIRE_PLUGIN_SCOPE: "*firebase_dynamic_links*"
FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE: "*firebase_dynamic_links_example*"
# TODO(Salakar): `flutter_driver` does not yet support NNBD
FLUTTER_COMMAND_FLAGS: "--no-sound-null-safety"

jobs:
android:
if: github.event_name == 'pull_request'
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 0
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: ./.github/workflows/scripts/install-tools.sh
- name: "Build Example"
run: ./.github/workflows/scripts/build-example.sh android
- name: "Drive Example"
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
arch: x86_64
# Firebase Database works without Google Play Services, so we don't use the `googleapis`
# emulator target as it's considerably slower on CI.
target: default
profile: Nexus 5X
script: ./.github/workflows/scripts/drive-example.sh android

apple:
runs-on: macos-latest
timeout-minutes: 35
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 0
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: |
./.github/workflows/scripts/install-tools.sh
flutter config --enable-macos-desktop
- name: "Build iOS Example"
run: ./.github/workflows/scripts/build-example.sh ios
- name: "Drive iOS Example"
run: ./.github/workflows/scripts/drive-example.sh ios
# TODO: Currently does not have macOS support.
# - name: "Build MacOS Example"
# run: ./.github/workflows/scripts/build-example.sh macos
# - name: "Drive MacOS Example"
# run: ./.github/workflows/scripts/drive-example.sh macos
60 changes: 26 additions & 34 deletions packages/firebase_dynamic_links/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,60 +1,52 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId "io.flutter.plugins.firebasedynamiclinksexample"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
signingConfig signingConfigs.debug
}
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId "io.flutter.plugins.firebasedynamiclinksexample"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
source '../..'
}

apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.firebasedynamiclinksexample">

<uses-permission android:name="android.permission.INTERNET"/>
<application>
<activity android:name="io.flutter.embedding.android.FlutterActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data android:name="flutterEmbedding" android:value="2"/>
</application>
package="io.flutter.plugins.firebasedynamiclinksexample">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="firebase_dynamic_links_example"
android:icon="@mipmap/ic_launcher">
<activity
android:name="io.flutter.plugins.firebasedynamiclinksexample.MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.flutter.plugins.firebasedynamiclinksexample;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>
18 changes: 7 additions & 11 deletions packages/firebase_dynamic_links/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
6 changes: 5 additions & 1 deletion packages/firebase_dynamic_links/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ dependency_overrides:
path: ../../firebase_core/firebase_core_web

dev_dependencies:
pedantic: ^1.11.0
drive: 0.1.0
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// @dart = 2.9
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:drive/drive.dart' as drive;
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
import 'package:flutter_test/flutter_test.dart';

void testsMain() {
group('DynamicLinks', () {
test('buildUrl', () async {
const String androidPackageName =
'io.flutter.plugins.firebasedynamiclinksexample';
const String iosBundleId =
'com.google.FirebaseCppDynamicLinksTestApp.dev';
const String urlHost = 'cx4k7.app.goo.gl';
const String link = 'https://dynamic.link.example/helloworld';

final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://$urlHost',
link: Uri.parse(link),
androidParameters: AndroidParameters(
packageName: androidPackageName,
minimumVersion: 1,
),
dynamicLinkParametersOptions: DynamicLinkParametersOptions(
shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
),
iosParameters: IosParameters(
bundleId: iosBundleId,
minimumVersion: '2',
),
);

final Uri uri = await parameters.buildUrl();

// androidParameters.minimumVersion
expect(
uri.queryParameters['amv'],
'1',
);
// iosParameters.minimumVersion
expect(
uri.queryParameters['imv'],
'2',
);
// androidParameters.packageName
expect(
uri.queryParameters['apn'],
androidPackageName,
);
// iosParameters.bundleId
expect(
uri.queryParameters['ibi'],
iosBundleId,
);
// link
expect(
uri.queryParameters['link'],
Uri.encodeFull(link),
);
// uriPrefix
expect(
uri.host,
urlHost,
);
});
});
}

void main() => drive.main(testsMain);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @dart = 2.9
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:drive/drive_driver.dart' as drive;

void main() => drive.main();
Loading