Unnecessary new (#20138)

* enable lint unnecessary_new

* fix tests

* fix tests

* fix tests
This commit is contained in:
Alexandre Ardhuin
2018-09-12 08:29:29 +02:00
committed by GitHub
parent d7a0dcaa4a
commit d927c93310
1285 changed files with 26519 additions and 26519 deletions

View File

@@ -23,7 +23,7 @@ const MethodChannel kSemanticsChannel = MethodChannel('semantics');
Future<String> dataHandler(String message) async {
if (message.contains('getSemanticsNode')) {
final Completer<String> completer = new Completer<String>();
final Completer<String> completer = Completer<String>();
final int id = int.tryParse(message.split('#')[1]) ?? 0;
Future<void> completeSemantics([Object _]) async {
final dynamic result = await kSemanticsChannel.invokeMethod('getSemanticsNode', <String, dynamic>{
@@ -37,7 +37,7 @@ Future<String> dataHandler(String message) async {
completeSemantics();
return completer.future;
}
throw new UnimplementedError();
throw UnimplementedError();
}
const List<String> routes = <String>[
@@ -50,18 +50,18 @@ class TestApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
routes: <String, WidgetBuilder>{
selectionControlsRoute: (BuildContext context) => new SelectionControlsPage(),
textFieldRoute: (BuildContext context) => new TextFieldPage(),
selectionControlsRoute: (BuildContext context) => SelectionControlsPage(),
textFieldRoute: (BuildContext context) => TextFieldPage(),
},
home: new Builder(
home: Builder(
builder: (BuildContext context) {
return new Scaffold(
body: new ListView(
return Scaffold(
body: ListView(
children: routes.map((String value) {
return new MaterialButton(
child: new Text(value),
return MaterialButton(
child: Text(value),
onPressed: () {
Navigator.of(context).pushNamed(value);
},

View File

@@ -51,7 +51,7 @@ class AndroidSemanticsNode {
/// ]
/// }
factory AndroidSemanticsNode.deserialize(String value) {
return new AndroidSemanticsNode._(json.decode(value));
return AndroidSemanticsNode._(json.decode(value));
}
final Map<String, Object> _values;
@@ -129,7 +129,7 @@ class AndroidSemanticsNode {
Rect getRect() {
final Map<String, Object> rawRect = _values['rect'];
final Map<String, int> rect = rawRect.cast<String, int>();
return new Rect.fromLTRB(
return Rect.fromLTRB(
rect['left'].toDouble(),
rect['top'].toDouble(),
rect['right'].toDouble(),
@@ -140,7 +140,7 @@ class AndroidSemanticsNode {
/// Gets a [Size] which defines the size of the semantics node.
Size getSize() {
final Rect rect = getRect();
return new Size(rect.bottom - rect.top, rect.right - rect.left);
return Size(rect.bottom - rect.top, rect.right - rect.left);
}
/// Gets a list of [AndroidSemanticsActions] which are defined for the node.

View File

@@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher;
export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
/// A matcher that compares the type of the actual value to the type argument T.
Matcher isInstanceOf<T>() => new test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544

View File

@@ -31,7 +31,7 @@ Matcher hasAndroidSemantics({
bool isPassword,
bool isLongClickable,
}) {
return new _AndroidSemanticsMatcher(
return _AndroidSemanticsMatcher(
text: text,
contentDescription: contentDescription,
className: className,

View File

@@ -11,7 +11,7 @@ export 'controls_constants.dart';
/// A test page with a checkbox, three radio buttons, and a switch.
class SelectionControlsPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _SelectionControlsPageState();
State<StatefulWidget> createState() => _SelectionControlsPageState();
}
class _SelectionControlsPageState extends State<SelectionControlsPage> {
@@ -53,13 +53,13 @@ class _SelectionControlsPageState extends State<SelectionControlsPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: new Material(
child: new Column(children: <Widget>[
new Row(
return Scaffold(
appBar: AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: Material(
child: Column(children: <Widget>[
Row(
children: <Widget>[
new Checkbox(
Checkbox(
key: checkbox1Key,
value: _isChecked,
onChanged: _updateCheckbox,
@@ -72,23 +72,23 @@ class _SelectionControlsPageState extends State<SelectionControlsPage> {
],
),
const Spacer(),
new Row(children: <Widget>[
new Radio<int>(key: radio1Key, value: 0, groupValue: _radio, onChanged: _updateRadio),
new Radio<int>(key: radio2Key, value: 1, groupValue: _radio, onChanged: _updateRadio),
new Radio<int>(key: radio3Key, value: 2, groupValue: _radio, onChanged: _updateRadio),
Row(children: <Widget>[
Radio<int>(key: radio1Key, value: 0, groupValue: _radio, onChanged: _updateRadio),
Radio<int>(key: radio2Key, value: 1, groupValue: _radio, onChanged: _updateRadio),
Radio<int>(key: radio3Key, value: 2, groupValue: _radio, onChanged: _updateRadio),
]),
const Spacer(),
new Switch(
Switch(
key: switchKey,
value: _isOn,
onChanged: _updateSwitch,
),
const Spacer(),
new MergeSemantics(
child: new Row(
MergeSemantics(
child: Row(
children: <Widget>[
const Text(switchLabel),
new Switch(
Switch(
key: labeledSwitchKey,
value: _isLabeledOn,
onChanged: _updateLabeledSwitch,

View File

@@ -11,28 +11,28 @@ export 'text_field_constants.dart';
/// A page with a normal text field and a password field.
class TextFieldPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _TextFieldPageState();
State<StatefulWidget> createState() => _TextFieldPageState();
}
class _TextFieldPageState extends State<TextFieldPage> {
final TextEditingController _normalController = new TextEditingController();
final TextEditingController _passwordController = new TextEditingController();
final TextEditingController _normalController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final Key normalTextFieldKey = const ValueKey<String>(normalTextFieldKeyValue);
final Key passwordTextFieldKey = const ValueKey<String>(passwordTextFieldKeyValue);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: new Material(
child: new Column(children: <Widget>[
new TextField(
return Scaffold(
appBar: AppBar(leading: const BackButton(key: ValueKey<String>('back'))),
body: Material(
child: Column(children: <Widget>[
TextField(
key: normalTextFieldKey,
controller: _normalController,
autofocus: false,
),
const Spacer(),
new TextField(
TextField(
key: passwordTextFieldKey,
controller: _passwordController,
obscureText: true,

View File

@@ -17,7 +17,7 @@ void main() {
Future<AndroidSemanticsNode> getSemantics(SerializableFinder finder) async {
final int id = await driver.getSemanticsId(finder);
final String data = await driver.requestData('getSemanticsNode#$id');
return new AndroidSemanticsNode.deserialize(data);
return AndroidSemanticsNode.deserialize(data);
}
setUpAll(() async {

View File

@@ -23,7 +23,7 @@ const String kEventsFileName = 'touchEvents';
/// set by the app in which case the requestData call will only complete once the app is ready
/// for it.
class FutureDataHandler {
final Completer<DataHandler> handlerCompleter = new Completer<DataHandler>();
final Completer<DataHandler> handlerCompleter = Completer<DataHandler>();
Future<String> handleMessage(String message) async {
final DataHandler handler = await handlerCompleter.future;
@@ -31,20 +31,20 @@ class FutureDataHandler {
}
}
FutureDataHandler driverDataHandler = new FutureDataHandler();
FutureDataHandler driverDataHandler = FutureDataHandler();
void main() {
enableFlutterDriverExtension(handler: driverDataHandler.handleMessage);
runApp(new MyApp());
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Android Views Integration Test',
home: new Scaffold(
body: new PlatformViewPage(),
home: Scaffold(
body: PlatformViewPage(),
),
);
}
@@ -52,7 +52,7 @@ class MyApp extends StatelessWidget {
class PlatformViewPage extends StatefulWidget {
@override
State createState() => new PlatformViewState();
State createState() => PlatformViewState();
}
class PlatformViewState extends State<PlatformViewPage> {
@@ -68,27 +68,27 @@ class PlatformViewState extends State<PlatformViewPage> {
@override
Widget build(BuildContext context) {
return new Column(
return Column(
children: <Widget>[
new SizedBox(
SizedBox(
height: 300.0,
child: new AndroidView(
child: AndroidView(
viewType: 'simple_view',
onPlatformViewCreated: onPlatformViewCreated),
),
new Expanded(
child: new ListView.builder(
Expanded(
child: ListView.builder(
itemBuilder: buildEventTile,
itemCount: flutterViewEvents.length,
),
),
new Row(
Row(
children: <Widget>[
new RaisedButton(
RaisedButton(
child: const Text('RECORD'),
onPressed: listenToFlutterViewEvents,
),
new RaisedButton(
RaisedButton(
child: const Text('CLEAR'),
onPressed: () {
setState(() {
@@ -97,7 +97,7 @@ class PlatformViewState extends State<PlatformViewPage> {
});
},
),
new RaisedButton(
RaisedButton(
child: const Text('SAVE'),
onPressed: () {
const StandardMessageCodec codec = StandardMessageCodec();
@@ -105,7 +105,7 @@ class PlatformViewState extends State<PlatformViewPage> {
codec.encodeMessage(flutterViewEvents), context);
},
),
new RaisedButton(
RaisedButton(
key: const ValueKey<String>('play'),
child: const Text('PLAY FILE'),
onPressed: () { playEventsFile(); },
@@ -138,7 +138,7 @@ class PlatformViewState extends State<PlatformViewPage> {
if (flutterViewEvents.length != embeddedViewEvents.length)
return 'Synthesized ${flutterViewEvents.length} events but the embedded view received ${embeddedViewEvents.length} events';
final StringBuffer diff = new StringBuffer();
final StringBuffer diff = StringBuffer();
for (int i = 0; i < flutterViewEvents.length; ++i) {
final String currentDiff = diffMotionEvents(flutterViewEvents[i], embeddedViewEvents[i]);
if (currentDiff.isEmpty)
@@ -168,7 +168,7 @@ class PlatformViewState extends State<PlatformViewPage> {
try {
final Directory outDir = await getExternalStorageDirectory();
// This test only runs on Android so we can assume path separator is '/'.
final File file = new File('${outDir.path}/$kEventsFileName');
final File file = File('${outDir.path}/$kEventsFileName');
await file.writeAsBytes(data.buffer.asUint8List(0, data.lengthInBytes), flush: true);
showMessage(context, 'Saved original events to ${file.path}');
} catch (e) {
@@ -177,14 +177,14 @@ class PlatformViewState extends State<PlatformViewPage> {
}
void showMessage(BuildContext context, String message) {
Scaffold.of(context).showSnackBar(new SnackBar(
content: new Text(message),
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(message),
duration: const Duration(seconds: 3),
));
}
void onPlatformViewCreated(int id) {
viewChannel = new MethodChannel('simple_view/$id');
viewChannel = MethodChannel('simple_view/$id');
viewChannel.setMethodCallHandler(onViewMethodChannelCall);
driverDataHandler.handlerCompleter.complete(handleDriverMessage);
}
@@ -192,7 +192,7 @@ class PlatformViewState extends State<PlatformViewPage> {
void listenToFlutterViewEvents() {
channel.invokeMethod('pipeFlutterViewEvents');
viewChannel.invokeMethod('pipeTouchEvents');
new Timer(const Duration(seconds: 3), () {
Timer(const Duration(seconds: 3), () {
channel.invokeMethod('stopFlutterViewEvents');
viewChannel.invokeMethod('stopTouchEvents');
});
@@ -216,7 +216,7 @@ class PlatformViewState extends State<PlatformViewPage> {
setState(() {});
break;
}
return new Future<dynamic>.sync(null);
return Future<dynamic>.sync(null);
}
Future<dynamic> onViewMethodChannelCall(MethodCall call) {
@@ -229,14 +229,14 @@ class PlatformViewState extends State<PlatformViewPage> {
setState(() {});
break;
}
return new Future<dynamic>.sync(null);
return Future<dynamic>.sync(null);
}
Widget buildEventTile(BuildContext context, int index) {
if (embeddedViewEvents.length > index)
return new TouchEventDiff(
return TouchEventDiff(
flutterViewEvents[index], embeddedViewEvents[index]);
return new Text(
return Text(
'Unmatched event, action: ${flutterViewEvents[index]['action']}');
}
}
@@ -262,23 +262,23 @@ class TouchEventDiff extends StatelessWidget {
color = Colors.red;
msg = '[$actionName] $diff';
}
return new GestureDetector(
return GestureDetector(
onLongPress: () {
print('expected:');
prettyPrintEvent(originalEvent);
print('\nactual:');
prettyPrintEvent(synthesizedEvent);
},
child: new Container(
child: Container(
color: color,
margin: const EdgeInsets.only(bottom: 2.0),
child: new Text(msg),
child: Text(msg),
),
);
}
void prettyPrintEvent(Map<String, dynamic> event) {
final StringBuffer buffer = new StringBuffer();
final StringBuffer buffer = StringBuffer();
final int action = event['action'];
final int maskedAction = getActionMasked(action);
final String actionName = getActionName(maskedAction, action);

View File

@@ -19,7 +19,7 @@ String diffMotionEvents(
Map<String, dynamic> originalEvent,
Map<String, dynamic> synthesizedEvent,
) {
final StringBuffer diff = new StringBuffer();
final StringBuffer diff = StringBuffer();
diffMaps(originalEvent, synthesizedEvent, diff, excludeKeys: const <String>[
'pointerProperties', // Compared separately.

View File

@@ -12,7 +12,7 @@ Future<void> main() async {
setUpAll(() async {
print('Cloning goldens repository...');
final GoldensClient goldensClient = new GoldensClient();
final GoldensClient goldensClient = GoldensClient();
await goldensClient.prepare();
});

View File

@@ -15,16 +15,16 @@ import 'src/test_step.dart';
void main() {
enableFlutterDriverExtension();
runApp(new TestApp());
runApp(TestApp());
}
class TestApp extends StatefulWidget {
@override
_TestAppState createState() => new _TestAppState();
_TestAppState createState() => _TestAppState();
}
class _TestAppState extends State<TestApp> {
static final dynamic anUnknownValue = new DateTime.fromMillisecondsSinceEpoch(1520777802314);
static final dynamic anUnknownValue = DateTime.fromMillisecondsSinceEpoch(1520777802314);
static final List<dynamic> aList = <dynamic>[
false,
0,
@@ -43,24 +43,24 @@ class _TestAppState extends State<TestApp> {
<String, dynamic>{'key': 42}
],
};
static final Uint8List someUint8s = new Uint8List.fromList(<int>[
static final Uint8List someUint8s = Uint8List.fromList(<int>[
0xBA,
0x5E,
0xBA,
0x11,
]);
static final Int32List someInt32s = new Int32List.fromList(<int>[
static final Int32List someInt32s = Int32List.fromList(<int>[
-0x7fffffff - 1,
0,
0x7fffffff,
]);
static final Int64List someInt64s = new Int64List.fromList(<int>[
static final Int64List someInt64s = Int64List.fromList(<int>[
-0x7fffffffffffffff - 1,
0,
0x7fffffffffffffff,
]);
static final Float64List someFloat64s =
new Float64List.fromList(<double>[
Float64List.fromList(<double>[
double.nan,
double.negativeInfinity,
-double.maxFinite,
@@ -73,7 +73,7 @@ class _TestAppState extends State<TestApp> {
]);
static final dynamic aCompoundUnknownValue = <dynamic>[
anUnknownValue,
new Pair(anUnknownValue, aList),
Pair(anUnknownValue, aList),
];
static final List<TestStep> steps = <TestStep>[
() => methodCallJsonSuccessHandshake(null),
@@ -97,8 +97,8 @@ class _TestAppState extends State<TestApp> {
() => methodCallStandardErrorHandshake('world'),
() => methodCallStandardNotImplementedHandshake(),
() => basicBinaryHandshake(null),
() => basicBinaryHandshake(new ByteData(0)),
() => basicBinaryHandshake(new ByteData(4)..setUint32(0, 0x12345678)),
() => basicBinaryHandshake(ByteData(0)),
() => basicBinaryHandshake(ByteData(4)..setUint32(0, 0x12345678)),
() => basicStringHandshake('hello, world'),
() => basicStringHandshake('hello \u263A \u{1f602} unicode'),
() => basicStringHandshake(''),
@@ -166,7 +166,7 @@ class _TestAppState extends State<TestApp> {
if (_step < steps.length)
_result = steps[_step++]();
else
_result = new Future<TestStepResult>.value(TestStepResult.complete);
_result = Future<TestStepResult>.value(TestStepResult.complete);
});
}
@@ -174,25 +174,25 @@ class _TestAppState extends State<TestApp> {
BuildContext context,
AsyncSnapshot<TestStepResult> snapshot,
) {
return new TestStepResult.fromSnapshot(snapshot).asWidget(context);
return TestStepResult.fromSnapshot(snapshot).asWidget(context);
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Channels Test',
home: new Scaffold(
appBar: new AppBar(
home: Scaffold(
appBar: AppBar(
title: const Text('Channels Test'),
),
body: new Padding(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: new FutureBuilder<TestStepResult>(
child: FutureBuilder<TestStepResult>(
future: _result,
builder: _buildTestResultWidget,
),
),
floatingActionButton: new FloatingActionButton(
floatingActionButton: FloatingActionButton(
key: const ValueKey<String>('step'),
onPressed: _executeNextStep,
child: const Icon(Icons.navigate_next),

View File

@@ -33,9 +33,9 @@ class ExtendedStandardMessageCodec extends StandardMessageCodec {
dynamic readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case _dateTime:
return new DateTime.fromMillisecondsSinceEpoch(buffer.getInt64());
return DateTime.fromMillisecondsSinceEpoch(buffer.getInt64());
case _pair:
return new Pair(readValue(buffer), readValue(buffer));
return Pair(readValue(buffer), readValue(buffer));
default: return super.readValueOfType(type, buffer);
}
}

View File

@@ -89,7 +89,7 @@ Future<TestStepResult> _methodCallErrorHandshake(
final List<dynamic> received = <dynamic>[];
channel.setMethodCallHandler((MethodCall call) async {
received.add(call.arguments);
throw new PlatformException(
throw PlatformException(
code: 'error', message: null, details: arguments);
});
dynamic errorDetails = nothing;
@@ -118,7 +118,7 @@ Future<TestStepResult> _methodCallNotImplementedHandshake(
final List<dynamic> received = <dynamic>[];
channel.setMethodCallHandler((MethodCall call) async {
received.add(call.arguments);
throw new MissingPluginException();
throw MissingPluginException();
});
dynamic result = nothing;
dynamic error = nothing;

View File

@@ -72,21 +72,21 @@ class TestStepResult {
final dynamic error;
Widget asWidget(BuildContext context) {
return new Column(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text('Step: $name', style: bold),
new Text(description),
Text('Step: $name', style: bold),
Text(description),
const Text(' '),
new Text('Msg sent: ${_toString(messageSent)}'),
new Text('Msg rvcd: ${_toString(messageReceived)}'),
new Text('Reply echo: ${_toString(replyEcho)}'),
new Text('Msg echo: ${_toString(messageEcho)}'),
new Text('Error: ${_toString(error)}'),
Text('Msg sent: ${_toString(messageSent)}'),
Text('Msg rvcd: ${_toString(messageReceived)}'),
Text('Reply echo: ${_toString(replyEcho)}'),
Text('Msg echo: ${_toString(messageEcho)}'),
Text('Error: ${_toString(error)}'),
const Text(' '),
new Text(
Text(
status.toString().substring('TestStatus.'.length),
key: new ValueKey<String>(
key: ValueKey<String>(
status == TestStatus.pending ? 'nostatus' : 'status'),
style: bold,
),
@@ -117,7 +117,7 @@ Future<TestStepResult> resultOfHandshake(
} else {
status = TestStatus.ok;
}
return new TestStepResult(
return TestStepResult(
name,
description,
status,

View File

@@ -11,12 +11,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
debugPrint('Application starting...');
runApp(new MyApp());
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
State createState() => new MyAppState();
State createState() => MyAppState();
}
const MethodChannel channel = MethodChannel('texture');
@@ -92,7 +92,7 @@ Widget builds: $_widgetBuilds''';
/// Measures Flutter's frame rate.
Future<Null> _calibrate() async {
debugPrint('Awaiting calm (3 second pause)...');
await new Future<Null>.delayed(const Duration(milliseconds: 3000));
await Future<Null>.delayed(const Duration(milliseconds: 3000));
debugPrint('Calibrating...');
DateTime startTime;
int tickCount = 0;
@@ -100,7 +100,7 @@ Widget builds: $_widgetBuilds''';
ticker = createTicker((Duration time) {
tickCount += 1;
if (tickCount == calibrationTickCount) { // about 10 seconds
final Duration elapsed = new DateTime.now().difference(startTime);
final Duration elapsed = DateTime.now().difference(startTime);
ticker.stop();
ticker.dispose();
setState(() {
@@ -118,7 +118,7 @@ Press play to produce texture frames.''';
}
});
ticker.start();
startTime = new DateTime.now();
startTime = DateTime.now();
setState(() {
_summary = 'Calibrating...';
_icon = null;
@@ -128,23 +128,23 @@ Press play to produce texture frames.''';
@override
Widget build(BuildContext context) {
_widgetBuilds += 1;
return new MaterialApp(
home: new Scaffold(
body: new Center(
child: new Column(
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
Container(
width: 300.0,
height: 200.0,
child: const Texture(textureId: 0),
),
new Container(
Container(
width: 300.0,
height: 60.0,
color: Colors.grey,
child: new Center(
child: new Text(
child: Center(
child: Text(
_summary,
key: const ValueKey<String>('summary'),
),
@@ -153,9 +153,9 @@ Press play to produce texture frames.''';
],
),
),
floatingActionButton: _icon == null ? null : new FloatingActionButton(
floatingActionButton: _icon == null ? null : FloatingActionButton(
key: const ValueKey<String>('fab'),
child: new Icon(_icon),
child: Icon(_icon),
onPressed: _nextState,
),
),

View File

@@ -7,8 +7,8 @@ import 'dart:async';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
final RegExp calibrationRegExp = new RegExp('Flutter frame rate is (.*)fps');
final RegExp statsRegExp = new RegExp('Produced: (.*)fps\nConsumed: (.*)fps\nWidget builds: (.*)');
final RegExp calibrationRegExp = RegExp('Flutter frame rate is (.*)fps');
final RegExp statsRegExp = RegExp('Produced: (.*)fps\nConsumed: (.*)fps\nWidget builds: (.*)');
const Duration samplingTime = Duration(seconds: 8);
Future<Null> main() async {
@@ -38,7 +38,7 @@ Future<Null> main() async {
// Texture frame stats at 0.5x Flutter frame rate
await driver.tap(fab);
await new Future<Null>.delayed(samplingTime);
await Future<Null>.delayed(samplingTime);
await driver.tap(fab);
final String statsSlow = await driver.getText(summary);
@@ -50,7 +50,7 @@ Future<Null> main() async {
// Texture frame stats at 2.0x Flutter frame rate
await driver.tap(fab);
await new Future<Null>.delayed(samplingTime);
await Future<Null>.delayed(samplingTime);
await driver.tap(fab);
final String statsFast = await driver.getText(summary);

View File

@@ -4,12 +4,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(new Center(child: new Flavor()));
runApp(Center(child: Flavor()));
}
class Flavor extends StatefulWidget {
@override
_FlavorState createState() => new _FlavorState();
_FlavorState createState() => _FlavorState();
}
class _FlavorState extends State<Flavor> {
@@ -27,11 +27,11 @@ class _FlavorState extends State<Flavor> {
@override
Widget build(BuildContext context) {
return new Directionality(
return Directionality(
textDirection: TextDirection.ltr,
child: _flavor == null
? const Text('Awaiting flavor...')
: new Text(_flavor, key: const ValueKey<String>('flavor')),
: Text(_flavor, key: const ValueKey<String>('flavor')),
);
}
}

View File

@@ -12,12 +12,12 @@ import 'src/test_step.dart';
void main() {
enableFlutterDriverExtension();
runApp(new TestApp());
runApp(TestApp());
}
class TestApp extends StatefulWidget {
@override
_TestAppState createState() => new _TestAppState();
_TestAppState createState() => _TestAppState();
}
class _TestAppState extends State<TestApp> {
@@ -37,7 +37,7 @@ class _TestAppState extends State<TestApp> {
if (_step < steps.length)
_result = steps[_step++]();
else
_result = new Future<TestStepResult>.value(TestStepResult.complete);
_result = Future<TestStepResult>.value(TestStepResult.complete);
});
}
@@ -45,25 +45,25 @@ class _TestAppState extends State<TestApp> {
BuildContext context,
AsyncSnapshot<TestStepResult> snapshot,
) {
return new TestStepResult.fromSnapshot(snapshot).asWidget(context);
return TestStepResult.fromSnapshot(snapshot).asWidget(context);
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Platform Interaction Test',
home: new Scaffold(
appBar: new AppBar(
home: Scaffold(
appBar: AppBar(
title: const Text('Platform Interaction Test'),
),
body: new Padding(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: new FutureBuilder<TestStepResult>(
child: FutureBuilder<TestStepResult>(
future: _result,
builder: _buildTestResultWidget,
),
),
floatingActionButton: new FloatingActionButton(
floatingActionButton: FloatingActionButton(
key: const ValueKey<String>('step'),
onPressed: _executeNextStep,
child: const Icon(Icons.navigate_next),

View File

@@ -12,7 +12,7 @@ Future<TestStepResult> systemNavigatorPop() {
StringCodec(),
);
final Completer<TestStepResult> completer = new Completer<TestStepResult>();
final Completer<TestStepResult> completer = Completer<TestStepResult>();
channel.setMessageHandler((String message) async {
completer.complete(

View File

@@ -46,15 +46,15 @@ class TestStepResult {
final TestStatus status;
Widget asWidget(BuildContext context) {
return new Column(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text('Step: $name', style: bold),
new Text(description),
Text('Step: $name', style: bold),
Text(description),
const Text(' '),
new Text(
Text(
status.toString().substring('TestStatus.'.length),
key: new ValueKey<String>(
key: ValueKey<String>(
status == TestStatus.pending ? 'nostatus' : 'status'),
style: bold,
),

View File

@@ -15,7 +15,7 @@ void main() {
await WidgetsBinding.instance.reassembleApplication();
return log;
});
runApp(new MaterialApp(home: const Test()));
runApp(MaterialApp(home: const Test()));
}
class Test extends SingleChildRenderObjectWidget {
@@ -23,7 +23,7 @@ class Test extends SingleChildRenderObjectWidget {
@override
RenderTest createRenderObject(BuildContext context) {
return new RenderTest();
return RenderTest();
}
}

View File

@@ -8,13 +8,13 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(new DriverTestApp());
runApp(DriverTestApp());
}
class DriverTestApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new DriverTestAppState();
return DriverTestAppState();
}
}
@@ -24,20 +24,20 @@ class DriverTestAppState extends State<DriverTestApp> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('FlutterDriver test'),
),
body: new ListView(
body: ListView(
padding: const EdgeInsets.all(5.0),
children: <Widget>[
new Row(
Row(
children: <Widget>[
new Expanded(
child: new Text(present ? 'present' : 'absent'),
Expanded(
child: Text(present ? 'present' : 'absent'),
),
new RaisedButton(
RaisedButton(
child: const Text(
'toggle',
key: ValueKey<String>('togglePresent'),
@@ -50,12 +50,12 @@ class DriverTestAppState extends State<DriverTestApp> {
),
],
),
new Row(
Row(
children: <Widget>[
const Expanded(
child: Text('hit testability'),
),
new DropdownButton<Letter>(
DropdownButton<Letter>(
key: const ValueKey<String>('dropdown'),
value: _selectedValue,
onChanged: (Letter newValue) {

View File

@@ -12,49 +12,49 @@ void main() {
// TODO(cbernaschina): remove when test flakiness is resolved
return 'keyboard_resize';
});
runApp(new MyApp());
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Text Editing',
theme: new ThemeData(primarySwatch: Colors.blue),
home: new MyHomePage(),
theme: ThemeData(primarySwatch: Colors.blue),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final TextEditingController _controller = new TextEditingController();
final TextEditingController _controller = TextEditingController();
@override
Widget build(BuildContext context) {
final TextField textField = new TextField(
final TextField textField = TextField(
key: const Key(keys.kDefaultTextField),
controller: _controller,
focusNode: new FocusNode(),
focusNode: FocusNode(),
);
return new Scaffold(
body: new Stack(
return Scaffold(
body: Stack(
fit: StackFit.expand,
alignment: Alignment.bottomCenter,
children: <Widget>[
new LayoutBuilder(
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return new Center(child: new Text('${constraints.biggest.height}', key: const Key(keys.kHeightText)));
return Center(child: Text('${constraints.biggest.height}', key: const Key(keys.kHeightText)));
}
),
textField,
],
),
floatingActionButton: new FloatingActionButton(
floatingActionButton: FloatingActionButton(
key: const Key(keys.kUnfocusButton),
onPressed: () { textField.focusNode.unfocus(); },
tooltip: 'Unfocus',

View File

@@ -10,27 +10,27 @@ import 'keys.dart' as keys;
void main() {
enableFlutterDriverExtension();
runApp(new MyApp());
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Keyboard & TextField',
theme: new ThemeData(primarySwatch: Colors.blue),
home: new MyHomePage(),
theme: ThemeData(primarySwatch: Colors.blue),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final ScrollController _controller = new ScrollController();
final ScrollController _controller = ScrollController();
double offset = 0.0;
@override
@@ -45,18 +45,18 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Column(
return Scaffold(
body: Column(
children: <Widget>[
new Text('$offset',
Text('$offset',
key: const ValueKey<String>(keys.kOffsetText),
),
new Expanded(
child: new ListView(
Expanded(
child: ListView(
key: const ValueKey<String>(keys.kListView),
controller: _controller,
children: <Widget>[
new Container(
Container(
height: MediaQuery.of(context).size.height,
),
const TextField(

View File

@@ -12,12 +12,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(new Toggler());
runApp(Toggler());
}
class Toggler extends StatefulWidget {
@override
State<Toggler> createState() => new TogglerState();
State<Toggler> createState() => TogglerState();
}
class TogglerState extends State<Toggler> {
@@ -25,15 +25,15 @@ class TogglerState extends State<Toggler> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('FlutterDriver test'),
),
body: new Material(
child: new Column(
body: Material(
child: Column(
children: <Widget>[
new FlatButton(
FlatButton(
key: const ValueKey<String>('toggle'),
child: const Text('Toggle visibility'),
onPressed: () {
@@ -42,8 +42,8 @@ class TogglerState extends State<Toggler> {
});
},
),
new Expanded(
child: new ListView(
Expanded(
child: ListView(
children: _buildRows(_visible ? 10 : 0),
),
),
@@ -56,8 +56,8 @@ class TogglerState extends State<Toggler> {
}
List<Widget> _buildRows(int count) {
return new List<Widget>.generate(count, (int i) {
return new Row(
return List<Widget>.generate(count, (int i) {
return Row(
children: _buildCells(i / count),
);
});
@@ -66,12 +66,12 @@ List<Widget> _buildRows(int count) {
/// Builds cells that are known to take time to render causing a delay on the
/// GPU thread.
List<Widget> _buildCells(double epsilon) {
return new List<Widget>.generate(15, (int i) {
return new Expanded(
child: new Material(
return List<Widget>.generate(15, (int i) {
return Expanded(
child: Material(
// A magic color that the test will be looking for on the screenshot.
color: const Color(0xffff0102),
borderRadius: new BorderRadius.all(new Radius.circular(i.toDouble() + epsilon)),
borderRadius: BorderRadius.all(Radius.circular(i.toDouble() + epsilon)),
elevation: 5.0,
child: const SizedBox(height: 10.0, width: 10.0),
),

View File

@@ -36,14 +36,14 @@ void main() {
test('waitForAbsent should resolve when text "present" disappears', () async {
// Begin waiting for it to disappear
final Completer<Null> whenWaitForAbsentResolves = new Completer<Null>();
final Completer<Null> whenWaitForAbsentResolves = Completer<Null>();
driver.waitForAbsent(presentText).then(
whenWaitForAbsentResolves.complete,
onError: whenWaitForAbsentResolves.completeError,
);
// Wait 1 second then make it disappear
await new Future<Null>.delayed(const Duration(seconds: 1));
await Future<Null>.delayed(const Duration(seconds: 1));
await driver.tap(find.byValueKey('togglePresent'));
// Ensure waitForAbsent resolves
@@ -61,14 +61,14 @@ void main() {
test('waitFor should resolve when text "present" reappears', () async {
// Begin waiting for it to reappear
final Completer<Null> whenWaitForResolves = new Completer<Null>();
final Completer<Null> whenWaitForResolves = Completer<Null>();
driver.waitFor(presentText).then(
whenWaitForResolves.complete,
onError: whenWaitForResolves.completeError,
);
// Wait 1 second then make it appear
await new Future<Null>.delayed(const Duration(seconds: 1));
await Future<Null>.delayed(const Duration(seconds: 1));
await driver.tap(find.byValueKey('togglePresent'));
// Ensure waitFor resolves

View File

@@ -33,7 +33,7 @@ void main() {
final SerializableFinder defaultTextField = find.byValueKey(keys.kDefaultTextField);
await driver.waitFor(defaultTextField);
await driver.tap(defaultTextField);
await new Future<Null>.delayed(const Duration(seconds: 1));
await Future<Null>.delayed(const Duration(seconds: 1));
// Measure the height with keyboard displayed.
final String heightWithKeyboardShown = await driver.getText(heightText);
@@ -43,7 +43,7 @@ void main() {
final SerializableFinder unfocusButton = find.byValueKey(keys.kUnfocusButton);
await driver.waitFor(unfocusButton);
await driver.tap(unfocusButton);
await new Future<Null>.delayed(const Duration(seconds: 1));
await Future<Null>.delayed(const Duration(seconds: 1));
// Measure the final height.
final String endHeight = await driver.getText(heightText);

View File

@@ -41,7 +41,7 @@ void main() {
// Bring up keyboard
await driver.tap(textFieldFinder);
await new Future<Null>.delayed(const Duration(seconds: 1));
await Future<Null>.delayed(const Duration(seconds: 1));
// Ensure that TextField is visible again
await driver.waitFor(textFieldFinder);