Skip to content
Open
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
3 changes: 3 additions & 0 deletions e2e/demo_app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# FVM Version Cache
.fvm/
13 changes: 13 additions & 0 deletions e2e/demo_app/.maestro/local_notification.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
appId: com.example.example
name: Local Notification Visible While App Foregrounded
tags:
- passing
---
- launchApp:
clearState: true
- scrollUntilVisible:
element:
text: "Trigger Local Notification"
direction: DOWN
- tapOn: "Trigger Local Notification"
- assertVisible: "Hello from Maestro"
5 changes: 5 additions & 0 deletions e2e/demo_app/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ android {
ndkVersion = flutter.ndkVersion

compileOptions {
isCoreLibraryDesugaringEnabled = true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without changes in this file, the Android build fails with

Execution failed for task ':app:checkReleaseAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > An issue was found when checking AAR metadata:

       1.  Dependency ':flutter_local_notifications' requires core library desugaring to be enabled
           for :app.

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Expand Down Expand Up @@ -39,3 +40,7 @@ android {
flutter {
source = "../.."
}

dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
}
24 changes: 15 additions & 9 deletions e2e/demo_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PODS:
- Flutter (1.0.0)
- flutter_launch_arguments (1.0.0):
- Flutter
- flutter_local_notifications (0.0.1):
- Flutter
- geolocator_apple (1.2.0):
- Flutter
- FlutterMacOS
Expand All @@ -27,6 +29,7 @@ DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- Flutter (from `Flutter`)
- flutter_launch_arguments (from `.symlinks/plugins/flutter_launch_arguments/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/darwin`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
Expand All @@ -43,6 +46,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_launch_arguments:
:path: ".symlinks/plugins/flutter_launch_arguments/ios"
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
geolocator_apple:
:path: ".symlinks/plugins/geolocator_apple/darwin"
integration_test:
Expand All @@ -57,16 +62,17 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"

SPEC CHECKSUMS:
app_links: 3dbc685f76b1693c66a6d9dd1e9ab6f73d97dc0a
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
app_links: 585674be3c6661708e6cd794ab4f39fb9d8356f9
connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_launch_arguments: 612fe2bfca02045d0bc01a54cb23cd5a562c9fdf
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
sensors_plus: 1c5f0a01ce21c609a4df404c4e6879d62bce287f
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
webview_flutter_wkwebview: 8ebf4fded22593026f7dbff1fbff31ea98573c8d
flutter_launch_arguments: 79c3d6c461611a8cbaba75da84498b62e88e33a2
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
geolocator_apple: 66b711889fd333205763b83c9dcf0a57a28c7afd
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
sensors_plus: 42b9de1b8237675fa8d8121e4bb93be0f79fa61d
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
webview_flutter_wkwebview: 29eb20d43355b48fe7d07113835b9128f84e3af4

PODFILE CHECKSUM: 7aecb2f8279eaf0912ef36bd3b92e7f32ff0fc1a

Expand Down
15 changes: 15 additions & 0 deletions e2e/demo_app/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Flutter
import UIKit
import UserNotifications

@main
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -9,6 +10,8 @@ import UIKit
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

UNUserNotificationCenter.current().delegate = self

// Set up method channel for password test screen
let controller = window?.rootViewController as! FlutterViewController
let passwordTestChannel = FlutterMethodChannel(
Expand Down Expand Up @@ -88,4 +91,16 @@ import UIKit
passwordTestVC.modalPresentationStyle = .fullScreen
rootViewController.present(passwordTestVC, animated: true)
}

override func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
if #available(iOS 14.0, *) {
completionHandler([.banner, .list, .badge, .sound])
} else {
completionHandler([.alert, .badge, .sound])
}
}
}
49 changes: 49 additions & 0 deletions e2e/demo_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_launch_arguments/flutter_launch_arguments.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'dart:async';
import 'dart:io' show Platform;
import 'package:app_links/app_links.dart';
Expand Down Expand Up @@ -117,6 +118,50 @@ class _MyHomePageState extends State<MyHomePage> {
});
}

Future<void> _triggerLocalNotification() async {
final plugin = FlutterLocalNotificationsPlugin();

await plugin.initialize(
const InitializationSettings(
iOS: DarwinInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
),
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
),
);

await plugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(alert: true, badge: false, sound: false);

await plugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestNotificationsPermission();

await plugin.show(
0,
'Maestro Local Notification',
'Hello from Maestro',
const NotificationDetails(
iOS: DarwinNotificationDetails(
presentAlert: true,
presentBanner: true,
presentList: true,
),
android: AndroidNotificationDetails(
'demo_app_local_notifications',
'Local Notifications',
importance: Importance.max,
priority: Priority.high,
),
),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -342,6 +387,10 @@ class _MyHomePageState extends State<MyHomePage> {
},
child: const Text('assertScreenshot Threshold'),
),
ElevatedButton(
onPressed: _triggerLocalNotification,
child: const Text('Trigger Local Notification'),
),
],
),
),
Expand Down
32 changes: 32 additions & 0 deletions e2e/demo_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: "674173fd3c9eda9d4c8528da2ce0ea69f161577495a9cc835a2a4ecd7eadeb35"
url: "https://pub.dev"
source: hosted
version: "17.2.4"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
sha256: c49bd06165cad9beeb79090b18cd1eb0296f4bf4b23b84426e37dd7c027fc3af
url: "https://pub.dev"
source: hosted
version: "4.0.1"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
sha256: "85f8d07fe708c1bdcf45037f2c0109753b26ae077e9d9e899d55971711a4ea66"
url: "https://pub.dev"
source: hosted
version: "7.2.0"
flutter_test:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -572,6 +596,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.10"
timezone:
dependency: transitive
description:
name: timezone
sha256: "2236ec079a174ce07434e89fcd3fcda430025eb7692244139a9cf54fdcf1fc7d"
url: "https://pub.dev"
source: hosted
version: "0.9.4"
typed_data:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions e2e/demo_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
flutter_launch_arguments: ^1.0.1
webview_flutter: ^4.13.0
permission_handler: ^11.3.1
flutter_local_notifications: ^17.2.4
sensors_plus: ^4.0.2
geolocator: ^13.0.1
connectivity_plus: ^7.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ struct ViewHierarchyHandler: HTTPHandler {
}
NSLog("[Start] View hierarchy snapshot for \(foregroundApp)")
let appViewHierarchy = try await getAppViewHierarchy(foregroundApp: foregroundApp, excludeKeyboardElements: requestBody.excludeKeyboardElements)
let viewHierarchy = ViewHierarchy.init(axElement: appViewHierarchy, depth: appViewHierarchy.depth())

NSLog("[Done] View hierarchy snapshot for \(foregroundApp) ")
let body = try JSONEncoder().encode(viewHierarchy)
let springboardHierarchy = try elementHierarchy(xcuiElement: springboardApplication)

let combinedAXElement = AXElement(children: [springboardHierarchy, appViewHierarchy])
let combinedViewHierarchy = ViewHierarchy(axElement: combinedAXElement, depth: combinedAXElement.depth())

NSLog("[Done] View hierarchy snapshot for \(foregroundApp)")
let body = try JSONEncoder().encode(combinedViewHierarchy)
return HTTPResponse(statusCode: .ok, body: body)
} catch let error as AppError {
NSLog("AppError in handleRequest, Error:\(error)");
Expand Down
Loading