Move flutter_gallery to the testing folder (#52532)

Move Flutter Gallery to dev/integration_tests/ as it is an older copy used only for testing. The current version of the Flutter Gallery now lives in https://github.com/flutter/gallery.
This commit is contained in:
Michael Thomsen
2020-03-16 02:31:42 -07:00
committed by GitHub
parent 1606d87834
commit e167181444
250 changed files with 85 additions and 103 deletions

View File

@@ -0,0 +1,36 @@
// 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.
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
import 'package:flutter_test/flutter_test.dart';
Future<void> endOfAnimation() async {
do {
await SchedulerBinding.instance.endOfFrame;
} while (SchedulerBinding.instance.hasScheduledFrame);
}
int iteration = 0;
class LifecycleObserver extends WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
debugPrint('==== MEMORY BENCHMARK ==== $state ====');
debugPrint('This was lifecycle event number $iteration in this instance');
}
}
Future<void> main() async {
runApp(const GalleryApp());
await endOfAnimation();
await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
WidgetsBinding.instance.addObserver(LifecycleObserver());
}

View File

@@ -0,0 +1,63 @@
// 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.
// See //dev/devicelab/bin/tasks/flutter_gallery__image_cache_memory.dart
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
// Once we provide an option for images to be resized to
// fit the container, we should see a significant drop in
// the amount of memory consumed by this benchmark.
Future<void> main() async {
const int numItems = 10;
runApp(Directionality(
textDirection: TextDirection.ltr,
child: ListView.builder(
key: const Key('ImageList'),
itemCount: numItems,
itemBuilder: (BuildContext context, int position) {
return Container(
width: 200,
height: 200,
child: Center(
child: Image.asset(
'monochrome/red-square-1024x1024.png',
package: 'flutter_gallery_assets',
width: 100,
height: 100,
fit: BoxFit.contain,
key: Key('image_$position'),
),
),
);
},
),
));
await SchedulerBinding.instance.endOfFrame;
// We are waiting for the GPU to rasterize a frame here. This makes this flaky,
// we can rely on a more deterministic such as `Window.onReportTimings` once
// https://github.com/flutter/flutter/issues/26154 is addressed.
await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
final WidgetController controller =
LiveWidgetController(WidgetsBinding.instance);
debugPrint('Scrolling...');
final Finder list = find.byKey(const Key('ImageList'));
final Finder lastItem = find.byKey(const Key('image_${numItems - 1}'));
do {
await controller.drag(list, const Offset(0.0, -30.0));
await Future<void>.delayed(const Duration(milliseconds: 20));
} while (!lastItem.precache());
debugPrint('==== MEMORY BENCHMARK ==== DONE ====');
}

View File

@@ -0,0 +1,86 @@
// 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.
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
import 'package:flutter_test/flutter_test.dart';
Future<void> endOfAnimation() async {
do {
await SchedulerBinding.instance.endOfFrame;
} while (SchedulerBinding.instance.hasScheduledFrame);
}
Rect boundsFor(WidgetController controller, Finder item) {
final RenderBox box = controller.renderObject<RenderBox>(item);
return box.localToGlobal(Offset.zero) & box.size;
}
Future<void> main() async {
final Completer<void> ready = Completer<void>();
runApp(GestureDetector(
onTap: () {
debugPrint('Received tap.');
ready.complete();
},
behavior: HitTestBehavior.opaque,
child: const IgnorePointer(
ignoring: true,
child: GalleryApp(testMode: true),
),
));
await SchedulerBinding.instance.endOfFrame;
await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
await ready.future;
debugPrint('Continuing...');
// remove onTap handler, enable pointer events for app
runApp(GestureDetector(
child: const IgnorePointer(
ignoring: false,
child: GalleryApp(testMode: true),
),
));
await SchedulerBinding.instance.endOfFrame;
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance);
debugPrint('Navigating...');
await controller.tap(find.text('Material'));
await Future<void>.delayed(const Duration(milliseconds: 150));
final Finder demoList = find.byKey(const Key('GalleryDemoList'));
final Finder demoItem = find.text('Text fields');
do {
await controller.drag(demoList, const Offset(0.0, -300.0));
await Future<void>.delayed(const Duration(milliseconds: 20));
} while (!demoItem.precache());
// Ensure that the center of the "Text fields" item is visible
// because that's where we're going to tap
final Rect demoItemBounds = boundsFor(controller, demoItem);
final Rect demoListBounds = boundsFor(controller, demoList);
if (!demoListBounds.contains(demoItemBounds.center)) {
await controller.drag(demoList, Offset(0.0, demoListBounds.center.dy - demoItemBounds.center.dy));
await endOfAnimation();
}
for (int iteration = 0; iteration < 15; iteration += 1) {
debugPrint('Tapping... (iteration $iteration)');
await controller.tap(demoItem);
await endOfAnimation();
debugPrint('Backing out...');
await controller.tap(find.byTooltip('Back'));
await endOfAnimation();
await Future<void>.delayed(const Duration(milliseconds: 50));
}
debugPrint('==== MEMORY BENCHMARK ==== DONE ====');
}