Unverified Commit 3955276e authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate ios_add2app_life_cycle to earlgrey 2 and latest iOS SDK (#80822)

parent 63ba1b23
......@@ -6,10 +6,10 @@ load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'ios_add2app' do
install_all_flutter_pods(flutter_application_path)
pod 'EarlGreyApp'
end
target 'ios_add2appTests' do
inherit! :search_paths
install_flutter_engine_pod
pod 'EarlGrey'
pod 'EarlGreyTest'
end
......@@ -12,11 +12,9 @@ pushd flutterapp
popd
pod install
os_version=$(xcrun --show-sdk-version --sdk iphonesimulator)
xcodebuild \
xcrun xcodebuild \
-workspace ios_add2app.xcworkspace \
-scheme ios_add2app \
-sdk "iphonesimulator$os_version" \
-destination "OS=$os_version,name=iPhone X" test
-sdk "iphonesimulator" \
-destination "OS=latest,name=iPhone 12" test
......@@ -27,29 +27,27 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "24E221B421A28A0B008ADF09"
BuildableName = "ios_add2app.app"
BlueprintName = "ios_add2app"
ReferencedContainer = "container:ios_add2app.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "24D2933421A29627008787A5"
BlueprintIdentifier = "F73B66AC262F6F87002080A0"
BuildableName = "ios_add2appTests.xctest"
BlueprintName = "ios_add2appTests"
ReferencedContainer = "container:ios_add2app.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "24E221B421A28A0B008ADF09"
BuildableName = "ios_add2app.app"
BlueprintName = "ios_add2app"
ReferencedContainer = "container:ios_add2app.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
......@@ -71,8 +69,6 @@
ReferencedContainer = "container:ios_add2app.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
......
......@@ -5,8 +5,16 @@
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>
@interface AppDelegate : FlutterAppDelegate
#import <EarlGreyTest/GREYHostApplicationDistantObject.h>
@property(nonatomic, strong, readonly) FlutterEngine* engine;
NS_ASSUME_NONNULL_BEGIN
@interface GREYHostApplicationDistantObject (AppDelegate)
- (NSNotificationCenter *)notificationCenter;
@end
@interface AppDelegate : FlutterAppDelegate
@property(nonatomic, strong, readonly) FlutterEngine* engine;
@end
NS_ASSUME_NONNULL_END
......@@ -5,6 +5,14 @@
#import "AppDelegate.h"
#import "MainViewController.h"
@implementation GREYHostApplicationDistantObject (AppDelegate)
- (NSNotificationCenter *)notificationCenter {
return [NSNotificationCenter defaultCenter];
}
@end
@interface AppDelegate ()
@property(nonatomic, strong, readwrite) FlutterEngine* engine;
......
......@@ -13,7 +13,7 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#import <EarlGreyTest/EarlGrey.h>
#import <XCTest/XCTest.h>
#import "AppDelegate.h"
......@@ -13,33 +13,27 @@
@implementation FlutterTests
- (void)expectSemanticsNotification:(UIViewController*)viewController
engine:(FlutterEngine*)engine {
// Flutter app will only send semantics update if test passes in main.dart.
[self expectationForNotification:FlutterSemanticsUpdateNotification object:viewController handler:nil];
[self waitForExpectationsWithTimeout:30.0 handler:nil];
}
- (void)checkAppConnection {
FlutterEngine *engine = [((AppDelegate *)[[UIApplication sharedApplication] delegate]) engine];
UINavigationController *navController =
(UINavigationController *)((AppDelegate *)
[[UIApplication sharedApplication]
delegate])
.window.rootViewController;
__weak UIViewController *weakViewController = navController.visibleViewController;
[self expectSemanticsNotification:weakViewController
engine:engine];
GREYAssertNotNil(weakViewController,
@"Expected non-nil FullScreenViewController.");
- (void)setUp {
self.continueAfterFailure = NO;
XCUIApplication *app = [[XCUIApplication alloc] init];
[app launch];
}
- (void)testFullScreenCanPop {
XCTestExpectation *notificationReceived = [self expectationWithDescription:@"Remote semantics notification"];
NSNotificationCenter *notificationCenter = [[GREYHostApplicationDistantObject sharedInstance] notificationCenter];
id observer = [notificationCenter addObserverForName:FlutterSemanticsUpdateNotification object:nil queue:nil usingBlock:^(NSNotification *notification) {
XCTAssertTrue([notification.object isKindOfClass:GREY_REMOTE_CLASS_IN_APP(FullScreenViewController)]);
[notificationReceived fulfill];
}];
[[EarlGrey selectElementWithMatcher:grey_keyWindow()]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:grey_buttonTitle(@"Full Screen (Cold)")]
performAction:grey_tap()];
[self checkAppConnection];
[self waitForExpectationsWithTimeout:30.0 handler:nil];
[notificationCenter removeObserver:observer];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment