初始化提交
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <WebDriverAgentLib/FBElement.h>
|
||||
#import <XCTest/XCUIElementTypes.h>
|
||||
|
||||
@class XCUIApplication;
|
||||
|
||||
@interface XCUIElementDouble : NSObject<FBElement>
|
||||
@property (nonatomic, strong, nonnull) XCUIApplication *application;
|
||||
@property (nonatomic, readwrite, assign) CGRect frame;
|
||||
@property (nonatomic, readwrite, nullable) id lastSnapshot;
|
||||
@property (nonatomic, assign) BOOL fb_isObstructedByAlert;
|
||||
@property (nonatomic, readwrite, copy, nonnull) NSDictionary *wdRect;
|
||||
@property (nonatomic, readwrite, assign) CGRect wdFrame;
|
||||
@property (nonatomic, readwrite, copy, nonnull) NSString *wdUID;
|
||||
@property (nonatomic, copy, readwrite, nullable) NSString *wdName;
|
||||
@property (nonatomic, copy, readwrite, nullable) NSString *wdLabel;
|
||||
@property (nonatomic, copy, readwrite, nonnull) NSString *wdType;
|
||||
@property (nonatomic, strong, readwrite, nullable) NSString *wdValue;
|
||||
@property (nonatomic, readwrite, getter=isWDEnabled) BOOL wdEnabled;
|
||||
@property (nonatomic, readwrite, getter=isWDSelected) BOOL wdSelected;
|
||||
@property (nonatomic, readwrite) NSUInteger wdIndex;
|
||||
@property (nonatomic, readwrite, getter=isWDVisible) BOOL wdVisible;
|
||||
@property (nonatomic, readwrite, getter=isWDAccessible) BOOL wdAccessible;
|
||||
@property (nonatomic, readwrite, getter=isWDFocused) BOOL wdFocused;
|
||||
@property (nonatomic, readwrite, getter = isWDHittable) BOOL wdHittable;
|
||||
@property (copy, nonnull) NSArray *children;
|
||||
@property (nonatomic, readwrite, assign) XCUIElementType elementType;
|
||||
@property (nonatomic, readwrite, getter=isWDAccessibilityContainer) BOOL wdAccessibilityContainer;
|
||||
|
||||
- (void)resolve;
|
||||
- (id _Nonnull)fb_standardSnapshot;
|
||||
- (id _Nonnull)fb_customSnapshot;
|
||||
|
||||
// Checks
|
||||
@property (nonatomic, assign, readonly) BOOL didResolve;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "XCUIElementDouble.h"
|
||||
|
||||
@interface XCUIElementDouble ()
|
||||
@property (nonatomic, assign, readwrite) BOOL didResolve;
|
||||
@end
|
||||
|
||||
@implementation XCUIElementDouble
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.wdFrame = CGRectMake(0, 0, 0, 0);
|
||||
self.wdName = @"testName";
|
||||
self.wdLabel = @"testLabel";
|
||||
self.wdValue = @"magicValue";
|
||||
self.wdVisible = YES;
|
||||
self.wdAccessible = YES;
|
||||
self.wdEnabled = YES;
|
||||
self.wdSelected = YES;
|
||||
self.wdHittable = YES;
|
||||
self.wdIndex = 0;
|
||||
#if TARGET_OS_TV
|
||||
self.wdFocused = YES;
|
||||
#endif
|
||||
self.children = @[];
|
||||
self.wdRect = @{@"x": @0,
|
||||
@"y": @0,
|
||||
@"width": @0,
|
||||
@"height": @0,
|
||||
};
|
||||
self.wdAccessibilityContainer = NO;
|
||||
self.elementType = XCUIElementTypeOther;
|
||||
self.wdType = @"XCUIElementTypeOther";
|
||||
self.wdUID = @"0";
|
||||
self.lastSnapshot = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)fb_valueForWDAttributeName:(NSString *)name
|
||||
{
|
||||
return @"test";
|
||||
}
|
||||
|
||||
- (id)fb_standardSnapshot
|
||||
{
|
||||
return [self lastSnapshot];
|
||||
}
|
||||
|
||||
- (id)fb_customSnapshot
|
||||
{
|
||||
return [self lastSnapshot];
|
||||
}
|
||||
|
||||
- (void)resolve
|
||||
{
|
||||
self.didResolve = YES;
|
||||
}
|
||||
|
||||
- (id)lastSnapshot
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)fb_uid
|
||||
{
|
||||
return self.wdUID;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "XCUIElementDouble.h"
|
||||
#import "FBTVNavigationTracker.h"
|
||||
#import "FBTVNavigationTracker-Private.h"
|
||||
|
||||
@interface FBTVNavigationTrackerTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation FBTVNavigationTrackerTests
|
||||
|
||||
- (void)testHorizontalDirectionWithItemShouldBeRight
|
||||
{
|
||||
XCUIElementDouble *el1 = XCUIElementDouble.new;
|
||||
|
||||
FBTVNavigationItem *item = [FBTVNavigationItem itemWithUid:@"123456789"];
|
||||
FBTVNavigationTracker *tracker = [FBTVNavigationTracker trackerWithTargetElement:(XCUIElement *)el1];
|
||||
|
||||
FBTVDirection direction = [tracker horizontalDirectionWithItem:item andDelta:0.1];
|
||||
XCTAssertEqual(FBTVDirectionRight, direction);
|
||||
}
|
||||
|
||||
- (void)testHorizontalDirectionWithItemShouldBeLeft
|
||||
{
|
||||
XCUIElementDouble *el1 = XCUIElementDouble.new;
|
||||
|
||||
FBTVNavigationItem *item = [FBTVNavigationItem itemWithUid:@"123456789"];
|
||||
FBTVNavigationTracker *tracker = [FBTVNavigationTracker trackerWithTargetElement:(XCUIElement *)el1];
|
||||
|
||||
FBTVDirection direction = [tracker horizontalDirectionWithItem:item andDelta:-0.1];
|
||||
XCTAssertEqual(FBTVDirectionLeft, direction);
|
||||
}
|
||||
|
||||
- (void)testHorizontalDirectionWithItemShouldBeNone
|
||||
{
|
||||
XCUIElementDouble *el1 = XCUIElementDouble.new;
|
||||
|
||||
FBTVNavigationItem *item = [FBTVNavigationItem itemWithUid:@"123456789"];
|
||||
FBTVNavigationTracker *tracker = [FBTVNavigationTracker trackerWithTargetElement:(XCUIElement *)el1];
|
||||
|
||||
FBTVDirection direction = [tracker horizontalDirectionWithItem:item andDelta:DBL_EPSILON];
|
||||
XCTAssertEqual(FBTVDirectionNone, direction);
|
||||
}
|
||||
|
||||
- (void)testVerticalDirectionWithItemShouldBeDown
|
||||
{
|
||||
XCUIElementDouble *el1 = XCUIElementDouble.new;
|
||||
|
||||
FBTVNavigationItem *item = [FBTVNavigationItem itemWithUid:@"123456789"];
|
||||
FBTVNavigationTracker *tracker = [FBTVNavigationTracker trackerWithTargetElement:(XCUIElement *)el1];
|
||||
|
||||
FBTVDirection direction = [tracker verticalDirectionWithItem:item andDelta:0.1];
|
||||
XCTAssertEqual(FBTVDirectionDown, direction);
|
||||
}
|
||||
|
||||
- (void)testVerticalDirectionWithItemShouldBeUp
|
||||
{
|
||||
XCUIElementDouble *el1 = XCUIElementDouble.new;
|
||||
|
||||
FBTVNavigationItem *item = [FBTVNavigationItem itemWithUid:@"123456789"];
|
||||
FBTVNavigationTracker *tracker = [FBTVNavigationTracker trackerWithTargetElement:(XCUIElement *)el1];
|
||||
|
||||
FBTVDirection direction = [tracker verticalDirectionWithItem:item andDelta:-0.1];
|
||||
XCTAssertEqual(FBTVDirectionUp, direction);
|
||||
}
|
||||
|
||||
- (void)testVerticalDirectionWithItemShouldBeNone
|
||||
{
|
||||
XCUIElementDouble *el1 = XCUIElementDouble.new;
|
||||
|
||||
FBTVNavigationItem *item = [FBTVNavigationItem itemWithUid:@"123456789"];
|
||||
FBTVNavigationTracker *tracker = [FBTVNavigationTracker trackerWithTargetElement:(XCUIElement *)el1];
|
||||
|
||||
FBTVDirection direction = [tracker verticalDirectionWithItem:item andDelta:DBL_EPSILON];
|
||||
XCTAssertEqual(FBTVDirectionNone, direction);
|
||||
}
|
||||
|
||||
@end
|
||||
24
WebDriverAgentTests/UnitTests_tvOS/Info.plist
Normal file
24
WebDriverAgentTests/UnitTests_tvOS/Info.plist
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.facebook.wda.unitTests</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user