Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 5428114

Browse files
Add sample code from appium/appium
1 parent 44ec0ed commit 5428114

172 files changed

Lines changed: 10027 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
25.3 KB
Binary file not shown.

sample-code/apps/RobotCalibration/RobotCalibration.xcodeproj/project.pbxproj

Lines changed: 487 additions & 0 deletions
Large diffs are not rendered by default.

sample-code/apps/RobotCalibration/RobotCalibration.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
18.2 KB
Loading
6.39 KB
Loading
15.7 KB
Loading
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2012 Appium Committers
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
#import <UIKit/UIKit.h>
23+
24+
@interface RCAppDelegate : UIResponder <UIApplicationDelegate>
25+
26+
@property (strong, nonatomic) UIWindow *window;
27+
28+
@end
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2012 Appium Committers
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
#import "RCAppDelegate.h"
23+
24+
@implementation RCAppDelegate
25+
26+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
27+
{
28+
// Override point for customization after application launch.
29+
return YES;
30+
}
31+
32+
- (void)applicationWillResignActive:(UIApplication *)application
33+
{
34+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
35+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
36+
}
37+
38+
- (void)applicationDidEnterBackground:(UIApplication *)application
39+
{
40+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
41+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
42+
}
43+
44+
- (void)applicationWillEnterForeground:(UIApplication *)application
45+
{
46+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
47+
}
48+
49+
- (void)applicationDidBecomeActive:(UIApplication *)application
50+
{
51+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
52+
}
53+
54+
- (void)applicationWillTerminate:(UIApplication *)application
55+
{
56+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
57+
}
58+
59+
@end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2012 Appium Committers
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
#import <UIKit/UIKit.h>
23+
24+
@interface RCViewController : UIViewController
25+
@property (strong, nonatomic) IBOutlet UITapGestureRecognizer *tapRecognizer;
26+
@property (strong, nonatomic) IBOutlet UILabel *coordinateLabel;
27+
@property (strong, nonatomic) IBOutlet UISwipeGestureRecognizer *swipeRecognizer;
28+
29+
@end
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/**
2+
* Copyright 2012 Appium Committers
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
#import "RCViewController.h"
23+
24+
@interface RCViewController ()
25+
26+
@end
27+
28+
@implementation RCViewController
29+
30+
- (void)viewDidLoad
31+
{
32+
[super viewDidLoad];
33+
// Do any additional setup after loading the view, typically from a nib.
34+
[self becomeFirstResponder];
35+
36+
}
37+
38+
- (void)didReceiveMemoryWarning
39+
{
40+
[super didReceiveMemoryWarning];
41+
// Dispose of any resources that can be recreated.
42+
}
43+
44+
- (NSUInteger)supportedInterfaceOrientations
45+
{
46+
return UIInterfaceOrientationMaskAllButUpsideDown;
47+
}
48+
49+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
50+
{
51+
if ((orientation == UIInterfaceOrientationPortrait) ||
52+
(orientation == UIInterfaceOrientationLandscapeLeft) ||
53+
(orientation == UIInterfaceOrientationLandscapeRight))
54+
return YES;
55+
56+
return NO;
57+
}
58+
59+
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
60+
[self.view setNeedsLayout];
61+
[self.view setNeedsDisplay];
62+
}
63+
64+
65+
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
66+
//UITouch *touch = [touches anyObject];
67+
for (UIView *view in self.view.subviews) {
68+
[view removeFromSuperview];
69+
}
70+
for (UITouch *touch in [[event allTouches] allObjects]) {
71+
[self displayCoordinatesForTouch:touch];
72+
}
73+
}
74+
75+
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
76+
//UITouch *touch = [touches anyObject];
77+
for (UIView *view in self.view.subviews) {
78+
[view removeFromSuperview];
79+
}
80+
for (UITouch *touch in [[event allTouches] allObjects]) {
81+
[self displayCoordinatesForTouch:touch];
82+
}
83+
84+
}
85+
86+
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
87+
for (UIView *view in self.view.subviews) {
88+
[view removeFromSuperview];
89+
}
90+
}
91+
92+
- (void)displayCoordinatesForTouch:(UITouch *)touch {
93+
CGPoint locationInView = [touch locationInView:self.view];
94+
int viewWidth = self.view.frame.size.width;
95+
int viewHeight = self.view.frame.size.height;
96+
97+
if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) ||
98+
([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight)) {
99+
viewWidth = self.view.frame.size.height;
100+
viewHeight = self.view.frame.size.width;
101+
}
102+
// Calculate the Coordinate Label Frame
103+
CGRect coordinateLabelFrame = CGRectMake(0, 0, 0, 0);
104+
coordinateLabelFrame.size.height = 20;
105+
coordinateLabelFrame.size.width = 100;
106+
// We want the label to stay 40pts from the edges
107+
coordinateLabelFrame.origin.x = MIN(MAX(locationInView.x - 40, 40), viewWidth - coordinateLabelFrame.size.width - 40);
108+
coordinateLabelFrame.origin.y = MIN(MAX(locationInView.y - 30, 40), viewHeight - coordinateLabelFrame.size.height - 40);
109+
110+
// Set the frame and test of the label
111+
UILabel *coordinateLabel = [[UILabel alloc] initWithFrame:coordinateLabelFrame];
112+
coordinateLabel.text = [NSString stringWithFormat:@"(%d, %d)", (int)locationInView.x, (int)locationInView.y];
113+
coordinateLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0f];
114+
[self.view addSubview:coordinateLabel];
115+
}
116+
117+
@end

0 commit comments

Comments
 (0)