Upgrade Patrol to 4.5.0 (#4446)
This commit is contained in:
@@ -6,4 +6,6 @@ abstract class CoreRobot {
|
||||
CoreRobot(this.$);
|
||||
|
||||
dynamic ignoreException() => $.tester.takeException();
|
||||
|
||||
MobileAutomator get native => $.platformAutomator.mobile;
|
||||
}
|
||||
@@ -28,8 +28,8 @@ class TestBase {
|
||||
visibleTimeout: Duration(seconds: 30),
|
||||
printLogs: true,
|
||||
),
|
||||
nativeAutomatorConfig: const NativeAutomatorConfig(
|
||||
findTimeout: Duration(seconds: 10),
|
||||
platformAutomatorConfig: PlatformAutomatorConfig.fromOptions(
|
||||
findTimeout: const Duration(seconds: 10),
|
||||
),
|
||||
framePolicy: LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive,
|
||||
($) async {
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:io' hide HttpClient;
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/http/http_client.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:labels/extensions/list_label_extension.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:patrol/patrol.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/upload_attachment_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/create_new_and_send_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/upload_attachment_interactor.dart';
|
||||
@@ -287,4 +289,14 @@ mixin ScenarioUtilsMixin {
|
||||
void hideKeyboard() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
}
|
||||
|
||||
Future<void> mobileBack(PatrolIntegrationTester $) async {
|
||||
if (PlatformInfo.isIOS) {
|
||||
await $.platformAutomator.ios.swipeBack();
|
||||
} else if (PlatformInfo.isAndroid) {
|
||||
await $.platformAutomator.android.pressBack();
|
||||
} else {
|
||||
throw UnsupportedError('mobileBack() is only supported on Android/iOS');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ class ComposerRobot extends CoreRobot {
|
||||
}
|
||||
|
||||
Future<void> grantContactPermission() async {
|
||||
if (await $.native
|
||||
if (await native
|
||||
.isPermissionDialogVisible(timeout: const Duration(seconds: 5))) {
|
||||
await $.native.grantPermissionWhenInUse();
|
||||
await native.grantPermissionWhenInUse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patrol/patrol.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../base/core_robot.dart';
|
||||
@@ -10,9 +9,9 @@ class LoginRobot extends CoreRobot {
|
||||
|
||||
LoginRobot(super.$);
|
||||
|
||||
Future<void> grantNotificationPermission(NativeAutomator nativeAutomator) async {
|
||||
if (await nativeAutomator.isPermissionDialogVisible(timeout: const Duration(seconds: 1))) {
|
||||
await nativeAutomator.grantPermissionWhenInUse();
|
||||
Future<void> grantNotificationPermission() async {
|
||||
if (await native.isPermissionDialogVisible(timeout: const Duration(seconds: 1))) {
|
||||
await native.grantPermissionWhenInUse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class MailboxMenuRobot extends CoreRobot {
|
||||
}
|
||||
|
||||
Future<void> closeMenu() async {
|
||||
await $.native.swipe(from: const Offset(0.9, 0.5), to: const Offset(0, 0.5));
|
||||
await native.swipe(from: const Offset(0.9, 0.5), to: const Offset(0, 0.5));
|
||||
}
|
||||
|
||||
int getCurrentInboxCount() {
|
||||
@@ -130,8 +130,8 @@ class MailboxMenuRobot extends CoreRobot {
|
||||
}
|
||||
|
||||
Future<void> tapConfirmRecoverDeletedMessages() async {
|
||||
if (await $.native.isPermissionDialogVisible(timeout: const Duration(seconds: 2))) {
|
||||
await $.native.grantPermissionWhenInUse();
|
||||
if (await native.isPermissionDialogVisible(timeout: const Duration(seconds: 2))) {
|
||||
await native.grantPermissionWhenInUse();
|
||||
}
|
||||
await $(AppLocalizations().restore).tap();
|
||||
await $.pumpAndSettle();
|
||||
|
||||
@@ -35,19 +35,20 @@ class AppGridScenario extends BaseTestScenario {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
if (PlatformInfo.isAndroid) {
|
||||
await $.native.pressHome();
|
||||
await $.native.openApp();
|
||||
final native = $.platformAutomator.android;
|
||||
await native.pressHome();
|
||||
await native.openApp();
|
||||
|
||||
await appGridRobot.openAppInAppGridByAppName('Twake Sync');
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
await $.native.pressBack();
|
||||
await native.pressBack();
|
||||
|
||||
await appGridRobot.openAppInAppGridByAppName('Twake Chat');
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
await $.native.pressBack();
|
||||
await $.native.pressBack();
|
||||
await native.pressBack();
|
||||
await native.pressBack();
|
||||
|
||||
await _expectMailboxViewVisible();
|
||||
} else if (PlatformInfo.isIOS) {
|
||||
|
||||
@@ -45,6 +45,6 @@ class DownloadAllAttachmentsScenario extends BaseTestScenario {
|
||||
}
|
||||
|
||||
Future<void> _expectNativeSaveButtonVisible() async {
|
||||
await expectLater($.native.tap(Selector(text: 'SAVE')), completes);
|
||||
await expectLater($.platformAutomator.tap(Selector(text: 'SAVE')), completes);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class ExportAttachmentScenario extends BaseTestScenario {
|
||||
await emailRobot.onTapAttachmentItem();
|
||||
await $.pumpAndSettle();
|
||||
|
||||
await $.native.pressBack();
|
||||
await mobileBack($);
|
||||
_expectEmailViewVisible();
|
||||
_expectExportDialogLoadingInvisible(appLocalizations);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class LoginWithBasicAuthScenario extends BaseScenario {
|
||||
|
||||
await loginRobot.loginBasicAuth();
|
||||
|
||||
await loginRobot.grantNotificationPermission($.native);
|
||||
await loginRobot.grantNotificationPermission();
|
||||
|
||||
await _expectThreadViewVisible();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class SendEmailWithReadReceiptEnabledScenario extends BaseTestScenario {
|
||||
await threadRobot.openEmailWithSubject(emailSubject);
|
||||
await _expectReadReceiptRequestDialog(appLocalizations);
|
||||
|
||||
await $.native.pressBack();
|
||||
await mobileBack($);
|
||||
await emailRobot.onTapBackButton();
|
||||
|
||||
await $.pumpAndSettle(duration: seconds(5));
|
||||
|
||||
Reference in New Issue
Block a user