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
23 changes: 23 additions & 0 deletions e2e/demo_app/.maestro/issues/setPickerValue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Test for setPickerValue command on iOS UIPickerView.
##
## The demo app's "Picker Test" Flutter screen presents a native iOS
## PickerTestViewController via a method channel — this controller hosts
## a real UIPickerView (CupertinoPicker in Flutter does NOT render as a
## native UIPickerView, so XCTest's pickerWheels query can't see it).
##
## The flow opens the picker, asserts the default selection, calls
## setPickerValue: "United States", and asserts the picker's selected-
## value label updated.

appId: com.example.example
name: setPickerValue
tags:
- ios
---
- launchApp:
clearState: true
- tapOn: "Picker Test"
- tapOn: "Open Native Picker"
- assertVisible: "Selected: Afghanistan"
- setPickerValue: "United States"
- assertVisible: "Selected: United States"
26 changes: 26 additions & 0 deletions e2e/demo_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
A1B2C3D4E5F60001AABBCCDD /* PasswordTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4E5F60002AABBCCDD /* PasswordTestViewController.swift */; };
A1B2C3D4E5F61001AABBCCDD /* PickerTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4E5F61002AABBCCDD /* PickerTestViewController.swift */; };
A1B2C3D4E5F60003AABBCCDD /* HealthAccessManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4E5F60004AABBCCDD /* HealthAccessManager.swift */; };
8CD3B1C813F46CF508C7570F /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C84B54319100153F2E74F242 /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -57,6 +59,7 @@
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A1B2C3D4E5F60002AABBCCDD /* PasswordTestViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordTestViewController.swift; sourceTree = "<group>"; };
A1B2C3D4E5F61002AABBCCDD /* PickerTestViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerTestViewController.swift; sourceTree = "<group>"; };
A1B2C3D4E5F60004AABBCCDD /* HealthAccessManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HealthAccessManager.swift; sourceTree = "<group>"; };
A1B2C3D4E5F60005AABBCCDD /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand All @@ -70,6 +73,7 @@
C36038B188D853DA10C718D3 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
C84B54319100153F2E74F242 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DD6B8822E94F481C51C658F4 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -85,6 +89,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
8CD3B1C813F46CF508C7570F /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -112,6 +117,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
Expand Down Expand Up @@ -152,6 +158,7 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
A1B2C3D4E5F60002AABBCCDD /* PasswordTestViewController.swift */,
A1B2C3D4E5F61002AABBCCDD /* PickerTestViewController.swift */,
A1B2C3D4E5F60004AABBCCDD /* HealthAccessManager.swift */,
A1B2C3D4E5F60005AABBCCDD /* Runner.entitlements */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
Expand Down Expand Up @@ -196,6 +203,9 @@
productType = "com.apple.product-type.bundle.unit-test";
};
97C146ED1CF9000F007C117D /* Runner */ = {
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
Expand All @@ -222,6 +232,9 @@

/* Begin PBXProject section */
97C146E61CF9000F007C117D /* Project object */ = {
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */,
);
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
Expand Down Expand Up @@ -405,6 +418,7 @@
files = (
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
A1B2C3D4E5F60001AABBCCDD /* PasswordTestViewController.swift in Sources */,
A1B2C3D4E5F61001AABBCCDD /* PickerTestViewController.swift in Sources */,
A1B2C3D4E5F60003AABBCCDD /* HealthAccessManager.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
Expand Down Expand Up @@ -757,6 +771,18 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
141 changes: 81 additions & 60 deletions e2e/demo_app/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,96 @@ import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

// Set up method channel for password test screen
let controller = window?.rootViewController as! FlutterViewController
let passwordTestChannel = FlutterMethodChannel(
name: "com.example.demo_app/password_test",
binaryMessenger: controller.binaryMessenger
)
// Set up method channel for password test screen
let controller = window?.rootViewController as! FlutterViewController
let passwordTestChannel = FlutterMethodChannel(
name: "com.example.demo_app/password_test",
binaryMessenger: controller.binaryMessenger
)

passwordTestChannel.setMethodCallHandler { [weak self] (call, result) in
if call.method == "openPasswordTest" {
self?.openPasswordTestScreen()
result(nil)
} else {
result(FlutterMethodNotImplemented)
}
}
passwordTestChannel.setMethodCallHandler { [weak self] call, result in
if call.method == "openPasswordTest" {
self?.openPasswordTestScreen()
result(nil)
} else {
result(FlutterMethodNotImplemented)
}
}

let orientationChannel = FlutterMethodChannel(
name: "com.example.demo_app/orientation",
binaryMessenger: controller.binaryMessenger
)
let orientationChannel = FlutterMethodChannel(
name: "com.example.demo_app/orientation",
binaryMessenger: controller.binaryMessenger
)

UIDevice.current.beginGeneratingDeviceOrientationNotifications()
UIDevice.current.beginGeneratingDeviceOrientationNotifications()

orientationChannel.setMethodCallHandler { (call, result) in
if call.method == "getOrientation" {
switch UIDevice.current.orientation {
case .portrait: result("Portrait")
case .portraitUpsideDown: result("Portrait Upside Down")
case .landscapeLeft: result("Landscape Left")
case .landscapeRight: result("Landscape Right")
default: result("Unknown")
orientationChannel.setMethodCallHandler { call, result in
if call.method == "getOrientation" {
switch UIDevice.current.orientation {
case .portrait: result("Portrait")
case .portraitUpsideDown: result("Portrait Upside Down")
case .landscapeLeft: result("Landscape Left")
case .landscapeRight: result("Landscape Right")
default: result("Unknown")
}
} else {
result(FlutterMethodNotImplemented)
}
}
} else {
result(FlutterMethodNotImplemented)
}
}

let healthAccessChannel = FlutterMethodChannel(
name: "com.example.demo_app/health_access",
binaryMessenger: controller.binaryMessenger
)
let pickerTestChannel = FlutterMethodChannel(
name: "com.example.demo_app/picker_test",
binaryMessenger: controller.binaryMessenger
)

healthAccessChannel.setMethodCallHandler { (call, result) in
if call.method == "requestHealthAccess" {
HealthAccessManager.requestAuthorization { success, error in
if let error = error {
result(FlutterError(code: "HEALTH_ERROR", message: error.localizedDescription, details: nil))
} else {
result(success)
}
pickerTestChannel.setMethodCallHandler { [weak self] call, result in
if call.method == "openPickerTest" {
self?.openPickerTestScreen()
result(nil)
} else {
result(FlutterMethodNotImplemented)
}
}
} else {
result(FlutterMethodNotImplemented)
}

let healthAccessChannel = FlutterMethodChannel(
name: "com.example.demo_app/health_access",
binaryMessenger: controller.binaryMessenger
)

healthAccessChannel.setMethodCallHandler { call, result in
if call.method == "requestHealthAccess" {
HealthAccessManager.requestAuthorization { success, error in
if let error = error {
result(FlutterError(code: "HEALTH_ERROR", message: error.localizedDescription, details: nil))
} else {
result(success)
}
}
} else {
result(FlutterMethodNotImplemented)
}
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
private func openPasswordTestScreen() {
guard let rootViewController = window?.rootViewController else { return }
let passwordTestVC = PasswordTestViewController()
passwordTestVC.modalPresentationStyle = .fullScreen
rootViewController.present(passwordTestVC, animated: true)
}

private func openPasswordTestScreen() {
guard let rootViewController = window?.rootViewController else { return }
let passwordTestVC = PasswordTestViewController()
passwordTestVC.modalPresentationStyle = .fullScreen
rootViewController.present(passwordTestVC, animated: true)
}
}
private func openPickerTestScreen() {
guard let rootViewController = window?.rootViewController else { return }
let pickerTestVC = PickerTestViewController()
pickerTestVC.modalPresentationStyle = .fullScreen
rootViewController.present(pickerTestVC, animated: true)
}
}
Loading
Loading