Skip to content

Commit 5f67634

Browse files
committed
fix review
1 parent 9c8043b commit 5f67634

File tree

8 files changed

+43
-68
lines changed

8 files changed

+43
-68
lines changed

WebDriverAgentLib copy-Info.plist

Lines changed: 0 additions & 26 deletions
This file was deleted.

WebDriverAgentLib/Categories/XCUIApplication+FBFocused.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
1717
/**
1818
Return current focused element
1919
*/
20-
- (id<FBElement>) fb_focusedElement;
20+
- (id<FBElement>)fb_focusedElement;
2121

2222
@end
2323

WebDriverAgentLib/Categories/XCUIElement+FBTVFocuse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515
@interface XCUIElement (FBTVFocuse)
1616

1717
/**
18-
Sets focuse
18+
Sets focus
1919
2020
@param error If there is an error, upon return contains an NSError object that describes the problem.
2121
@return YES if the operation succeeds, otherwise NO.

WebDriverAgentLib/Categories/XCUIElement+FBTVFocuse.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ - (BOOL)fb_setFocusWithError:(NSError**) error
4646
return NO;
4747
}
4848

49-
FBTVDirection direction = tracker.directionToMoveFocuse;
49+
FBTVDirection direction = tracker.directionToFocusedElement;
5050
if (direction != FBTVDirectionNone) {
5151
[[XCUIRemote sharedRemote] pressButton: (XCUIRemoteButton)direction];
5252
}

WebDriverAgentLib/Categories/XCUIElement+FBTyping.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ - (BOOL)fb_typeText:(NSString *)text frequency:(NSUInteger)frequency error:(NSEr
5151
// There is no ability to open text field via tap
5252
#if TARGET_OS_TV
5353
if (!self.hasKeyboardFocus) {
54-
[[[FBErrorBuilder builder] withDescription:@"Keyboard is not opened."] buildError:error];
55-
return NO;
54+
return [[[FBErrorBuilder builder] withDescription:@"Keyboard is not opened."] buildError:error];
5655
}
5756
#else
5857
if (![self fb_prepareForTextInputWithError:error]) {

WebDriverAgentLib/FBSpringboardApplication.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern NSString *const SPRINGBOARD_BUNDLE_ID;
2323

2424
/**
2525
Opens application on SpringBoard(HeadBoard) app with given identifier
26+
2627
@param identifier identifier of the application to tap
2728
@param error If there is an error, upon return contains an NSError object that describes the problem.
2829
@return YES if the operation succeeds, otherwise NO.

WebDriverAgentLib/Utilities/FBTVNavigationTracker.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,22 @@ NS_ASSUME_NONNULL_BEGIN
2828

2929
@interface FBTVNavigationTracker : NSObject
3030

31-
/**
32-
Track the target element's point
33-
@param targetElement A target element which will track
34-
@return An instancce of FBTVNavigationTracker
35-
*/
36-
+(instancetype)trackerWithTargetElement: (id<FBElement>) targetElement;
37-
38-
/**
39-
Move focuse to the tracked target element from current focuse
40-
*/
41-
-(FBTVDirection)directionToMoveFocuse;
42-
43-
@end
31+
/**
32+
Track the target element's point
33+
34+
@param targetElement A target element which will track
35+
@return An instancce of FBTVNavigationTracker
36+
*/
37+
+ (instancetype)trackerWithTargetElement: (id<FBElement>) targetElement;
38+
39+
/**
40+
Move the focus to the tracked target element from the currently focused one
41+
42+
@return FBTVDirection to move the focus to
43+
*/
44+
- (FBTVDirection)directionToFocusedElement;
45+
46+
@end
4447

4548
NS_ASSUME_NONNULL_END
4649

WebDriverAgentLib/Utilities/FBTVNavigationTracker.m

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@interface FBTVNavigationItem : NSObject
2121
@property (nonatomic, readonly) NSUInteger uid;
22-
@property (nonatomic, strong) NSMutableSet<NSNumber *>* directions;
22+
@property (nonatomic, readonly) NSMutableSet<NSNumber *>* directions;
2323

2424
+ (instancetype)itemWithUid:(NSUInteger) uid;
2525
@end
@@ -69,11 +69,11 @@ - (instancetype)initWithTargetElement:(id<FBElement>)targetElement
6969
return self;
7070
}
7171

72-
- (FBTVDirection)directionToMoveFocuse
72+
- (FBTVDirection)directionToFocusedElement
7373
{
7474
id<FBElement> focused = self.focusedElement;
7575
CGPoint focusedCenter = FBRectGetCenter(focused.wdFrame);
76-
FBTVNavigationItem *item = [self navigationItemFromElement:focused];
76+
FBTVNavigationItem *item = [self navigationItemWithElement:focused];
7777
CGFloat yDelta = self.targetCenter.y - focusedCenter.y;
7878
CGFloat xDelta = self.targetCenter.x - focusedCenter.x;
7979
FBTVDirection direction;
@@ -98,7 +98,7 @@ - (FBTVDirection)directionToMoveFocuse
9898
return [FBApplication fb_activeApplication].fb_focusedElement;
9999
}
100100

101-
- (FBTVNavigationItem*) navigationItemFromElement:(id<FBElement>)element
101+
- (FBTVNavigationItem*)navigationItemWithElement:(id<FBElement>)element
102102
{
103103
NSNumber *key = [NSNumber numberWithUnsignedInteger:element.wdUID];
104104
FBTVNavigationItem* item = [self.navigationItems objectForKey: key];
@@ -112,34 +112,32 @@ - (FBTVNavigationItem*) navigationItemFromElement:(id<FBElement>)element
112112

113113
- (FBTVDirection)getHorizontalDirectionForItem:(FBTVNavigationItem *)item withDelta:(CGFloat)delta
114114
{
115-
if (delta > 0) {
116-
if(![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionRight]]) {
117-
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionRight]];
118-
return FBTVDirectionRight;
119-
}
115+
// GCFloat is double in 64bit. tvOS is only for arm64
116+
if (delta > DBL_EPSILON &&
117+
![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionRight]]) {
118+
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionRight]];
119+
return FBTVDirectionRight;
120120
}
121-
if (delta < 0) {
122-
if(![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionLeft]]) {
123-
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionLeft]];
124-
return FBTVDirectionLeft;
125-
}
121+
if (delta < DBL_EPSILON &&
122+
![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionLeft]]) {
123+
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionLeft]];
124+
return FBTVDirectionLeft;
126125
}
127126
return FBTVDirectionNone;
128127
}
129128

130129
- (FBTVDirection)getVerticalDirectionForItem:(FBTVNavigationItem *)item withDelta:(CGFloat)delta
131130
{
132-
if (delta > 0) {
133-
if(![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionDown]]) {
134-
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionDown]];
135-
return FBTVDirectionDown;
136-
}
131+
// GCFloat is double in 64bit. tvOS is only for arm64
132+
if (delta > DBL_EPSILON &&
133+
![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionDown]]) {
134+
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionDown]];
135+
return FBTVDirectionDown;
137136
}
138-
if (delta < 0) {
139-
if(![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionUp]]) {
140-
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionUp]];
141-
return FBTVDirectionUp;
142-
}
137+
if (delta < DBL_EPSILON &&
138+
![item.directions containsObject: [NSNumber numberWithInteger: FBTVDirectionUp]]) {
139+
[item.directions addObject: [NSNumber numberWithInteger: FBTVDirectionUp]];
140+
return FBTVDirectionUp;
143141
}
144142
return FBTVDirectionNone;
145143
}

0 commit comments

Comments
 (0)