Commit f6c53d58 authored by Dan Rubel's avatar Dan Rubel Committed by GitHub

Test create proj content (#5546)

* test flutter create project dart file is properly formatted

* restore driver-test

* cleanup lint warnings

* address comment
parent 20b9750a
......@@ -21,7 +21,7 @@ void main() {
}
class FlutterDemo extends StatefulWidget {
FlutterDemo({ Key key }) : super(key: key);
FlutterDemo({Key key}) : super(key: key);
@override
_FlutterDemoState createState() => new _FlutterDemoState();
......@@ -43,7 +43,8 @@ class _FlutterDemoState extends State<FlutterDemo> {
title: new Text('Flutter Demo'),
),
body: new Center(
child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.'),
child: new Text(
'Button tapped $_counter time${ _counter == 1 ? '' : 's' }.'),
),
floatingActionButton: new FloatingActionButton(
onPressed: _incrementCounter,
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:args/command_runner.dart';
......@@ -36,6 +37,37 @@ void main() {
return _createAndAnalyzeProject(temp, <String>['--with-driver-test']);
});
// Verify content and formatting
testUsingContext('content', () async {
Cache.flutterRoot = '../..';
CreateCommand command = new CreateCommand();
CommandRunner runner = createTestCommandRunner(command);
int code = await runner.run(<String>['create', '--no-pub', temp.path]);
expect(code, 0);
void expectExists(String relPath) {
expect(FileSystemEntity.isFileSync('${temp.path}/$relPath'), true);
}
expectExists('lib/main.dart');
for (FileSystemEntity file in temp.listSync(recursive: true)) {
if (file is File && file.path.endsWith('.dart')) {
String original= file.readAsStringSync();
Process process = await Process.start(
sdkBinaryName('dartfmt'),
<String>[file.path],
workingDirectory: temp.path,
);
String formatted =
await process.stdout.transform(UTF8.decoder).join();
expect(original, formatted, reason: file.path);
}
}
});
// Verify that we can regenerate over an existing project.
testUsingContext('can re-gen over existing project', () async {
Cache.flutterRoot = '../..';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment