Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(package_info_plus): Fix integration test for Android #3082

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:package_info_plus_example/main.dart';

const android14SDK = 34;

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

Expand All @@ -25,12 +28,19 @@ void main() {
expect(info.installerStore, null);
} else {
if (Platform.isAndroid) {
final androidVersionInfo = await DeviceInfoPlugin().androidInfo;

expect(info.appName, 'package_info_example');
expect(info.buildNumber, '4');
expect(info.buildSignature, isNotEmpty);
expect(info.packageName, 'io.flutter.plugins.packageinfoexample');
expect(info.version, '1.2.3');
expect(info.installerStore, null);
// Since Android 14 (API 34) OS returns com.android.shell when app is installed via package installer
if (androidVersionInfo.version.sdkInt >= android14SDK) {
expect(info.installerStore, 'com.android.shell');
} else {
expect(info.installerStore, null);
}
} else if (Platform.isIOS) {
expect(info.appName, 'Package Info Plus Example');
expect(info.buildNumber, '4');
Expand Down Expand Up @@ -75,13 +85,22 @@ void main() {
expect(find.text('not available'), findsOneWidget);
} else {
if (Platform.isAndroid) {
final androidVersionInfo = await DeviceInfoPlugin().androidInfo;

expect(find.text('package_info_example'), findsOneWidget);
expect(find.text('4'), findsOneWidget);
expect(
find.text('io.flutter.plugins.packageinfoexample'), findsOneWidget);
find.text('io.flutter.plugins.packageinfoexample'),
findsOneWidget,
);
expect(find.text('1.2.3'), findsOneWidget);
expect(find.text('Not set'), findsNothing);
expect(find.text('not available'), findsOneWidget);
// Since Android 14 (API 34) OS returns com.android.shell when app is installed via package installer
if (androidVersionInfo.version.sdkInt >= android14SDK) {
expect(find.text('com.android.shell'), findsOneWidget);
} else {
expect(find.text('not available'), findsOneWidget);
}
} else if (Platform.isIOS) {
expect(find.text('Package Info Plus Example'), findsOneWidget);
expect(find.text('4'), findsOneWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.3.3
device_info_plus: ^10.1.0
integration_test:
sdk: flutter
flutter_driver:
Expand Down
Loading