Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/CordovaLibTests/CDVStatusBarTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ @interface CDVStatusBarTests : XCTestCase

@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];

Expand Down Expand Up @@ -63,6 +77,7 @@ - (void) testStatusBarBackgroundColorNamedColor {
[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);
Expand All @@ -85,6 +100,7 @@ - (void) testStatusBarBackgroundColor3HexColor {
[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);
Expand All @@ -107,6 +123,7 @@ - (void) testStatusBarBackgroundColor6HexColor {
[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);
Expand All @@ -129,6 +146,7 @@ - (void) testStatusBarBackgroundColor8HexColor {
[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);
Expand All @@ -151,6 +169,7 @@ - (void) testStatusBarBackgroundColorRGB {
[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);
Expand All @@ -173,6 +192,7 @@ - (void) testStatusBarBackgroundColorRGBA {
[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);
Expand Down
Loading