blob: c8f2e1163e2a8d7c38ccd96ebc1adb05b6ea72e8 [file] [log] [blame]
Ian Hickson872e88c2018-08-06 12:46:51 -07001// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
6
7import 'dart:async';
8
9import 'package:flutter/material.dart';
10import 'package:flutter/scheduler.dart';
11import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
12import 'package:flutter_test/flutter_test.dart';
13
14Future<void> endOfAnimation() async {
15 do {
16 await SchedulerBinding.instance.endOfFrame;
17 } while (SchedulerBinding.instance.hasScheduledFrame);
18}
19
20int iteration = 0;
21
22class LifecycleObserver extends WidgetsBindingObserver {
23 @override
24 void didChangeAppLifecycleState(AppLifecycleState state) {
25 debugPrint('==== MEMORY BENCHMARK ==== $state ====');
26 debugPrint('This was lifecycle event number $iteration in this instance');
27 }
28}
29
30Future<void> main() async {
Ian Hickson872e88c2018-08-06 12:46:51 -070031 runApp(const GalleryApp());
32 await endOfAnimation();
Alexandre Ardhuind927c932018-09-12 08:29:29 +020033 await Future<Null>.delayed(const Duration(milliseconds: 50));
Ian Hickson872e88c2018-08-06 12:46:51 -070034 debugPrint('==== MEMORY BENCHMARK ==== READY ====');
Alexandre Ardhuind927c932018-09-12 08:29:29 +020035 WidgetsBinding.instance.addObserver(LifecycleObserver());
Ian Hickson872e88c2018-08-06 12:46:51 -070036}