-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SDL 0179 - Pixel density and Scale #1360
Implement SDL 0179 - Pixel density and Scale #1360
Conversation
…amingCapability'.
…nges in the view controller's size to the accepted video resolution divided by the scale.
… Scale' proposal.
428b300
to
e4a8547
Compare
@joeljfischer please review. |
@kshala-ford can you please confirm if you have reviewed and approved this PR? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment regarding the OnTouchEvent
scaling. Other than that it looks good. I was missing code/tests regarding the hit tester (see https://github.com/smartdevicelink/sdl_ios/blob/master/SmartDeviceLink/SDLTouchManager.m#L89). This is using the focusable item tester here https://github.com/smartdevicelink/sdl_ios/blob/master/SmartDeviceLink/SDLFocusableItemLocator.h
Can you explain if the hit tester is covered by updating the touch event notifications?
…el_density_and_scale
…deo streaming source match size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments on the code. When I run the all of the test cases all at once (Product > Test), 19 test case s fail. However, when I run the classes where the test cases fail individually, all the class test cases succeed. I tried to debug the test cases but I'm not sure exactly what is happening. I would recommend commenting out the changes you made and adding them back in one-by-one.
SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLVideoStreamingCapabilitySpec.m
Show resolved
Hide resolved
@@ -23,6 +23,8 @@ | |||
#import "SDLTouchManagerDelegate.h" | |||
#import "SDLTouchType.h" | |||
#import "SDLTouch.h" | |||
#import "SDLVideoStreamingCapability.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run all the test cases at once, I get 14 failing test cases in this class, but when I run just the test cases in this class they all pass. I'm baffled as to why this is happening. Maybe the new scale
parameter is messing things up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did noticed that some of the tests are faulty, but at the end they pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main problem there is that:
- SDLTouchManager is recreated on every test.
- SDLTouchManager subscribes for notifications in its -init* method (which is not the best solution by itself but it works)
- SDLTouchManager never unsubscribes from notifications.
- A few instances of SDLTouchManager receive notifications and handle them "properly"
- Tests fail due to wrong event number
Hotfix in SDLTouchManagerSpec.m:
if (touchManager) {
//FIXIT: SDLTouchManager must unsubscribe from notifications
[[NSNotificationCenter defaultCenter] removeObserver:touchManager];
touchManager = nil;
}
SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m
Outdated
Show resolved
Hide resolved
…el_density_and_scale
@NicoleYarroch Done. All your comments have been addressed in a new commit. |
699d4db
to
4cd321e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments on the implementation and the tests.
if (scale != nil) { | ||
return scale; | ||
} | ||
return SDLVideoStreamingCapability.sdl_DefaultScale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you are trying to do here, but a custom getter should not be created in this class. The SDL convention is for this to return the value set by Core. In the future we might need to know if scale
is null
or if it has been set by Core and we wouldn't be able to get this information with the current setup. I added another comment to the SDLStreamingVideoLifecycleManager
with an idea of how to best reuse the code.
@@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN | |||
|
|||
@property (strong, nonatomic, readonly) SDLStateMachine *videoStreamStateMachine; | |||
@property (strong, nonatomic, readonly) SDLVideoStreamManagerState *currentVideoStreamState; | |||
@property (nullable, strong, nonatomic, readonly) SDLVideoStreamingCapability *videoStreamingCapability; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you want to makevideoStreamingCapability
public? Iit doesn't appear to be used by another class. If developers want to get the videoStreamingCapability
they can use the SDLSystemCapabilityManager
.
@@ -58,6 +58,8 @@ @interface SDLStreamingVideoLifecycleManager() <SDLVideoEncoderDelegate> | |||
@property (assign, nonatomic, readonly, getter=isAppStateVideoStreamCapable) BOOL appStateVideoStreamCapable; | |||
@property (assign, nonatomic, readonly, getter=isHmiStateVideoStreamCapable) BOOL hmiStateVideoStreamCapable; | |||
|
|||
@property (nullable, strong, nonatomic, readwrite) SDLVideoStreamingCapability *videoStreamingCapability; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This my idea of how to best prevent duplicate code for the scale
value.
- In the
SDLStreamingVideoLifecycleManager
create a customsdl_scale
getter to returnvideoStreamingCapability.scale
or1
if thescale
value does not exists. - Add another init to
SDLTouchManger
that takes ascale
value in addition to thehitTester
. In theSDLStreamingVideoLifecycleManager
class setsdl_scale
for thescale
value in the touch manager init. Then later, when we get thevideoStreamingCapability
from core, the actual scale value can be set in the touch manager class. - Do the same thing for
SDLCarWindow
. Add another init toSDLCarWindow
that takes ascale
value in addition to thestreamManager
andconfiguration
. In theSDLStreamingVideoLifecycleManager
class setsdl_scale
for thescale
value in the car window init. Then later, when we get thevideoStreamingCapability
from core, the actual scale value can be set in the car window class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented here:
yLeonid@91b30ce
@@ -42,7 +45,10 @@ | |||
NSMutableDictionary* dict = [@{SDLRPCParameterNamePreferredResolution: resolution, | |||
SDLRPCParameterNameMaxBitrate: maxBitrate, | |||
SDLRPCParameterNameSupportedFormats: formatArray, | |||
SDLRPCParameterNameHapticSpatialDataSupported: hapticDataSupported} mutableCopy]; | |||
SDLRPCParameterNameHapticSpatialDataSupported: hapticDataSupported, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add checks for the new values added to the dictionary to this test case:
expect(testStruct.diagonalScreenSize).to(equal(diagonalScreenSize));
expect(testStruct.pixelPerInch).to(equal(pixelPerInch));
expect(testStruct.scale).to(equal(scale));
@@ -60,6 +66,9 @@ | |||
expect(testStruct.preferredResolution).to(beNil()); | |||
expect(testStruct.maxBitrate).to(beNil()); | |||
expect(testStruct.supportedFormats).to(beNil()); | |||
expect(testStruct.diagonalScreenSize).to(beNil()); | |||
expect(testStruct.pixelPerInch).to(beNil()); | |||
expect(testStruct.scale).to(equal(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be expect(testStruct.scale).to(beNil());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here:
lnafarrateluxoft@c8a9e5e
@@ -80,12 +92,15 @@ | |||
|
|||
NSArray<SDLVideoStreamingFormat *> *formatArray = @[format1, format2]; | |||
|
|||
SDLVideoStreamingCapability *testStruct = [[SDLVideoStreamingCapability alloc] initWithPreferredResolution:resolution maxBitrate:maxBitrate supportedFormats:formatArray hapticDataSupported:hapticDataSupported]; | |||
SDLVideoStreamingCapability *testStruct = [[SDLVideoStreamingCapability alloc] initWithPreferredResolution:resolution maxBitrate:maxBitrate supportedFormats:formatArray hapticDataSupported:hapticDataSupported diagonalScreenSize:diagonalScreenSize pixelPerInch:pixelPerInch scale:scale]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add another test case so you have one test case for the new init
and another test case for the deprecated init
. The SDLMediaServiceDataSpec
has an example of how to suppress warnings when testing a deprecated init.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented here (lines 109-140)
lnafarrateluxoft@c8a9e5e
@@ -40,6 +40,7 @@ | |||
@interface SDLStreamingVideoLifecycleManager () | |||
@property (copy, nonatomic, readonly) NSString *appName; | |||
@property (copy, nonatomic, readonly) NSString *videoStreamBackgroundString; | |||
@property (strong, nonatomic, readwrite) SDLVideoStreamingCapability *videoStreamingCapability; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should match what is in the class being tested (missing the nullable
)
@property (nullable, strong, nonatomic, readwrite) SDLVideoStreamingCapability *videoStreamingCapability;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in (line 43):
lnafarrateluxoft@c8a9e5e
@@ -40,6 +40,7 @@ | |||
@interface SDLStreamingVideoLifecycleManager () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests in this class are crashing due to the videoStreamingCapability
not yet being set in the SDLCarWindow
class. In the sdl_getScaledScreenSizeFrame
of the SDLCarWindow
class it is dividing by a scale
of 0
. This would be solved by setting a default scale value in the init
of SDLCarWindow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -184,7 +185,8 @@ - (void)sdl_onTouchEvent:(SDLRPCNotificationNotification *)notification { | |||
return; | |||
} | |||
|
|||
SDLOnTouchEvent* onTouchEvent = (SDLOnTouchEvent*)notification.notification; | |||
SDLOnTouchEvent *onTouchEvent = (SDLOnTouchEvent *)notification.notification; | |||
onTouchEvent = [self sdl_applyScaleToEventCoordinates:onTouchEvent.copy]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think copy
is working as expected here which is why the TouchManager
test cases are breaking when I run all the tests. Maybe copyWithZone:
has a bug?
@lnafarrateluxoft can you please let us know when you anticipate this PR being ready for re-review? Thank you! |
SDLLogD(@"Video stream started, setting CarWindow frame to: %@", NSStringFromCGRect(self.rootViewController.view.bounds)); | ||
}); | ||
} | ||
|
||
- (CGRect)sdl_getScaledScreenSizeFrame { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading method name:
- We can use a property name without the prefix get
- (CGRect)sdl_scaledScreenSizeFrame {}
- If we really want to use the prefix get then the method must look like this:
- (void)sdl_getScaledScreenSizeFrame:(CGRect * outRect) {
if (outRect) {
*outRect = <the rect value>;
}
}
(See Apple Objective-C guideline)
Travis tests had no chance to pass or even to get executed: |
smartdevicelink#1360 (comment) smartdevicelink#1360 (comment) update CarWindow and TouchManager to use scale from StreamingVideoLifecycleManager in init smartdevicelink#1360 (comment)
smartdevicelink#1360 (comment) smartdevicelink#1360 (comment) update private property of tested class in test to meet its declaration
@NicoleYarroch Please review updates related to your comments |
Closing this PR in favor of PR #1401 |
Fixes #1007
This PR is ready for review.
Risk
This PR makes minor API changes.
Testing Plan
Unit tests added for:
Functional testing can be done by editing the preferred resolution,
and scale in HMI and testing that the captured view has the proper size and touches are reported
correctly and with the correct coordinates while clicking on the HMI interface.
Also the Automatic Haptic Rect sent to HMI should have the propper size according to the scale value set.
Summary
The main change is related to changing the size of the view captured.
This is done by adding a new scale parameter in the video
streaming capability and by dividing the preferred resolution from the
HMI and the scale.
Also touch coordinates need some changes to match in the HMI with the new resolution, I had to divide the coordinates with the new scale value.
CLA