diff --git a/packages/firebase_remote_config/CHANGELOG.md b/packages/firebase_remote_config/CHANGELOG.md index 1421eeebe871..916da23a4332 100644 --- a/packages/firebase_remote_config/CHANGELOG.md +++ b/packages/firebase_remote_config/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.1 + +* Support Android V2 embedding. +* Migrate to using the new e2e test binding. + ## 0.2.0+9 * Updated README instructions for contributing for consistency with other Flutterfire plugins. diff --git a/packages/firebase_remote_config/android/build.gradle b/packages/firebase_remote_config/android/build.gradle index c2fe40952353..71661657bcdf 100644 --- a/packages/firebase_remote_config/android/build.gradle +++ b/packages/firebase_remote_config/android/build.gradle @@ -39,3 +39,28 @@ android { } apply from: file("./user-agent.gradle") + +afterEvaluate { + def containsEmbeddingDependencies = false + for (def configuration : configurations.all) { + for (def dependency : configuration.dependencies) { + if (dependency.group == 'io.flutter' && + dependency.name.startsWith('flutter_embedding') && + dependency.isTransitive()) + { + containsEmbeddingDependencies = true + break + } + } + } + if (!containsEmbeddingDependencies) { + android { + dependencies { + def lifecycle_version = "1.1.1" + compileOnly "android.arch.lifecycle:runtime:$lifecycle_version" + compileOnly "android.arch.lifecycle:common:$lifecycle_version" + compileOnly "android.arch.lifecycle:common-java8:$lifecycle_version" + } + } + } +} diff --git a/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/FirebaseRemoteConfigPlugin.java b/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/FirebaseRemoteConfigPlugin.java index d07a9ad1d57a..faee7bd4a26a 100644 --- a/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/FirebaseRemoteConfigPlugin.java +++ b/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/FirebaseRemoteConfigPlugin.java @@ -5,192 +5,45 @@ package io.flutter.plugins.firebase.firebaseremoteconfig; import android.content.Context; -import android.content.SharedPreferences; -import androidx.annotation.NonNull; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.remoteconfig.FirebaseRemoteConfig; -import com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchThrottledException; -import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo; -import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings; -import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; -import io.flutter.plugin.common.MethodCall; +import io.flutter.embedding.engine.plugins.FlutterPlugin; +import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.MethodChannel; -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; -import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.PluginRegistry.Registrar; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; /** FirebaseRemoteConfigPlugin */ -public class FirebaseRemoteConfigPlugin implements MethodCallHandler { +public class FirebaseRemoteConfigPlugin implements FlutterPlugin { - public static final String TAG = "FirebaseRemoteConfigPlugin"; - public static final String PREFS_NAME = + static final String TAG = "FirebaseRemoteConfigPlugin"; + static final String PREFS_NAME = "io.flutter.plugins.firebase.firebaseremoteconfig.FirebaseRemoteConfigPlugin"; - public static final String DEFAULT_PREF_KEY = "default_keys"; + static final String METHOD_CHANNEL = "plugins.flutter.io/firebase_remote_config"; - private static SharedPreferences sharedPreferences; + private MethodChannel channel; public static void registerWith(Registrar registrar) { - final MethodChannel channel = - new MethodChannel(registrar.messenger(), "plugins.flutter.io/firebase_remote_config"); - channel.setMethodCallHandler(new FirebaseRemoteConfigPlugin()); - sharedPreferences = registrar.context().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); + FirebaseRemoteConfigPlugin plugin = new FirebaseRemoteConfigPlugin(); + plugin.setupChannel(registrar.messenger(), registrar.context()); } @Override - public void onMethodCall(MethodCall call, final Result result) { - switch (call.method) { - case "RemoteConfig#instance": - { - FirebaseRemoteConfigInfo firebaseRemoteConfigInfo = - FirebaseRemoteConfig.getInstance().getInfo(); - - Map properties = new HashMap<>(); - properties.put("lastFetchTime", firebaseRemoteConfigInfo.getFetchTimeMillis()); - properties.put( - "lastFetchStatus", mapLastFetchStatus(firebaseRemoteConfigInfo.getLastFetchStatus())); - properties.put( - "inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled()); - properties.put("parameters", getConfigParameters()); - result.success(properties); - break; - } - case "RemoteConfig#setConfigSettings": - { - boolean debugMode = call.argument("debugMode"); - final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); - FirebaseRemoteConfigSettings settings = - new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(debugMode).build(); - firebaseRemoteConfig.setConfigSettings(settings); - result.success(null); - break; - } - case "RemoteConfig#fetch": - { - long expiration = ((Number) call.argument("expiration")).longValue(); - final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); - firebaseRemoteConfig - .fetch(expiration) - .addOnCompleteListener( - new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - FirebaseRemoteConfigInfo firebaseRemoteConfigInfo = - firebaseRemoteConfig.getInfo(); - Map properties = new HashMap<>(); - properties.put( - "lastFetchTime", firebaseRemoteConfigInfo.getFetchTimeMillis()); - properties.put( - "lastFetchStatus", - mapLastFetchStatus(firebaseRemoteConfigInfo.getLastFetchStatus())); - if (!task.isSuccessful()) { - final Exception exception = task.getException(); - - if (exception instanceof FirebaseRemoteConfigFetchThrottledException) { - properties.put( - "fetchThrottledEnd", - ((FirebaseRemoteConfigFetchThrottledException) exception) - .getThrottleEndTimeMillis()); - String errorMessage = - "Fetch has been throttled. See the error's " - + "FETCH_THROTTLED_END field for throttle end time."; - result.error("fetchFailedThrottled", errorMessage, properties); - } else { - String errorMessage = - "Unable to complete fetch. Reason is unknown " - + "but this could be due to lack of connectivity."; - result.error("fetchFailed", errorMessage, properties); - } - } else { - result.success(properties); - } - } - }); - break; - } - case "RemoteConfig#activate": - { - boolean newConfig = FirebaseRemoteConfig.getInstance().activateFetched(); - Map properties = new HashMap<>(); - properties.put("parameters", getConfigParameters()); - properties.put("newConfig", newConfig); - result.success(properties); - break; - } - case "RemoteConfig#setDefaults": - { - Map defaults = call.argument("defaults"); - FirebaseRemoteConfig.getInstance().setDefaults(defaults); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putStringSet(DEFAULT_PREF_KEY, defaults.keySet()).apply(); - result.success(null); - break; - } - default: - { - result.notImplemented(); - break; - } - } + public void onAttachedToEngine(FlutterPluginBinding binding) { + setupChannel(binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext()); } - private Map getConfigParameters() { - FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); - Map parameterMap = new HashMap<>(); - Set keys = firebaseRemoteConfig.getKeysByPrefix(""); - for (String key : keys) { - FirebaseRemoteConfigValue remoteConfigValue = firebaseRemoteConfig.getValue(key); - parameterMap.put(key, createRemoteConfigValueMap(remoteConfigValue)); - } - // Add default parameters if missing since `getKeysByPrefix` does not return default keys. - Set defaultKeys = - sharedPreferences.getStringSet(DEFAULT_PREF_KEY, new HashSet()); - for (String defaultKey : defaultKeys) { - if (!parameterMap.containsKey(defaultKey)) { - FirebaseRemoteConfigValue remoteConfigValue = firebaseRemoteConfig.getValue(defaultKey); - parameterMap.put(defaultKey, createRemoteConfigValueMap(remoteConfigValue)); - } - } - return parameterMap; - } - - private Map createRemoteConfigValueMap( - FirebaseRemoteConfigValue remoteConfigValue) { - Map valueMap = new HashMap<>(); - valueMap.put("value", remoteConfigValue.asByteArray()); - valueMap.put("source", mapValueSource(remoteConfigValue.getSource())); - return valueMap; + @Override + public void onDetachedFromEngine(FlutterPluginBinding binding) { + tearDownChannel(); } - private String mapLastFetchStatus(int status) { - switch (status) { - case FirebaseRemoteConfig.LAST_FETCH_STATUS_SUCCESS: - return "success"; - case FirebaseRemoteConfig.LAST_FETCH_STATUS_FAILURE: - return "failure"; - case FirebaseRemoteConfig.LAST_FETCH_STATUS_THROTTLED: - return "throttled"; - case FirebaseRemoteConfig.LAST_FETCH_STATUS_NO_FETCH_YET: - return "noFetchYet"; - default: - return "failure"; - } + private void setupChannel(BinaryMessenger messenger, Context context) { + MethodCallHandlerImpl handler = + new MethodCallHandlerImpl(context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)); + channel = new MethodChannel(messenger, METHOD_CHANNEL); + channel.setMethodCallHandler(handler); } - private String mapValueSource(int source) { - switch (source) { - case FirebaseRemoteConfig.VALUE_SOURCE_STATIC: - return "static"; - case FirebaseRemoteConfig.VALUE_SOURCE_DEFAULT: - return "default"; - case FirebaseRemoteConfig.VALUE_SOURCE_REMOTE: - return "remote"; - default: - return "static"; - } + private void tearDownChannel() { + channel.setMethodCallHandler(null); + channel = null; } } diff --git a/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/MethodCallHandlerImpl.java b/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/MethodCallHandlerImpl.java new file mode 100644 index 000000000000..c377554a9733 --- /dev/null +++ b/packages/firebase_remote_config/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/MethodCallHandlerImpl.java @@ -0,0 +1,184 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.firebase.firebaseremoteconfig; + +import android.content.SharedPreferences; +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.remoteconfig.FirebaseRemoteConfig; +import com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchThrottledException; +import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo; +import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings; +import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +class MethodCallHandlerImpl implements MethodChannel.MethodCallHandler { + + private static final String DEFAULT_PREF_KEY = "default_keys"; + + private static SharedPreferences sharedPreferences; + + MethodCallHandlerImpl(SharedPreferences sharedPreferences) { + MethodCallHandlerImpl.sharedPreferences = sharedPreferences; + } + + @Override + public void onMethodCall(MethodCall call, final MethodChannel.Result result) { + switch (call.method) { + case "RemoteConfig#instance": + { + FirebaseRemoteConfigInfo firebaseRemoteConfigInfo = + FirebaseRemoteConfig.getInstance().getInfo(); + + Map properties = new HashMap<>(); + properties.put("lastFetchTime", firebaseRemoteConfigInfo.getFetchTimeMillis()); + properties.put( + "lastFetchStatus", mapLastFetchStatus(firebaseRemoteConfigInfo.getLastFetchStatus())); + properties.put( + "inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled()); + properties.put("parameters", getConfigParameters()); + result.success(properties); + break; + } + case "RemoteConfig#setConfigSettings": + { + boolean debugMode = call.argument("debugMode"); + final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); + FirebaseRemoteConfigSettings settings = + new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(debugMode).build(); + firebaseRemoteConfig.setConfigSettings(settings); + result.success(null); + break; + } + case "RemoteConfig#fetch": + { + long expiration = ((Number) call.argument("expiration")).longValue(); + final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); + firebaseRemoteConfig + .fetch(expiration) + .addOnCompleteListener( + new OnCompleteListener() { + @Override + public void onComplete(Task task) { + FirebaseRemoteConfigInfo firebaseRemoteConfigInfo = + firebaseRemoteConfig.getInfo(); + Map properties = new HashMap<>(); + properties.put( + "lastFetchTime", firebaseRemoteConfigInfo.getFetchTimeMillis()); + properties.put( + "lastFetchStatus", + mapLastFetchStatus(firebaseRemoteConfigInfo.getLastFetchStatus())); + if (!task.isSuccessful()) { + final Exception exception = task.getException(); + + if (exception instanceof FirebaseRemoteConfigFetchThrottledException) { + properties.put( + "fetchThrottledEnd", + ((FirebaseRemoteConfigFetchThrottledException) exception) + .getThrottleEndTimeMillis()); + String errorMessage = + "Fetch has been throttled. See the error's " + + "FETCH_THROTTLED_END field for throttle end time."; + result.error("fetchFailedThrottled", errorMessage, properties); + } else { + String errorMessage = + "Unable to complete fetch. Reason is unknown " + + "but this could be due to lack of connectivity."; + result.error("fetchFailed", errorMessage, properties); + } + } else { + result.success(properties); + } + } + }); + break; + } + case "RemoteConfig#activate": + { + boolean newConfig = FirebaseRemoteConfig.getInstance().activateFetched(); + Map properties = new HashMap<>(); + properties.put("parameters", getConfigParameters()); + properties.put("newConfig", newConfig); + result.success(properties); + break; + } + case "RemoteConfig#setDefaults": + { + Map defaults = call.argument("defaults"); + FirebaseRemoteConfig.getInstance().setDefaults(defaults); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putStringSet(DEFAULT_PREF_KEY, defaults.keySet()).apply(); + result.success(null); + break; + } + default: + { + result.notImplemented(); + break; + } + } + } + + private Map getConfigParameters() { + FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); + Map parameterMap = new HashMap<>(); + Set keys = firebaseRemoteConfig.getKeysByPrefix(""); + for (String key : keys) { + FirebaseRemoteConfigValue remoteConfigValue = firebaseRemoteConfig.getValue(key); + parameterMap.put(key, createRemoteConfigValueMap(remoteConfigValue)); + } + // Add default parameters if missing since `getKeysByPrefix` does not return default keys. + Set defaultKeys = + sharedPreferences.getStringSet(DEFAULT_PREF_KEY, new HashSet()); + for (String defaultKey : defaultKeys) { + if (!parameterMap.containsKey(defaultKey)) { + FirebaseRemoteConfigValue remoteConfigValue = firebaseRemoteConfig.getValue(defaultKey); + parameterMap.put(defaultKey, createRemoteConfigValueMap(remoteConfigValue)); + } + } + return parameterMap; + } + + private Map createRemoteConfigValueMap( + FirebaseRemoteConfigValue remoteConfigValue) { + Map valueMap = new HashMap<>(); + valueMap.put("value", remoteConfigValue.asByteArray()); + valueMap.put("source", mapValueSource(remoteConfigValue.getSource())); + return valueMap; + } + + private String mapLastFetchStatus(int status) { + switch (status) { + case FirebaseRemoteConfig.LAST_FETCH_STATUS_SUCCESS: + return "success"; + case FirebaseRemoteConfig.LAST_FETCH_STATUS_FAILURE: + return "failure"; + case FirebaseRemoteConfig.LAST_FETCH_STATUS_THROTTLED: + return "throttled"; + case FirebaseRemoteConfig.LAST_FETCH_STATUS_NO_FETCH_YET: + return "noFetchYet"; + default: + return "failure"; + } + } + + private String mapValueSource(int source) { + switch (source) { + case FirebaseRemoteConfig.VALUE_SOURCE_STATIC: + return "static"; + case FirebaseRemoteConfig.VALUE_SOURCE_DEFAULT: + return "default"; + case FirebaseRemoteConfig.VALUE_SOURCE_REMOTE: + return "remote"; + default: + return "static"; + } + } +} diff --git a/packages/firebase_remote_config/example/android/app/src/main/AndroidManifest.xml b/packages/firebase_remote_config/example/android/app/src/main/AndroidManifest.xml index fe4292fe0322..7100b12a4e6e 100644 --- a/packages/firebase_remote_config/example/android/app/src/main/AndroidManifest.xml +++ b/packages/firebase_remote_config/example/android/app/src/main/AndroidManifest.xml @@ -17,8 +17,9 @@ android:label="firebase_remote_config_example" android:icon="@mipmap/ic_launcher"> + + diff --git a/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/EmbeddingV1Activity.java b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/EmbeddingV1Activity.java new file mode 100644 index 000000000000..37b8ecf074fa --- /dev/null +++ b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/EmbeddingV1Activity.java @@ -0,0 +1,17 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.firebase.firebaseremoteconfigexample; + +import android.os.Bundle; +import io.flutter.app.FlutterActivity; +import io.flutter.plugins.GeneratedPluginRegistrant; + +public class EmbeddingV1Activity extends FlutterActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + GeneratedPluginRegistrant.registerWith(this); + } +} diff --git a/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/EmbeddingV1ActivityTest.java b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/EmbeddingV1ActivityTest.java new file mode 100644 index 000000000000..b7ab6b3f5b55 --- /dev/null +++ b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/EmbeddingV1ActivityTest.java @@ -0,0 +1,17 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.firebase.firebaseremoteconfigexample; + +import androidx.test.rule.ActivityTestRule; +import dev.flutter.plugins.e2e.FlutterRunner; +import org.junit.Rule; +import org.junit.runner.RunWith; + +@RunWith(FlutterRunner.class) +public class EmbeddingV1ActivityTest { + @Rule + public ActivityTestRule rule = + new ActivityTestRule<>(EmbeddingV1Activity.class); +} diff --git a/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivity.java b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivity.java index ef048c74f4df..491f04a7b0a6 100644 --- a/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivity.java +++ b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivity.java @@ -1,13 +1,22 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + package io.flutter.plugins.firebase.firebaseremoteconfigexample; -import android.os.Bundle; -import io.flutter.app.FlutterActivity; -import io.flutter.plugins.GeneratedPluginRegistrant; +import io.flutter.embedding.android.FlutterActivity; +import io.flutter.embedding.engine.FlutterEngine; +import io.flutter.plugins.firebase.core.FirebaseCorePlugin; +import io.flutter.plugins.firebase.firebaseremoteconfig.FirebaseRemoteConfigPlugin; public class MainActivity extends FlutterActivity { + + // TODO(cyanglaz): Remove this once v2 of GeneratedPluginRegistrant rolls to stable. + // https://github.com/flutter/flutter/issues/42694 @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - GeneratedPluginRegistrant.registerWith(this); + public void configureFlutterEngine(FlutterEngine flutterEngine) { + super.configureFlutterEngine(flutterEngine); + flutterEngine.getPlugins().add(new FirebaseRemoteConfigPlugin()); + flutterEngine.getPlugins().add(new FirebaseCorePlugin()); } } diff --git a/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivityTest.java b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivityTest.java new file mode 100644 index 000000000000..3531b55a3fdc --- /dev/null +++ b/packages/firebase_remote_config/example/android/app/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfigexample/MainActivityTest.java @@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.firebase.firebaseremoteconfigexample; + +import androidx.test.rule.ActivityTestRule; +import dev.flutter.plugins.e2e.FlutterRunner; +import org.junit.Rule; +import org.junit.runner.RunWith; + +@RunWith(FlutterRunner.class) +public class MainActivityTest { + @Rule public ActivityTestRule rule = new ActivityTestRule<>(MainActivity.class); +} diff --git a/packages/firebase_remote_config/example/android/gradle.properties b/packages/firebase_remote_config/example/android/gradle.properties index 8bd86f680510..38c8d4544ff1 100644 --- a/packages/firebase_remote_config/example/android/gradle.properties +++ b/packages/firebase_remote_config/example/android/gradle.properties @@ -1 +1,4 @@ org.gradle.jvmargs=-Xmx1536M +android.enableR8=true +android.useAndroidX=true +android.enableJetifier=true diff --git a/packages/firebase_remote_config/example/lib/main.dart b/packages/firebase_remote_config/example/lib/main.dart index 8db737372086..89a7d6de387e 100644 --- a/packages/firebase_remote_config/example/lib/main.dart +++ b/packages/firebase_remote_config/example/lib/main.dart @@ -8,6 +8,7 @@ import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:flutter/material.dart'; void main() { + WidgetsFlutterBinding.ensureInitialized(); runApp(MaterialApp( title: 'Remote Config Example', home: FutureBuilder( diff --git a/packages/firebase_remote_config/example/pubspec.yaml b/packages/firebase_remote_config/example/pubspec.yaml index 06c9b5bea711..77e4a07a48da 100644 --- a/packages/firebase_remote_config/example/pubspec.yaml +++ b/packages/firebase_remote_config/example/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: cupertino_icons: ^0.1.0 firebase_remote_config: path: ../ - firebase_core: ^0.4.0 + firebase_core: ^0.4.1 dev_dependencies: flutter_test: @@ -18,3 +18,9 @@ dev_dependencies: flutter_driver: sdk: flutter test: any + e2e: ^0.2.0 + +environment: + sdk: ">=2.0.0-dev.28.0 <3.0.0" + flutter: ">=1.9.1+hotfix.2 <2.0.0" + diff --git a/packages/firebase_remote_config/example/test_driver/firebase_remote_config.dart b/packages/firebase_remote_config/example/test_driver/firebase_remote_config_e2e.dart similarity index 82% rename from packages/firebase_remote_config/example/test_driver/firebase_remote_config.dart rename to packages/firebase_remote_config/example/test_driver/firebase_remote_config_e2e.dart index 2514b2a08a1d..5748e2cf1823 100644 --- a/packages/firebase_remote_config/example/test_driver/firebase_remote_config.dart +++ b/packages/firebase_remote_config/example/test_driver/firebase_remote_config_e2e.dart @@ -1,12 +1,9 @@ -import 'dart:async'; -import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:e2e/e2e.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; void main() { - final Completer completer = Completer(); - enableFlutterDriverExtension(handler: (_) => completer.future); - tearDownAll(() => completer.complete(null)); + E2EWidgetsFlutterBinding.ensureInitialized(); group('$RemoteConfig', () { RemoteConfig remoteConfig; @@ -21,7 +18,7 @@ void main() { }); }); - test('fetch', () async { + testWidgets('fetch', (WidgetTester tester) async { final DateTime lastFetchTime = remoteConfig.lastFetchTime; expect(lastFetchTime.isBefore(DateTime.now()), true); await remoteConfig.fetch(expiration: const Duration(seconds: 0)); diff --git a/packages/firebase_remote_config/example/test_driver/firebase_remote_config_e2e_test.dart b/packages/firebase_remote_config/example/test_driver/firebase_remote_config_e2e_test.dart new file mode 100644 index 000000000000..bcfa86da4455 --- /dev/null +++ b/packages/firebase_remote_config/example/test_driver/firebase_remote_config_e2e_test.dart @@ -0,0 +1,11 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:flutter_driver/flutter_driver.dart'; + +Future main() async { + final FlutterDriver driver = await FlutterDriver.connect(); + final String result = + await driver.requestData(null, timeout: const Duration(minutes: 1)); + driver.close(); + exit(result == 'pass' ? 0 : 1); +} diff --git a/packages/firebase_remote_config/example/test_driver/firebase_remote_config_test.dart b/packages/firebase_remote_config/example/test_driver/firebase_remote_config_test.dart deleted file mode 100644 index 38fe6c447e05..000000000000 --- a/packages/firebase_remote_config/example/test_driver/firebase_remote_config_test.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - await driver.requestData(null, timeout: const Duration(minutes: 1)); - driver.close(); -} diff --git a/packages/firebase_remote_config/pubspec.yaml b/packages/firebase_remote_config/pubspec.yaml index 8f9cf2d4f347..f448aedb32c0 100644 --- a/packages/firebase_remote_config/pubspec.yaml +++ b/packages/firebase_remote_config/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Remote Config. Update your application re-releasing. author: Flutter Team homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_remote_config -version: 0.2.0+9 +version: 0.2.1 dependencies: flutter: @@ -16,6 +16,7 @@ dev_dependencies: flutter_driver: sdk: flutter test: any + e2e: ^0.2.0 flutter: plugin: @@ -24,4 +25,4 @@ flutter: environment: sdk: ">=2.0.0-dev.28.0 <3.0.0" - flutter: ">=1.5.0 <2.0.0" + flutter: ">=1.9.1+hotfix.2 <2.0.0"