1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-30 16:23:23 +00:00

[federated_plugin] adds web implementation of federated_plugin (#507)

This commit is contained in:
Ayush Bherwani
2020-08-05 11:08:20 +05:30
committed by GitHub
parent 18758bf5af
commit c5c2da9a4b
20 changed files with 678 additions and 52 deletions

View File

@@ -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);
});
});
}

View File

@@ -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<void> main() async => e2e.main();