Skip to content

Commit 708d88f

Browse files
hellohuanlinmauricioluz
authored andcommitted
[quick_actions]Migrate the XCUITests to Swift (flutter#6425)
1 parent a4e7473 commit 708d88f

File tree

4 files changed

+110
-103
lines changed

4 files changed

+110
-103
lines changed

packages/quick_actions/quick_actions_ios/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Migrates `RunnerUITests` to Swift.
4+
15
## 1.0.1
26

37
* Removes custom modulemap file with "Test" submodule and private headers for Swift migration.

packages/quick_actions/quick_actions_ios/example/ios/Runner.xcodeproj/project.pbxproj

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1111
2632072169FF635893D8EB4D /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 436668746754BEEA28B76E55 /* libPods-RunnerTests.a */; };
1212
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13-
686BE83025E58CCF00862533 /* RunnerUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 686BE82F25E58CCF00862533 /* RunnerUITests.m */; };
1413
6A841C2B6AED5CF8DB2A1894 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C35AD3650AB6BF850E016715 /* libPods-Runner.a */; };
1514
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1615
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
1716
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1817
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
1918
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
19+
E092A7F628D128EB005C7F67 /* RunnerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E092A7F528D128EB005C7F67 /* RunnerUITests.swift */; };
2020
E0C09C29289C729D00E6977E /* FLTQuickActionsPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C09C28289C729D00E6977E /* FLTQuickActionsPluginTests.m */; };
2121
E0C09C32289DBFCA00E6977E /* FLTShortcutStateManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C09C31289DBFCA00E6977E /* FLTShortcutStateManagerTests.m */; };
2222
/* End PBXBuildFile section */
@@ -60,7 +60,6 @@
6060
436668746754BEEA28B76E55 /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6161
5278439583922091276A37C9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
6262
686BE82D25E58CCF00862533 /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
63-
686BE82F25E58CCF00862533 /* RunnerUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RunnerUITests.m; sourceTree = "<group>"; };
6463
686BE83125E58CCF00862533 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6564
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
6665
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -76,6 +75,7 @@
7675
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7776
9D27FE1F0F21D4D47DDA16DE /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
7877
C35AD3650AB6BF850E016715 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
78+
E092A7F528D128EB005C7F67 /* RunnerUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerUITests.swift; sourceTree = "<group>"; };
7979
E0C09C28289C729D00E6977E /* FLTQuickActionsPluginTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FLTQuickActionsPluginTests.m; sourceTree = "<group>"; };
8080
E0C09C31289DBFCA00E6977E /* FLTShortcutStateManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTShortcutStateManagerTests.m; sourceTree = "<group>"; };
8181
F0609304FBCAEC2289164BD5 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
@@ -121,8 +121,8 @@
121121
686BE82E25E58CCF00862533 /* RunnerUITests */ = {
122122
isa = PBXGroup;
123123
children = (
124-
686BE82F25E58CCF00862533 /* RunnerUITests.m */,
125124
686BE83125E58CCF00862533 /* Info.plist */,
125+
E092A7F528D128EB005C7F67 /* RunnerUITests.swift */,
126126
);
127127
path = RunnerUITests;
128128
sourceTree = "<group>";
@@ -281,6 +281,7 @@
281281
};
282282
686BE82C25E58CCF00862533 = {
283283
CreatedOnToolsVersion = 12.4;
284+
LastSwiftMigration = 1330;
284285
ProvisioningStyle = Automatic;
285286
TestTargetID = 97C146ED1CF9000F007C117D;
286287
};
@@ -424,7 +425,7 @@
424425
isa = PBXSourcesBuildPhase;
425426
buildActionMask = 2147483647;
426427
files = (
427-
686BE83025E58CCF00862533 /* RunnerUITests.m in Sources */,
428+
E092A7F628D128EB005C7F67 /* RunnerUITests.swift in Sources */,
428429
);
429430
runOnlyForDeploymentPostprocessing = 0;
430431
};
@@ -512,6 +513,7 @@
512513
buildSettings = {
513514
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
514515
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
516+
CLANG_ENABLE_MODULES = YES;
515517
CLANG_ENABLE_OBJC_WEAK = YES;
516518
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
517519
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
@@ -529,6 +531,8 @@
529531
MTL_FAST_MATH = YES;
530532
PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerUITests;
531533
PRODUCT_NAME = "$(TARGET_NAME)";
534+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
535+
SWIFT_VERSION = 5.0;
532536
TARGETED_DEVICE_FAMILY = "1,2";
533537
TEST_TARGET_NAME = Runner;
534538
};
@@ -539,6 +543,7 @@
539543
buildSettings = {
540544
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
541545
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
546+
CLANG_ENABLE_MODULES = YES;
542547
CLANG_ENABLE_OBJC_WEAK = YES;
543548
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
544549
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
@@ -555,6 +560,7 @@
555560
MTL_FAST_MATH = YES;
556561
PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerUITests;
557562
PRODUCT_NAME = "$(TARGET_NAME)";
563+
SWIFT_VERSION = 5.0;
558564
TARGETED_DEVICE_FAMILY = "1,2";
559565
TEST_TARGET_NAME = Runner;
560566
};

packages/quick_actions/quick_actions_ios/example/ios/RunnerUITests/RunnerUITests.m

-99
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import XCTest
6+
7+
private let elementWaitingTime: TimeInterval = 30
8+
9+
class RunnerUITests: XCTestCase {
10+
11+
private var exampleApp: XCUIApplication!
12+
13+
override func setUp() {
14+
super.setUp()
15+
self.continueAfterFailure = false
16+
exampleApp = XCUIApplication()
17+
}
18+
19+
override func tearDown() {
20+
super.tearDown()
21+
exampleApp.terminate()
22+
exampleApp = nil
23+
}
24+
25+
func testQuickActionWithFreshStart() {
26+
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
27+
let quickActionsAppIcon = springboard.icons["quick_actions_example"]
28+
if !quickActionsAppIcon.waitForExistence(timeout: elementWaitingTime) {
29+
XCTFail(
30+
"Failed due to not able to find the example app from springboard with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
31+
)
32+
}
33+
34+
quickActionsAppIcon.press(forDuration: 2)
35+
36+
let actionTwo = springboard.buttons["Action two"]
37+
if !actionTwo.waitForExistence(timeout: elementWaitingTime) {
38+
XCTFail(
39+
"Failed due to not able to find the actionTwo button from springboard with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
40+
)
41+
}
42+
43+
actionTwo.tap()
44+
45+
let actionTwoConfirmation = exampleApp.otherElements["action_two"]
46+
if !actionTwoConfirmation.waitForExistence(timeout: elementWaitingTime) {
47+
XCTFail(
48+
"Failed due to not able to find the actionTwoConfirmation in the app with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
49+
)
50+
}
51+
52+
XCTAssert(actionTwoConfirmation.exists)
53+
}
54+
55+
func testQuickActionWhenAppIsInBackground() {
56+
exampleApp.launch()
57+
58+
let actionsReady = exampleApp.otherElements["actions ready"]
59+
60+
if !actionsReady.waitForExistence(timeout: elementWaitingTime) {
61+
XCTFail(
62+
"Failed due to not able to find the actionsReady in the app with \(elementWaitingTime) seconds. App debug description: \(exampleApp.debugDescription)"
63+
)
64+
}
65+
66+
XCUIDevice.shared.press(.home)
67+
68+
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
69+
let quickActionsAppIcon = springboard.icons["quick_actions_example"]
70+
if !quickActionsAppIcon.waitForExistence(timeout: elementWaitingTime) {
71+
XCTFail(
72+
"Failed due to not able to find the example app from springboard with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
73+
)
74+
}
75+
76+
quickActionsAppIcon.press(forDuration: 2)
77+
78+
let actionOne = springboard.buttons["Action one"]
79+
if !actionOne.waitForExistence(timeout: elementWaitingTime) {
80+
XCTFail(
81+
"Failed due to not able to find the actionOne button from springboard with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
82+
)
83+
}
84+
85+
actionOne.tap()
86+
87+
let actionOneConfirmation = exampleApp.otherElements["action_one"]
88+
if !actionOneConfirmation.waitForExistence(timeout: elementWaitingTime) {
89+
XCTFail(
90+
"Failed due to not able to find the actionOneConfirmation in the app with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)"
91+
)
92+
}
93+
94+
XCTAssert(actionOneConfirmation.exists)
95+
}
96+
}

0 commit comments

Comments
 (0)