diff --git a/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart b/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart new file mode 100644 index 0000000000..90217afb34 --- /dev/null +++ b/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart @@ -0,0 +1,12 @@ +// Copyright 2016 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/framework.dart'; + +Future main() async { + await task(createGalleryNavigationMemoryTest()); +} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 31d74c844c..77788604b6 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -52,6 +52,14 @@ TaskFunction createHelloWorldMemoryTest() { ); } +TaskFunction createGalleryNavigationMemoryTest() { + return new MemoryTest( + '${flutterDirectory.path}/examples/flutter_gallery', + 'io.flutter.examples.gallery', + testTarget: 'test_driver/memory_nav.dart', + ); +} + /// Measure application startup performance. class StartupTest { static const Duration _startupTimeout = const Duration(minutes: 2); diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index a6d7549e5d..568c92924c 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml @@ -121,6 +121,12 @@ tasks: stage: devicelab required_agent_capabilities: ["has-android-device"] + flutter_gallery__memory_nav: + description: > + Measures memory usage after repeated navigation in Gallery. + stage: devicelab + required_agent_capabilities: ["has-android-device"] + # iOS on-device tests diff --git a/examples/flutter_gallery/test_driver/memory_nav.dart b/examples/flutter_gallery/test_driver/memory_nav.dart new file mode 100644 index 0000000000..c0010d05b2 --- /dev/null +++ b/examples/flutter_gallery/test_driver/memory_nav.dart @@ -0,0 +1,11 @@ +// Copyright 2016 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 'package:flutter_driver/driver_extension.dart'; +import 'package:flutter_gallery/main.dart' as app; + +void main() { + enableFlutterDriverExtension(); + app.main(); +} diff --git a/examples/flutter_gallery/test_driver/memory_nav_test.dart b/examples/flutter_gallery/test_driver/memory_nav_test.dart new file mode 100644 index 0000000000..71f35446f9 --- /dev/null +++ b/examples/flutter_gallery/test_driver/memory_nav_test.dart @@ -0,0 +1,31 @@ +import 'dart:async'; + +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; + +void main() { + group('flutter gallery transitions', () { + FlutterDriver driver; + setUpAll(() async { + driver = await FlutterDriver.connect(); + }); + + tearDownAll(() async { + if (driver != null) + await driver.close(); + }); + + test('navigation', () async { + SerializableFinder menuItem = find.text('Text fields'); + await driver.scrollIntoView(menuItem); + await new Future.delayed(new Duration(milliseconds: 500)); + + for (int i = 0; i < 15; i++) { + await driver.tap(menuItem); + await new Future.delayed(new Duration(milliseconds: 1000)); + await driver.tap(find.byTooltip('Back')); + await new Future.delayed(new Duration(milliseconds: 1000)); + } + }, timeout: new Timeout(new Duration(minutes: 1))); + }); +}