mirror of
https://github.com/flutter/flutter
synced 2024-08-27 12:00:58 +00:00
Add debug informations on ios_module_test (#96622)
This commit is contained in:
parent
accd6abae5
commit
7428ab66b4
|
@ -3,6 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
@import XCTest;
|
||||
@import os.log;
|
||||
|
||||
static const CGFloat kStandardTimeOut = 60.0;
|
||||
|
||||
|
@ -61,10 +62,13 @@ static const CGFloat kStandardTimeOut = 60.0;
|
|||
[self waitForAndTapElement:app.buttons[@"Flutter View (Warm)"]];
|
||||
BOOL newPageAppeared = [app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:kStandardTimeOut];
|
||||
if (!newPageAppeared) {
|
||||
// Sometimes, the element doesn't respond to the tap, it seems an XCUITest race condition where the tap happened
|
||||
// too soon. Trying to tap the element again.
|
||||
[self waitForAndTapElement:app.buttons[@"Flutter View (Warm)"]];
|
||||
newPageAppeared = [app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:kStandardTimeOut];
|
||||
// Sometimes, the element doesn't respond to the tap, it seems an XCUITest race condition where the tap happened
|
||||
// too soon. Trying to tap the element again.
|
||||
[self waitForAndTapElement:app.buttons[@"Flutter View (Warm)"]];
|
||||
newPageAppeared = [app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:kStandardTimeOut];
|
||||
if (!newPageAppeared) {
|
||||
os_log(OS_LOG_DEFAULT, "%@", app.debugDescription);
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(newPageAppeared);
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
@interface MainViewController ()
|
||||
|
||||
@property (weak, nonatomic) UIButton* flutterViewWarmButton;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -39,7 +41,7 @@
|
|||
[self addButton:@"Native iOS View" action:@selector(showNative)];
|
||||
[self addButton:@"Full Screen (Cold)" action:@selector(showFullScreenCold)];
|
||||
[self addButton:@"Full Screen (Warm)" action:@selector(showFullScreenWarm)];
|
||||
[self addButton:@"Flutter View (Warm)" action:@selector(showFlutterViewWarm)];
|
||||
self.flutterViewWarmButton = [self addButton:@"Flutter View (Warm)" action:@selector(showFlutterViewWarm)];
|
||||
[self addButton:@"Hybrid View (Warm)" action:@selector(showHybridView)];
|
||||
[self addButton:@"Dual Flutter View (Cold)" action:@selector(showDualView)];
|
||||
}
|
||||
|
@ -99,26 +101,47 @@
|
|||
}
|
||||
|
||||
- (void)showFlutterViewWarm {
|
||||
[[self engine].navigationChannel invokeMethod:@"setInitialRoute"
|
||||
self.flutterViewWarmButton.backgroundColor = UIColor.redColor;
|
||||
FlutterEngine *engine = [self engine];
|
||||
FlutterBasicMessageChannel* messageChannel = [self reloadMessageChannel];
|
||||
NSAssert(engine != nil, @"Engine is not nil.");
|
||||
NSAssert(engine.navigationChannel != nil, @"Engine.navigationChannel is not nil.");
|
||||
NSAssert(messageChannel != nil, @"messageChannel is not nil.");
|
||||
|
||||
[engine.navigationChannel invokeMethod:@"setInitialRoute"
|
||||
arguments:@"/"];
|
||||
[[self reloadMessageChannel] sendMessage:@"/"];
|
||||
[messageChannel sendMessage:@"/"];
|
||||
|
||||
|
||||
FlutterViewController *flutterViewController =
|
||||
[[FlutterViewController alloc] initWithEngine:[self engine]
|
||||
nibName:nil
|
||||
bundle:nil];
|
||||
flutterViewController.view.accessibilityLabel = @"flutter view";
|
||||
NSAssert(self.navigationController != nil, @"self.navigationController is not nil.");
|
||||
[self.navigationController pushViewController:flutterViewController
|
||||
animated:YES];
|
||||
animated:NO];
|
||||
|
||||
if (self.navigationController.topViewController != flutterViewController) {
|
||||
// For debugging:
|
||||
// Some unknown issue happened caused `flutterViewController` not being pushed.
|
||||
// We try to push an basic UIViewController to see if it would work.
|
||||
UIViewController *viewController = [[UIViewController alloc] init];
|
||||
viewController.view.backgroundColor = UIColor.blueColor;
|
||||
[self.navigationController pushViewController:viewController
|
||||
animated:NO];
|
||||
NSAssert(self.navigationController.topViewController == viewController, @"self.navigationController.topViewController should be the basic view controller");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addButton:(NSString *)title action:(SEL)action {
|
||||
- (UIButton *)addButton:(NSString *)title action:(SEL)action {
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[button addTarget:self
|
||||
action:action
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
[_stackView addArrangedSubview:button];
|
||||
return button;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue