Conversation
Cartfile
Outdated
|
|
||
| # Used by the element cache | ||
| github "appium/YYCache" | ||
| github "KazuCocoa/YYCache" "add-tvos-support" |
There was a problem hiding this comment.
Will change to appium/YYCache after appium/YYCache#1
| /** | ||
| Return current focused element | ||
| */ | ||
| - (id<FBElement>) fb_focusedElement; |
There was a problem hiding this comment.
Will move into XCUIApplication+FBHelpers.h in the next PR like https://github.com/KazuCocoa/WebDriverAgent/pull/4/files#diff-b4b112241fad0f90c09864fbe40aef25R56
|
|
||
| @implementation XCUIApplication (FBFocused) | ||
|
|
||
| - (id<FBElement>) fb_focusedElement |
There was a problem hiding this comment.
Will move into XCUIApplication+FBHelpers.m in the next PR
| return [[self fb_cachedValueWithAttributeName:@"isWDVisible" valueGetter:getter] boolValue]; | ||
| } | ||
|
|
||
| #if TARGET_OS_TV |
There was a problem hiding this comment.
Will remove since hasFocus is included in iPhone as well.
(I noticed after this change...)
https://developer.apple.com/documentation/xctest/xcuielementattributes/1627636-hasfocus
|
|
||
| - (FBTVDirection)directionToMoveFocuse | ||
| { | ||
| id<FBElement> focused = self.focusedElement; |
There was a problem hiding this comment.
FBElement will change to XCUIElement in the next PR like https://github.com/KazuCocoa/WebDriverAgent/pull/4/files#diff-ca69d06a77426842d4a7b3c34bfcedc4R44
| #if TARGET_OS_TV | ||
| @interface XCUIElement (FBTVFocuse) | ||
|
|
||
| -(BOOL)fb_focuseWithError:(NSError**) error; |
|
|
||
| -(BOOL)fb_focuseWithError:(NSError**) error; | ||
|
|
||
| -(BOOL)fb_selectWithError:(NSError**) error; |
There was a problem hiding this comment.
There should be a space after - or +
| -(BOOL)fb_focuseWithError:(NSError**) error | ||
| { | ||
| [[FBApplication fb_activeApplication] fb_waitUntilSnapshotIsStable]; | ||
| if (self.wdEnabled) { |
There was a problem hiding this comment.
Id' rather make the condition block shorter by checking !self.wdEnabled
| } | ||
| if (self.exists) { | ||
| FBTVDirection direction = tracker.directionToMoveFocuse; | ||
| if(direction != FBTVDirectionNone) { |
| continue; | ||
| } | ||
| } | ||
| [[[FBErrorBuilder builder] withDescription:@"Unable to reach element. Try to use XCUIRemote commands."] |
There was a problem hiding this comment.
I'd also put element.desciption into the error message
| } | ||
|
|
||
| /** | ||
| * Returns proper identifier |
| if (![appElement fb_selectWithError:error]) { | ||
| return NO; | ||
| } | ||
| [[XCUIRemote sharedRemote] pressButton: XCUIRemoteButtonSelect]; |
There was a problem hiding this comment.
isn't fb_selectWithError already pressing XCUIRemoteButtonSelect ?
| { | ||
| [self resolve]; | ||
| #if TARGET_OS_TV | ||
| return self.collectionViews[@"GridCollectionView"].isEnabled; |
There was a problem hiding this comment.
is GridCollectionView precise?
There was a problem hiding this comment.
so far, the GridCollectionView looks the most reasonable... at least, it appears on the top...
| #import "XCUIElement+FBWebDriverAttributes.h" | ||
|
|
||
| @interface FBTVNavigationItem : NSObject | ||
| @property (nonatomic, assign) NSUInteger uid; |
| CGFloat yDelta = self.targetCenter.y - focusedCenter.y; | ||
| CGFloat xDelta = self.targetCenter.x - focusedCenter.x; | ||
| FBTVDirection direction; | ||
| if(fabs(yDelta) > fabs(xDelta)) { |
| return [FBApplication fb_activeApplication].fb_focusedElement; | ||
| } | ||
|
|
||
| -(FBTVNavigationItem*) navigationItemFromElement:(id<FBElement>)element |
|
|
||
| - (BOOL)isWDFocused | ||
| { | ||
| return self.hasFocus; |
There was a problem hiding this comment.
should the value of the attribute be cached?
| return self; | ||
| } | ||
|
|
||
| - (FBTVDirection)directionToFocusedElement |
There was a problem hiding this comment.
this method is a classic example of the path finding algorithm. It would be nice to cover it with unit tests in the next PRs
mykola-mokhnach
left a comment
There was a problem hiding this comment.
I like the PR. Only some minor things are left to fix


2nd one for #148
This PR aims to build with tvOS scheme.
(I've added the scheme build on travis. So, Travis is green means tvOS build succeeds)
KazuCocoa#4 will come after this PR.
I'll add comments where will change in the next PR.
This PR is mainly add
!TARGET_OS_TVto avoid libraries which are not included in tvOSnote:
Xcode 9.2 on Travis has no tvOS device.