Skip to content

Commit

Permalink
Merge pull request #2058 from smartdevicelink/bugfix/issue-2050-video…
Browse files Browse the repository at this point in the history
…streamingrange-init

Deprecate SDLVideoStreamingRange.init
  • Loading branch information
joeljfischer authored Nov 1, 2021
2 parents 1d5f32c + cc02da9 commit bc3054b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 194 deletions.
4 changes: 0 additions & 4 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,6 @@
B38D8E8024A1E3D000B977D0 /* SDLTransmissionTypeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B38D8E7F24A1E3D000B977D0 /* SDLTransmissionTypeSpec.m */; };
B38D8E8224A1F53500B977D0 /* SDLCapacityUnitSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B38D8E8124A1F53500B977D0 /* SDLCapacityUnitSpec.m */; };
B3A0BA2925940ED100CC3BDF /* SDLCarWindowSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A0BA212593FE7400CC3BDF /* SDLCarWindowSpec.m */; };
B3A0BA2D259600D100CC3BDF /* SDLSupportedStreamingRangeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A0BA2C259600D100CC3BDF /* SDLSupportedStreamingRangeSpec.m */; };
B3A3CE9E2522241600A7121D /* SDLAppCapabilitySpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A3CE9D2522241600A7121D /* SDLAppCapabilitySpec.m */; };
B3A3CEA025222A2900A7121D /* SDLOnAppCapabilityUpdatedSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A3CE9F25222A2900A7121D /* SDLOnAppCapabilityUpdatedSpec.m */; };
B3A9D9E225D2571000CDFD21 /* SDLKeyboardCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B3A9D9E025D2571000CDFD21 /* SDLKeyboardCapabilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -3642,7 +3641,6 @@
B38D8E7F24A1E3D000B977D0 /* SDLTransmissionTypeSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLTransmissionTypeSpec.m; sourceTree = "<group>"; };
B38D8E8124A1F53500B977D0 /* SDLCapacityUnitSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLCapacityUnitSpec.m; sourceTree = "<group>"; };
B3A0BA212593FE7400CC3BDF /* SDLCarWindowSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLCarWindowSpec.m; sourceTree = "<group>"; };
B3A0BA2C259600D100CC3BDF /* SDLSupportedStreamingRangeSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLSupportedStreamingRangeSpec.m; sourceTree = "<group>"; };
B3A3CE9D2522241600A7121D /* SDLAppCapabilitySpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLAppCapabilitySpec.m; sourceTree = "<group>"; };
B3A3CE9F25222A2900A7121D /* SDLOnAppCapabilityUpdatedSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnAppCapabilityUpdatedSpec.m; sourceTree = "<group>"; };
B3A9D9DF25D2571000CDFD21 /* SDLKeyboardCapabilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLKeyboardCapabilities.m; path = public/SDLKeyboardCapabilities.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6005,7 +6003,6 @@
5DB1BCE41D245629002FFC37 /* State Machine */,
5D6EB4C71BF28D6800693731 /* Categories */,
5DCC458C221C9F6600036C2F /* SDLVersionSpec.m */,
B3A0BA2C259600D100CC3BDF /* SDLSupportedStreamingRangeSpec.m */,
);
name = Utilities;
sourceTree = "<group>";
Expand Down Expand Up @@ -8779,7 +8776,6 @@
5DA23FF31F2FA35C009C0313 /* SDLControlFramePayloadAudioStartServiceAckSpec.m in Sources */,
1EAA476820369BCF000FE74B /* SDLLightStateSpec.m in Sources */,
1680B11C1A9CD7AD00DBD79E /* SDLProtocolMessageAssemblerSpec.m in Sources */,
B3A0BA2D259600D100CC3BDF /* SDLSupportedStreamingRangeSpec.m in Sources */,
8850DB601F4475D30053A48D /* TestMultipleFilesConnectionManager.m in Sources */,
162E83181A9BDE8B00906325 /* SDLOnKeyboardInputSpec.m in Sources */,
1EE8C4441F34A1B900FDC2CF /* SDLClimateControlDataSpec.m in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions SmartDeviceLink/public/SDLVideoStreamingRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
/// The maximum resolution to support, it overrides .maximumAspectRatio
@property (nonatomic, strong, nullable) SDLImageResolution *maximumResolution;

/// Creates a disabled range without any min/max aspect ratio or min diagonal information.
- (instancetype)init __deprecated_msg("Use .disabled instead");

/// Create a video streaming range based on a minimum and maximum resolution
/// @param minResolution The minimum supported height / width resolution
/// @param maxResolution The maximum supported height / width resolution
Expand Down
6 changes: 3 additions & 3 deletions SmartDeviceLink/public/SDLVideoStreamingRange.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ - (instancetype)initWithMinimumResolution:(nullable SDLImageResolution *)minReso

_minimumResolution = minResolution;
_maximumResolution = maxResolution;
_minimumDiagonal = minimumDiagonal;
_minimumAspectRatio = minimumAspectRatio;
_maximumAspectRatio = maximumAspectRatio;
self.minimumDiagonal = minimumDiagonal;
self.minimumAspectRatio = minimumAspectRatio;
self.maximumAspectRatio = maximumAspectRatio;

return self;
}
Expand Down
135 changes: 79 additions & 56 deletions SmartDeviceLinkTests/DevAPISpecs/SDLVideoStreamingRangeSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,83 @@
describe(@"video streaming range", ^{
__block SDLVideoStreamingRange *testRange = nil;
SDLImageResolution *disabledResolution = [[SDLImageResolution alloc] initWithWidth:0 height:0];
SDLImageResolution *lowResolution = [[SDLImageResolution alloc] initWithWidth:1 height:1];
SDLImageResolution *highResolution = [[SDLImageResolution alloc] initWithWidth:999 height:999];
SDLImageResolution *minResolution = [[SDLImageResolution alloc] initWithWidth:10 height:50];
SDLImageResolution *maxResolution = [[SDLImageResolution alloc] initWithWidth:100 height:500];
const float minimumAspectRatio = 2.5;
const float maximumAspectRatio = 7.1;
const float minimumDiagonal = 3.3;

float defaultMinimumAspectRatio = 1.0;
float defaultMaximumAspectRatio = 9999.0;
float defaultMinimumDiagonal = 0.0;

float testMinimumAspectRatio = 4.0;
float testMaximumAspectRatio = 12.0;
float testMinimumDiagonal = 6.0;
describe(@"initialization", ^{
context(@"init", ^{
beforeEach(^{
testRange = [SDLVideoStreamingRange disabled];
});

beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:lowResolution maximumResolution:highResolution];;
});
it(@"expect object to be created with empty fields", ^{
expect(testRange).toNot(beNil());
expect(testRange.minimumResolution).to(equal(disabledResolution));
expect(testRange.maximumResolution).to(equal(disabledResolution));
expect(testRange.minimumAspectRatio).to(equal(defaultMinimumAspectRatio));
expect(testRange.maximumAspectRatio).to(equal(defaultMaximumAspectRatio));
expect(testRange.minimumDiagonal).to(equal(defaultMinimumDiagonal));
});

context(@"initialized with initWithMinimumResolution:maximumResolution", ^{
it(@"should set all parameters correctly", ^{
expect(testRange.minimumResolution).to(equal(lowResolution));
expect(testRange.maximumResolution).to(equal(highResolution));
expect(testRange.minimumAspectRatio).to(equal(1.0));
expect(testRange.maximumAspectRatio).to(equal(9999.0));
expect(testRange.minimumDiagonal).to(equal(0.0));
});
});
it(@"expect object to be created and properties are set properly", ^{
testRange.minimumResolution = minResolution;
testRange.maximumResolution = maxResolution;
testRange.minimumDiagonal = minimumDiagonal;
testRange.minimumAspectRatio = minimumAspectRatio;
testRange.maximumAspectRatio = maximumAspectRatio;

context(@"initialized with initWithMinimumResolution:maximumResolution:minimumAspectRatio:maximumAspectRatio:minimumDiagonal:", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:lowResolution maximumResolution:highResolution minimumAspectRatio:testMinimumAspectRatio maximumAspectRatio:testMaximumAspectRatio minimumDiagonal:testMinimumDiagonal];
expect(testRange).toNot(beNil());
expect(testRange.minimumResolution).to(equal(minResolution));
expect(testRange.maximumResolution).to(equal(maxResolution));
expect(testRange.minimumAspectRatio).to(equal(minimumAspectRatio));
expect(testRange.maximumAspectRatio).to(equal(maximumAspectRatio));
expect(testRange.minimumDiagonal).to(equal(minimumDiagonal));
});
});

it(@"should set all parameters correctly", ^{
expect(testRange.minimumResolution).to(equal(lowResolution));
expect(testRange.maximumResolution).to(equal(highResolution));
expect(testRange.minimumAspectRatio).to(equal(testMinimumAspectRatio));
expect(testRange.maximumAspectRatio).to(equal(testMaximumAspectRatio));
expect(testRange.minimumDiagonal).to(equal(testMinimumDiagonal));
});
});
context(@"initWithMinimumResolution:maximumResolution:", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:minResolution maximumResolution:maxResolution];
});

context(@"initialized with disabled", ^{
beforeEach(^{
testRange = [SDLVideoStreamingRange disabled];
it(@"expect min and max resolution to be set and others are defaults", ^{
expect(testRange).toNot(beNil());
expect(testRange.minimumResolution).to(equal(minResolution));
expect(testRange.maximumResolution).to(equal(maxResolution));
expect(testRange.minimumAspectRatio).to(equal(defaultMinimumAspectRatio));
expect(testRange.maximumAspectRatio).to(equal(defaultMaximumAspectRatio));
expect(testRange.minimumDiagonal).to(equal(defaultMinimumDiagonal));
});
});

it(@"should set all parameters correctly", ^{
expect(testRange.minimumResolution).to(equal(disabledResolution));
expect(testRange.maximumResolution).to(equal(disabledResolution));
expect(testRange.minimumAspectRatio).to(equal(defaultMinimumAspectRatio));
expect(testRange.maximumAspectRatio).to(equal(defaultMaximumAspectRatio));
expect(testRange.minimumDiagonal).to(equal(defaultMinimumDiagonal));
context(@"initWithMinimumResolution:maximumResolution:minimumAspectRatio:maximumAspectRatio:minimumDiagonal:", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:minResolution maximumResolution:maxResolution minimumAspectRatio:minimumAspectRatio maximumAspectRatio:maximumAspectRatio minimumDiagonal:minimumDiagonal];
});

it(@"expect min and max resolution to be set and others are defaults", ^{
expect(testRange).toNot(beNil());
expect(testRange.minimumResolution).to(equal(minResolution));
expect(testRange.maximumResolution).to(equal(maxResolution));
expect(testRange.minimumAspectRatio).to(equal(minimumAspectRatio));
expect(testRange.maximumAspectRatio).to(equal(maximumAspectRatio));
expect(testRange.minimumDiagonal).to(equal(minimumDiagonal));
});
});
});

describe(@"setting float parameters", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:minResolution maximumResolution:maxResolution];;
});

describe(@"minimum aspect ratio", ^{
context(@"below the minimum", ^{
it(@"should be set to the minimum", ^{
Expand All @@ -80,8 +103,8 @@

context(@"above the minimum", ^{
it(@"should set the value", ^{
testRange.minimumAspectRatio = testMinimumAspectRatio;
expect(testRange.minimumAspectRatio).to(equal(testMinimumAspectRatio));
testRange.minimumAspectRatio = minimumAspectRatio;
expect(testRange.minimumAspectRatio).to(equal(minimumAspectRatio));
});
});
});
Expand All @@ -96,8 +119,8 @@

context(@"above the minimum", ^{
it(@"should set the value", ^{
testRange.maximumAspectRatio = testMaximumAspectRatio;
expect(testRange.maximumAspectRatio).to(equal(testMaximumAspectRatio));
testRange.maximumAspectRatio = maximumAspectRatio;
expect(testRange.maximumAspectRatio).to(equal(maximumAspectRatio));
});
});
});
Expand All @@ -112,16 +135,16 @@

context(@"above the minimum", ^{
it(@"should set the value", ^{
testRange.minimumDiagonal = testMinimumDiagonal;
expect(testRange.minimumDiagonal).to(equal(testMinimumDiagonal));
testRange.minimumDiagonal = minimumDiagonal;
expect(testRange.minimumDiagonal).to(equal(minimumDiagonal));
});
});
});
});

describe(@"checking if the resolution is in a given range", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:lowResolution maximumResolution:highResolution];
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:minResolution maximumResolution:maxResolution];
});

context(@"when there is no minimum or maximum resolution", ^{
Expand All @@ -136,17 +159,17 @@

context(@"when there is no maximum resolution", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:lowResolution maximumResolution:nil];
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:minResolution maximumResolution:nil];
});

it(@"should return YES", ^{
expect([testRange isImageResolutionInRange:[[SDLImageResolution alloc] initWithWidth:2 height:2]]).to(beTrue());
it(@"should return YES when above the minimum resolution", ^{
expect([testRange isImageResolutionInRange:[[SDLImageResolution alloc] initWithWidth:12 height:52]]).to(beTrue());
});
});

context(@"when there is no minimum resolution", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:highResolution];
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:maxResolution];
});

it(@"should return YES", ^{
Expand All @@ -168,33 +191,33 @@

context(@"when the resolution is in the range", ^{
it(@"should return YES", ^{
expect([testRange isImageResolutionInRange:[[SDLImageResolution alloc] initWithWidth:2 height:2]]).to(beTrue());
expect([testRange isImageResolutionInRange:[[SDLImageResolution alloc] initWithWidth:12 height:52]]).to(beTrue());
});
});
});

describe(@"checking if the aspect ratio is in a given range", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:nil minimumAspectRatio:testMinimumAspectRatio maximumAspectRatio:testMaximumAspectRatio minimumDiagonal:1.0];
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:nil minimumAspectRatio:minimumAspectRatio maximumAspectRatio:maximumAspectRatio minimumDiagonal:1.0];
});

context(@"when there is no maximum aspect ratio", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:nil minimumAspectRatio:testMinimumAspectRatio maximumAspectRatio:0.0 minimumDiagonal:1.0];
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:nil minimumAspectRatio:minimumAspectRatio maximumAspectRatio:0.0 minimumDiagonal:1.0];
});

it(@"should return NO", ^{
expect([testRange isAspectRatioInRange:10.0]).to(beTrue());
expect([testRange isAspectRatioInRange:10.0]).to(beFalse());
});
});

context(@"when there is no minimum aspect ratio", ^{
beforeEach(^{
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:nil minimumAspectRatio:0.0 maximumAspectRatio:testMaximumAspectRatio minimumDiagonal:1.0];
testRange = [[SDLVideoStreamingRange alloc] initWithMinimumResolution:nil maximumResolution:nil minimumAspectRatio:0.0 maximumAspectRatio:maximumAspectRatio minimumDiagonal:1.0];
});

it(@"should return NO", ^{
expect([testRange isAspectRatioInRange:10.0]).to(beTrue());
it(@"should set the minimum to 1.0", ^{
expect(testRange.minimumAspectRatio).to(equal(1.0));
});
});

Expand All @@ -212,7 +235,7 @@

context(@"when the aspect ratio is in the range", ^{
it(@"should return NO", ^{
expect([testRange isAspectRatioInRange:10.0]).to(beTrue());
expect([testRange isAspectRatioInRange:6.0]).to(beTrue());
});
});
});
Expand Down
Loading

0 comments on commit bc3054b

Please # to comment.