-
Notifications
You must be signed in to change notification settings - Fork 392
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
[tvOS]2nd: tvos build #149
Conversation
Cartfile
Outdated
@@ -2,7 +2,7 @@ | |||
github "appium/RoutingHTTPServer" | |||
|
|||
# Used by the element cache | |||
github "appium/YYCache" | |||
github "KazuCocoa/YYCache" "add-tvos-support" |
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.
Will change to appium/YYCache after appium/YYCache#1
/** | ||
Return current focused element | ||
*/ | ||
- (id<FBElement>) fb_focusedElement; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move into XCUIApplication+FBHelpers.m in the next PR
@@ -191,6 +191,15 @@ - (BOOL)isWDVisible | |||
return [[self fb_cachedValueWithAttributeName:@"isWDVisible" valueGetter:getter] boolValue]; | |||
} | |||
|
|||
#if TARGET_OS_TV |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
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.
focuse -> setFocus
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.
docstrings are missing
|
||
-(BOOL)fb_focuseWithError:(NSError**) error; | ||
|
||
-(BOOL)fb_selectWithError:(NSError**) error; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id' rather make the condition block shorter by checking !self.wdEnabled
} | ||
if (self.exists) { | ||
FBTVDirection direction = tracker.directionToMoveFocuse; | ||
if(direction != FBTVDirectionNone) { |
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.
missing space
continue; | ||
} | ||
} | ||
[[[FBErrorBuilder builder] withDescription:@"Unable to reach element. Try to use XCUIRemote commands."] |
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'd also put element.desciption into the error message
@@ -36,6 +42,19 @@ + (instancetype)fb_springboard | |||
return _springboardApp; | |||
} | |||
|
|||
/** | |||
* Returns proper identifier |
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 this docstring correct?
if (![appElement fb_selectWithError:error]) { | ||
return NO; | ||
} | ||
[[XCUIRemote sharedRemote] pressButton: XCUIRemoteButtonSelect]; |
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.
isn't fb_selectWithError already pressing XCUIRemoteButtonSelect ?
@@ -99,9 +147,13 @@ - (BOOL)fb_waitUntilApplicationBoardIsVisible:(NSError **)error | |||
- (BOOL)fb_isApplicationBoardVisible | |||
{ | |||
[self resolve]; | |||
#if TARGET_OS_TV | |||
return self.collectionViews[@"GridCollectionView"].isEnabled; |
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 GridCollectionView
precise?
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.
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.
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; |
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.
readonly?
CGFloat yDelta = self.targetCenter.y - focusedCenter.y; | ||
CGFloat xDelta = self.targetCenter.x - focusedCenter.x; | ||
FBTVDirection direction; | ||
if(fabs(yDelta) > fabs(xDelta)) { |
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.
space after if
return [FBApplication fb_activeApplication].fb_focusedElement; | ||
} | ||
|
||
-(FBTVNavigationItem*) navigationItemFromElement:(id<FBElement>)element |
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.
space after -
|
||
- (BOOL)isWDFocused | ||
{ | ||
return self.hasFocus; |
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.
should the value of the attribute be cached?
return self; | ||
} | ||
|
||
- (FBTVDirection)directionToFocusedElement |
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 method is a classic example of the path finding algorithm. It would be nice to cover it with unit tests in the next PRs
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 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_TV
to avoid libraries which are not included in tvOSnote:
Xcode 9.2 on Travis has no tvOS device.