Commit 18db5a2e authored by Sarah Zakarias's avatar Sarah Zakarias Committed by GitHub

Add start-up test for flutter_view sample (#8892)

* Add start-up test for flutter_view sample

* add reportMetrics flag to startup test

* rewording in manifest.yaml
parent e918ef5d
// Copyright 2017 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.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(createFlutterViewStartupTest());
}
// Copyright 2017 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.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
deviceOperatingSystem = DeviceOperatingSystem.ios;
await task(createFlutterViewStartupTest());
}
...@@ -75,13 +75,21 @@ TaskFunction createGalleryBackButtonMemoryTest() { ...@@ -75,13 +75,21 @@ TaskFunction createGalleryBackButtonMemoryTest() {
); );
} }
TaskFunction createFlutterViewStartupTest() {
return new StartupTest(
'${flutterDirectory.path}/examples/flutter_view',
reportMetrics: false,
);
}
/// Measure application startup performance. /// Measure application startup performance.
class StartupTest { class StartupTest {
static const Duration _startupTimeout = const Duration(minutes: 5); static const Duration _startupTimeout = const Duration(minutes: 5);
StartupTest(this.testDirectory); StartupTest(this.testDirectory, { this.reportMetrics: true });
final String testDirectory; final String testDirectory;
final bool reportMetrics;
Future<TaskResult> call() async { Future<TaskResult> call() async {
return await inDirectory(testDirectory, () async { return await inDirectory(testDirectory, () async {
...@@ -101,6 +109,9 @@ class StartupTest { ...@@ -101,6 +109,9 @@ class StartupTest {
deviceId, deviceId,
]).timeout(_startupTimeout); ]).timeout(_startupTimeout);
final Map<String, dynamic> data = JSON.decode(file('$testDirectory/build/start_up_info.json').readAsStringSync()); final Map<String, dynamic> data = JSON.decode(file('$testDirectory/build/start_up_info.json').readAsStringSync());
if (!reportMetrics) return new TaskResult.success(data);
return new TaskResult.success(data, benchmarkScoreKeys: <String>[ return new TaskResult.success(data, benchmarkScoreKeys: <String>[
'timeToFirstFrameMicros', 'timeToFirstFrameMicros',
]); ]);
......
...@@ -144,6 +144,12 @@ tasks: ...@@ -144,6 +144,12 @@ tasks:
stage: devicelab stage: devicelab
required_agent_capabilities: ["has-android-device"] required_agent_capabilities: ["has-android-device"]
flutter_view__start_up:
description: >
Verifies that Flutter View can be used from an Android project.
stage: devicelab
required_agent_capabilities: ["has-android-device"]
# iOS on-device tests # iOS on-device tests
platform_services_test_ios: platform_services_test_ios:
...@@ -190,6 +196,12 @@ tasks: ...@@ -190,6 +196,12 @@ tasks:
stage: devicelab_ios stage: devicelab_ios
required_agent_capabilities: ["has-ios-device"] required_agent_capabilities: ["has-ios-device"]
flutter_view_ios__start_up:
description: >
Verifies that Flutter View can be used from an iOS project.
stage: devicelab_ios
required_agent_capabilities: ["has-ios-device"]
# Tests running on Windows host # Tests running on Windows host
flutter_gallery_win__build: flutter_gallery_win__build:
......
...@@ -9,7 +9,7 @@ import android.widget.TextView; ...@@ -9,7 +9,7 @@ import android.widget.TextView;
import io.flutter.plugin.common.FlutterMessageChannel; import io.flutter.plugin.common.FlutterMessageChannel;
import io.flutter.plugin.common.FlutterMessageChannel.MessageHandler; import io.flutter.plugin.common.FlutterMessageChannel.MessageHandler;
import io.flutter.plugin.common.FlutterMessageChannel.Reply; import io.flutter.plugin.common.FlutterMessageChannel.Reply;
import io.flutter.plugin.common.StringMessageCodec; import io.flutter.plugin.common.StringCodec;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterView; import io.flutter.view.FlutterView;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -58,7 +58,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -58,7 +58,7 @@ public class MainActivity extends AppCompatActivity {
flutterView.runFromBundle(FlutterMain.findAppBundlePath(getApplicationContext()), null); flutterView.runFromBundle(FlutterMain.findAppBundlePath(getApplicationContext()), null);
messageChannel = messageChannel =
new FlutterMessageChannel<String>(flutterView, CHANNEL, StringMessageCodec.INSTANCE); new FlutterMessageChannel<String>(flutterView, CHANNEL, StringCodec.INSTANCE);
messageChannel. messageChannel.
setMessageHandler(new MessageHandler<String>() { setMessageHandler(new MessageHandler<String>() {
@Override @Override
......
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