Unverified Commit d8034538 authored by Core's avatar Core Committed by GitHub

feat: enable flavor option on test command (#89045)

parent 24097328
......@@ -4,9 +4,15 @@
import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/tasks/integration_tests.dart';
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(createFlavorsTest());
await task(() async {
await createFlavorsTest().call();
await createIntegrationTestFlavorsTest().call();
return TaskResult.success(null);
});
}
......@@ -4,9 +4,15 @@
import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/tasks/integration_tests.dart';
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.ios;
await task(createFlavorsTest());
await task(() async {
await createFlavorsTest().call();
await createIntegrationTestFlavorsTest().call();
return TaskResult.success(null);
});
}
......@@ -4,9 +4,15 @@
import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/tasks/integration_tests.dart';
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(createFlavorsTest());
await task(() async {
await createFlavorsTest().call();
await createIntegrationTestFlavorsTest().call();
return TaskResult.success(null);
});
}
......@@ -29,6 +29,14 @@ TaskFunction createFlavorsTest() {
);
}
TaskFunction createIntegrationTestFlavorsTest() {
return IntegrationTest(
'${flutterDirectory.path}/dev/integration_tests/flavors',
'integration_test/integration_test.dart',
extraOptions: <String>['--flavor', 'paid'],
);
}
TaskFunction createExternalUiIntegrationTest() {
return DriverTest(
'${flutterDirectory.path}/dev/integration_tests/external_ui',
......@@ -166,10 +174,16 @@ class DriverTest {
}
class IntegrationTest {
IntegrationTest(this.testDirectory, this.testTarget);
IntegrationTest(
this.testDirectory,
this.testTarget, {
this.extraOptions = const <String>[],
}
);
final String testDirectory;
final String testTarget;
final List<String> extraOptions;
Future<TaskResult> call() {
return inDirectory<TaskResult>(testDirectory, () async {
......@@ -183,6 +197,7 @@ class IntegrationTest {
'-d',
deviceId,
testTarget,
...extraOptions,
];
await flutter('test', options: options);
......
// Copyright 2014 The Flutter Authors. 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:flavors/main.dart' as app;
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('Flavor Test', () {
testWidgets('check flavor', (WidgetTester tester) async {
app.runMainApp();
await tester.pumpAndSettle();
await tester.pumpAndSettle();
expect(find.text('paid'), findsOneWidget);
});
});
}
......@@ -8,6 +8,10 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runMainApp();
}
void runMainApp() {
runApp(const Center(child: Flavor()));
}
......
......@@ -73,6 +73,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
usesDartDefineOption();
usesWebRendererOption();
usesDeviceUserOption();
usesFlavorOption();
argParser
..addMultiOption('name',
......
......@@ -605,6 +605,32 @@ dev_dependencies:
]),
});
testUsingContext('Integration tests given flavor', () async {
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
final TestCommand testCommand = TestCommand(testRunner: testRunner);
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
await commandRunner.run(const <String>[
'test',
'--no-pub',
'--flavor',
'dev',
'integration_test',
]);
expect(
testRunner.lastDebuggingOptionsValue.buildInfo.flavor,
contains('dev'),
);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => _FakeDeviceManager(<Device>[
FakeDevice('ephemeral', 'ephemeral', type: PlatformType.android),
]),
});
testUsingContext('Builds the asset manifest by default', () async {
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment