diff --git a/experimental/federated_plugin/federated_plugin/example/pubspec.lock b/experimental/federated_plugin/federated_plugin/example/pubspec.lock index fb964ea38..d79c6d316 100644 --- a/experimental/federated_plugin/federated_plugin/example/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.4.1" boolean_selector: dependency: transitive description: @@ -15,13 +15,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0-nullsafety" charcode: dependency: transitive description: @@ -42,7 +35,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety" + version: "1.14.12" cupertino_icons: dependency: "direct main" description: @@ -71,6 +64,13 @@ packages: relative: true source: path version: "0.0.1" + federated_plugin_web: + dependency: transitive + description: + path: "../../federated_plugin_web" + relative: true + source: path + version: "0.0.1" flutter: dependency: "direct main" description: flutter @@ -81,20 +81,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety" + version: "1.1.8" path: dependency: transitive description: @@ -108,7 +113,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.9.0" plugin_platform_interface: dependency: transitive description: @@ -134,7 +139,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.9.3" stream_channel: dependency: transitive description: @@ -162,21 +167,21 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.16" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety" + version: "1.1.6" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.0.8" sdks: - dart: ">=2.9.0-18.0 <2.9.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.17.0 <2.0.0" diff --git a/experimental/federated_plugin/federated_plugin/example/web/favicon.png b/experimental/federated_plugin/federated_plugin/example/web/favicon.png new file mode 100644 index 000000000..8aaa46ac1 Binary files /dev/null and b/experimental/federated_plugin/federated_plugin/example/web/favicon.png differ diff --git a/experimental/federated_plugin/federated_plugin/example/web/icons/Icon-192.png b/experimental/federated_plugin/federated_plugin/example/web/icons/Icon-192.png new file mode 100644 index 000000000..b749bfef0 Binary files /dev/null and b/experimental/federated_plugin/federated_plugin/example/web/icons/Icon-192.png differ diff --git a/experimental/federated_plugin/federated_plugin/example/web/icons/Icon-512.png b/experimental/federated_plugin/federated_plugin/example/web/icons/Icon-512.png new file mode 100644 index 000000000..88cfd48df Binary files /dev/null and b/experimental/federated_plugin/federated_plugin/example/web/icons/Icon-512.png differ diff --git a/experimental/federated_plugin/federated_plugin/example/web/index.html b/experimental/federated_plugin/federated_plugin/example/web/index.html new file mode 100644 index 000000000..9b7a438f8 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin/example/web/index.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + example + + + + + + + + diff --git a/experimental/federated_plugin/federated_plugin/example/web/manifest.json b/experimental/federated_plugin/federated_plugin/example/web/manifest.json new file mode 100644 index 000000000..8c012917d --- /dev/null +++ b/experimental/federated_plugin/federated_plugin/example/web/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/experimental/federated_plugin/federated_plugin/pubspec.lock b/experimental/federated_plugin/federated_plugin/pubspec.lock index 4b3f803f2..91bb00350 100644 --- a/experimental/federated_plugin/federated_plugin/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.4.1" boolean_selector: dependency: transitive description: @@ -15,13 +15,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0-nullsafety" charcode: dependency: transitive description: @@ -42,7 +35,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety" + version: "1.14.12" fake_async: dependency: transitive description: @@ -57,6 +50,13 @@ packages: relative: true source: path version: "0.0.1" + federated_plugin_web: + dependency: "direct main" + description: + path: "../federated_plugin_web" + relative: true + source: path + version: "0.0.1" flutter: dependency: "direct main" description: flutter @@ -67,20 +67,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety" + version: "1.1.8" path: dependency: transitive description: @@ -94,7 +99,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.9.0" plugin_platform_interface: dependency: transitive description: @@ -120,7 +125,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.9.3" stream_channel: dependency: transitive description: @@ -148,21 +153,21 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.16" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety" + version: "1.1.6" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.0.8" sdks: - dart: ">=2.9.0-18.0 <2.9.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.17.0 <2.0.0" diff --git a/experimental/federated_plugin/federated_plugin/pubspec.yaml b/experimental/federated_plugin/federated_plugin/pubspec.yaml index 5a57d4a0a..2cb10ccb2 100644 --- a/experimental/federated_plugin/federated_plugin/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin/pubspec.yaml @@ -14,6 +14,8 @@ dependencies: sdk: flutter federated_plugin_platform_interface: path: ../federated_plugin_platform_interface + federated_plugin_web: + path: ../federated_plugin_web dev_dependencies: flutter_test: @@ -26,3 +28,5 @@ flutter: android: pluginClass: FederatedPlugin package: dev.flutter.federated_plugin + web: + default_package: federated_plugin_web diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock index 9232a970b..3b35a0d54 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.4.1" boolean_selector: dependency: transitive description: @@ -15,13 +15,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0-nullsafety" charcode: dependency: transitive description: @@ -42,7 +35,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety" + version: "1.14.12" fake_async: dependency: transitive description: @@ -66,14 +59,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety" + version: "1.1.8" path: dependency: transitive description: @@ -87,7 +80,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.9.0" plugin_platform_interface: dependency: "direct main" description: @@ -113,7 +106,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.9.3" stream_channel: dependency: transitive description: @@ -141,21 +134,21 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.16" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety" + version: "1.1.6" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.0.8" sdks: - dart: ">=2.9.0-18.0 <2.9.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.17.0 <2.0.0" diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml index e825f60da..6bf7cb129 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml @@ -1,5 +1,5 @@ name: federated_plugin_platform_interface -description: A new Flutter package project. +description: A platform interface for federated_plugin. version: 0.0.1 author: homepage: diff --git a/experimental/federated_plugin/federated_plugin_web/.gitignore b/experimental/federated_plugin/federated_plugin_web/.gitignore new file mode 100644 index 000000000..bb431f0d5 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/.gitignore @@ -0,0 +1,75 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/experimental/federated_plugin/federated_plugin_web/.metadata b/experimental/federated_plugin/federated_plugin_web/.metadata new file mode 100644 index 000000000..8d52aa40e --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 8c5c720ce60b1761ec2963053e0d415df60a29e1 + channel: master + +project_type: package diff --git a/experimental/federated_plugin/federated_plugin_web/README.md b/experimental/federated_plugin/federated_plugin_web/README.md new file mode 100644 index 000000000..71f60d980 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/README.md @@ -0,0 +1,11 @@ +# federated_plugin_web + +A flutter plugin to provide location support for web. The web implementation +of `federated_plugin` is tested using [e2e](https://pub.dev/packages/e2e) package. + +### Steps to run e2e test on browser + +- Download and install the ChromeDriver from [here](https://chromedriver.chromium.org/downloads) +for the version of Chrome you are using. +- Start the driver using `chromedrive --port=4444` +- Run the test using `flutter drive -d web-server --release --browser-name=chrome --target=test_driver/federated_plugin_web_e2e.dart` diff --git a/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml b/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml new file mode 100644 index 000000000..f5c207c72 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml @@ -0,0 +1,31 @@ +include: package:pedantic/analysis_options.yaml + +analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false + +linter: + rules: + - avoid_types_on_closure_parameters + - avoid_void_async + - await_only_futures + - camel_case_types + - cancel_subscriptions + - close_sinks + - constant_identifier_names + - control_flow_in_finally + - directives_ordering + - empty_statements + - hash_and_equals + - implementation_imports + - non_constant_identifier_names + - package_api_docs + - package_names + - package_prefixed_library_names + - test_types_in_equals + - throw_in_finally + - unnecessary_brace_in_string_interps + - unnecessary_getters_setters + - unnecessary_new + - unnecessary_statements diff --git a/experimental/federated_plugin/federated_plugin_web/lib/federated_plugin_web.dart b/experimental/federated_plugin/federated_plugin_web/lib/federated_plugin_web.dart new file mode 100644 index 000000000..611ffa740 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/lib/federated_plugin_web.dart @@ -0,0 +1,45 @@ +// Copyright 2020 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:html' as html; + +import 'package:federated_plugin_platform_interface/federated_plugin_platform_interface.dart'; +import 'package:federated_plugin_platform_interface/location_model.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +/// Web Implementation of [FederatedPluginInterface] to provide location. +class FederatedPlugin extends FederatedPluginInterface { + final html.Geolocation _geolocation; + + /// Constructor to override the geolocation object for testing purpose. + FederatedPlugin({html.Geolocation geolocation}) + : _geolocation = geolocation ?? html.window.navigator.geolocation; + + /// Method to register the plugin which sets [FederatedPlugin] to be the default + /// instance of [FederatedPluginInterface]. + static void registerWith(Registrar registrar) { + FederatedPluginInterface.instance = FederatedPlugin(); + } + + /// Returns [Location] to provide latitude and longitude. + /// + /// If any error, it's assume that user has denied the permission forever. + @override + Future getLocation() async { + try { + final geoPosition = await _geolocation.getCurrentPosition(); + return Location( + longitude: geoPosition.coords.longitude.toDouble(), + latitude: geoPosition.coords.latitude.toDouble(), + ); + } catch (error) { + throw PlatformException( + code: 'PERMISSION_DENIED', + message: 'Permission denied from User', + details: null, + ); + } + } +} diff --git a/experimental/federated_plugin/federated_plugin_web/pubspec.lock b/experimental/federated_plugin/federated_plugin_web/pubspec.lock new file mode 100644 index 000000000..f779018d8 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/pubspec.lock @@ -0,0 +1,288 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.0" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.3" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.14.12" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + e2e: + dependency: "direct dev" + description: + name: e2e + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.1" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + federated_plugin_platform_interface: + dependency: "direct main" + description: + path: "../federated_plugin_platform_interface" + relative: true + source: path + version: "0.0.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.16.1" + json_rpc_2: + dependency: transitive + description: + name: json_rpc_2 + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.6" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.8" + mockito: + dependency: "direct dev" + description: + name: mockito + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.1" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + pedantic: + dependency: "direct dev" + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.13" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.3" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + sync_http: + dependency: transitive + description: + name: sync_http + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.16" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.6" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + vm_service_client: + dependency: transitive + description: + name: vm_service_client + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.6+2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + webdriver: + dependency: transitive + description: + name: webdriver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" +sdks: + dart: ">=2.7.0 <3.0.0" + flutter: ">=1.17.0 <2.0.0" diff --git a/experimental/federated_plugin/federated_plugin_web/pubspec.yaml b/experimental/federated_plugin/federated_plugin_web/pubspec.yaml new file mode 100644 index 000000000..188d32a50 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/pubspec.yaml @@ -0,0 +1,31 @@ +name: federated_plugin_web +description: Web implementation of federated_plugin to provide location. +version: 0.0.1 +homepage: +publish_to: none + +environment: + sdk: ">=2.7.0 <3.0.0" + flutter: ">=1.17.0 <2.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_web_plugins: + sdk: flutter + federated_plugin_platform_interface: + path: ../federated_plugin_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + pedantic: ^1.9.0 + e2e: ^0.6.1 + mockito: ^4.1.1 + +flutter: + plugin: + platforms: + web: + pluginClass: FederatedPlugin + fileName: federated_plugin_web.dart diff --git a/experimental/federated_plugin/federated_plugin_web/test_driver/federated_plugin_web_e2e.dart b/experimental/federated_plugin/federated_plugin_web/test_driver/federated_plugin_web_e2e.dart new file mode 100644 index 000000000..ed856b6d0 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/test_driver/federated_plugin_web_e2e.dart @@ -0,0 +1,53 @@ +// Copyright 2020 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:html'; + +import 'package:e2e/e2e.dart'; +import 'package:federated_plugin_web/federated_plugin_web.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; + +const kLatitude = 4; +const kLongitude = 3; + +class GeoLocationMock extends Mock implements Geolocation {} + +class GeoPositionMock extends Mock implements Geoposition { + @override + Coordinates get coords => MockCoordinates(); +} + +class MockCoordinates extends Mock implements Coordinates { + @override + num get latitude => kLatitude; + + @override + num get longitude => kLongitude; +} + +void main() { + E2EWidgetsFlutterBinding.ensureInitialized(); + + group('FederatedPlugin test', () { + final geoLocationMock = GeoLocationMock(); + + setUp(() { + when(geoLocationMock.getCurrentPosition()) + .thenAnswer((realInvocation) async => GeoPositionMock()); + }); + + testWidgets('getLocation Method', (tester) async { + final federatedPlugin = FederatedPlugin(geolocation: geoLocationMock); + final location = await federatedPlugin.getLocation(); + + // Verify that getCurrentPosition was called. + verify(geoLocationMock.getCurrentPosition()); + + // Verify the values of Location.longitude and Location.latitude. + expect(location.longitude, kLongitude); + expect(location.latitude, kLatitude); + }); + }); +} diff --git a/experimental/federated_plugin/federated_plugin_web/test_driver/federated_plugin_web_e2e_test.dart b/experimental/federated_plugin/federated_plugin_web/test_driver/federated_plugin_web_e2e_test.dart new file mode 100644 index 000000000..6afbe42a7 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/test_driver/federated_plugin_web_e2e_test.dart @@ -0,0 +1,9 @@ +// Copyright 2020 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:e2e/e2e_driver.dart' as e2e; + +Future main() async => e2e.main(); diff --git a/experimental/federated_plugin/federated_plugin_web/web/index.html b/experimental/federated_plugin/federated_plugin_web/web/index.html new file mode 100644 index 000000000..2cf1b6a25 --- /dev/null +++ b/experimental/federated_plugin/federated_plugin_web/web/index.html @@ -0,0 +1,10 @@ + + + + + Browser Tests + + + + +