初始化提交
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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>
|
||||
|
||||
@interface XCElementSnapshotDouble : NSObject<XCUIElementAttributes>
|
||||
@property (readwrite, nullable) id value;
|
||||
@property (readwrite, nullable, copy) NSString *label;
|
||||
@property (nonatomic, assign) UIAccessibilityTraits traits;
|
||||
@end
|
||||
114
WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m
Normal file
114
WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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 "XCElementSnapshotDouble.h"
|
||||
|
||||
#import "FBXCAccessibilityElement.h"
|
||||
#import "FBXCElementSnapshot.h"
|
||||
#import "XCUIHitPointResult.h"
|
||||
|
||||
@implementation XCElementSnapshotDouble
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
self->_value = @"magicValue";
|
||||
self->_label = @"testLabel";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)identifier
|
||||
{
|
||||
return @"testName";
|
||||
}
|
||||
|
||||
- (CGRect)frame
|
||||
{
|
||||
return CGRectZero;
|
||||
}
|
||||
|
||||
- (NSString *)title
|
||||
{
|
||||
return @"testTitle";
|
||||
}
|
||||
|
||||
- (XCUIElementType)elementType
|
||||
{
|
||||
return XCUIElementTypeOther;
|
||||
}
|
||||
|
||||
- (BOOL)isEnabled
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (XCUIUserInterfaceSizeClass)horizontalSizeClass
|
||||
{
|
||||
return XCUIUserInterfaceSizeClassUnspecified;
|
||||
}
|
||||
|
||||
- (XCUIUserInterfaceSizeClass)verticalSizeClass
|
||||
{
|
||||
return XCUIUserInterfaceSizeClassUnspecified;
|
||||
}
|
||||
|
||||
- (NSString *)placeholderValue
|
||||
{
|
||||
return @"testPlaceholderValue";
|
||||
}
|
||||
|
||||
- (BOOL)isSelected
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)hasFocus
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSDictionary *)additionalAttributes
|
||||
{
|
||||
return @{};
|
||||
}
|
||||
|
||||
- (id<FBXCAccessibilityElement>)accessibilityElement
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id<FBXCElementSnapshot>)parent
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (XCUIHitPointResult *)hitPoint:(NSError **)error
|
||||
{
|
||||
return [[XCUIHitPointResult alloc] initWithHitPoint:CGPointZero hittable:YES];
|
||||
}
|
||||
|
||||
- (NSArray *)children
|
||||
{
|
||||
return @[];
|
||||
}
|
||||
|
||||
- (NSArray *)_allDescendants
|
||||
{
|
||||
return @[];
|
||||
}
|
||||
|
||||
- (CGRect)visibleFrame
|
||||
{
|
||||
return CGRectZero;
|
||||
}
|
||||
|
||||
- (UIAccessibilityTraits)traits
|
||||
{
|
||||
return UIAccessibilityTraitButton;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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>
|
||||
|
||||
@interface XCUIApplicationDouble : NSObject
|
||||
@property (nonatomic, assign, readonly) BOOL didTerminate;
|
||||
@property (nonatomic, strong) NSString* bundleID;
|
||||
@property (nonatomic) BOOL fb_shouldWaitForQuiescence;
|
||||
|
||||
- (BOOL)running;
|
||||
@end
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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 "XCUIApplicationDouble.h"
|
||||
|
||||
@interface XCUIApplicationDouble ()
|
||||
@property (nonatomic, assign, readwrite) BOOL didTerminate;
|
||||
@end
|
||||
|
||||
@implementation XCUIApplicationDouble
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_bundleID = @"some.bundle.identifier";
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)terminate
|
||||
{
|
||||
self.didTerminate = YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)processID
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSString *)bundleID
|
||||
{
|
||||
return @"com.facebook.awesome";
|
||||
}
|
||||
|
||||
- (void)fb_nativeResolve
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (id)query
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)fb_shouldWaitForQuiescence
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(void)setFb_shouldWaitForQuiescence:(BOOL)value
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)running
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
50
WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.h
Normal file
50
WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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, readonly, nonnull) NSString *fb_cacheId;
|
||||
@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, assign) CGRect wdNativeFrame;
|
||||
@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 (nonatomic, copy, readwrite, nullable) NSString *wdPlaceholderValue;
|
||||
@property (copy, nonnull) NSArray *children;
|
||||
@property (nonatomic, readwrite, assign) XCUIElementType elementType;
|
||||
@property (nonatomic, readwrite, getter=isWDAccessibilityContainer) BOOL wdAccessibilityContainer;
|
||||
@property (nonatomic, copy, readwrite, nullable) NSString *wdTraits;
|
||||
|
||||
- (void)resolve;
|
||||
- (id _Nonnull)fb_standardSnapshot;
|
||||
- (id _Nonnull)fb_customSnapshot;
|
||||
- (nullable id)query;
|
||||
|
||||
// Checks
|
||||
@property (nonatomic, assign, readonly) BOOL didResolve;
|
||||
|
||||
@end
|
||||
103
WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.m
Normal file
103
WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.m
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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 = CGRectZero;
|
||||
self.wdNativeFrame = CGRectZero;
|
||||
self.wdName = @"testName";
|
||||
self.wdLabel = @"testLabel";
|
||||
self.wdValue = @"magicValue";
|
||||
self.wdPlaceholderValue = @"testPlaceholderValue";
|
||||
self.wdTraits = @"testTraits";
|
||||
self.wdVisible = YES;
|
||||
self.wdAccessible = YES;
|
||||
self.wdEnabled = YES;
|
||||
self.wdSelected = YES;
|
||||
self.wdFocused = 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)query
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)resolve
|
||||
{
|
||||
self.didResolve = YES;
|
||||
}
|
||||
|
||||
- (void)fb_nativeResolve
|
||||
{
|
||||
self.didResolve = YES;
|
||||
}
|
||||
|
||||
- (id _Nonnull)fb_standardSnapshot;
|
||||
{
|
||||
return [self lastSnapshot];
|
||||
}
|
||||
|
||||
- (id _Nonnull)fb_customSnapshot;
|
||||
{
|
||||
return [self lastSnapshot];
|
||||
}
|
||||
|
||||
- (NSString *)fb_cacheId
|
||||
{
|
||||
return self.wdUID;
|
||||
}
|
||||
|
||||
- (id)lastSnapshot
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)fb_uid
|
||||
{
|
||||
return self.wdUID;
|
||||
}
|
||||
|
||||
- (NSString *)wdTraits
|
||||
{
|
||||
return self.wdTraits;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user