This is an automated email from the ASF dual-hosted git repository. GitToTheHub pushed a commit to branch fix-CDVStatusBarTests-add-waitForStatusBarBackgroundColor in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
commit 61d1c6cd5b7634fb23be07ea7bf4e8b32155502f Author: Manuel Beck <[email protected]> AuthorDate: Fri Jul 10 07:26:38 2026 +0200 fix(CDVStatusBarTests): add `waitForStatusBarBackgroundColor` - Sometimes actions will fail due to race conditions on the `testStatusBarBackgroundColor*`-methods. `evaluateJavaScript` completes once JavaScript has executed, but `cordova.exec(...)` queues the native `StatusBarInternal.setBackgroundColor` command asynchronously. The test then immediately reads `statusBarBackgroundColor`, potentially before the native command runs. - Generated-By: GPT-5.5 Medium --- tests/CordovaLibTests/CDVStatusBarTests.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/CordovaLibTests/CDVStatusBarTests.m b/tests/CordovaLibTests/CDVStatusBarTests.m index db670c73..c7a390b6 100644 --- a/tests/CordovaLibTests/CDVStatusBarTests.m +++ b/tests/CordovaLibTests/CDVStatusBarTests.m @@ -34,6 +34,20 @@ @implementation CDVStatusBarTests +/** + * Wait until statusBarBackgroundColor is set natively, because calling the JS part would return immediately + * and not wait for the native part to finish. + */ +- (void)waitForStatusBarBackgroundColor { + NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id _, NSDictionary *__) { + return self.viewController.statusBarBackgroundColor != nil; + }]; + XCTestExpectation *colorExpectation = [[XCTNSPredicateExpectation alloc] + initWithPredicate:predicate + object:self.viewController]; + [self waitForExpectations:@[colorExpectation] timeout:5]; +} + - (void)setUp { [super setUp]; @@ -63,6 +77,7 @@ [redExpectation fulfill]; }]; [self waitForExpectations:@[redExpectation] timeout:5]; + [self waitForStatusBarBackgroundColor]; [self.viewController.statusBarBackgroundColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]]; XCTAssertEqual(rgba[0], 1.f); @@ -85,6 +100,7 @@ [redExpectation fulfill]; }]; [self waitForExpectations:@[redExpectation] timeout:5]; + [self waitForStatusBarBackgroundColor]; [self.viewController.statusBarBackgroundColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]]; XCTAssertEqual(rgba[0], 1.f); @@ -107,6 +123,7 @@ [redExpectation fulfill]; }]; [self waitForExpectations:@[redExpectation] timeout:5]; + [self waitForStatusBarBackgroundColor]; [self.viewController.statusBarBackgroundColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]]; XCTAssertEqual(rgba[0], 1.f); @@ -129,6 +146,7 @@ [redExpectation fulfill]; }]; [self waitForExpectations:@[redExpectation] timeout:5]; + [self waitForStatusBarBackgroundColor]; [self.viewController.statusBarBackgroundColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]]; XCTAssertEqual(rgba[0], 1.f); @@ -151,6 +169,7 @@ [redExpectation fulfill]; }]; [self waitForExpectations:@[redExpectation] timeout:5]; + [self waitForStatusBarBackgroundColor]; [self.viewController.statusBarBackgroundColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]]; XCTAssertEqual(rgba[0], 1.f); @@ -173,6 +192,7 @@ [redExpectation fulfill]; }]; [self waitForExpectations:@[redExpectation] timeout:5]; + [self waitForStatusBarBackgroundColor]; [self.viewController.statusBarBackgroundColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]]; XCTAssertEqual(rgba[0], 1.f); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
