Revert "[O] Remove many timeouts. (#23531)" (#25646)

This reverts commit 76f70810e4.
This commit is contained in:
Ian Hickson
2018-12-20 18:46:36 -08:00
committed by GitHub
parent 76f70810e4
commit 8426910a19
59 changed files with 1199 additions and 1831 deletions

View File

@@ -19,22 +19,15 @@ class BasicProject extends Project {
@override
final String main = r'''
import 'dart:async';
import 'package:flutter/material.dart';
Future<void> main() async {
while (true) {
runApp(new MyApp());
await Future.delayed(const Duration(milliseconds: 50));
}
}
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
topLevelFunction();
return new MaterialApp( // BUILD BREAKPOINT
return new MaterialApp( // BREAKPOINT
title: 'Flutter Demo',
home: new Container(),
);
@@ -46,9 +39,9 @@ class BasicProject extends Project {
}
''';
Uri get buildMethodBreakpointUri => mainDart;
int get buildMethodBreakpointLine => lineContaining(main, '// BUILD BREAKPOINT');
Uri get buildMethodBreakpointUri => breakpointUri;
int get buildMethodBreakpointLine => breakpointLine;
Uri get topLevelFunctionBreakpointUri => mainDart;
Uri get topLevelFunctionBreakpointUri => breakpointUri;
int get topLevelFunctionBreakpointLine => lineContaining(main, '// TOP LEVEL BREAKPOINT');
}

View File

@@ -22,63 +22,33 @@ class HotReloadProject extends Project {
@override
final String main = r'''
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(new MyApp());
int count = 1;
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// This method gets called each time we hot reload, during reassemble.
// Do not remove the next line, it's uncommented by a test to verify that
// hot reloading worked:
// Do not remove this line, it's uncommented by a test to verify that hot
// reloading worked.
// printHotReloadWorked();
print('((((TICK $count))))');
// tick 1 = startup warmup frame
// tick 2 = hot reload warmup reassemble frame
// after that there's a post-hot-reload frame scheduled by the tool that
// doesn't trigger this to rebuild, but does trigger the first callback
// below, then that callback schedules another frame on which we do the
// breakpoint.
// tick 3 = second hot reload warmup reassemble frame (pre breakpoint)
if (count == 2) {
SchedulerBinding.instance.scheduleFrameCallback((Duration timestamp) {
SchedulerBinding.instance.scheduleFrameCallback((Duration timestamp) {
print('breakpoint line'); // SCHEDULED BREAKPOINT
});
});
}
count += 1;
return MaterialApp( // BUILD BREAKPOINT
return new MaterialApp( // BREAKPOINT
title: 'Flutter Demo',
home: Container(),
home: new Container(),
);
}
}
void printHotReloadWorked() {
printHotReloadWorked() {
// The call to this function is uncommented by a test to verify that hot
// reloading worked.
print('(((((RELOAD WORKED)))))');
}
''';
Uri get scheduledBreakpointUri => mainDart;
int get scheduledBreakpointLine => lineContaining(main, '// SCHEDULED BREAKPOINT');
Uri get buildBreakpointUri => mainDart;
int get buildBreakpointLine => lineContaining(main, '// BUILD BREAKPOINT');
void uncommentHotReloadPrint() {
final String newMainContents = main.replaceAll(
'// printHotReloadWorked();',
'printHotReloadWorked();'
);
'// printHotReloadWorked();', 'printHotReloadWorked();');
writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
}
}

View File

@@ -15,7 +15,9 @@ abstract class Project {
String get pubspec;
String get main;
Uri get mainDart => Uri.parse('package:test/main.dart');
// Valid locations for a breakpoint for tests that just need to break somewhere.
Uri get breakpointUri => Uri.parse('package:test/main.dart');
int get breakpointLine => lineContaining(main, '// BREAKPOINT');
Future<void> setUpIn(Directory dir) async {
this.dir = dir;
@@ -30,6 +32,6 @@ abstract class Project {
final int index = contents.split('\n').indexWhere((String l) => l.contains(search));
if (index == -1)
throw Exception("Did not find '$search' inside the file");
return index + 1; // first line is line 1, not line 0
return index;
}
}

View File

@@ -35,11 +35,11 @@ class SteppingProject extends Project {
Future<void> doAsyncStuff() async {
print("test"); // BREAKPOINT
await new Future.value(true); // STEP 1 // STEP 2
await new Future.microtask(() => true); // STEP 3 // STEP 4
await new Future.delayed(const Duration(milliseconds: 1)); // STEP 5 // STEP 6
print("done!"); // STEP 7
} // STEP 8
await new Future.value(true); // STEP 1
await new Future.microtask(() => true); // STEP 2 // STEP 3
await new Future.delayed(const Duration(milliseconds: 1)); // STEP 4 // STEP 5
print("done!"); // STEP 6
}
@override
Widget build(BuildContext context) {
@@ -51,9 +51,7 @@ class SteppingProject extends Project {
}
''';
Uri get breakpointUri => mainDart;
int get breakpointLine => lineContaining(main, '// BREAKPOINT');
int lineForStep(int i) => lineContaining(main, '// STEP $i');
final int numberOfSteps = 8;
final int numberOfSteps = 6;
}