Unverified Commit 2a6f1b73 authored by Dan Field's avatar Dan Field Committed by GitHub

Fix up iOS Add to App tests (#38603)

parent c55d2516
...@@ -534,6 +534,8 @@ task: ...@@ -534,6 +534,8 @@ task:
- name: add2app-macos - name: add2app-macos
env: env:
SHARD: add2app_test SHARD: add2app_test
setup_xcpretty_script:
- sudo gem install xcpretty
test_all_script: test_all_script:
- ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976 - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
- dart --enable-asserts dev/bots/test.dart - dart --enable-asserts dev/bots/test.dart
......
...@@ -10,4 +10,15 @@ popd ...@@ -10,4 +10,15 @@ popd
pod install pod install
os_version=$(xcrun --show-sdk-version --sdk iphonesimulator) os_version=$(xcrun --show-sdk-version --sdk iphonesimulator)
xcodebuild -workspace ios_add2app.xcworkspace -scheme ios_add2appTests -sdk "iphonesimulator$os_version" -destination "OS=$os_version,name=iPhone X" test
\ No newline at end of file PRETTY="cat"
if which xcpretty; then
PRETTY="xcpretty"
fi
set -o pipefail && xcodebuild \
-workspace ios_add2app.xcworkspace \
-scheme ios_add2appTests \
-sdk "iphonesimulator$os_version" \
-destination "OS=$os_version,name=iPhone X" test | $PRETTY
...@@ -338,7 +338,7 @@ ...@@ -338,7 +338,7 @@
name = "[CP-User] Run Flutter Build Script"; name = "[CP-User] Run Flutter Build Script";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/flutterapp/.ios/Flutter/flutter_export_environment.sh\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build\n"; shellScript = "set -e\nset -u\nsource \"${SRCROOT}/flutterapp/.ios/Flutter/flutter_export_environment.sh\"\n\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build";
}; };
DE5CDCD8B3565EAB9F38F455 /* [CP] Check Pods Manifest.lock */ = { DE5CDCD8B3565EAB9F38F455 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
...@@ -502,8 +502,10 @@ ...@@ -502,8 +502,10 @@
"DEBUG=1", "DEBUG=1",
"$(inherited)", "$(inherited)",
); );
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
...@@ -513,6 +515,11 @@ ...@@ -513,6 +515,11 @@
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
WARNING_CFLAGS = "-Wno-gnu";
WARNING_LDFLAGS = (
"-Wall",
"-Werror",
);
}; };
name = Debug; name = Debug;
}; };
...@@ -556,8 +563,10 @@ ...@@ -556,8 +563,10 @@
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES; GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
...@@ -567,6 +576,11 @@ ...@@ -567,6 +576,11 @@
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = "-Wno-gnu";
WARNING_LDFLAGS = (
"-Wall",
"-Werror",
);
}; };
name = Release; name = Release;
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
@interface AppDelegate : FlutterAppDelegate @interface AppDelegate : FlutterAppDelegate
@property(nonatomic, strong) FlutterEngine* engine; @property(nonatomic, strong) FlutterEngine* engine;
@property(nonatomic, strong) UIWindow* window;
@property(nonatomic, strong) FlutterBasicMessageChannel* reloadMessageChannel; @property(nonatomic, strong) FlutterBasicMessageChannel* reloadMessageChannel;
@end @end
...@@ -41,7 +41,7 @@ static NSString *_kReloadChannelName = @"reload"; ...@@ -41,7 +41,7 @@ static NSString *_kReloadChannelName = @"reload";
_reloadMessageChannel = [[FlutterBasicMessageChannel alloc] _reloadMessageChannel = [[FlutterBasicMessageChannel alloc]
initWithName:_kReloadChannelName initWithName:_kReloadChannelName
binaryMessenger:_engine binaryMessenger:_engine.binaryMessenger
codec:[FlutterStringCodec sharedInstance]]; codec:[FlutterStringCodec sharedInstance]];
self.window.rootViewController = _navigationController; self.window.rootViewController = _navigationController;
......
...@@ -56,7 +56,7 @@ static NSString *_kPing = @"ping"; ...@@ -56,7 +56,7 @@ static NSString *_kPing = @"ping";
_messageChannel = [[FlutterBasicMessageChannel alloc] _messageChannel = [[FlutterBasicMessageChannel alloc]
initWithName:_kChannel initWithName:_kChannel
binaryMessenger:_flutterViewController binaryMessenger:_flutterViewController.binaryMessenger
codec:[FlutterStringCodec sharedInstance]]; codec:[FlutterStringCodec sharedInstance]];
[self addChildViewController:_flutterViewController]; [self addChildViewController:_flutterViewController];
[stackView addArrangedSubview:_flutterViewController.view]; [stackView addArrangedSubview:_flutterViewController.view];
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
[viewController viewWillAppear:NO]; [viewController viewWillAppear:NO];
[viewController viewDidDisappear:NO]; [viewController viewDidDisappear:NO];
} }
XCTAssertNil(weakEngine); XCTAssertNil(weakEngine, @"Engine failed to release.");
} }
@end @end
...@@ -11,36 +11,6 @@ ...@@ -11,36 +11,6 @@
#import "../ios_add2app/MainViewController.h" #import "../ios_add2app/MainViewController.h"
#import "../ios_add2app/HybridViewController.h" #import "../ios_add2app/HybridViewController.h"
static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
int tries = 10;
double delay = 1.0;
// ensureSemanticsEnabled is a synchronous call, but only ensures that the
// semantics tree will be built on a subsequent frame (as opposed to being
// available at time it returns).
// To actually get the tree, we have to wait for the FlutterSemanticsUpdate
// notification, which lets us know that a semantics tree has been built;
// but we cannot block the main thread while waiting (so we use
// CFRunLoopRunInMode).
__block BOOL semanticsAvailable = NO;
__block id<NSObject> observer = [[NSNotificationCenter defaultCenter]
addObserverForName:@"FlutterSemanticsUpdate"
object:viewController
queue:nil
usingBlock:^(NSNotification *notification) {
semanticsAvailable = YES;
[[NSNotificationCenter defaultCenter] removeObserver:observer];
}];
[viewController.engine ensureSemanticsEnabled];
while (semanticsAvailable == NO && tries != 0) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, delay, false);
tries--;
[viewController.engine ensureSemanticsEnabled];
}
GREYAssertTrue(semanticsAvailable, @"Semantics Tree did not build!");
}
@interface FlutterTests : XCTestCase @interface FlutterTests : XCTestCase
@end @end
...@@ -58,6 +28,12 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) { ...@@ -58,6 +28,12 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
return self; return self;
} }
- (void)expectSemanticsNotification:(FlutterViewController*)viewController {
[self expectationForNotification:FlutterSemanticsUpdateNotification object:viewController handler:nil];
[viewController.engine ensureSemanticsEnabled];
[self waitForExpectationsWithTimeout:30.0 handler:nil];
}
- (void)testFullScreenCanPop { - (void)testFullScreenCanPop {
[[EarlGrey selectElementWithMatcher:grey_keyWindow()] [[EarlGrey selectElementWithMatcher:grey_keyWindow()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
...@@ -74,7 +50,7 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) { ...@@ -74,7 +50,7 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
.window.rootViewController; .window.rootViewController;
weakViewController = weakViewController =
(FullScreenViewController *)navController.visibleViewController; (FullScreenViewController *)navController.visibleViewController;
waitForFlutterSemanticsTree(weakViewController); [self expectSemanticsNotification:weakViewController];
GREYAssertNotNil(weakViewController, GREYAssertNotNil(weakViewController,
@"Expected non-nil FullScreenViewController."); @"Expected non-nil FullScreenViewController.");
} }
...@@ -112,8 +88,8 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) { ...@@ -112,8 +88,8 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
(DualFlutterViewController *)navController.visibleViewController; (DualFlutterViewController *)navController.visibleViewController;
GREYAssertNotNil(viewController, GREYAssertNotNil(viewController,
@"Expected non-nil DualFlutterViewController."); @"Expected non-nil DualFlutterViewController.");
waitForFlutterSemanticsTree(viewController.topFlutterViewController); [self expectSemanticsNotification:viewController.topFlutterViewController];
waitForFlutterSemanticsTree(viewController.bottomFlutterViewController); [self expectSemanticsNotification:viewController.bottomFlutterViewController];
} }
// Verify that there are two Flutter views with the expected marquee text. // Verify that there are two Flutter views with the expected marquee text.
...@@ -148,7 +124,7 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) { ...@@ -148,7 +124,7 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
(HybridViewController *)navController.visibleViewController; (HybridViewController *)navController.visibleViewController;
GREYAssertNotNil(viewController.flutterViewController, GREYAssertNotNil(viewController.flutterViewController,
@"Expected non-nil FlutterViewController."); @"Expected non-nil FlutterViewController.");
waitForFlutterSemanticsTree(viewController.flutterViewController); [self expectSemanticsNotification:viewController.flutterViewController];
} }
[self validateCountsFlutter:@"Platform" count:0]; [self validateCountsFlutter:@"Platform" count:0];
......
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