Skip to content
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
6 changes: 5 additions & 1 deletion widget_driver/example/macos/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.11'
platform :macos, '12'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -36,5 +36,9 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
target.build_configurations.each do |config|
# Force a consistent deployment target; some pod subprojects ship stale defaults (e.g. 10.14/10.15)
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
37 changes: 15 additions & 22 deletions widget_driver/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
PODS:
- FlutterMacOS (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- path_provider_macos (0.0.1):
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqflite (0.0.2):
- sqflite_darwin (0.0.4):
- Flutter
- FlutterMacOS
- FMDB (>= 2.7.5)

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`)

SPEC REPOS:
trunk:
- FMDB
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- sqflite_darwin (from `Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin`)

EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral
path_provider_macos:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
sqflite:
:path: Flutter/ephemeral/.symlinks/plugins/sqflite/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
sqflite_darwin:
:path: Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin

SPEC CHECKSUMS:
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
PODFILE CHECKSUM: 33bf4e124084a7b149886b8b5bc450dc18071137

COCOAPODS: 1.11.3
COCOAPODS: 1.16.2
11 changes: 6 additions & 5 deletions widget_driver/example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXAggregateTarget section */
Expand Down Expand Up @@ -203,7 +203,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
Expand Down Expand Up @@ -256,6 +256,7 @@
/* Begin PBXShellScriptBuildPhase section */
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -404,7 +405,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -483,7 +484,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -530,7 +531,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,6 +48,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
6 changes: 5 additions & 1 deletion widget_driver/example/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
4 changes: 2 additions & 2 deletions widget_driver/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dependencies:
meta: ^1.7.0
get_it: ^7.2.0
provider: ^6.0.4
cached_network_image: ^3.0.0
http: ^0.13.5
cached_network_image: ^3.4.1
http: ^1.6.0

dev_dependencies:
flutter_test:
Expand Down
22 changes: 1 addition & 21 deletions widget_driver/example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,8 @@

<title>example</title>
<link rel="manifest" href="manifest.json">

<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
}
}).then(function(engineInitializer) {
return engineInitializer.initializeEngine();
}).then(function(appRunner) {
return appRunner.runApp();
});
});
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
46 changes: 0 additions & 46 deletions widget_driver/lib/src/utils/platform_environment.dart

This file was deleted.

21 changes: 15 additions & 6 deletions widget_driver/lib/src/utils/runtime_environment_info.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import 'platform_environment.dart';
import 'package:flutter/widgets.dart';

/// A callback which returns `true` if the current runtime is a `flutter test` run.
typedef IsRunningInTestCallback = bool Function();

/// A helper class which gives you info about
/// the environment for the current runtime.
class RuntimeEnvironmentInfo {
static const String _flutterTestEnvKey = 'FLUTTER_TEST';
// `flutter test` always installs `AutomatedTestWidgetsFlutterBinding`, on every
// platform (including web, where there is no process environment to check instead).
static const String _testBindingTypeName = 'AutomatedTestWidgetsFlutterBinding';

final PlatformEnvironment _platformEnvironment;
final IsRunningInTestCallback _isRunningInTest;

RuntimeEnvironmentInfo({
PlatformEnvironment? platformEnvironment,
}) : _platformEnvironment = platformEnvironment ?? PlatformEnvironment();
IsRunningInTestCallback? isRunningInTest,
}) : _isRunningInTest = isRunningInTest ?? _isRunningInTestBinding;

static bool _isRunningInTestBinding() {
return WidgetsBinding.instance.runtimeType.toString() == _testBindingTypeName;
}

/// Returns `true` if the current runtime is in a test environment and tests are running.
bool isRunningInTestEnvironment() {
bool isRunningInTest = false;
assert(() {
isRunningInTest = _platformEnvironment.containsKey(_flutterTestEnvKey);
isRunningInTest = _isRunningInTest();
return true;
}());
return isRunningInTest;
Expand Down
1 change: 1 addition & 0 deletions widget_driver/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ dev_dependencies:
flutter_lints: ^1.0.4
mocktail: ^1.0.4
provider: ^6.0.4
widget_driver_test:
56 changes: 0 additions & 56 deletions widget_driver/test/utils/platform_environment_test.dart

This file was deleted.

31 changes: 11 additions & 20 deletions widget_driver/test/utils/runtime_environment_info_test.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';

import 'package:widget_driver/src/utils/platform_environment.dart';
import 'package:widget_driver/src/utils/runtime_environment_info.dart';

class MockPlatformEnvironment extends Mock implements PlatformEnvironment {}

void main() {
group('RuntimeEnvironmentInfo:', () {
late MockPlatformEnvironment _mockPlatformEnvironment;

setUp(() {
_mockPlatformEnvironment = MockPlatformEnvironment();
});

group('Is running tests:', () {
test('Returns true when environment says `test` key exists', () {
when(() => _mockPlatformEnvironment.containsKey(any())).thenReturn(true);
final runtimeEnvironmentInfo = RuntimeEnvironmentInfo(platformEnvironment: _mockPlatformEnvironment);
test('Returns true when the test binding is detected', () {
final runtimeEnvironmentInfo = RuntimeEnvironmentInfo(isRunningInTest: () => true);
expect(runtimeEnvironmentInfo.isRunningInTestEnvironment(), true);
});

test('Returns false when environment says that no `test` key exists', () {
when(() => _mockPlatformEnvironment.containsKey(any())).thenReturn(false);
final runtimeEnvironmentInfo = RuntimeEnvironmentInfo(platformEnvironment: _mockPlatformEnvironment);
test('Returns false when the test binding is not detected', () {
final runtimeEnvironmentInfo = RuntimeEnvironmentInfo(isRunningInTest: () => false);
expect(runtimeEnvironmentInfo.isRunningInTestEnvironment(), false);
});
});

group('Constructor:', () {
test('Can construct with no input parameters using real logic. Which returns true for isRunningTests', () {
final runtimeEnvironmentInfo = RuntimeEnvironmentInfo();
expect(runtimeEnvironmentInfo.isRunningInTestEnvironment(), true);
});
testWidgets(
'Can construct with no input parameters using real logic. Which returns true for isRunningTests',
(tester) async {
final runtimeEnvironmentInfo = RuntimeEnvironmentInfo();
expect(runtimeEnvironmentInfo.isRunningInTestEnvironment(), true);
},
);
});
});
}
Loading
Loading