初始化提交
This commit is contained in:
15
WebDriverAgentTests/IntegrationApp/Classes/AppDelegate.h
Normal file
15
WebDriverAgentTests/IntegrationApp/Classes/AppDelegate.h
Normal file
@@ -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 <UIKit/UIKit.h>
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@end
|
||||
15
WebDriverAgentTests/IntegrationApp/Classes/AppDelegate.m
Normal file
15
WebDriverAgentTests/IntegrationApp/Classes/AppDelegate.m
Normal file
@@ -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 "AppDelegate.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
|
||||
@interface FBAlertViewController : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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 "FBAlertViewController.h"
|
||||
|
||||
#import <Photos/Photos.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
@interface FBAlertViewController ()
|
||||
@property (nonatomic, strong) CLLocationManager *locationManager;
|
||||
@end
|
||||
|
||||
@implementation FBAlertViewController
|
||||
|
||||
- (IBAction)createAppAlert:(UIButton *)sender
|
||||
{
|
||||
[self presentAlertController];
|
||||
}
|
||||
|
||||
- (IBAction)createAppSheet:(UIButton *)sender
|
||||
{
|
||||
UIAlertController *alerController =
|
||||
[UIAlertController alertControllerWithTitle:@"Magic Sheet"
|
||||
message:@"Should read"
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIPopoverPresentationController *popPresenter = [alerController popoverPresentationController];
|
||||
popPresenter.sourceView = sender;
|
||||
[self presentViewController:alerController animated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
- (IBAction)createNotificationAlert:(UIButton *)sender
|
||||
{
|
||||
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
||||
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound|UNAuthorizationOptionAlert|UNAuthorizationOptionBadge)
|
||||
completionHandler:^(BOOL granted, NSError * _Nullable error)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)createCameraRollAccessAlert:(UIButton *)sender
|
||||
{
|
||||
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)createGPSAccessAlert:(UIButton *)sender
|
||||
{
|
||||
self.locationManager = [CLLocationManager new];
|
||||
[self.locationManager requestAlwaysAuthorization];
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
for (UITouch *touch in touches) {
|
||||
if (fabs(touch.maximumPossibleForce - touch.force) < 0.0001) {
|
||||
[self presentAlertController];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)presentAlertController
|
||||
{
|
||||
UIAlertController *alerController =
|
||||
[UIAlertController alertControllerWithTitle:@"Magic"
|
||||
message:@"Should read"
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alerController addAction:[UIAlertAction actionWithTitle:@"Will do" style:UIAlertActionStyleDefault handler:nil]];
|
||||
[self presentViewController:alerController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
@interface FBNavigationController : UINavigationController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 "FBNavigationController.h"
|
||||
|
||||
@implementation FBNavigationController
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||
{
|
||||
return UIInterfaceOrientationMaskAll;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
@interface FBScrollViewController : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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 "FBScrollViewController.h"
|
||||
|
||||
#import "FBTableDataSource.h"
|
||||
|
||||
static const CGFloat FBSubviewHeight = 40.0;
|
||||
|
||||
@interface FBScrollViewController ()
|
||||
@property (nonatomic, weak) IBOutlet UIScrollView *scrollView;
|
||||
@property (nonatomic, strong) IBOutlet FBTableDataSource *dataSource;
|
||||
@end
|
||||
|
||||
@implementation FBScrollViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self setupLabelViews];
|
||||
self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.view.frame), self.dataSource.count * FBSubviewHeight);
|
||||
}
|
||||
|
||||
- (void)setupLabelViews
|
||||
{
|
||||
NSUInteger count = self.dataSource.count;
|
||||
for (NSInteger i = 0 ; i < count ; i++) {
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, i * FBSubviewHeight, CGRectGetWidth(self.view.frame), FBSubviewHeight)];
|
||||
label.text = [self.dataSource textForElementAtIndex:i];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[self.scrollView addSubview:label];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
@interface FBTableDataSource : NSObject <UITableViewDataSource>
|
||||
|
||||
- (NSUInteger)count;
|
||||
- (NSString *)textForElementAtIndex:(NSInteger)index;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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 "FBTableDataSource.h"
|
||||
|
||||
@implementation FBTableDataSource
|
||||
|
||||
- (NSUInteger)count
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
- (NSString *)textForElementAtIndex:(NSInteger)index
|
||||
{
|
||||
return [NSString stringWithFormat:@"%ld", (long)index];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
|
||||
cell.textLabel.text = [self textForElementAtIndex:indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
17
WebDriverAgentTests/IntegrationApp/Classes/TouchSpotView.h
Normal file
17
WebDriverAgentTests/IntegrationApp/Classes/TouchSpotView.h
Normal file
@@ -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 <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TouchSpotView : UIView
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
28
WebDriverAgentTests/IntegrationApp/Classes/TouchSpotView.m
Normal file
28
WebDriverAgentTests/IntegrationApp/Classes/TouchSpotView.m
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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 "TouchSpotView.h"
|
||||
|
||||
@implementation TouchSpotView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = UIColor.lightGrayColor;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setBounds:(CGRect)newBounds
|
||||
{
|
||||
super.bounds = newBounds;
|
||||
self.layer.cornerRadius = newBounds.size.width / 2.0;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
#import "TouchableView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TouchViewController : UIViewController
|
||||
|
||||
@property (weak, nonatomic) IBOutlet TouchableView *touchable;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *numberOfTapsLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *numberOfTouchesLabel;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 "TouchViewController.h"
|
||||
|
||||
@implementation TouchViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
self.touchable.delegate = self;
|
||||
self.numberOfTouchesLabel.text = @"0";
|
||||
self.numberOfTapsLabel.text = @"0";
|
||||
}
|
||||
|
||||
- (void)shouldHandleTapsNumber:(int)numberOfTaps {
|
||||
self.numberOfTapsLabel.text = [NSString stringWithFormat:@"%d", numberOfTaps];
|
||||
}
|
||||
|
||||
- (void)shouldHandleTouchesNumber:(int)touchesCount {
|
||||
self.numberOfTouchesLabel.text = [NSString stringWithFormat:@"%d", touchesCount];
|
||||
}
|
||||
|
||||
@end
|
||||
29
WebDriverAgentTests/IntegrationApp/Classes/TouchableView.h
Normal file
29
WebDriverAgentTests/IntegrationApp/Classes/TouchableView.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
#import "TouchSpotView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol TouchableViewDelegate <NSObject>
|
||||
|
||||
- (void)shouldHandleTouchesNumber:(int)touchesCount;
|
||||
- (void)shouldHandleTapsNumber:(int)numberOfTaps;
|
||||
|
||||
@end
|
||||
|
||||
@interface TouchableView : UIView
|
||||
|
||||
@property (nonatomic) NSMutableDictionary<NSNumber*, TouchSpotView*> *touchViews;
|
||||
@property (nonatomic) int numberOFTaps;
|
||||
@property (nonatomic) id delegate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
108
WebDriverAgentTests/IntegrationApp/Classes/TouchableView.m
Normal file
108
WebDriverAgentTests/IntegrationApp/Classes/TouchableView.m
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* 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 "TouchableView.h"
|
||||
|
||||
@implementation TouchableView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.multipleTouchEnabled = YES;
|
||||
self.numberOFTaps = 0;
|
||||
self.touchViews = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (self) {
|
||||
self.multipleTouchEnabled = YES;
|
||||
self.numberOFTaps = 0;
|
||||
self.touchViews = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
self.numberOFTaps += 1;
|
||||
[self.delegate shouldHandleTouchesNumber:(int)touches.count];
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
[self createViewForTouch:touch];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
TouchSpotView *view = [self viewForTouch:touch];
|
||||
CGPoint newLocation = [touch locationInView:self];
|
||||
view.center = newLocation;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
[self removeViewForTouch:touch];
|
||||
}
|
||||
[self.delegate shouldHandleTapsNumber:self.numberOFTaps];
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
[self removeViewForTouch:touch];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createViewForTouch:(UITouch *)touch
|
||||
{
|
||||
if (touch)
|
||||
{
|
||||
TouchSpotView *newView = [[TouchSpotView alloc] init];
|
||||
newView.bounds = CGRectMake(0, 0, 1, 1);
|
||||
newView.center = [touch locationInView:self];
|
||||
[self addSubview:newView];
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
newView.bounds = CGRectMake(0, 0, 100, 100);
|
||||
}];
|
||||
|
||||
self.touchViews[[self touchHash:touch]] = newView;
|
||||
}
|
||||
}
|
||||
|
||||
- (TouchSpotView *)viewForTouch:(UITouch *)touch
|
||||
{
|
||||
return self.touchViews[[self touchHash:touch]];
|
||||
}
|
||||
|
||||
- (void)removeViewForTouch:(UITouch *)touch
|
||||
{
|
||||
NSNumber *touchHash = [self touchHash:touch];
|
||||
UIView *view = self.touchViews[touchHash];
|
||||
if (view)
|
||||
{
|
||||
[view removeFromSuperview];
|
||||
[self.touchViews removeObjectForKey:touchHash];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSNumber *)touchHash:(UITouch *)touch
|
||||
{
|
||||
return [NSNumber numberWithUnsignedInteger:touch.hash];
|
||||
}
|
||||
@end
|
||||
12
WebDriverAgentTests/IntegrationApp/Classes/ViewController.h
Normal file
12
WebDriverAgentTests/IntegrationApp/Classes/ViewController.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
@end
|
||||
66
WebDriverAgentTests/IntegrationApp/Classes/ViewController.m
Normal file
66
WebDriverAgentTests/IntegrationApp/Classes/ViewController.m
Normal file
@@ -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 "ViewController.h"
|
||||
|
||||
@interface ViewController ()
|
||||
@property (weak, nonatomic) IBOutlet UILabel *orentationLabel;
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (IBAction)deadlockApp:(id)sender
|
||||
{
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
// This will never execute
|
||||
});
|
||||
}
|
||||
|
||||
- (IBAction)didTapButton:(UIButton *)button
|
||||
{
|
||||
button.selected = !button.selected;
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews
|
||||
{
|
||||
[super viewDidLayoutSubviews];
|
||||
[self updateOrentationLabel];
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
- (void)updateOrentationLabel
|
||||
{
|
||||
NSString *orientation = nil;
|
||||
switch (UIDevice.currentDevice.orientation) {
|
||||
case UIInterfaceOrientationPortrait:
|
||||
orientation = @"Portrait";
|
||||
break;
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
orientation = @"PortraitUpsideDown";
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
orientation = @"LandscapeLeft";
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
orientation = @"LandscapeRight";
|
||||
break;
|
||||
case UIDeviceOrientationFaceUp:
|
||||
orientation = @"FaceUp";
|
||||
break;
|
||||
case UIDeviceOrientationFaceDown:
|
||||
orientation = @"FaceDown";
|
||||
break;
|
||||
case UIInterfaceOrientationUnknown:
|
||||
orientation = @"Unknown";
|
||||
break;
|
||||
}
|
||||
self.orentationLabel.text = orientation;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user