Skip to content

Commit

Permalink
test: update new testing device (iPhone 13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobile CI committed Jan 8, 2024
1 parent 857a2b3 commit c12ba26
Show file tree
Hide file tree
Showing 44 changed files with 196 additions and 179 deletions.
2 changes: 1 addition & 1 deletion e2e/iOSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { execSync } from 'shell-utils/src/exec';
const utils = {
setDemoMode: () => {
execSync(
'xcrun simctl status_bar "iPhone 11" override --time "12:00" --batteryState charged --batteryLevel 100 --wifiBars 3 --cellularMode active --cellularBars 4'
'xcrun simctl status_bar "iPhone 13" override --time "12:00" --batteryState charged --batteryLevel 100 --wifiBars 3 --cellularMode active --cellularBars 4'
);
},
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"ios.none": {
"binaryPath": "playground/ios/DerivedData/playground/Build/Products/Debug-iphonesimulator/playground.app",
"type": "ios.none",
"name": "iPhone 11",
"name": "iPhone 13",
"session": {
"server": "ws://localhost:8099",
"sessionId": "playground"
Expand Down Expand Up @@ -229,4 +229,4 @@
}
}
}
}
}
141 changes: 74 additions & 67 deletions playground/ios/NavigationTests/RNNButtonsPresenterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#import <ReactNativeNavigation/RNNButtonsPresenter.h>
#import <XCTest/XCTest.h>

static UIImage *createTestImage(void) {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0.0);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

@interface RNNButtonsPresenterTest : XCTestCase

@property(nonatomic, retain) RNNButtonsPresenter *uut;
Expand All @@ -12,97 +19,97 @@ @interface RNNButtonsPresenterTest : XCTestCase
@implementation RNNButtonsPresenterTest

- (void)setUp {
_viewController = UIViewController.new;
__unused UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:_viewController];
_uut = [[RNNButtonsPresenter alloc] initWithComponentRegistry:nil eventEmitter:nil];
[_uut bindViewController:_viewController];
_viewController = UIViewController.new;
__unused UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:_viewController];
_uut = [[RNNButtonsPresenter alloc] initWithComponentRegistry:nil eventEmitter:nil];
[_uut bindViewController:_viewController];
}

- (void)testApplyButtons_shouldNotAddEmptyButton {
[_uut applyLeftButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.leftBarButtonItems.count == 0);

[_uut applyRightButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.rightBarButtonItems.count == 0);
[_uut applyLeftButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.leftBarButtonItems.count == 0);

[_uut applyRightButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.rightBarButtonItems.count == 0);
}

- (void)testApplyButtons_shouldAddButtonWithTitle {
[_uut applyLeftButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.leftBarButtonItems.count == 1);

[_uut applyRightButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.rightBarButtonItems.count == 1);
[_uut applyLeftButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.leftBarButtonItems.count == 1);

[_uut applyRightButtons:@[ [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}] ]
defaultColor:nil
defaultDisabledColor:nil
animated:NO];
XCTAssertTrue(_viewController.navigationItem.rightBarButtonItems.count == 1);
}

- (void)testApplyButtons_shouldCreateCustomButtonView {
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId"}];
button.icon = [Image withValue:UIImage.new];
button.iconBackground.color = [Color withValue:UIColor.blackColor];
[_uut applyLeftButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
XCTAssertNotNil([_viewController.navigationItem.leftBarButtonItems.lastObject customView]);
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId"}];
button.icon = [Image withValue:createTestImage()];
button.iconBackground.color = [Color withValue:UIColor.blackColor];
[_uut applyLeftButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
XCTAssertNotNil([_viewController.navigationItem.leftBarButtonItems.lastObject customView]);
}

- (void)testApplyLeftButtonColor_shouldApplyTintColor {
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId"}];
button.icon = [Image withValue:UIImage.new];
[_uut applyLeftButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyLeftButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual(_viewController.navigationItem.leftBarButtonItems.firstObject.tintColor,
UIColor.redColor);
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId"}];
button.icon = [Image withValue:UIImage.new];
[_uut applyLeftButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyLeftButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual(_viewController.navigationItem.leftBarButtonItems.firstObject.tintColor,
UIColor.redColor);
}

- (void)testApplyLeftButtonColor_shouldApplyTextAttributesColor {
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}];
[_uut applyLeftButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyLeftButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual([[_viewController.navigationItem.leftBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateNormal]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
XCTAssertEqual([[_viewController.navigationItem.leftBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateHighlighted]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}];
[_uut applyLeftButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyLeftButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual([[_viewController.navigationItem.leftBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateNormal]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
XCTAssertEqual([[_viewController.navigationItem.leftBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateHighlighted]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
}

- (void)testApplyRightButtonColor_shouldApplyTintColor {
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId"}];
button.icon = [Image withValue:UIImage.new];
[_uut applyRightButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyRightButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual(_viewController.navigationItem.rightBarButtonItems.firstObject.tintColor,
UIColor.redColor);
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId"}];
button.icon = [Image withValue:UIImage.new];
[_uut applyRightButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyRightButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual(_viewController.navigationItem.rightBarButtonItems.firstObject.tintColor,
UIColor.redColor);
}

- (void)testApplyRightButtonColor_shouldApplyTextAttributesColor {
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}];
[_uut applyRightButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyRightButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual([[_viewController.navigationItem.rightBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateNormal]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
XCTAssertEqual([[_viewController.navigationItem.rightBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateHighlighted]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
RNNButtonOptions *button = [self buttonWithDict:@{@"id" : @"buttonId", @"text" : @"title"}];
[_uut applyRightButtons:@[ button ] defaultColor:nil defaultDisabledColor:nil animated:NO];
[_uut applyRightButtonsColor:[Color withValue:UIColor.redColor]];
XCTAssertEqual([[_viewController.navigationItem.rightBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateNormal]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
XCTAssertEqual([[_viewController.navigationItem.rightBarButtonItems.firstObject
titleTextAttributesForState:UIControlStateHighlighted]
valueForKey:NSForegroundColorAttributeName],
UIColor.redColor);
}

- (RNNButtonOptions *)buttonWithDict:(NSDictionary *)buttonDict {
return [[RNNButtonOptions alloc] initWithDict:buttonDict];
return [[RNNButtonOptions alloc] initWithDict:buttonDict];
}

@end
4 changes: 2 additions & 2 deletions playground/ios/NavigationTests/RNNCommandsHandlerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ - (void)testShowOverlay_withCreatedLayout {
- (void)testShowOverlay_invokeNavigationCommandEventWithLayout {
[self.uut setReadyToReceiveCommands:true];
OCMStub([self.overlayManager showOverlayWindow:[OCMArg any]]);
id mockedVC = [OCMockObject partialMockForObject:self.vc1];
OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);

OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(self.vc1);

[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"showOverlay"
commandId:[OCMArg any]];
Expand Down
Loading

0 comments on commit c12ba26

Please sign in to comment.