[tool] Remove some usages of deprecated usage package (#151359)

Partially addresses https://github.com/flutter/flutter/issues/150575 and https://github.com/flutter/flutter/issues/150665

Will require a g3fix.
This commit is contained in:
Andrew Kolos 2024-07-09 11:17:21 -07:00 committed by GitHub
parent 5ebc993dff
commit 5103d75743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 183 additions and 381 deletions

View File

@ -912,9 +912,8 @@ Future<void> verifyNoTestImports(String workingDirectory) async {
} }
// Fail if any errors // Fail if any errors
if (errors.isNotEmpty) { if (errors.isNotEmpty) {
final String s = errors.length == 1 ? '' : 's';
foundError(<String>[ foundError(<String>[
'${bold}The following file$s import a test directly. Test utilities should be in their own file.$reset', '${bold}The following file(s) import a test directly. Test utilities should be in their own file.$reset',
...errors, ...errors,
]); ]);
} }

View File

@ -29,7 +29,6 @@ import '../convert.dart';
import '../flutter_manifest.dart'; import '../flutter_manifest.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../reporting/reporting.dart';
import 'android_builder.dart'; import 'android_builder.dart';
import 'android_studio.dart'; import 'android_studio.dart';
import 'gradle_errors.dart'; import 'gradle_errors.dart';
@ -149,7 +148,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
required ProcessManager processManager, required ProcessManager processManager,
required FileSystem fileSystem, required FileSystem fileSystem,
required Artifacts artifacts, required Artifacts artifacts,
required Usage usage,
required Analytics analytics, required Analytics analytics,
required GradleUtils gradleUtils, required GradleUtils gradleUtils,
required Platform platform, required Platform platform,
@ -158,7 +156,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
_logger = logger, _logger = logger,
_fileSystem = fileSystem, _fileSystem = fileSystem,
_artifacts = artifacts, _artifacts = artifacts,
_usage = usage,
_analytics = analytics, _analytics = analytics,
_gradleUtils = gradleUtils, _gradleUtils = gradleUtils,
_androidStudio = androidStudio, _androidStudio = androidStudio,
@ -170,7 +167,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
final ProcessUtils _processUtils; final ProcessUtils _processUtils;
final FileSystem _fileSystem; final FileSystem _fileSystem;
final Artifacts _artifacts; final Artifacts _artifacts;
final Usage _usage;
final Analytics _analytics; final Analytics _analytics;
final GradleUtils _gradleUtils; final GradleUtils _gradleUtils;
final FileSystemUtils _fileSystemUtils; final FileSystemUtils _fileSystemUtils;
@ -304,7 +300,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
@visibleForTesting int? maxRetries, @visibleForTesting int? maxRetries,
}) async { }) async {
if (!project.android.isSupportedVersion) { if (!project.android.isSupportedVersion) {
_exitWithUnsupportedProjectMessage(_usage, _logger.terminal, analytics: _analytics); _exitWithUnsupportedProjectMessage(_logger.terminal, _analytics);
} }
final List<ProjectMigrator> migrators = <ProjectMigrator>[ final List<ProjectMigrator> migrators = <ProjectMigrator>[
@ -322,10 +318,8 @@ class AndroidGradleBuilder implements AndroidBuilder {
final bool usesAndroidX = isAppUsingAndroidX(project.android.hostAppGradleRoot); final bool usesAndroidX = isAppUsingAndroidX(project.android.hostAppGradleRoot);
if (usesAndroidX) { if (usesAndroidX) {
BuildEvent('app-using-android-x', type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: 'app-using-android-x', buildType: 'gradle')); _analytics.send(Event.flutterBuildInfo(label: 'app-using-android-x', buildType: 'gradle'));
} else if (!usesAndroidX) { } else if (!usesAndroidX) {
BuildEvent('app-not-using-android-x', type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle')); _analytics.send(Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle'));
_logger.printStatus("${_logger.terminal.warningMark} Your app isn't using AndroidX.", emphasis: true); _logger.printStatus("${_logger.terminal.warningMark} Your app isn't using AndroidX.", emphasis: true);
@ -485,7 +479,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
} }
final Duration elapsedDuration = sw.elapsed; final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('build', 'gradle', elapsedDuration);
_analytics.send(Event.timing( _analytics.send(Event.timing(
workflow: 'build', workflow: 'build',
variableName: 'gradle', variableName: 'gradle',
@ -494,7 +487,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
if (exitCode != 0) { if (exitCode != 0) {
if (detectedGradleError == null) { if (detectedGradleError == null) {
BuildEvent('gradle-unknown-failure', type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: 'gradle-unknown-failure', buildType: 'gradle')); _analytics.send(Event.flutterBuildInfo(label: 'gradle-unknown-failure', buildType: 'gradle'));
throwToolExit( throwToolExit(
@ -529,7 +521,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
); );
final String successEventLabel = 'gradle-${detectedGradleError!.eventLabel}-success'; final String successEventLabel = 'gradle-${detectedGradleError!.eventLabel}-success';
BuildEvent(successEventLabel, type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: successEventLabel, buildType: 'gradle')); _analytics.send(Event.flutterBuildInfo(label: successEventLabel, buildType: 'gradle'));
return; return;
@ -538,7 +529,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
} }
} }
final String usageLabel = 'gradle-${detectedGradleError?.eventLabel}-failure'; final String usageLabel = 'gradle-${detectedGradleError?.eventLabel}-failure';
BuildEvent(usageLabel, type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: usageLabel, buildType: 'gradle')); _analytics.send(Event.flutterBuildInfo(label: usageLabel, buildType: 'gradle'));
throwToolExit( throwToolExit(
@ -548,7 +538,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
} }
if (isBuildingBundle) { if (isBuildingBundle) {
final File bundleFile = findBundleFile(project, buildInfo, _logger, _usage, _analytics); final File bundleFile = findBundleFile(project, buildInfo, _logger, _analytics);
final String appSize = (buildInfo.mode == BuildMode.debug) final String appSize = (buildInfo.mode == BuildMode.debug)
? '' // Don't display the size when building a debug variant. ? '' // Don't display the size when building a debug variant.
: ' (${getSizeAsPlatformMB(bundleFile.lengthSync())})'; : ' (${getSizeAsPlatformMB(bundleFile.lengthSync())})';
@ -566,7 +556,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
} }
// Gradle produced APKs. // Gradle produced APKs.
final Iterable<String> apkFilesPaths = project.isModule final Iterable<String> apkFilesPaths = project.isModule
? findApkFilesModule(project, androidBuildInfo, _logger, _usage, _analytics) ? findApkFilesModule(project, androidBuildInfo, _logger, _analytics)
: listApkPaths(androidBuildInfo); : listApkPaths(androidBuildInfo);
final Directory apkDirectory = getApkDirectory(project); final Directory apkDirectory = getApkDirectory(project);
@ -577,7 +567,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
project: project, project: project,
fileExtension: '.apk', fileExtension: '.apk',
logger: _logger, logger: _logger,
usage: _usage,
analytics: _analytics, analytics: _analytics,
); );
} }
@ -608,7 +597,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
final SizeAnalyzer sizeAnalyzer = SizeAnalyzer( final SizeAnalyzer sizeAnalyzer = SizeAnalyzer(
fileSystem: _fileSystem, fileSystem: _fileSystem,
logger: _logger, logger: _logger,
flutterUsage: _usage,
analytics: _analytics, analytics: _analytics,
); );
final String archName = androidBuildInfo.targetArchs.single.archName; final String archName = androidBuildInfo.targetArchs.single.archName;
@ -759,7 +747,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
status.stop(); status.stop();
} }
final Duration elapsedDuration = sw.elapsed; final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('build', 'gradle-aar', elapsedDuration);
_analytics.send(Event.timing( _analytics.send(Event.timing(
workflow: 'build', workflow: 'build',
variableName: 'gradle-aar', variableName: 'gradle-aar',
@ -801,7 +788,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
); );
final Duration elapsedDuration = sw.elapsed; final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('print', 'android build variants', elapsedDuration);
_analytics.send(Event.timing( _analytics.send(Event.timing(
workflow: 'print', workflow: 'print',
variableName: 'android build variants', variableName: 'android build variants',
@ -840,7 +826,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
project: project, project: project,
); );
final Duration elapsedDuration = sw.elapsed; final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('outputs', 'app link settings', elapsedDuration);
_analytics.send(Event.timing( _analytics.send(Event.timing(
workflow: 'outputs', workflow: 'outputs',
variableName: 'app link settings', variableName: 'app link settings',
@ -927,8 +912,7 @@ String _calculateSha(File file) {
return _hex(sha1.convert(bytes).bytes); return _hex(sha1.convert(bytes).bytes);
} }
void _exitWithUnsupportedProjectMessage(Usage usage, Terminal terminal, {required Analytics analytics}) { void _exitWithUnsupportedProjectMessage(Terminal terminal, Analytics analytics) {
BuildEvent('unsupported-project', type: 'gradle', eventError: 'gradle-plugin', flutterUsage: usage).send();
analytics.send(Event.flutterBuildInfo( analytics.send(Event.flutterBuildInfo(
label: 'unsupported-project', label: 'unsupported-project',
buildType: 'gradle', buildType: 'gradle',
@ -959,7 +943,6 @@ Iterable<String> findApkFilesModule(
FlutterProject project, FlutterProject project,
AndroidBuildInfo androidBuildInfo, AndroidBuildInfo androidBuildInfo,
Logger logger, Logger logger,
Usage usage,
Analytics analytics, Analytics analytics,
) { ) {
final Iterable<String> apkFileNames = _apkFilesFor(androidBuildInfo); final Iterable<String> apkFileNames = _apkFilesFor(androidBuildInfo);
@ -995,7 +978,6 @@ Iterable<String> findApkFilesModule(
project: project, project: project,
fileExtension: '.apk', fileExtension: '.apk',
logger: logger, logger: logger,
usage: usage,
analytics: analytics, analytics: analytics,
); );
} }
@ -1035,7 +1017,12 @@ Iterable<String> listApkPaths(
} }
@visibleForTesting @visibleForTesting
File findBundleFile(FlutterProject project, BuildInfo buildInfo, Logger logger, Usage usage, Analytics analytics) { File findBundleFile(
FlutterProject project,
BuildInfo buildInfo,
Logger logger,
Analytics analytics,
) {
final List<File> fileCandidates = <File>[ final List<File> fileCandidates = <File>[
getBundleDirectory(project) getBundleDirectory(project)
.childDirectory(camelCase(buildInfo.modeName)) .childDirectory(camelCase(buildInfo.modeName))
@ -1091,7 +1078,6 @@ File findBundleFile(FlutterProject project, BuildInfo buildInfo, Logger logger,
project: project, project: project,
fileExtension: '.aab', fileExtension: '.aab',
logger: logger, logger: logger,
usage: usage,
analytics: analytics, analytics: analytics,
); );
} }
@ -1101,7 +1087,6 @@ Never _exitWithExpectedFileNotFound({
required FlutterProject project, required FlutterProject project,
required String fileExtension, required String fileExtension,
required Logger logger, required Logger logger,
required Usage usage,
required Analytics analytics, required Analytics analytics,
}) { }) {
@ -1110,11 +1095,6 @@ Never _exitWithExpectedFileNotFound({
final String gradleBuildSettings = 'androidGradlePluginVersion: $androidGradlePluginVersion, ' final String gradleBuildSettings = 'androidGradlePluginVersion: $androidGradlePluginVersion, '
'fileExtension: $fileExtension'; 'fileExtension: $fileExtension';
BuildEvent('gradle-expected-file-not-found',
type: 'gradle',
settings: gradleBuildSettings,
flutterUsage: usage,
).send();
analytics.send(Event.flutterBuildInfo( analytics.send(Event.flutterBuildInfo(
label: 'gradle-expected-file-not-found', label: 'gradle-expected-file-not-found',
buildType: 'gradle', buildType: 'gradle',

View File

@ -10,7 +10,6 @@ import '../base/process.dart';
import '../base/terminal.dart'; import '../base/terminal.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../reporting/reporting.dart';
import 'gradle_utils.dart'; import 'gradle_utils.dart';
typedef GradleErrorTest = bool Function(String); typedef GradleErrorTest = bool Function(String);

View File

@ -18,7 +18,6 @@ import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../reporting/reporting.dart';
import 'android_sdk.dart'; import 'android_sdk.dart';
// These are the versions used in the project templates. // These are the versions used in the project templates.
@ -787,11 +786,6 @@ void writeLocalProperties(File properties) {
} }
void exitWithNoSdkMessage() { void exitWithNoSdkMessage() {
BuildEvent('unsupported-project',
type: 'gradle',
eventError: 'android-sdk-not-found',
flutterUsage: globals.flutterUsage)
.send();
globals.analytics.send(Event.flutterBuildInfo( globals.analytics.send(Event.flutterBuildInfo(
label: 'unsupported-project', label: 'unsupported-project',
buildType: 'gradle', buildType: 'gradle',

View File

@ -9,7 +9,6 @@ import 'package:unified_analytics/unified_analytics.dart';
import 'package:vm_snapshot_analysis/treemap.dart'; import 'package:vm_snapshot_analysis/treemap.dart';
import '../convert.dart'; import '../convert.dart';
import '../reporting/reporting.dart';
import 'common.dart'; import 'common.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'logger.dart'; import 'logger.dart';
@ -20,11 +19,9 @@ class SizeAnalyzer {
SizeAnalyzer({ SizeAnalyzer({
required FileSystem fileSystem, required FileSystem fileSystem,
required Logger logger, required Logger logger,
required Usage flutterUsage,
required Analytics analytics, required Analytics analytics,
Pattern appFilenamePattern = 'libapp.so', Pattern appFilenamePattern = 'libapp.so',
}) : _flutterUsage = flutterUsage, }) : _analytics = analytics,
_analytics = analytics,
_fileSystem = fileSystem, _fileSystem = fileSystem,
_logger = logger, _logger = logger,
_appFilenamePattern = appFilenamePattern; _appFilenamePattern = appFilenamePattern;
@ -32,7 +29,6 @@ class SizeAnalyzer {
final FileSystem _fileSystem; final FileSystem _fileSystem;
final Logger _logger; final Logger _logger;
final Pattern _appFilenamePattern; final Pattern _appFilenamePattern;
final Usage _flutterUsage;
final Analytics _analytics; final Analytics _analytics;
String? _appFilename; String? _appFilename;
@ -91,7 +87,6 @@ class SizeAnalyzer {
); );
assert(_appFilename != null); assert(_appFilename != null);
CodeSizeEvent(type, flutterUsage: _flutterUsage).send();
_analytics.send(Event.codeSizeAnalysis(platform: type)); _analytics.send(Event.codeSizeAnalysis(platform: type));
return apkAnalysisJson; return apkAnalysisJson;
} }
@ -145,7 +140,6 @@ class SizeAnalyzer {
aotSnapshotJson: processedAotSnapshotJson, aotSnapshotJson: processedAotSnapshotJson,
precompilerTrace: json.decode(precompilerTrace.readAsStringSync()) as Map<String, Object?>? ?? <String, Object?>{}, precompilerTrace: json.decode(precompilerTrace.readAsStringSync()) as Map<String, Object?>? ?? <String, Object?>{},
); );
CodeSizeEvent(kind, flutterUsage: _flutterUsage).send();
_analytics.send(Event.codeSizeAnalysis(platform: kind)); _analytics.send(Event.codeSizeAnalysis(platform: kind));
return apkAnalysisJson; return apkAnalysisJson;
} }

View File

@ -713,7 +713,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
result, result,
analytics: globals.analytics, analytics: globals.analytics,
fileSystem: globals.fs, fileSystem: globals.fs,
flutterUsage: globals.flutterUsage,
logger: globals.logger, logger: globals.logger,
platform: SupportedPlatform.ios, platform: SupportedPlatform.ios,
project: app.project.parent, project: app.project.parent,
@ -726,7 +725,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
final SizeAnalyzer sizeAnalyzer = SizeAnalyzer( final SizeAnalyzer sizeAnalyzer = SizeAnalyzer(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
flutterUsage: globals.flutterUsage,
analytics: analytics, analytics: analytics,
appFilenamePattern: 'App' appFilenamePattern: 'App'
); );

View File

@ -91,7 +91,6 @@ class BuildLinuxCommand extends BuildSubCommand {
sizeAnalyzer: SizeAnalyzer( sizeAnalyzer: SizeAnalyzer(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: logger, logger: logger,
flutterUsage: globals.flutterUsage,
analytics: analytics, analytics: analytics,
), ),
needCrossBuild: needCrossBuild, needCrossBuild: needCrossBuild,

View File

@ -67,7 +67,6 @@ class BuildMacosCommand extends BuildSubCommand {
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
appFilenamePattern: 'App', appFilenamePattern: 'App',
flutterUsage: globals.flutterUsage,
analytics: analytics, analytics: analytics,
), ),
usingCISystem: usingCISystem, usingCISystem: usingCISystem,

View File

@ -71,7 +71,6 @@ class BuildWindowsCommand extends BuildSubCommand {
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
appFilenamePattern: 'app.so', appFilenamePattern: 'app.so',
flutterUsage: globals.flutterUsage,
analytics: analytics, analytics: analytics,
), ),
); );

View File

@ -102,7 +102,6 @@ Future<T> runInContext<T>(
processManager: globals.processManager, processManager: globals.processManager,
fileSystem: globals.fs, fileSystem: globals.fs,
artifacts: globals.artifacts!, artifacts: globals.artifacts!,
usage: globals.flutterUsage,
analytics: globals.analytics, analytics: globals.analytics,
gradleUtils: globals.gradleUtils!, gradleUtils: globals.gradleUtils!,
platform: globals.platform, platform: globals.platform,

View File

@ -500,7 +500,6 @@ class IOSDevice extends Device {
buildResult, buildResult,
analytics: globals.analytics, analytics: globals.analytics,
fileSystem: globals.fs, fileSystem: globals.fs,
flutterUsage: globals.flutterUsage,
logger: globals.logger, logger: globals.logger,
platform: SupportedPlatform.ios, platform: SupportedPlatform.ios,
project: package.project.parent, project: package.project.parent,

View File

@ -30,7 +30,6 @@ import '../migrations/xcode_script_build_phase_migration.dart';
import '../migrations/xcode_thin_binary_build_phase_input_paths_migration.dart'; import '../migrations/xcode_thin_binary_build_phase_input_paths_migration.dart';
import '../plugins.dart'; import '../plugins.dart';
import '../project.dart'; import '../project.dart';
import '../reporting/reporting.dart';
import 'application_package.dart'; import 'application_package.dart';
import 'code_signing.dart'; import 'code_signing.dart';
import 'migrations/host_app_info_plist_migration.dart'; import 'migrations/host_app_info_plist_migration.dart';
@ -155,7 +154,7 @@ Future<XcodeBuildResult> buildXcodeProject({
final FlutterProject project = FlutterProject.current(); final FlutterProject project = FlutterProject.current();
final List<ProjectMigrator> migrators = <ProjectMigrator>[ final List<ProjectMigrator> migrators = <ProjectMigrator>[
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.flutterUsage, globals.analytics), RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.analytics),
XcodeBuildSystemMigration(app.project, globals.logger), XcodeBuildSystemMigration(app.project, globals.logger),
ProjectBaseConfigurationMigration(app.project, globals.logger), ProjectBaseConfigurationMigration(app.project, globals.logger),
ProjectBuildLocationMigration(app.project, globals.logger), ProjectBuildLocationMigration(app.project, globals.logger),
@ -452,7 +451,6 @@ Future<XcodeBuildResult> buildXcodeProject({
+ getElapsedAsSeconds(sw.elapsed).padLeft(5), + getElapsedAsSeconds(sw.elapsed).padLeft(5),
); );
final Duration elapsedDuration = sw.elapsed; final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming(xcodeBuildActionToString(buildAction), 'xcode-ios', elapsedDuration);
globals.analytics.send(Event.timing( globals.analytics.send(Event.timing(
workflow: xcodeBuildActionToString(buildAction), workflow: xcodeBuildActionToString(buildAction),
variableName: 'xcode-ios', variableName: 'xcode-ios',
@ -625,7 +623,6 @@ Future<void> diagnoseXcodeBuildFailure(
required Analytics analytics, required Analytics analytics,
required Logger logger, required Logger logger,
required FileSystem fileSystem, required FileSystem fileSystem,
required Usage flutterUsage,
required SupportedPlatform platform, required SupportedPlatform platform,
required FlutterProject project, required FlutterProject project,
}) async { }) async {
@ -639,13 +636,6 @@ Future<void> diagnoseXcodeBuildFailure(
final String command = xcodeBuildExecution.buildCommands.toString(); final String command = xcodeBuildExecution.buildCommands.toString();
final String settings = xcodeBuildExecution.buildSettings.toString(); final String settings = xcodeBuildExecution.buildSettings.toString();
BuildEvent(
label,
type: buildType,
command: command,
settings: settings,
flutterUsage: flutterUsage,
).send();
analytics.send(Event.flutterBuildInfo( analytics.send(Event.flutterBuildInfo(
label: label, label: label,
buildType: buildType, buildType: buildType,

View File

@ -7,7 +7,6 @@ import 'package:unified_analytics/unified_analytics.dart';
import '../../base/common.dart'; import '../../base/common.dart';
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../base/project_migrator.dart'; import '../../base/project_migrator.dart';
import '../../reporting/reporting.dart';
import '../../xcode_project.dart'; import '../../xcode_project.dart';
// Xcode 11.4 requires linked and embedded frameworks to contain all targeted architectures before build phases are run. // Xcode 11.4 requires linked and embedded frameworks to contain all targeted architectures before build phases are run.
@ -17,14 +16,11 @@ class RemoveFrameworkLinkAndEmbeddingMigration extends ProjectMigrator {
RemoveFrameworkLinkAndEmbeddingMigration( RemoveFrameworkLinkAndEmbeddingMigration(
IosProject project, IosProject project,
super.logger, super.logger,
Usage usage,
Analytics analytics, Analytics analytics,
) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile, ) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile,
_usage = usage,
_analytics = analytics; _analytics = analytics;
final File _xcodeProjectInfoFile; final File _xcodeProjectInfoFile;
final Usage _usage;
final Analytics _analytics; final Analytics _analytics;
@override @override
@ -95,7 +91,6 @@ class RemoveFrameworkLinkAndEmbeddingMigration extends ProjectMigrator {
if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) { if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) {
// Print scary message. // Print scary message.
UsageEvent('ios-migration', 'remove-frameworks', label: 'failure', flutterUsage: _usage).send();
_analytics.send(Event.appleUsageEvent( _analytics.send(Event.appleUsageEvent(
workflow: 'ios-migration', workflow: 'ios-migration',
parameter: 'remove-frameworks', parameter: 'remove-frameworks',

View File

@ -569,7 +569,6 @@ class IOSSimulator extends Device {
buildResult, buildResult,
analytics: globals.analytics, analytics: globals.analytics,
fileSystem: globals.fs, fileSystem: globals.fs,
flutterUsage: globals.flutterUsage,
logger: globals.logger, logger: globals.logger,
platform: SupportedPlatform.ios, platform: SupportedPlatform.ios,
project: app.project.parent, project: app.project.parent,

View File

@ -22,7 +22,6 @@ import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -71,7 +70,6 @@ final Platform notMacosPlatform = FakePlatform(
void main() { void main() {
late MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
late TestUsage usage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
late BufferLogger logger; late BufferLogger logger;
late FakeProcessManager processManager; late FakeProcessManager processManager;
@ -85,7 +83,6 @@ void main() {
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem); artifacts = Artifacts.test(fileSystem: fileSystem);
usage = TestUsage();
fakeAnalytics = getInitializedFakeAnalyticsInstance( fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem, fs: fileSystem,
fakeFlutterVersion: FakeFlutterVersion(), fakeFlutterVersion: FakeFlutterVersion(),
@ -570,9 +567,6 @@ void main() {
expect(logger.statusText, contains('A summary of your iOS bundle analysis can be found at')); expect(logger.statusText, contains('A summary of your iOS bundle analysis can be found at'));
expect(logger.statusText, contains('dart devtools --appSizeBase=')); expect(logger.statusText, contains('dart devtools --appSizeBase='));
expect(usage.events, contains(
const TestUsageEvent('code-size-analysis', 'ios'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.codeSizeAnalysis(platform: 'ios') Event.codeSizeAnalysis(platform: 'ios')
)); ));
@ -582,7 +576,6 @@ void main() {
ProcessManager: () => processManager, ProcessManager: () => processManager,
Platform: () => macosPlatform, Platform: () => macosPlatform,
FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform), FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform),
Usage: () => usage,
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
}); });
@ -645,7 +638,6 @@ void main() {
fileSystem: fileSystem, fileSystem: fileSystem,
platform: macosPlatform, platform: macosPlatform,
), ),
Usage: () => usage,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
}); });
@ -700,7 +692,6 @@ void main() {
fileSystem: fileSystem, fileSystem: fileSystem,
platform: macosPlatform, platform: macosPlatform,
), ),
Usage: () => usage,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
FlutterProjectFactory: () => FlutterProjectFactory( FlutterProjectFactory: () => FlutterProjectFactory(
fileSystem: fileSystem, fileSystem: fileSystem,

View File

@ -18,7 +18,6 @@ import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_ios.dart'; import 'package:flutter_tools/src/commands/build_ios.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -79,7 +78,6 @@ class FakePlistUtils extends Fake implements PlistParser {
void main() { void main() {
late MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
late TestUsage usage;
late FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils; late ProcessUtils processUtils;
late FakePlistUtils plistUtils; late FakePlistUtils plistUtils;
@ -94,7 +92,6 @@ void main() {
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem); artifacts = Artifacts.test(fileSystem: fileSystem);
usage = TestUsage();
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
logger = BufferLogger.test(); logger = BufferLogger.test();
processUtils = ProcessUtils( processUtils = ProcessUtils(
@ -1041,9 +1038,6 @@ void main() {
expect(logger.statusText, contains('A summary of your iOS bundle analysis can be found at')); expect(logger.statusText, contains('A summary of your iOS bundle analysis can be found at'));
expect(logger.statusText, contains('dart devtools --appSizeBase=')); expect(logger.statusText, contains('dart devtools --appSizeBase='));
expect(usage.events, contains(
const TestUsageEvent('code-size-analysis', 'ios'),
));
expect(fakeProcessManager, hasNoRemainingExpectations); expect(fakeProcessManager, hasNoRemainingExpectations);
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.codeSizeAnalysis(platform: 'ios') Event.codeSizeAnalysis(platform: 'ios')
@ -1054,7 +1048,6 @@ void main() {
ProcessManager: () => fakeProcessManager, ProcessManager: () => fakeProcessManager,
Platform: () => macosPlatform, Platform: () => macosPlatform,
FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform), FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform),
Usage: () => usage,
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
}); });

View File

@ -19,7 +19,6 @@ import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_linux.dart'; import 'package:flutter_tools/src/commands/build_linux.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -53,7 +52,6 @@ void main() {
late FakeProcessManager processManager; late FakeProcessManager processManager;
late ProcessUtils processUtils; late ProcessUtils processUtils;
late Logger logger; late Logger logger;
late TestUsage usage;
late Artifacts artifacts; late Artifacts artifacts;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
@ -61,7 +59,6 @@ void main() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem); artifacts = Artifacts.test(fileSystem: fileSystem);
Cache.flutterRoot = _kTestFlutterRoot; Cache.flutterRoot = _kTestFlutterRoot;
usage = TestUsage();
logger = BufferLogger.test(); logger = BufferLogger.test();
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
processUtils = ProcessUtils( processUtils = ProcessUtils(
@ -751,9 +748,6 @@ set(BINARY_NAME "fizz_bar")
expect(testLogger.statusText, contains('A summary of your Linux bundle analysis can be found at')); expect(testLogger.statusText, contains('A summary of your Linux bundle analysis can be found at'));
expect(testLogger.statusText, contains('dart devtools --appSizeBase=')); expect(testLogger.statusText, contains('dart devtools --appSizeBase='));
expect(usage.events, contains(
const TestUsageEvent('code-size-analysis', 'linux'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.codeSizeAnalysis(platform: 'linux') Event.codeSizeAnalysis(platform: 'linux')
)); ));
@ -762,7 +756,6 @@ set(BINARY_NAME "fizz_bar")
ProcessManager: () => processManager, ProcessManager: () => processManager,
Platform: () => linuxPlatform, Platform: () => linuxPlatform,
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
Usage: () => usage,
OperatingSystemUtils: () => FakeOperatingSystemUtils(), OperatingSystemUtils: () => FakeOperatingSystemUtils(),
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
}); });
@ -808,9 +801,6 @@ set(BINARY_NAME "fizz_bar")
// check if libapp.so of "build/linux/arm64/release" directory can be referenced. // check if libapp.so of "build/linux/arm64/release" directory can be referenced.
expect(testLogger.statusText, contains('libapp.so (Dart AOT)')); expect(testLogger.statusText, contains('libapp.so (Dart AOT)'));
expect(usage.events, contains(
const TestUsageEvent('code-size-analysis', 'linux'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.codeSizeAnalysis(platform: 'linux') Event.codeSizeAnalysis(platform: 'linux')
)); ));
@ -819,7 +809,6 @@ set(BINARY_NAME "fizz_bar")
ProcessManager: () => processManager, ProcessManager: () => processManager,
Platform: () => linuxPlatform, Platform: () => linuxPlatform,
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
Usage: () => usage,
OperatingSystemUtils: () => CustomFakeOperatingSystemUtils(hostPlatform: HostPlatform.linux_arm64), OperatingSystemUtils: () => CustomFakeOperatingSystemUtils(hostPlatform: HostPlatform.linux_arm64),
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
}); });

View File

@ -20,7 +20,6 @@ import 'package:flutter_tools/src/commands/build_macos.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
import '../../src/common.dart'; import '../../src/common.dart';
@ -66,7 +65,6 @@ final Platform notMacosPlatform = FakePlatform(
void main() { void main() {
late MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
late TestUsage usage;
late FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils; late ProcessUtils processUtils;
late BufferLogger logger; late BufferLogger logger;
@ -82,7 +80,6 @@ void main() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem); artifacts = Artifacts.test(fileSystem: fileSystem);
logger = BufferLogger.test(); logger = BufferLogger.test();
usage = TestUsage();
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
processUtils = ProcessUtils( processUtils = ProcessUtils(
logger: logger, logger: logger,
@ -657,7 +654,6 @@ STDERR STUFF
Platform: () => macosPlatform, Platform: () => macosPlatform,
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true), FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform), FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform),
Usage: () => usage,
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
}); });
testUsingContext('Performs code size analysis and sends analytics from arm64 host', () async { testUsingContext('Performs code size analysis and sends analytics from arm64 host', () async {
@ -682,9 +678,6 @@ STDERR STUFF
expect(testLogger.statusText, contains('A summary of your macOS bundle analysis can be found at')); expect(testLogger.statusText, contains('A summary of your macOS bundle analysis can be found at'));
expect(testLogger.statusText, contains('dart devtools --appSizeBase=')); expect(testLogger.statusText, contains('dart devtools --appSizeBase='));
expect(usage.events, contains(
const TestUsageEvent('code-size-analysis', 'macos'),
));
expect(fakeAnalytics.sentEvents, contains(Event.codeSizeAnalysis(platform: 'macos'))); expect(fakeAnalytics.sentEvents, contains(Event.codeSizeAnalysis(platform: 'macos')));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
@ -711,7 +704,6 @@ STDERR STUFF
Platform: () => macosPlatform, Platform: () => macosPlatform,
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true), FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform), FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform),
Usage: () => usage,
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
}); });

View File

@ -11,7 +11,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_windows.dart'; import 'package:flutter_tools/src/commands/build_windows.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/windows/build_windows.dart'; import 'package:flutter_tools/src/windows/build_windows.dart';
import 'package:flutter_tools/src/windows/visual_studio.dart'; import 'package:flutter_tools/src/windows/visual_studio.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
@ -47,7 +46,6 @@ final Platform notWindowsPlatform = FakePlatform(
void main() { void main() {
late MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
late ProcessManager processManager; late ProcessManager processManager;
late TestUsage usage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
setUpAll(() { setUpAll(() {
@ -58,7 +56,6 @@ void main() {
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
Cache.flutterRoot = flutterRoot; Cache.flutterRoot = flutterRoot;
usage = TestUsage();
fakeAnalytics = getInitializedFakeAnalyticsInstance( fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem, fs: fileSystem,
fakeFlutterVersion: FakeFlutterVersion(), fakeFlutterVersion: FakeFlutterVersion(),
@ -997,9 +994,6 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
expect(testLogger.statusText, contains('A summary of your Windows bundle analysis can be found at')); expect(testLogger.statusText, contains('A summary of your Windows bundle analysis can be found at'));
expect(testLogger.statusText, contains('dart devtools --appSizeBase=')); expect(testLogger.statusText, contains('dart devtools --appSizeBase='));
expect(usage.events, contains(
const TestUsageEvent('code-size-analysis', 'windows'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.codeSizeAnalysis(platform: 'windows') Event.codeSizeAnalysis(platform: 'windows')
)); ));
@ -1009,7 +1003,6 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
ProcessManager: () => processManager, ProcessManager: () => processManager,
Platform: () => windowsPlatform, Platform: () => windowsPlatform,
FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: windowsPlatform), FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: windowsPlatform),
Usage: () => usage,
Analytics: () => fakeAnalytics, Analytics: () => fakeAnalytics,
}); });

View File

@ -15,8 +15,8 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_apk.dart'; import 'package:flutter_tools/src/commands/build_apk.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/testing.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
import '../../src/android_common.dart'; import '../../src/android_common.dart';
@ -31,11 +31,9 @@ void main() {
group('Usage', () { group('Usage', () {
late Directory tempDir; late Directory tempDir;
late TestUsage testUsage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
setUp(() { setUp(() {
testUsage = TestUsage();
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
fakeAnalytics = getInitializedFakeAnalyticsInstance( fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: MemoryFileSystem.test(), fs: MemoryFileSystem.test(),
@ -50,9 +48,7 @@ void main() {
testUsingContext('indicate the default target platforms', () async { testUsingContext('indicate the default target platforms', () async {
final String projectPath = await createProject(tempDir, final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=app']); arguments: <String>['--no-pub', '--template=app']);
final BuildApkCommand command = await runBuildApkCommand(projectPath); await runBuildApkCommand(projectPath);
expect((await command.usageValues).commandBuildApkTargetPlatform, 'android-arm,android-arm64,android-x64');
expect( expect(
fakeAnalytics.sentEvents, fakeAnalytics.sentEvents,
@ -77,11 +73,19 @@ void main() {
final BuildApkCommand commandWithFlag = await runBuildApkCommand(projectPath, final BuildApkCommand commandWithFlag = await runBuildApkCommand(projectPath,
arguments: <String>['--split-per-abi']); arguments: <String>['--split-per-abi']);
expect((await commandWithFlag.usageValues).commandBuildApkSplitPerAbi, true);
expect(
(await commandWithFlag.unifiedAnalyticsUsageValues('run'))
.eventData['buildApkSplitPerAbi'],
isTrue,
);
final BuildApkCommand commandWithoutFlag = await runBuildApkCommand(projectPath); final BuildApkCommand commandWithoutFlag = await runBuildApkCommand(projectPath);
expect((await commandWithoutFlag.usageValues).commandBuildApkSplitPerAbi, false); expect(
(await commandWithoutFlag.unifiedAnalyticsUsageValues('run'))
.eventData['buildApkSplitPerAbi'],
isFalse
);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
AndroidBuilder: () => FakeAndroidBuilder(), AndroidBuilder: () => FakeAndroidBuilder(),
}); });
@ -90,23 +94,27 @@ void main() {
final String projectPath = await createProject(tempDir, final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=app']); arguments: <String>['--no-pub', '--template=app']);
final BuildApkCommand commandDefault = await runBuildApkCommand(projectPath); final BuildApkCommand defaultBuildCommand = await runBuildApkCommand(projectPath);
expect((await commandDefault.usageValues).commandBuildApkBuildMode, 'release'); final Event defaultBuildCommandUsageValues = await defaultBuildCommand.unifiedAnalyticsUsageValues('build');
expect(defaultBuildCommandUsageValues.eventData['buildApkBuildMode'], 'release');
final BuildApkCommand commandInRelease = await runBuildApkCommand(projectPath, final BuildApkCommand releaseBuildCommand = await runBuildApkCommand(projectPath, arguments: <String>['--release']);
arguments: <String>['--release']); final Event releaseBuildCommandUsageValues = await releaseBuildCommand.unifiedAnalyticsUsageValues('build');
expect((await commandInRelease.usageValues).commandBuildApkBuildMode, 'release'); expect(releaseBuildCommandUsageValues.eventData['buildApkBuildMode'], 'release');
final BuildApkCommand commandInDebug = await runBuildApkCommand(projectPath, final BuildApkCommand debugBuildCommand = await runBuildApkCommand(projectPath, arguments: <String>['--debug']);
arguments: <String>['--debug']); final Event debugBuildCommandUsageValues = await debugBuildCommand.unifiedAnalyticsUsageValues('build');
expect((await commandInDebug.usageValues).commandBuildApkBuildMode, 'debug'); expect(debugBuildCommandUsageValues.eventData['buildApkBuildMode'], 'debug');
final BuildApkCommand commandInProfile = await runBuildApkCommand(projectPath, final BuildApkCommand profileBuildCommand = await runBuildApkCommand(projectPath, arguments: <String>['--profile']);
arguments: <String>['--profile']); final Event profileBuildCommandUsageValues = await profileBuildCommand.unifiedAnalyticsUsageValues('build');
expect((await commandInProfile.usageValues).commandBuildApkBuildMode, 'profile'); expect(profileBuildCommandUsageValues.eventData['buildApkBuildMode'], 'profile');
fakeAnalytics.sentEvents.clear();
await runBuildApkCommand(projectPath, arguments: <String>['--profile']);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
AndroidBuilder: () => FakeAndroidBuilder(), AndroidBuilder: () => FakeAndroidBuilder(),
Analytics: () => fakeAnalytics,
}); });
testUsingContext('logs success', () async { testUsingContext('logs success', () async {
@ -115,22 +123,22 @@ void main() {
await runBuildApkCommand(projectPath); await runBuildApkCommand(projectPath);
expect(testUsage.events, contains( final Iterable<Event> successEvent = fakeAnalytics.sentEvents.where(
const TestUsageEvent( (Event e) =>
'tool-command-result', e.eventName == DashEvent.flutterCommandResult &&
'apk', e.eventData['commandPath'] == 'create' &&
label: 'success', e.eventData['result'] == 'success',
), );
)); expect(successEvent, isNotEmpty, reason: 'Tool should send create success event');
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
AndroidBuilder: () => FakeAndroidBuilder(), AndroidBuilder: () => FakeAndroidBuilder(),
Usage: () => testUsage, Analytics: () => fakeAnalytics,
}); });
group('Impeller AndroidManifest.xml setting', () { group('Impeller AndroidManifest.xml setting', () {
// Adds a key-value `<meta-data>` pair to the `<application>` tag in the // Adds a key-value `<meta-data>` pair to the `<application>` tag in the
// cooresponding `AndroidManifest.xml` file, right before the closing // corresponding `AndroidManifest.xml` file, right before the closing
// `</application>` tag. // `</application>` tag.
void writeManifestMetadata({ void writeManifestMetadata({
required String projectPath, required String projectPath,
@ -248,15 +256,18 @@ void main() {
late FakeProcessManager processManager; late FakeProcessManager processManager;
late String gradlew; late String gradlew;
late AndroidSdk mockAndroidSdk; late AndroidSdk mockAndroidSdk;
late TestUsage testUsage; late FakeAnalytics analytics;
setUp(() { setUp(() {
testUsage = TestUsage();
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', 'android', gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', 'android',
globals.platform.isWindows ? 'gradlew.bat' : 'gradlew'); globals.platform.isWindows ? 'gradlew.bat' : 'gradlew');
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
mockAndroidSdk = FakeAndroidSdk(globals.fs.directory('irrelevant')); mockAndroidSdk = FakeAndroidSdk(globals.fs.directory('irrelevant'));
analytics = getInitializedFakeAnalyticsInstance(
fs: MemoryFileSystem.test(),
fakeFlutterVersion: FakeFlutterVersion(),
);
}); });
tearDown(() { tearDown(() {
@ -449,14 +460,16 @@ void main() {
containsIgnoringWhitespace('To learn more, see: https://developer.android.com/studio/build/shrink-code'), containsIgnoringWhitespace('To learn more, see: https://developer.android.com/studio/build/shrink-code'),
) )
); );
expect(testUsage.events, contains(
const TestUsageEvent( expect(
'build', analytics.sentEvents,
'gradle', contains(
Event.flutterBuildInfo(
label: 'gradle-r8-failure', label: 'gradle-r8-failure',
parameters: CustomDimensions(), buildType: 'gradle',
), ),
)); ),
);
expect(processManager, hasNoRemainingExpectations); expect(processManager, hasNoRemainingExpectations);
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
@ -464,7 +477,7 @@ void main() {
Java: () => null, Java: () => null,
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir), FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
ProcessManager: () => processManager, ProcessManager: () => processManager,
Usage: () => testUsage, Analytics: () => analytics,
AndroidStudio: () => FakeAndroidStudio(), AndroidStudio: () => FakeAndroidStudio(),
}); });
@ -503,14 +516,14 @@ void main() {
), ),
), ),
); );
expect(testUsage.events, contains(
const TestUsageEvent( expect(
'build', analytics.sentEvents,
'gradle', contains(
label: 'app-not-using-android-x', Event.flutterBuildInfo(
parameters: CustomDimensions(), label: 'app-not-using-android-x', buildType: 'gradle'),
), ),
)); );
expect(processManager, hasNoRemainingExpectations); expect(processManager, hasNoRemainingExpectations);
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
@ -518,7 +531,7 @@ void main() {
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir), FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
Java: () => null, Java: () => null,
ProcessManager: () => processManager, ProcessManager: () => processManager,
Usage: () => testUsage, Analytics: () => analytics,
AndroidStudio: () => FakeAndroidStudio(), AndroidStudio: () => FakeAndroidStudio(),
}); });
@ -550,14 +563,14 @@ void main() {
)) ))
), ),
); );
expect(testUsage.events, contains(
const TestUsageEvent( expect(
'build', analytics.sentEvents,
'gradle', contains(Event.flutterBuildInfo(
label: 'app-using-android-x', label: 'app-using-android-x',
parameters: CustomDimensions(), buildType: 'gradle',
), )),
)); );
expect(processManager, hasNoRemainingExpectations); expect(processManager, hasNoRemainingExpectations);
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
@ -565,7 +578,7 @@ void main() {
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir), FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
Java: () => null, Java: () => null,
ProcessManager: () => processManager, ProcessManager: () => processManager,
Usage: () => testUsage, Analytics: () => analytics,
AndroidStudio: () => FakeAndroidStudio(), AndroidStudio: () => FakeAndroidStudio(),
}); });
}); });

View File

@ -12,7 +12,6 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_appbundle.dart'; import 'package:flutter_tools/src/commands/build_appbundle.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -25,14 +24,12 @@ import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
Cache.disableLocking(); Cache.disableLocking();
group('Usage', () { group('analytics', () {
late Directory tempDir; late Directory tempDir;
late TestUsage testUsage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
setUp(() { setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
testUsage = TestUsage();
fakeAnalytics = getInitializedFakeAnalyticsInstance( fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: MemoryFileSystem.test(), fs: MemoryFileSystem.test(),
fakeFlutterVersion: FakeFlutterVersion(), fakeFlutterVersion: FakeFlutterVersion(),
@ -46,9 +43,8 @@ void main() {
testUsingContext('indicate the default target platforms', () async { testUsingContext('indicate the default target platforms', () async {
final String projectPath = await createProject(tempDir, final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=app']); arguments: <String>['--no-pub', '--template=app']);
final BuildAppBundleCommand command = await runBuildAppBundleCommand(projectPath);
expect((await command.usageValues).commandBuildAppBundleTargetPlatform, 'android-arm,android-arm64,android-x64'); await runBuildAppBundleCommand(projectPath);
expect( expect(
fakeAnalytics.sentEvents, fakeAnalytics.sentEvents,
@ -74,23 +70,56 @@ void main() {
final String projectPath = await createProject(tempDir, final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=app']); arguments: <String>['--no-pub', '--template=app']);
final BuildAppBundleCommand commandDefault = await runBuildAppBundleCommand(projectPath); await runBuildAppBundleCommand(projectPath);
expect((await commandDefault.usageValues).commandBuildAppBundleBuildMode, 'release'); expect(
fakeAnalytics.sentEvents,
contains(Event.commandUsageValues(
workflow: 'appbundle',
commandHasTerminal: false,
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
buildAppBundleBuildMode: 'release',
)),
);
final BuildAppBundleCommand commandInRelease = await runBuildAppBundleCommand(projectPath, fakeAnalytics.sentEvents.clear();
arguments: <String>['--release']); await runBuildAppBundleCommand(projectPath, arguments: <String>['--release']);
expect((await commandInRelease.usageValues).commandBuildAppBundleBuildMode, 'release'); expect(
fakeAnalytics.sentEvents,
contains(Event.commandUsageValues(
workflow: 'appbundle',
commandHasTerminal: false,
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
buildAppBundleBuildMode: 'release',
)),
);
final BuildAppBundleCommand commandInDebug = await runBuildAppBundleCommand(projectPath, fakeAnalytics.sentEvents.clear();
arguments: <String>['--debug']); await runBuildAppBundleCommand(projectPath, arguments: <String>['--debug']);
expect((await commandInDebug.usageValues).commandBuildAppBundleBuildMode, 'debug'); expect(
fakeAnalytics.sentEvents,
contains(Event.commandUsageValues(
workflow: 'appbundle',
commandHasTerminal: false,
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
buildAppBundleBuildMode: 'debug',
)),
);
final BuildAppBundleCommand commandInProfile = await runBuildAppBundleCommand(projectPath, fakeAnalytics.sentEvents.clear();
arguments: <String>['--profile']); await runBuildAppBundleCommand(projectPath, arguments: <String>['--profile']);
expect((await commandInProfile.usageValues).commandBuildAppBundleBuildMode, 'profile');
expect(
fakeAnalytics.sentEvents,
contains(Event.commandUsageValues(
workflow: 'appbundle',
commandHasTerminal: false,
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
buildAppBundleBuildMode: 'profile',
)),
);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
AndroidBuilder: () => FakeAndroidBuilder(), AndroidBuilder: () => FakeAndroidBuilder(),
Analytics: () => fakeAnalytics,
}); });
testUsingContext('logs success', () async { testUsingContext('logs success', () async {
@ -99,27 +128,38 @@ void main() {
await runBuildAppBundleCommand(projectPath); await runBuildAppBundleCommand(projectPath);
expect(testUsage.events, contains( expect(
const TestUsageEvent('tool-command-result', 'appbundle', label: 'success'), fakeAnalytics.sentEvents,
)); contains(
Event.flutterCommandResult(
commandPath: 'create',
result: 'success',
commandHasTerminal: false,
maxRss: globals.processInfo.maxRss,
),
),
);
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
AndroidBuilder: () => FakeAndroidBuilder(), AndroidBuilder: () => FakeAndroidBuilder(),
Usage: () => testUsage, Analytics: () => fakeAnalytics,
}); });
}); });
group('Gradle', () { group('Gradle', () {
late Directory tempDir; late Directory tempDir;
late FakeProcessManager processManager; late FakeProcessManager processManager;
late FakeAndroidSdk fakeAndroidSdk; late FakeAndroidSdk androidSdk;
late TestUsage testUsage; late FakeAnalytics analytics;
setUp(() { setUp(() {
testUsage = TestUsage(); analytics = getInitializedFakeAnalyticsInstance(
fs: MemoryFileSystem.test(),
fakeFlutterVersion: FakeFlutterVersion(),
);
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
processManager = FakeProcessManager.any(); processManager = FakeProcessManager.any();
fakeAndroidSdk = FakeAndroidSdk(globals.fs.directory('irrelevant')); androidSdk = FakeAndroidSdk(globals.fs.directory('irrelevant'));
}); });
tearDown(() { tearDown(() {
@ -176,20 +216,18 @@ void main() {
), ),
); );
expect(testUsage.events, contains( expect(analytics.sentEvents, contains(
const TestUsageEvent( Event.flutterBuildInfo(
'build',
'gradle',
label: 'app-not-using-android-x', label: 'app-not-using-android-x',
parameters: CustomDimensions(), buildType: 'gradle',
), ),
)); ));
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
AndroidSdk: () => fakeAndroidSdk, AndroidSdk: () => androidSdk,
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir), FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
ProcessManager: () => processManager, ProcessManager: () => processManager,
Usage: () => testUsage, Analytics: () => analytics,
}); });
testUsingContext('reports when the app is using AndroidX', () async { testUsingContext('reports when the app is using AndroidX', () async {
@ -216,20 +254,18 @@ void main() {
) )
); );
expect(testUsage.events, contains( expect(analytics.sentEvents, contains(
const TestUsageEvent( Event.flutterBuildInfo(
'build',
'gradle',
label: 'app-using-android-x', label: 'app-using-android-x',
parameters: CustomDimensions(), buildType: 'gradle',
), ),
)); ));
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
AndroidSdk: () => fakeAndroidSdk, AndroidSdk: () => androidSdk,
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir), FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
ProcessManager: () => processManager, ProcessManager: () => processManager,
Usage: () => testUsage, Analytics: () => analytics,
}); });
}); });
} }

View File

@ -21,7 +21,6 @@ import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -44,7 +43,6 @@ const String minimalV2EmbeddingManifest = r'''
void main() { void main() {
group('gradle build', () { group('gradle build', () {
late BufferLogger logger; late BufferLogger logger;
late TestUsage testUsage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
late MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
late FakeProcessManager processManager; late FakeProcessManager processManager;
@ -52,7 +50,6 @@ void main() {
setUp(() { setUp(() {
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
logger = BufferLogger.test(); logger = BufferLogger.test();
testUsage = TestUsage();
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
Cache.flutterRoot = ''; Cache.flutterRoot = '';
@ -69,7 +66,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -149,16 +145,6 @@ void main() {
expect(handlerCalled, isTrue); expect(handlerCalled, isTrue);
expect(testUsage.events, contains(
const TestUsageEvent(
'build',
'gradle',
label: 'gradle-random-event-label-failure',
parameters: CustomDimensions(),
),
));
expect(testUsage.events, hasLength(2));
expect( expect(
fakeAnalytics.sentEvents, fakeAnalytics.sentEvents,
containsAll(<Event>[ containsAll(<Event>[
@ -187,7 +173,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -262,7 +247,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -355,15 +339,6 @@ void main() {
expect(logger.statusText, contains('Retrying Gradle Build: #2, wait time: 200ms')); expect(logger.statusText, contains('Retrying Gradle Build: #2, wait time: 200ms'));
expect(testFnCalled, equals(maxRetries + 1)); expect(testFnCalled, equals(maxRetries + 1));
expect(testUsage.events, contains(
const TestUsageEvent(
'build',
'gradle',
label: 'gradle-random-event-label-failure',
parameters: CustomDimensions(),
),
));
expect(testUsage.events, hasLength(4));
expect(fakeAnalytics.sentEvents, hasLength(7)); expect(fakeAnalytics.sentEvents, hasLength(7));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
@ -383,7 +358,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -463,16 +437,6 @@ void main() {
expect(handlerCalled, isTrue); expect(handlerCalled, isTrue);
expect(testUsage.events, contains(
const TestUsageEvent(
'build',
'gradle',
label: 'gradle-random-event-label-failure',
parameters: CustomDimensions(),
),
));
expect(testUsage.events, hasLength(2));
expect(fakeAnalytics.sentEvents, hasLength(3)); expect(fakeAnalytics.sentEvents, hasLength(3));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.flutterBuildInfo( Event.flutterBuildInfo(
@ -492,7 +456,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -564,7 +527,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -654,14 +616,14 @@ void main() {
), ),
], ],
); );
expect(testUsage.events, contains(
const TestUsageEvent( expect(
'build', fakeAnalytics.sentEvents,
'gradle', contains(
label: 'gradle-random-event-label-success', Event.flutterBuildInfo(
parameters: CustomDimensions(), label: 'gradle-random-event-label-success', buildType: 'gradle'),
), ),
)); );
expect(processManager, hasNoRemainingExpectations); expect(processManager, hasNoRemainingExpectations);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
AndroidStudio: () => FakeAndroidStudio(), AndroidStudio: () => FakeAndroidStudio(),
@ -674,7 +636,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform( platform: FakePlatform(
@ -766,12 +727,10 @@ void main() {
localGradleErrors: <GradleHandledError>[], localGradleErrors: <GradleHandledError>[],
); );
expect(testUsage.events, contains( expect(
const TestUsageEvent( fakeAnalytics.sentEvents,
'code-size-analysis', contains(Event.codeSizeAnalysis(platform: 'apk')),
'apk', );
),
));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
AndroidStudio: () => FakeAndroidStudio(), AndroidStudio: () => FakeAndroidStudio(),
}); });
@ -783,7 +742,6 @@ void main() {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -922,7 +880,6 @@ android {
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -968,7 +925,6 @@ BuildVariant: paidProfile
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1002,7 +958,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1043,7 +998,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1127,7 +1081,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1194,7 +1147,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1262,7 +1214,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1348,7 +1299,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm64', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm64', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1434,7 +1384,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x86', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x86', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1520,7 +1469,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x64', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x64', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1607,7 +1555,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1674,7 +1621,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1771,7 +1717,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm64', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm64', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1867,7 +1812,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x86', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x86', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),
@ -1963,7 +1907,6 @@ Gradle Crashed
processManager: processManager, processManager: processManager,
fileSystem: fileSystem, fileSystem: fileSystem,
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x64', localEngineHost: 'out/host_release'), artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x64', localEngineHost: 'out/host_release'),
usage: testUsage,
analytics: fakeAnalytics, analytics: fakeAnalytics,
gradleUtils: FakeGradleUtils(), gradleUtils: FakeGradleUtils(),
platform: FakePlatform(), platform: FakePlatform(),

View File

@ -8,7 +8,6 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
import '../../src/common.dart'; import '../../src/common.dart';
@ -37,7 +36,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -56,7 +54,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -75,7 +72,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -94,7 +90,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -113,7 +108,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -132,7 +126,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -151,7 +144,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -170,7 +162,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -189,7 +180,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -208,7 +198,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -227,7 +216,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -241,7 +229,6 @@ void main() {
project, project,
BuildInfo.debug, BuildInfo.debug,
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -260,7 +247,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -279,7 +265,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -298,7 +283,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -317,7 +301,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -336,7 +319,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -355,7 +337,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -374,7 +355,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -393,7 +373,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -407,7 +386,6 @@ void main() {
project, project,
BuildInfo.debug, BuildInfo.debug,
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -426,7 +404,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -445,7 +422,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -464,7 +440,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -483,7 +458,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -503,7 +477,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -523,7 +496,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
TestUsage(),
fakeAnalytics, fakeAnalytics,
); );
@ -533,7 +505,6 @@ void main() {
testWithoutContext('AAB not found', () { testWithoutContext('AAB not found', () {
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory); final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
final TestUsage testUsage = TestUsage();
expect( expect(
() { () {
findBundleFile( findBundleFile(
@ -545,7 +516,6 @@ void main() {
packageConfigPath: '.dart_tool/package_config.json', packageConfigPath: '.dart_tool/package_config.json',
), ),
BufferLogger.test(), BufferLogger.test(),
testUsage,
fakeAnalytics, fakeAnalytics,
); );
}, },
@ -553,16 +523,6 @@ void main() {
message: message:
"Gradle build failed to produce an .aab file. It's likely that this file " "Gradle build failed to produce an .aab file. It's likely that this file "
"was generated under ${project.android.buildDirectory.path}, but the tool couldn't find it.")); "was generated under ${project.android.buildDirectory.path}, but the tool couldn't find it."));
expect(testUsage.events, contains(
TestUsageEvent(
'build',
'gradle',
label: 'gradle-expected-file-not-found',
parameters: CustomDimensions.fromMap(<String, String> {
'cd37': 'androidGradlePluginVersion: 7.6.3, fileExtension: .aab',
}),
),
));
expect(fakeAnalytics.sentEvents, hasLength(1)); expect(fakeAnalytics.sentEvents, hasLength(1));
expect( expect(
fakeAnalytics.sentEvents, fakeAnalytics.sentEvents,

View File

@ -7,7 +7,6 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/analyze_size.dart'; import 'package:flutter_tools/src/base/analyze_size.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
import '../../src/common.dart'; import '../../src/common.dart';
@ -66,7 +65,6 @@ void main() {
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
appFilenamePattern: RegExp(r'lib.*app\.so'), appFilenamePattern: RegExp(r'lib.*app\.so'),
flutterUsage: TestUsage(),
analytics: const NoOpAnalytics(), analytics: const NoOpAnalytics(),
); );
@ -151,7 +149,6 @@ void main() {
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
appFilenamePattern: RegExp(r'lib.*app\.so'), appFilenamePattern: RegExp(r'lib.*app\.so'),
flutterUsage: TestUsage(),
analytics: const NoOpAnalytics(), analytics: const NoOpAnalytics(),
); );
@ -194,7 +191,6 @@ void main() {
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
appFilenamePattern: RegExp(r'lib.*app\.so'), appFilenamePattern: RegExp(r'lib.*app\.so'),
flutterUsage: TestUsage(),
analytics: const NoOpAnalytics(), analytics: const NoOpAnalytics(),
); );
@ -238,7 +234,6 @@ void main() {
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
appFilenamePattern: RegExp(r'lib.*app\.so'), appFilenamePattern: RegExp(r'lib.*app\.so'),
flutterUsage: TestUsage(),
analytics: const NoOpAnalytics(), analytics: const NoOpAnalytics(),
); );

View File

@ -21,7 +21,6 @@ import 'package:flutter_tools/src/migrations/cocoapods_toolchain_directory_migra
import 'package:flutter_tools/src/migrations/xcode_project_object_version_migration.dart'; import 'package:flutter_tools/src/migrations/xcode_project_object_version_migration.dart';
import 'package:flutter_tools/src/migrations/xcode_script_build_phase_migration.dart'; import 'package:flutter_tools/src/migrations/xcode_script_build_phase_migration.dart';
import 'package:flutter_tools/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart'; import 'package:flutter_tools/src/migrations/xcode_thin_binary_build_phase_input_paths_migration.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/xcode_project.dart'; import 'package:flutter_tools/src/xcode_project.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -32,15 +31,11 @@ import '../../src/fakes.dart';
void main () { void main () {
group('iOS migration', () { group('iOS migration', () {
late TestUsage testUsage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
setUp(() { setUp(() {
testUsage = TestUsage();
final MemoryFileSystem fs = MemoryFileSystem.test();
fakeAnalytics = getInitializedFakeAnalyticsInstance( fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fs, fs: MemoryFileSystem.test(),
fakeFlutterVersion: FakeFlutterVersion(), fakeFlutterVersion: FakeFlutterVersion(),
); );
}); });
@ -69,11 +64,9 @@ void main () {
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
await iosProjectMigration.migrate(); await iosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(fakeAnalytics.sentEvents, isEmpty); expect(fakeAnalytics.sentEvents, isEmpty);
expect(xcodeProjectInfoFile.existsSync(), isFalse); expect(xcodeProjectInfoFile.existsSync(), isFalse);
@ -90,11 +83,9 @@ void main () {
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
await iosProjectMigration.migrate(); await iosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(fakeAnalytics.sentEvents, isEmpty); expect(fakeAnalytics.sentEvents, isEmpty);
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified); expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
@ -112,7 +103,6 @@ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
await iosProjectMigration.migrate(); await iosProjectMigration.migrate();
@ -140,11 +130,9 @@ keep this 2
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
await iosProjectMigration.migrate(); await iosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(fakeAnalytics.sentEvents, isEmpty); expect(fakeAnalytics.sentEvents, isEmpty);
expect(xcodeProjectInfoFile.readAsStringSync(), r''' expect(xcodeProjectInfoFile.readAsStringSync(), r'''
@ -163,14 +151,11 @@ keep this 2
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
expect(testUsage.events, contains(
const TestUsageEvent('ios-migration', 'remove-frameworks', label: 'failure'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.appleUsageEvent( Event.appleUsageEvent(
workflow: 'ios-migration', workflow: 'ios-migration',
@ -188,13 +173,9 @@ keep this 2
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
expect(testUsage.events, contains(
const TestUsageEvent('ios-migration', 'remove-frameworks', label: 'failure'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.appleUsageEvent( Event.appleUsageEvent(
workflow: 'ios-migration', workflow: 'ios-migration',
@ -212,13 +193,10 @@ keep this 2
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
project, project,
testLogger, testLogger,
testUsage,
fakeAnalytics, fakeAnalytics,
); );
expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
expect(testUsage.events, contains(
const TestUsageEvent('ios-migration', 'remove-frameworks', label: 'failure'),
));
expect(fakeAnalytics.sentEvents, contains( expect(fakeAnalytics.sentEvents, contains(
Event.appleUsageEvent( Event.appleUsageEvent(
workflow: 'ios-migration', workflow: 'ios-migration',

View File

@ -16,7 +16,6 @@ import 'package:flutter_tools/src/ios/code_signing.dart';
import 'package:flutter_tools/src/ios/mac.dart'; import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/ios/xcresult.dart'; import 'package:flutter_tools/src/ios/xcresult.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart'; import 'package:unified_analytics/unified_analytics.dart';
@ -191,14 +190,12 @@ void main() {
group('Diagnose Xcode build failure', () { group('Diagnose Xcode build failure', () {
late Map<String, String> buildSettings; late Map<String, String> buildSettings;
late TestUsage testUsage;
late FakeAnalytics fakeAnalytics; late FakeAnalytics fakeAnalytics;
setUp(() { setUp(() {
buildSettings = <String, String>{ buildSettings = <String, String>{
'PRODUCT_BUNDLE_IDENTIFIER': 'test.app', 'PRODUCT_BUNDLE_IDENTIFIER': 'test.app',
}; };
testUsage = TestUsage();
final MemoryFileSystem fs = MemoryFileSystem.test(); final MemoryFileSystem fs = MemoryFileSystem.test();
fakeAnalytics = getInitializedFakeAnalyticsInstance( fakeAnalytics = getInitializedFakeAnalyticsInstance(
@ -222,24 +219,12 @@ void main() {
final MemoryFileSystem fs = MemoryFileSystem.test(); final MemoryFileSystem fs = MemoryFileSystem.test();
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
platform: SupportedPlatform.ios, platform: SupportedPlatform.ios,
project: FakeFlutterProject(fileSystem: fs), project: FakeFlutterProject(fileSystem: fs),
); );
expect(testUsage.events, contains(
TestUsageEvent(
'build',
'ios',
label: 'xcode-bitcode-failure',
parameters: CustomDimensions(
buildEventCommand: buildCommands.toString(),
buildEventSettings: buildSettings.toString(),
),
),
));
expect( expect(
fakeAnalytics.sentEvents, fakeAnalytics.sentEvents,
contains(Event.flutterBuildInfo( contains(Event.flutterBuildInfo(
@ -323,7 +308,6 @@ Error launching application on iPhone.''',
final MemoryFileSystem fs = MemoryFileSystem.test(); final MemoryFileSystem fs = MemoryFileSystem.test();
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -369,7 +353,6 @@ Error launching application on iPhone.''',
final MemoryFileSystem fs = MemoryFileSystem.test(); final MemoryFileSystem fs = MemoryFileSystem.test();
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -417,7 +400,6 @@ Could not build the precompiled application for the device.''',
final MemoryFileSystem fs = MemoryFileSystem.test(); final MemoryFileSystem fs = MemoryFileSystem.test();
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -469,7 +451,6 @@ Could not build the precompiled application for the device.''',
final MemoryFileSystem fs = MemoryFileSystem.test(); final MemoryFileSystem fs = MemoryFileSystem.test();
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -504,7 +485,6 @@ Could not build the precompiled application for the device.''',
project.ios.podfile.createSync(recursive: true); project.ios.podfile.createSync(recursive: true);
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -549,7 +529,6 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
project.ios.podfile.createSync(recursive: true); project.ios.podfile.createSync(recursive: true);
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -591,7 +570,6 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
project.ios.podfile.createSync(recursive: true); project.ios.podfile.createSync(recursive: true);
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -632,7 +610,6 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
project.ios.podfile.createSync(recursive: true); project.ios.podfile.createSync(recursive: true);
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,
@ -675,7 +652,6 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
.createSync(recursive: true); .createSync(recursive: true);
await diagnoseXcodeBuildFailure( await diagnoseXcodeBuildFailure(
buildResult, buildResult,
flutterUsage: testUsage,
logger: logger, logger: logger,
analytics: fakeAnalytics, analytics: fakeAnalytics,
fileSystem: fs, fileSystem: fs,