flutter/packages/flutter_tools/test/integration.shard/android_e2e_api_test.dart
Michael Goderbauer 5491c8c146
Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
2024-12-19 20:06:21 +00:00

73 lines
1.9 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/io.dart';
import '../src/common.dart';
import 'test_utils.dart';
void main() {
late Directory tempDir;
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
});
tearDown(() async {
tryToDelete(tempDir);
});
testWithoutContext('build succeeds with api 33 features', () async {
ProcessResult result = await processManager.run(<String>[
flutterBin,
'create',
tempDir.path,
'--project-name=testapp',
], workingDirectory: tempDir.path);
expect(result, const ProcessResultMatcher());
final File api33File = tempDir
.childDirectory('android')
.childDirectory('app')
.childDirectory('src')
.childDirectory('main')
.childDirectory('java')
.childFile('Android33Api.java');
api33File.createSync(recursive: true);
// AccessibilityManager.isAudioDescriptionRequested() is an API 33 feature
api33File.writeAsStringSync('''
import android.app.Activity;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.Keep;
import io.flutter.Log;
@Keep
public final class Android33Api extends Activity {
private AccessibilityManager accessibilityManager;
public Android33Api() {
accessibilityManager = getSystemService(AccessibilityManager.class);
}
public void doSomething() {
if (accessibilityManager.isAudioDescriptionRequested()) {
Log.e("flutter", "User has requested to enable audio descriptions");
}
}
}
''');
result = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'apk',
], workingDirectory: tempDir.path);
expect(result, const ProcessResultMatcher(stdoutPattern: 'app-release.apk'));
});
}