mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Test create proj content (#5546)
* test flutter create project dart file is properly formatted * restore driver-test * cleanup lint warnings * address comment
This commit is contained in:
parent
20b9750a73
commit
f6c53d58cd
@ -21,7 +21,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FlutterDemo extends StatefulWidget {
|
class FlutterDemo extends StatefulWidget {
|
||||||
FlutterDemo({ Key key }) : super(key: key);
|
FlutterDemo({Key key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_FlutterDemoState createState() => new _FlutterDemoState();
|
_FlutterDemoState createState() => new _FlutterDemoState();
|
||||||
@ -43,7 +43,8 @@ class _FlutterDemoState extends State<FlutterDemo> {
|
|||||||
title: new Text('Flutter Demo'),
|
title: new Text('Flutter Demo'),
|
||||||
),
|
),
|
||||||
body: new Center(
|
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(
|
floatingActionButton: new FloatingActionButton(
|
||||||
onPressed: _incrementCounter,
|
onPressed: _incrementCounter,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
@ -36,6 +37,37 @@ void main() {
|
|||||||
return _createAndAnalyzeProject(temp, <String>['--with-driver-test']);
|
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.
|
// Verify that we can regenerate over an existing project.
|
||||||
testUsingContext('can re-gen over existing project', () async {
|
testUsingContext('can re-gen over existing project', () async {
|
||||||
Cache.flutterRoot = '../..';
|
Cache.flutterRoot = '../..';
|
||||||
|
Loading…
Reference in New Issue
Block a user