Revert "Instrument add to app flows (#33297)" (#33449)

This reverts commit faec4ca361.
This commit is contained in:
Jonah Williams
2019-05-28 12:52:58 -07:00
committed by GitHub
parent 2d9b158faf
commit 8e3e0a89f4
9 changed files with 56 additions and 310 deletions

View File

@@ -14,16 +14,13 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import '../src/common.dart';
import '../src/context.dart';
const String frameworkRevision = '12345678';
const String frameworkChannel = 'omega';
final Generator _kNoColorTerminalPlatform = () => FakePlatform.fromPlatform(const LocalPlatform())..stdoutSupportsAnsi = false;
@@ -930,71 +927,8 @@ void main() {
HttpClientFactory: () =>
() => MockHttpClient(404, result: 'not found'),
});
group('usageValues', () {
testUsingContext('set template type as usage value', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', '--template=module', projectDir.path]);
expect(await command.usageValues, containsPair(kCommandCreateProjectType, 'module'));
await runner.run(<String>['create', '--no-pub', '--template=app', projectDir.path]);
expect(await command.usageValues, containsPair(kCommandCreateProjectType, 'app'));
await runner.run(<String>['create', '--no-pub', '--template=package', projectDir.path]);
expect(await command.usageValues, containsPair(kCommandCreateProjectType, 'package'));
await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
expect(await command.usageValues, containsPair(kCommandCreateProjectType, 'plugin'));
}, timeout: allowForCreateFlutterProject);
testUsingContext('set iOS host language type as usage value', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', '--template=app', projectDir.path]);
expect(await command.usageValues, containsPair(kCommandCreateIosLanguage, 'objc'));
await runner.run(<String>[
'create',
'--no-pub',
'--template=app',
'--ios-language=swift',
projectDir.path,
]);
expect(await command.usageValues, containsPair(kCommandCreateIosLanguage, 'swift'));
}, timeout: allowForCreateFlutterProject);
testUsingContext('set Android host language type as usage value', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', '--template=app', projectDir.path]);
expect(await command.usageValues, containsPair(kCommandCreateAndroidLanguage, 'java'));
await runner.run(<String>[
'create',
'--no-pub',
'--template=app',
'--android-language=kotlin',
projectDir.path,
]);
expect(await command.usageValues, containsPair(kCommandCreateAndroidLanguage, 'kotlin'));
}, timeout: allowForCreateFlutterProject);
});
}
Future<void> _createProject(
Directory dir,
List<String> createArgs,

View File

@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/packages.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:process/process.dart';
import '../src/common.dart';
@@ -58,7 +57,7 @@ void main() {
return projectPath;
}
Future<PackagesCommand> runCommandIn(String projectPath, String verb, { List<String> args }) async {
Future<void> runCommandIn(String projectPath, String verb, { List<String> args }) async {
final PackagesCommand command = PackagesCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
@@ -68,7 +67,6 @@ void main() {
commandArgs.add(projectPath);
await runner.run(commandArgs);
return command;
}
void expectExists(String projectPath, String relPath) {
@@ -219,39 +217,6 @@ void main() {
expectZeroPluginsInjected(projectPath);
}, timeout: allowForCreateFlutterProject);
testUsingContext('set the number of plugins as usage value', () async {
final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=module']);
removeGeneratedFiles(projectPath);
final PackagesCommand command = await runCommandIn(projectPath, 'get');
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
expect(await getCommand.usageValues, containsPair(kCommandPackagesNumberPlugins, '0'));
}, timeout: allowForCreateFlutterProject);
testUsingContext('indicate that the project is not a module in usage value', () async {
final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub']);
removeGeneratedFiles(projectPath);
final PackagesCommand command = await runCommandIn(projectPath, 'get');
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
expect(await getCommand.usageValues, containsPair(kCommandPackagesProjectModule, 'false'));
}, timeout: allowForCreateFlutterProject);
testUsingContext('indicate that the project is a module in usage value', () async {
final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=module']);
removeGeneratedFiles(projectPath);
final PackagesCommand command = await runCommandIn(projectPath, 'get');
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
expect(await getCommand.usageValues, containsPair(kCommandPackagesProjectModule, 'true'));
}, timeout: allowForCreateFlutterProject);
testUsingContext('upgrade fetches packages', () async {
final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=module']);

View File

@@ -227,41 +227,6 @@ void main() {
});
});
group('language', () {
MockXcodeProjectInterpreter mockXcodeProjectInterpreter;
MemoryFileSystem fs;
setUp(() {
fs = MemoryFileSystem();
mockXcodeProjectInterpreter = MockXcodeProjectInterpreter();
});
testInMemory('default host app language', () async {
final FlutterProject project = await someProject();
expect(project.ios.isSwift, isFalse);
expect(project.android.isKotlin, isFalse);
});
testUsingContext('swift and kotlin host app language', () async {
final FlutterProject project = await someProject();
when(mockXcodeProjectInterpreter.getBuildSettings(any, any)).thenReturn(<String, String>{
'SWIFT_VERSION': '3.0',
});
addAndroidGradleFile(project.directory,
gradleFileContent: () {
return '''
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
''';
});
expect(project.ios.isSwift, isTrue);
expect(project.android.isKotlin, isTrue);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
});
});
group('product bundle identifier', () {
MemoryFileSystem fs;
MockIOSWorkflow mockIOSWorkflow;
@@ -286,9 +251,7 @@ apply plugin: 'kotlin-android'
});
testWithMocks('from pbxproj file, if no plist', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject');
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
});
testWithMocks('from plist, if no variables', () async {
@@ -298,9 +261,7 @@ apply plugin: 'kotlin-android'
});
testWithMocks('from pbxproj and plist, if default variable', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject');
when(mockIOSWorkflow.getPlistValueFromFile(any, any)).thenReturn('\$(PRODUCT_BUNDLE_IDENTIFIER)');
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
});
@@ -315,23 +276,17 @@ apply plugin: 'kotlin-android'
});
testWithMocks('empty surrounded by quotes', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('', qualifier: '"');
});
addIosWithBundleId(project.directory, '', qualifier: '"');
expect(project.ios.productBundleIdentifier, '');
});
testWithMocks('surrounded by double quotes', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject', qualifier: '"');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject', qualifier: '"');
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
});
testWithMocks('surrounded by single quotes', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject', qualifier: '\'');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject', qualifier: '\'');
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
});
});
@@ -348,32 +303,22 @@ apply plugin: 'kotlin-android'
});
testInMemory('is populated from iOS bundle identifier', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject', qualifier: '\'');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject');
expect(project.organizationNames, <String>['io.flutter']);
});
testInMemory('is populated from Android application ID', () async {
final FlutterProject project = await someProject();
addAndroidGradleFile(project.directory,
gradleFileContent: () {
return gradleFileWithApplicationId('io.flutter.someproject');
});
addAndroidWithApplicationId(project.directory, 'io.flutter.someproject');
expect(project.organizationNames, <String>['io.flutter']);
});
testInMemory('is populated from iOS bundle identifier in plugin example', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.example.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject', qualifier: '\'');
});
addIosWithBundleId(project.example.directory, 'io.flutter.someProject');
expect(project.organizationNames, <String>['io.flutter']);
});
testInMemory('is populated from Android application ID in plugin example', () async {
final FlutterProject project = await someProject();
addAndroidGradleFile(project.example.directory,
gradleFileContent: () {
return gradleFileWithApplicationId('io.flutter.someproject');
});
addAndroidWithApplicationId(project.example.directory, 'io.flutter.someproject');
expect(project.organizationNames, <String>['io.flutter']);
});
testInMemory('is populated from Android group in plugin', () async {
@@ -383,24 +328,14 @@ apply plugin: 'kotlin-android'
});
testInMemory('is singleton, if sources agree', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject');
});
addAndroidGradleFile(project.directory,
gradleFileContent: () {
return gradleFileWithApplicationId('io.flutter.someproject');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject');
addAndroidWithApplicationId(project.directory, 'io.flutter.someproject');
expect(project.organizationNames, <String>['io.flutter']);
});
testInMemory('is non-singleton, if sources disagree', () async {
final FlutterProject project = await someProject();
addIosProjectFile(project.directory, projectFileContent: () {
return projectFileWithBundleId('io.flutter.someProject');
});
addAndroidGradleFile(project.directory,
gradleFileContent: () {
return gradleFileWithApplicationId('io.clutter.someproject');
});
addIosWithBundleId(project.directory, 'io.flutter.someProject');
addAndroidWithApplicationId(project.directory, 'io.clutter.someproject');
expect(
project.organizationNames,
<String>['io.flutter', 'io.clutter'],
@@ -540,22 +475,22 @@ void expectNotExists(FileSystemEntity entity) {
expect(entity.existsSync(), isFalse);
}
void addIosProjectFile(Directory directory, {String projectFileContent()}) {
void addIosWithBundleId(Directory directory, String id, {String qualifier}) {
directory
.childDirectory('ios')
.childDirectory('Runner.xcodeproj')
.childFile('project.pbxproj')
..createSync(recursive: true)
..writeAsStringSync(projectFileContent());
..writeAsStringSync(projectFileWithBundleId(id, qualifier: qualifier));
}
void addAndroidGradleFile(Directory directory, { String gradleFileContent() }) {
void addAndroidWithApplicationId(Directory directory, String id) {
directory
.childDirectory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
..writeAsStringSync(gradleFileContent());
..writeAsStringSync(gradleFileWithApplicationId(id));
}
void addAndroidWithGroup(Directory directory, String id) {