summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleonid lokhmatov, Luxoft <zaqqqqqqqq@gmail.com>2020-08-04 11:03:19 +0300
committerleonid lokhmatov, Luxoft <zaqqqqqqqq@gmail.com>2020-08-04 11:03:19 +0300
commit863053ac95ad803b7e822f49949364706618966a (patch)
treecc8541fbb4b82e3b6759ad7e6d9c6c9b0219ca65
parent208cd6a28384f22ab2e1b3b6739a182a3d76c9e2 (diff)
downloadsdl_ios-863053ac95ad803b7e822f49949364706618966a.tar.gz
0261 'New vehicle data WindowStatus': code review, update Window State & Status structs and tests.
-rw-r--r--SmartDeviceLink/SDLWindowState.h3
-rw-r--r--SmartDeviceLink/SDLWindowState.m6
-rw-r--r--SmartDeviceLink/SDLWindowStatus.m6
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStateSpec.m30
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStatusSpec.m30
5 files changed, 41 insertions, 34 deletions
diff --git a/SmartDeviceLink/SDLWindowState.h b/SmartDeviceLink/SDLWindowState.h
index 8a75caca8..fcbab5691 100644
--- a/SmartDeviceLink/SDLWindowState.h
+++ b/SmartDeviceLink/SDLWindowState.h
@@ -54,8 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) NSNumber<SDLUInt> *approximatePosition;
/**
- * The percentage deviation of the approximatePosition. e.g. If the approximatePosition is 50 and the deviation is
- * 10, then the window's location is somewhere between 40 and 60.
+ * The percentage deviation of the approximatePosition. e.g. If the approximatePosition is 50 and the deviation is 10, then the window's location is somewhere between 40 and 60.
*
* Mandatory, Integer, 0 - 100
*/
diff --git a/SmartDeviceLink/SDLWindowState.m b/SmartDeviceLink/SDLWindowState.m
index c2685af1f..ee22c09bb 100644
--- a/SmartDeviceLink/SDLWindowState.m
+++ b/SmartDeviceLink/SDLWindowState.m
@@ -53,7 +53,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (NSNumber<SDLUInt> *)approximatePosition {
- return [self.store sdl_objectForName:SDLRPCParameterNameApproximatePosition ofClass:NSNumber.class error:NULL];
+ NSError *error = nil;
+ return [self.store sdl_objectForName:SDLRPCParameterNameApproximatePosition ofClass:NSNumber.class error:&error];
}
- (void)setDeviation:(NSNumber<SDLUInt> *)deviation {
@@ -61,7 +62,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (NSNumber<SDLUInt> *)deviation {
- return [self.store sdl_objectForName:SDLRPCParameterNameDeviation ofClass:NSNumber.class error:NULL];
+ NSError *error = nil;
+ return [self.store sdl_objectForName:SDLRPCParameterNameDeviation ofClass:NSNumber.class error:&error];
}
@end
diff --git a/SmartDeviceLink/SDLWindowStatus.m b/SmartDeviceLink/SDLWindowStatus.m
index 094b1022e..1fc54b359 100644
--- a/SmartDeviceLink/SDLWindowStatus.m
+++ b/SmartDeviceLink/SDLWindowStatus.m
@@ -55,7 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (SDLGrid *)location {
- return [self.store sdl_objectForName:SDLRPCParameterNameLocation ofClass:SDLGrid.class error:NULL];
+ NSError *error = nil;
+ return [self.store sdl_objectForName:SDLRPCParameterNameLocation ofClass:SDLGrid.class error:&error];
}
- (void)setState:(SDLWindowState *)state {
@@ -63,7 +64,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (SDLWindowState *)state {
- return [self.store sdl_objectForName:SDLRPCParameterNameState ofClass:SDLWindowState.class error:NULL];
+ NSError *error = nil;
+ return [self.store sdl_objectForName:SDLRPCParameterNameState ofClass:SDLWindowState.class error:&error];
}
@end
diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStateSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStateSpec.m
index b6bb356ea..daac097e9 100644
--- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStateSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStateSpec.m
@@ -15,31 +15,33 @@ const UInt8 approximatePosition = 13;
const UInt8 deviation = 42;
describe(@"Getter/Setter Tests", ^ {
- it(@"Should set and get correctly", ^ {
+ context(@"initWithApproximatePosition:deviation:", ^{
SDLWindowState *testStruct = [[SDLWindowState alloc] initWithApproximatePosition:approximatePosition deviation:deviation];
-
- expect(testStruct.approximatePosition).to(equal(approximatePosition));
- expect(testStruct.deviation).to(equal(deviation));
+ it(@"Expect all properties to be set properly", ^ {
+ expect(testStruct.approximatePosition).to(equal(approximatePosition));
+ expect(testStruct.deviation).to(equal(deviation));
+ });
});
- it(@"Should get correctly when initialized", ^ {
- NSDictionary *dict = @{SDLRPCParameterNameDeviation:@(deviation),
- SDLRPCParameterNameApproximatePosition:@(approximatePosition)
- };
+ context(@"initWithDictionary:", ^{
+ NSDictionary *dict = @{SDLRPCParameterNameDeviation:@(deviation), SDLRPCParameterNameApproximatePosition:@(approximatePosition)};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLWindowState *testStruct = [[SDLWindowState alloc] initWithDictionary:dict];
#pragma clang diagnostic pop
-
- expect(testStruct.approximatePosition).to(equal(approximatePosition));
- expect(testStruct.deviation).to(equal(deviation));
+ it(@"Expect all properties to be set properly", ^ {
+ expect(testStruct.approximatePosition).to(equal(approximatePosition));
+ expect(testStruct.deviation).to(equal(deviation));
+ });
});
- it(@"Should return nil if not set", ^ {
+ context(@"init", ^{
SDLWindowState *testStruct = [[SDLWindowState alloc] init];
- expect(testStruct.approximatePosition).to(beNil());
- expect(testStruct.deviation).to(beNil());
+ it(@"Should return nil if not set", ^ {
+ expect(testStruct.approximatePosition).to(beNil());
+ expect(testStruct.deviation).to(beNil());
+ });
});
});
diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStatusSpec.m
index 72254f7da..477ed3e83 100644
--- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStatusSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLWindowStatusSpec.m
@@ -17,35 +17,37 @@ const UInt8 deviation = 42;
QuickSpecBegin(SDLWindowStatusSpec)
describe(@"Getter/Setter Tests", ^ {
- it(@"Should set and get correctly", ^ {
+ context(@"initWithLocation:state", ^{
SDLWindowState *state = [[SDLWindowState alloc] initWithApproximatePosition:approximatePosition deviation:deviation];
SDLGrid *location = [[SDLGrid alloc] init];
SDLWindowStatus *testStruct = [[SDLWindowStatus alloc] initWithLocation:location state:state];
- expect(testStruct.location).to(equal(location));
- expect(testStruct.state).to(equal(state));
+ it(@"Expect all properties to be set properly", ^ {
+ expect(testStruct.location).to(equal(location));
+ expect(testStruct.state).to(equal(state));
+ });
});
- it(@"Should get correctly when initialized", ^ {
+ context(@"initWithDictionary:", ^{
SDLWindowState *state = [[SDLWindowState alloc] initWithApproximatePosition:approximatePosition deviation:deviation];
SDLGrid *location = [[SDLGrid alloc] init];
- NSDictionary *dict = @{SDLRPCParameterNameLocation:location,
- SDLRPCParameterNameState:state
- };
+ NSDictionary *dict = @{SDLRPCParameterNameLocation:location, SDLRPCParameterNameState:state};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLWindowStatus *testStruct = [[SDLWindowStatus alloc] initWithDictionary:dict];
#pragma clang diagnostic pop
-
- expect(testStruct.location).to(equal(location));
- expect(testStruct.state).to(equal(state));
+ it(@"Expect all properties to be set properly", ^ {
+ expect(testStruct.location).to(equal(location));
+ expect(testStruct.state).to(equal(state));
+ });
});
- it(@"Should return nil if not set", ^ {
+ context(@"init", ^{
SDLWindowStatus *testStruct = [[SDLWindowStatus alloc] init];
-
- expect(testStruct.location).to(beNil());
- expect(testStruct.state).to(beNil());
+ it(@"Should return nil if not set", ^ {
+ expect(testStruct.location).to(beNil());
+ expect(testStruct.state).to(beNil());
+ });
});
});