Skip to content
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

Merged
merged 16 commits into from
Mar 24, 2019
Merged

[tvOS]2nd: tvos build #149

merged 16 commits into from
Mar 24, 2019

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Mar 21, 2019

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 tvOS


note:

Xcode 9.2 on Travis has no tvOS device.

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ OS:11.2, name:Apple TV }
	Ineligible destinations for the "WebDriverAgentRunner_tvOS" scheme:
		{ platform:tvOS, id:dvtdevice-DVTiOSDevicePlaceholder-appletvos:placeholder, name:Generic tvOS Device }
		{ platform:tvOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-appletvsimulator:placeholder, name:Generic tvOS Simulator Device }
The command "./Scripts/build.sh" exited with 1.

Cartfile Outdated
@@ -2,7 +2,7 @@
github "appium/RoutingHTTPServer"

# Used by the element cache
github "appium/YYCache"
github "KazuCocoa/YYCache" "add-tvos-support"
Copy link
Member Author

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;
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if TARGET_OS_TV
@interface XCUIElement (FBTVFocuse)

-(BOOL)fb_focuseWithError:(NSError**) error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

focuse -> setFocus

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;

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) {

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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space

@KazuCocoa
Copy link
Member Author

image

Will update YYCache soon

continue;
}
}
[[[FBErrorBuilder builder] withDescription:@"Unable to reach element. Try to use XCUIRemote commands."]

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

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];

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is GridCollectionView precise?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, yes since like below...
I need to make sure "HomeBoard" in the application class can use for it, maybe...

image

Copy link
Member Author

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;

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)) {

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

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;

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
Copy link

@mykola-mokhnach mykola-mokhnach Mar 23, 2019

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

Copy link

@mykola-mokhnach mykola-mokhnach left a 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

@KazuCocoa KazuCocoa merged commit 1173666 into appium:master Mar 24, 2019
@KazuCocoa KazuCocoa mentioned this pull request Mar 30, 2019
@KazuCocoa KazuCocoa deleted the tvos-build branch March 30, 2019 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants