Fix up iOS Add to App tests (#38603)

This commit is contained in:
Dan Field 2019-08-14 23:01:17 -07:00 committed by GitHub
parent c55d251601
commit 2a6f1b7342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 40 deletions

View file

@ -534,6 +534,8 @@ task:
- name: add2app-macos
env:
SHARD: add2app_test
setup_xcpretty_script:
- sudo gem install xcpretty
test_all_script:
- ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
- dart --enable-asserts dev/bots/test.dart

View file

@ -10,4 +10,15 @@ popd
pod install
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
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

View file

@ -338,7 +338,7 @@
name = "[CP-User] Run Flutter Build Script";
runOnlyForDeploymentPostprocessing = 0;
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 */ = {
isa = PBXShellScriptBuildPhase;
@ -502,8 +502,10 @@
"DEBUG=1",
"$(inherited)",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
@ -513,6 +515,11 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
WARNING_CFLAGS = "-Wno-gnu";
WARNING_LDFLAGS = (
"-Wall",
"-Werror",
);
};
name = Debug;
};
@ -556,8 +563,10 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
@ -567,6 +576,11 @@
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = "-Wno-gnu";
WARNING_LDFLAGS = (
"-Wall",
"-Werror",
);
};
name = Release;
};

View file

@ -8,7 +8,6 @@
@interface AppDelegate : FlutterAppDelegate
@property(nonatomic, strong) FlutterEngine* engine;
@property(nonatomic, strong) UIWindow* window;
@property(nonatomic, strong) FlutterBasicMessageChannel* reloadMessageChannel;
@end

View file

@ -41,7 +41,7 @@ static NSString *_kReloadChannelName = @"reload";
_reloadMessageChannel = [[FlutterBasicMessageChannel alloc]
initWithName:_kReloadChannelName
binaryMessenger:_engine
binaryMessenger:_engine.binaryMessenger
codec:[FlutterStringCodec sharedInstance]];
self.window.rootViewController = _navigationController;

View file

@ -56,7 +56,7 @@ static NSString *_kPing = @"ping";
_messageChannel = [[FlutterBasicMessageChannel alloc]
initWithName:_kChannel
binaryMessenger:_flutterViewController
binaryMessenger:_flutterViewController.binaryMessenger
codec:[FlutterStringCodec sharedInstance]];
[self addChildViewController:_flutterViewController];
[stackView addArrangedSubview:_flutterViewController.view];

View file

@ -21,7 +21,7 @@
[viewController viewWillAppear:NO];
[viewController viewDidDisappear:NO];
}
XCTAssertNil(weakEngine);
XCTAssertNil(weakEngine, @"Engine failed to release.");
}
@end

View file

@ -11,36 +11,6 @@
#import "../ios_add2app/MainViewController.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
@end
@ -58,6 +28,12 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
return self;
}
- (void)expectSemanticsNotification:(FlutterViewController*)viewController {
[self expectationForNotification:FlutterSemanticsUpdateNotification object:viewController handler:nil];
[viewController.engine ensureSemanticsEnabled];
[self waitForExpectationsWithTimeout:30.0 handler:nil];
}
- (void)testFullScreenCanPop {
[[EarlGrey selectElementWithMatcher:grey_keyWindow()]
assertWithMatcher:grey_sufficientlyVisible()];
@ -74,7 +50,7 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
.window.rootViewController;
weakViewController =
(FullScreenViewController *)navController.visibleViewController;
waitForFlutterSemanticsTree(weakViewController);
[self expectSemanticsNotification:weakViewController];
GREYAssertNotNil(weakViewController,
@"Expected non-nil FullScreenViewController.");
}
@ -112,8 +88,8 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
(DualFlutterViewController *)navController.visibleViewController;
GREYAssertNotNil(viewController,
@"Expected non-nil DualFlutterViewController.");
waitForFlutterSemanticsTree(viewController.topFlutterViewController);
waitForFlutterSemanticsTree(viewController.bottomFlutterViewController);
[self expectSemanticsNotification:viewController.topFlutterViewController];
[self expectSemanticsNotification:viewController.bottomFlutterViewController];
}
// Verify that there are two Flutter views with the expected marquee text.
@ -148,7 +124,7 @@ static void waitForFlutterSemanticsTree(FlutterViewController *viewController) {
(HybridViewController *)navController.visibleViewController;
GREYAssertNotNil(viewController.flutterViewController,
@"Expected non-nil FlutterViewController.");
waitForFlutterSemanticsTree(viewController.flutterViewController);
[self expectSemanticsNotification:viewController.flutterViewController];
}
[self validateCountsFlutter:@"Platform" count:0];