summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-11-29 13:59:47 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-11-29 13:59:47 -0500
commit26f7dea62c26586fe203ddd2227fd48fee3b0b65 (patch)
tree790486871efdd53651b451dcca4f820a613b0df5
parent16105434f36c547f4533219978bb2db206392f61 (diff)
downloadsdl_ios-26f7dea62c26586fe203ddd2227fd48fee3b0b65.tar.gz
Fix existing tests
-rw-r--r--SmartDeviceLink/SDLFocusableItemLocator.m2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.h2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m4
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLStreamingMediaConfigurationSpec.m12
-rw-r--r--SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m53
-rw-r--r--SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m4
6 files changed, 38 insertions, 39 deletions
diff --git a/SmartDeviceLink/SDLFocusableItemLocator.m b/SmartDeviceLink/SDLFocusableItemLocator.m
index 382eb579e..5751ab5a8 100644
--- a/SmartDeviceLink/SDLFocusableItemLocator.m
+++ b/SmartDeviceLink/SDLFocusableItemLocator.m
@@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateInterfaceLayout {
if (@available(iOS 9.0, *)) {
self.focusableViews = [[NSMutableArray alloc] init];
- [self sdl_parseViewHierarchy:self.viewController.view.subviews.lastObject];
+ [self sdl_parseViewHierarchy:self.viewController.view];
// If there is a preferred view bring that into top of the array
NSUInteger preferredViewIndex = [self.focusableViews indexOfObject:self.viewController.view.subviews.lastObject.preferredFocusedView];
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.h b/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.h
index 1f71cffa8..4b1d7249a 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.h
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.h
@@ -12,7 +12,7 @@
@interface SDLFakeViewControllerPresenter : NSObject <SDLViewControllerPresentable>
-@property (strong, nonatomic) UIViewController *viewController;
+@property (strong, nonatomic) UIViewController *lockViewController;
@property (assign, nonatomic, readonly) BOOL presented;
@end
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m
index 0630fd9f7..3e6230897 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m
@@ -19,13 +19,13 @@
@implementation SDLFakeViewControllerPresenter
- (void)present {
- if (!self.viewController) { return; }
+ if (!self.lockViewController) { return; }
_presented = YES;
}
- (void)dismiss {
- if (!self.viewController) { return; }
+ if (!self.lockViewController) { return; }
_presented = NO;
}
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingMediaConfigurationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingMediaConfigurationSpec.m
index 447dac87b..56b66ea5d 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingMediaConfigurationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingMediaConfigurationSpec.m
@@ -17,7 +17,7 @@ describe(@"a streaming media configuration", ^{
__block SDLStreamingEncryptionFlag testEncryptionFlag = SDLStreamingEncryptionFlagNone;
__block SDLFakeStreamingManagerDataSource *testDataSource = nil;
__block NSDictionary<NSString *, id> *testVideoEncoderSettings = nil;
- __block UIWindow *testWindow = nil;
+ __block UIViewController *testViewController = nil;
beforeEach(^{
testFakeSecurityManager = [[SDLFakeSecurityManager alloc] init];
@@ -25,10 +25,10 @@ describe(@"a streaming media configuration", ^{
testVideoEncoderSettings = @{
(__bridge NSString *)kVTCompressionPropertyKey_ExpectedFrameRate : @1
};
- testWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
+ testViewController = [[UIViewController alloc] init];
testEncryptionFlag = SDLStreamingEncryptionFlagAuthenticateAndEncrypt;
- testConfig = [[SDLStreamingMediaConfiguration alloc] initWithSecurityManagers:@[testFakeSecurityManager.class] encryptionFlag:testEncryptionFlag videoSettings:testVideoEncoderSettings dataSource:testDataSource window:testWindow];
+ testConfig = [[SDLStreamingMediaConfiguration alloc] initWithSecurityManagers:@[testFakeSecurityManager.class] encryptionFlag:testEncryptionFlag videoSettings:testVideoEncoderSettings dataSource:testDataSource rootViewController:testViewController];
});
it(@"should have properly set properties", ^{
@@ -36,7 +36,7 @@ describe(@"a streaming media configuration", ^{
expect(@(testConfig.maximumDesiredEncryption)).to(equal(@(SDLStreamingEncryptionFlagAuthenticateAndEncrypt)));
expect(testConfig.customVideoEncoderSettings).to(equal(testVideoEncoderSettings));
expect(testConfig.dataSource).to(equal(testDataSource));
- expect(testConfig.window).to(equal(testWindow));
+ expect(testConfig.rootViewController).to(equal(testViewController));
});
});
@@ -50,7 +50,7 @@ describe(@"a streaming media configuration", ^{
expect(@(testConfig.maximumDesiredEncryption)).to(equal(@(SDLStreamingEncryptionFlagNone)));
expect(testConfig.customVideoEncoderSettings).to(beNil());
expect(testConfig.dataSource).to(beNil());
- expect(testConfig.window).to(beNil());
+ expect(testConfig.rootViewController).to(beNil());
});
});
@@ -68,7 +68,7 @@ describe(@"a streaming media configuration", ^{
expect(@(testConfig.maximumDesiredEncryption)).to(equal(@(SDLStreamingEncryptionFlagAuthenticateAndEncrypt)));
expect(testConfig.customVideoEncoderSettings).to(beNil());
expect(testConfig.dataSource).to(beNil());
- expect(testConfig.window).to(beNil());
+ expect(testConfig.rootViewController).to(beNil());
});
});
});
diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
index 9eb2f019d..8413e6abf 100644
--- a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
+++ b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
@@ -19,8 +19,7 @@
#import "SDLTouchEvent.h"
#import "SDLTouch.h"
-BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect)
-{
+BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
expect(sdlRectangle.x).to(equal(cgRect.origin.x));
expect(sdlRectangle.y).to(equal(cgRect.origin.y));
expect(sdlRectangle.width).to(equal(cgRect.size.width));
@@ -47,8 +46,8 @@ describe(@"the haptic manager", ^{
uiWindow = [[UIWindow alloc] init];
uiViewController = [[UIViewController alloc] init];
-
- [uiWindow addSubview:uiViewController.view];
+
+ uiWindow.rootViewController = uiViewController;
OCMExpect([[sdlLifecycleManager stub] sendManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
@@ -62,10 +61,10 @@ describe(@"the haptic manager", ^{
context(@"when disabled", ^{
beforeEach(^{
viewRect1 = CGRectMake(101, 101, 50, 50);
- UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
- [uiWindow insertSubview:textField1 aboveSubview:uiWindow];
+ UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
+ [uiViewController.view addSubview:textField1];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = NO;
[hapticManager updateInterfaceLayout];
});
@@ -79,7 +78,7 @@ describe(@"the haptic manager", ^{
context(@"when initialized with no focusable view", ^{
beforeEach(^{
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
[hapticManager updateInterfaceLayout];
});
@@ -93,9 +92,9 @@ describe(@"the haptic manager", ^{
beforeEach(^{
viewRect1 = CGRectMake(101, 101, 50, 50);
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
- [uiWindow insertSubview:textField1 aboveSubview:uiWindow];
+ [uiViewController.view addSubview:textField1];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -119,10 +118,10 @@ describe(@"the haptic manager", ^{
context(@"when initialized with single button view", ^{
beforeEach(^{
viewRect1 = CGRectMake(101, 101, 50, 50);
- UIButton *button = [[UIButton alloc] initWithFrame:viewRect1];
- [uiWindow addSubview:button];
+ UIButton *button = [[UIButton alloc] initWithFrame:viewRect1];
+ [uiViewController.view addSubview:button];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -145,16 +144,16 @@ describe(@"the haptic manager", ^{
context(@"when initialized with no views and then updated with two additional views", ^{
beforeEach(^{
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
viewRect1 = CGRectMake(101, 101, 50, 50);
- UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
+ UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];
viewRect2 = CGRectMake(201, 201, 50, 50);
- UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
+ UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[uiViewController.view addSubview:textField2];
[hapticManager updateInterfaceLayout];
@@ -174,8 +173,8 @@ describe(@"the haptic manager", ^{
SDLHapticRect *sdlhapticRect2 = hapticRectData[1];
SDLRectangle *sdlRect2 = sdlhapticRect2.rect;
- compareRectangle(sdlRect1, viewRect1);
- compareRectangle(sdlRect2, viewRect2);
+ compareRectangle(sdlRect1, viewRect2);
+ compareRectangle(sdlRect2, viewRect1);
}
});
});
@@ -193,7 +192,7 @@ describe(@"the haptic manager", ^{
UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[textField addSubview:textField2];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -231,7 +230,7 @@ describe(@"the haptic manager", ^{
UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[button addSubview:textField2];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -266,7 +265,7 @@ describe(@"the haptic manager", ^{
UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[uiViewController.view addSubview:textField2];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
@@ -297,7 +296,7 @@ describe(@"the haptic manager", ^{
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
@@ -322,8 +321,8 @@ describe(@"the haptic manager", ^{
SDLHapticRect *sdlhapticRect2 = hapticRectData[1];
SDLRectangle *sdlRect2 = sdlhapticRect2.rect;
- compareRectangle(sdlRect1, viewRect1);
- compareRectangle(sdlRect2, viewRect2);
+ compareRectangle(sdlRect1, viewRect2);
+ compareRectangle(sdlRect2, viewRect1);
}
});
});
@@ -336,7 +335,7 @@ describe(@"the haptic manager", ^{
UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(201, 201, 50, 50)];
[uiViewController.view addSubview:textField2];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -358,7 +357,7 @@ describe(@"the haptic manager", ^{
UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(126, 126, 50, 50)];
[uiViewController.view addSubview:textField2];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -374,7 +373,7 @@ describe(@"the haptic manager", ^{
UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(101, 101, 50, 50)];
[uiWindow insertSubview:textField1 aboveSubview:uiWindow];
- hapticManager = [[SDLFocusableItemLocator alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
diff --git a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m
index d20ed828a..877c65b42 100644
--- a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m
@@ -46,7 +46,7 @@ QuickSpecBegin(SDLStreamingMediaLifecycleManagerSpec)
describe(@"the streaming media manager", ^{
__block SDLStreamingMediaLifecycleManager *streamingLifecycleManager = nil;
__block SDLStreamingMediaConfiguration *testConfiguration = [SDLStreamingMediaConfiguration insecureConfiguration];
- __block UIWindow *testWindow = [[UIWindow alloc] init];
+ __block UIViewController *testViewController = [[UIViewController alloc] init];
__block SDLFakeStreamingManagerDataSource *testDataSource = [[SDLFakeStreamingManagerDataSource alloc] init];
__block NSString *someBackgroundTitleString = nil;
__block TestConnectionManager *testConnectionManager = nil;
@@ -65,7 +65,7 @@ describe(@"the streaming media manager", ^{
(__bridge NSString *)kVTCompressionPropertyKey_ExpectedFrameRate : @1
};
testConfiguration.dataSource = testDataSource;
- testConfiguration.window = testWindow;
+ testConfiguration.rootViewController = testViewController;
someBackgroundTitleString = @"Open Test App";
testConnectionManager = [[TestConnectionManager alloc] init];
streamingLifecycleManager = [[SDLStreamingMediaLifecycleManager alloc] initWithConnectionManager:testConnectionManager configuration:testConfiguration];