Unverified Commit ee98003e authored by hellohuanlin's avatar hellohuanlin Committed by GitHub

[platform_view]add timeout for alert buttons and a few other changes to fix a test flake (#110516)

parent 99372ba1
...@@ -36,17 +36,30 @@ static const CGFloat kStandardTimeOut = 60.0; ...@@ -36,17 +36,30 @@ static const CGFloat kStandardTimeOut = 60.0;
if ([appIcon waitForExistenceWithTimeout:kStandardTimeOut]) { if ([appIcon waitForExistenceWithTimeout:kStandardTimeOut]) {
NSLog(@"Deleting previously installed app."); NSLog(@"Deleting previously installed app.");
// Make icons wiggle // It's possible that app icon is not hittable yet.
[appIcon pressForDuration:3]; NSPredicate *hittable = [NSPredicate predicateWithFormat:@"exists == YES AND hittable == YES"];
[self expectationForPredicate:hittable evaluatedWithObject:appIcon handler:nil];
[self waitForExpectationsWithTimeout:kStandardTimeOut handler:nil];
// Pressing for 2 seconds will bring up context menu.
// Pressing for 3 seconds will dismiss the context menu and make icons wiggle.
[appIcon pressForDuration:2];
// The "Remove App" button in context menu.
XCUIElement *contextMenuRemoveButton = springboard.buttons[@"Remove App"];
XCTAssert([contextMenuRemoveButton waitForExistenceWithTimeout:kStandardTimeOut], @"The context menu remove app button must appear.");
[contextMenuRemoveButton tap];
// Tap the "x" button
[appIcon.buttons[@"DeleteButton"] tap];
// Tap the delete confirmation // Tap the delete confirmation
[springboard.alerts.buttons[@"Delete App"] tap]; XCUIElement *deleteConfirmationButton = springboard.alerts.buttons[@"Delete App"];
XCTAssert([deleteConfirmationButton waitForExistenceWithTimeout:kStandardTimeOut], @"The first delete confirmation button must appear.");
[deleteConfirmationButton tap];
// Tap the second delete confirmation // Tap the second delete confirmation
[springboard.alerts.buttons[@"Delete"] tap]; XCUIElement *secondDeleteConfirmationButton = springboard.alerts.buttons[@"Delete"];
// Press home button to stop wiggling XCTAssert([secondDeleteConfirmationButton waitForExistenceWithTimeout:kStandardTimeOut], @"The second delete confirmation button must appear.");
[XCUIDevice.sharedDevice pressButton:XCUIDeviceButtonHome]; [secondDeleteConfirmationButton tap];
[NSThread sleepForTimeInterval:3]; [NSThread sleepForTimeInterval:3];
} else { } else {
NSLog(@"No previously installed app found."); NSLog(@"No previously installed app found.");
......
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