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
@ -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 = '../..';
|
||||
|
Loading…
Reference in New Issue
Block a user