mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
96 lines
3.8 KiB
Dart
96 lines
3.8 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:file/memory.dart';
|
|
import 'package:flutter_tools/src/base/common.dart';
|
|
import 'package:flutter_tools/src/base/context.dart';
|
|
import 'package:flutter_tools/src/base/file_system.dart';
|
|
import 'package:flutter_tools/src/base/io.dart';
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
import 'package:flutter_tools/src/commands/shell_completion.dart';
|
|
import 'package:process/process.dart';
|
|
|
|
import '../../src/common.dart';
|
|
import '../../src/context.dart';
|
|
import '../../src/mocks.dart';
|
|
|
|
void main() {
|
|
group('shell_completion', () {
|
|
MockStdio mockStdio;
|
|
|
|
setUp(() {
|
|
Cache.disableLocking();
|
|
mockStdio = MockStdio();
|
|
});
|
|
|
|
testUsingContext('generates bash initialization script to stdout', () async {
|
|
final ShellCompletionCommand command = ShellCompletionCommand();
|
|
await createTestCommandRunner(command).run(<String>['bash-completion']);
|
|
expect(mockStdio.writtenToStdout.length, equals(1));
|
|
expect(mockStdio.writtenToStdout.first, contains('__flutter_completion'));
|
|
}, overrides: <Type, Generator>{
|
|
Stdio: () => mockStdio,
|
|
});
|
|
|
|
testUsingContext('generates bash initialization script to stdout with arg', () async {
|
|
final ShellCompletionCommand command = ShellCompletionCommand();
|
|
await createTestCommandRunner(command).run(<String>['bash-completion', '-']);
|
|
expect(mockStdio.writtenToStdout.length, equals(1));
|
|
expect(mockStdio.writtenToStdout.first, contains('__flutter_completion'));
|
|
}, overrides: <Type, Generator>{
|
|
Stdio: () => mockStdio,
|
|
});
|
|
|
|
testUsingContext('generates bash initialization script to output file', () async {
|
|
final ShellCompletionCommand command = ShellCompletionCommand();
|
|
const String outputFile = 'bash-setup.sh';
|
|
await createTestCommandRunner(command).run(
|
|
<String>['bash-completion', outputFile],
|
|
);
|
|
expect(fs.isFileSync(outputFile), isTrue);
|
|
expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion'));
|
|
}, overrides: <Type, Generator>{
|
|
FileSystem: () => MemoryFileSystem(),
|
|
ProcessManager: () => FakeProcessManager.any(),
|
|
Stdio: () => mockStdio,
|
|
});
|
|
|
|
testUsingContext("won't overwrite existing output file ", () async {
|
|
final ShellCompletionCommand command = ShellCompletionCommand();
|
|
const String outputFile = 'bash-setup.sh';
|
|
fs.file(outputFile).createSync();
|
|
try {
|
|
await createTestCommandRunner(command).run(
|
|
<String>['bash-completion', outputFile],
|
|
);
|
|
fail('Expect ToolExit exception');
|
|
} on ToolExit catch (error) {
|
|
expect(error.exitCode ?? 1, 1);
|
|
expect(error.message, contains('Use --overwrite'));
|
|
}
|
|
expect(fs.isFileSync(outputFile), isTrue);
|
|
expect(fs.file(outputFile).readAsStringSync(), isEmpty);
|
|
}, overrides: <Type, Generator>{
|
|
FileSystem: () => MemoryFileSystem(),
|
|
ProcessManager: () => FakeProcessManager.any(),
|
|
Stdio: () => mockStdio,
|
|
});
|
|
|
|
testUsingContext('will overwrite existing output file if given --overwrite', () async {
|
|
final ShellCompletionCommand command = ShellCompletionCommand();
|
|
const String outputFile = 'bash-setup.sh';
|
|
fs.file(outputFile).createSync();
|
|
await createTestCommandRunner(command).run(
|
|
<String>['bash-completion', '--overwrite', outputFile],
|
|
);
|
|
expect(fs.isFileSync(outputFile), isTrue);
|
|
expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion'));
|
|
}, overrides: <Type, Generator>{
|
|
FileSystem: () => MemoryFileSystem(),
|
|
ProcessManager: () => FakeProcessManager.any(),
|
|
Stdio: () => mockStdio,
|
|
});
|
|
});
|
|
}
|