summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleonid lokhmatov, Luxoft <zaqqqqqqqq@gmail.com>2021-02-13 04:52:26 +0200
committerleonid lokhmatov, Luxoft <zaqqqqqqqq@gmail.com>2021-02-13 05:49:15 +0200
commit299b9070c4d9ff3d0302c34b7d0df185d3f4cd24 (patch)
tree7da3be5be2e520dcd9fadb109df51566bd8c9c8b
parentdc911ee399177ac795d2aed22fc8a693393dce88 (diff)
downloadsdl_ios-299b9070c4d9ff3d0302c34b7d0df185d3f4cd24.tar.gz
SDL0238 'Keyboard Enhancements r2': apply review comments (keyboard operation, delegate)
-rw-r--r--SmartDeviceLink/private/SDLPresentKeyboardOperation.m4
-rw-r--r--SmartDeviceLink/public/SDLKeyboardDelegate.h8
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m21
3 files changed, 27 insertions, 6 deletions
diff --git a/SmartDeviceLink/private/SDLPresentKeyboardOperation.m b/SmartDeviceLink/private/SDLPresentKeyboardOperation.m
index 039cdb252..d4c47b780 100644
--- a/SmartDeviceLink/private/SDLPresentKeyboardOperation.m
+++ b/SmartDeviceLink/private/SDLPresentKeyboardOperation.m
@@ -211,9 +211,9 @@ NS_ASSUME_NONNULL_BEGIN
[self.keyboardDelegate keyboardDidAbortWithReason:onKeyboard.event];
} else if ([onKeyboard.event isEqualToEnum:SDLKeyboardEventInputKeyMaskEnabled] || [onKeyboard.event isEqualToEnum:SDLKeyboardEventInputKeyMaskDisabled]) {
// Notify of key mask change
- if ([self.keyboardDelegate respondsToSelector:@selector(keyboardDidEnableInputKeyMask:)]) {
+ if ([self.keyboardDelegate respondsToSelector:@selector(keyboardDidUpdateInputMask:)]) {
BOOL isEnabled = [onKeyboard.event isEqualToEnum:SDLKeyboardEventInputKeyMaskEnabled];
- [self.keyboardDelegate keyboardDidEnableInputKeyMask:isEnabled];
+ [self.keyboardDelegate keyboardDidUpdateInputMask:isEnabled];
}
}
}
diff --git a/SmartDeviceLink/public/SDLKeyboardDelegate.h b/SmartDeviceLink/public/SDLKeyboardDelegate.h
index b2cf8edb2..33da49969 100644
--- a/SmartDeviceLink/public/SDLKeyboardDelegate.h
+++ b/SmartDeviceLink/public/SDLKeyboardDelegate.h
@@ -94,12 +94,12 @@ typedef void(^SDLKeyboardCharacterSetCompletionHandler)(NSArray<NSString *> *_Nu
- (void)keyboardDidSendEvent:(SDLKeyboardEvent)event text:(NSString *)currentInputText;
/**
- Implement this to be notified of input key mask update
-
- @param isEnabled - mask is enabled or disabled flag
+ Implement this to be notified of input key mask update (whether or not the user has changed the input to be hidden, like passwords)
+
+ @param isEnabled - YES if the mask is enabled, NO if the mask is disabled
@added in SmartDeviceLink 7.1.0
*/
-- (void)keyboardDidEnableInputKeyMask:(BOOL)isEnabled;
+- (void)keyboardDidUpdateInputMask:(BOOL)isEnabled;
@end
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m
index eae0c2098..274687ff7 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m
@@ -48,6 +48,8 @@ describe(@"present keyboard operation", ^{
afterEach(^{
if (testOp) {
+ // rationale: every test run creates a new operation to test, the old operation from a previous test
+ // stays 'undead' undefined time and can receive notifications causing a test fail at random
[[NSNotificationCenter defaultCenter] removeObserver:testOp];
testOp = nil;
}
@@ -155,6 +157,25 @@ describe(@"present keyboard operation", ^{
}]]);
});
+ it(@"should respond to enabled keyboard event", ^{
+ SDLRPCNotificationNotification *notification = nil;
+
+ // Submit notification
+ SDLOnKeyboardInput *input = [[SDLOnKeyboardInput alloc] init];
+ input.event = SDLKeyboardEventInputKeyMaskEnabled;
+ notification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidReceiveKeyboardInputNotification object:nil rpcNotification:input];
+
+ [[NSNotificationCenter defaultCenter] postNotification:notification];
+
+ OCMVerify([testDelegate keyboardDidSendEvent:[OCMArg checkWithBlock:^BOOL(id obj) {
+ return [(SDLKeyboardEvent)obj isEqualToEnum:SDLKeyboardEventInputKeyMaskEnabled];
+ }] text:[OCMArg isNil]]);
+
+ OCMVerify([testDelegate keyboardDidUpdateInputMask:[OCMArg checkWithBlock:^BOOL(id obj) {
+ return [(SDLKeyboardEvent)obj isEqualToEnum:SDLKeyboardEventInputKeyMaskEnabled];
+ }]]);
+ });
+
it(@"should respond to cancellation notifications", ^{
SDLRPCNotificationNotification *notification = nil;