Files
Monkey-Test/WebDriverAgent/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m
T
2019-01-25 17:01:52 +08:00

57 lines
1.4 KiB
Objective-C
Executable File

/**
* 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. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <XCTest/XCTest.h>
#import "FBIntegrationTestCase.h"
#import "FBApplication.h"
#import "XCUIDevice+FBHelpers.h"
@interface XCUIDeviceHelperTests : FBIntegrationTestCase
@end
@implementation XCUIDeviceHelperTests
- (void)setUp
{
[super setUp];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self launchApplication];
});
}
- (void)testScreenshot
{
NSError *error = nil;
NSData *screenshotData = [[XCUIDevice sharedDevice] fb_screenshotWithError:&error];
XCTAssertNotNil([UIImage imageWithData:screenshotData]);
XCTAssertNil(error);
}
- (void)testWifiAddress
{
NSString *adderss = [XCUIDevice sharedDevice].fb_wifiIPAddress;
if (!adderss) {
return;
}
NSRange range = [adderss rangeOfString:@"^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})" options:NSRegularExpressionSearch];
XCTAssertTrue(range.location != NSNotFound);
}
- (void)testGoToHomeScreen
{
NSError *error;
XCTAssertTrue([[XCUIDevice sharedDevice] fb_goToHomescreenWithError:&error]);
XCTAssertNil(error);
XCTAssertTrue([FBApplication fb_activeApplication].icons[@"Safari"].exists);
}
@end