iCuke 0.5.5 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.gitmodules +3 -0
- data/README.rdoc +8 -7
- data/Rakefile +10 -30
- data/VERSION +1 -1
- data/app/.gitignore +3 -0
- data/app/LICENSE +20 -0
- data/app/Readme.markdown +3 -0
- data/app/Shared/AppDelegate_Shared.h +17 -0
- data/app/Shared/AppDelegate_Shared.m +25 -0
- data/app/{images/yellowslide.png → Shared/Icon.png} +0 -0
- data/app/Shared/ModalViewController.h +15 -0
- data/app/Shared/ModalViewController.m +96 -0
- data/app/Shared/TestViewController_Shared.h +15 -0
- data/app/Shared/TestViewController_Shared.m +43 -0
- data/app/{Info.plist → Shared/Universal-Info.plist} +17 -4
- data/app/Shared/Universal_Prefix.pch +8 -0
- data/app/Shared/main.m +14 -0
- data/app/Universal.xcodeproj/project.pbxproj +301 -0
- data/app/iPad/AppDelegate_Pad.h +15 -0
- data/app/iPad/AppDelegate_Pad.m +28 -0
- data/app/iPad/Default-Landscape.png +0 -0
- data/app/iPad/Default-Portrait.png +0 -0
- data/app/iPad/MainWindow_Pad.xib +343 -0
- data/app/iPad/TestViewController_Pad.h +15 -0
- data/app/iPad/TestViewController_Pad.m +52 -0
- data/app/iPhone/AppDelegate_Phone.h +15 -0
- data/app/iPhone/AppDelegate_Phone.m +28 -0
- data/app/{images/segment_search.png → iPhone/Default.png} +0 -0
- data/app/iPhone/MainWindow_Phone.xib +363 -0
- data/app/iPhone/TestViewController_Phone.h +15 -0
- data/app/iPhone/TestViewController_Phone.m +36 -0
- data/bin/.gitignore +1 -0
- data/bin/icuke +10 -0
- data/bin/icuke-module +17 -0
- data/ext/.gitignore +1 -0
- data/ext/Rakefile +6 -0
- data/ext/WaxSim/Simulator.h +31 -0
- data/ext/WaxSim/Simulator.m +131 -0
- data/ext/WaxSim/WaxSim.m +110 -0
- data/ext/WaxSim/WaxSim.xcodeproj/project.pbxproj +238 -0
- data/ext/WaxSim/WaxSim_Prefix.pch +7 -0
- data/ext/WaxSim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +126 -0
- data/ext/iCuke/Rakefile +14 -17
- data/ext/iCuke/libicuke-sdk3.1.dylib +0 -0
- data/ext/iCuke/libicuke-sdk4.0.dylib +0 -0
- data/ext/iCuke/libicuke.dylib +0 -0
- data/ext/iCuke/{DefaultsResponse.h → sdk3.1/DefaultsResponse.h} +0 -0
- data/ext/iCuke/{DefaultsResponse.m → sdk3.1/DefaultsResponse.m} +0 -0
- data/ext/iCuke/{EventResponse.h → sdk3.1/EventResponse.h} +0 -0
- data/ext/iCuke/{EventResponse.m → sdk3.1/EventResponse.m} +0 -0
- data/ext/iCuke/sdk3.1/ModuleResponse.h +5 -0
- data/ext/iCuke/sdk3.1/ModuleResponse.m +76 -0
- data/ext/iCuke/sdk3.1/Rakefile +20 -0
- data/ext/iCuke/{Recorder.h → sdk3.1/Recorder.h} +0 -0
- data/ext/iCuke/{Recorder.m → sdk3.1/Recorder.m} +0 -0
- data/ext/iCuke/{RecorderResponse.h → sdk3.1/RecorderResponse.h} +0 -0
- data/ext/iCuke/{RecorderResponse.m → sdk3.1/RecorderResponse.m} +0 -0
- data/ext/iCuke/{SynthesizeSingleton.h → sdk3.1/SynthesizeSingleton.h} +0 -0
- data/ext/iCuke/{ViewResponse.h → sdk3.1/ViewResponse.h} +0 -0
- data/ext/iCuke/{ViewResponse.m → sdk3.1/ViewResponse.m} +0 -0
- data/ext/iCuke/{Viewer.h → sdk3.1/Viewer.h} +0 -0
- data/ext/iCuke/sdk3.1/Viewer.m +203 -0
- data/ext/iCuke/{iCukeHTTPResponseHandler.h → sdk3.1/iCukeHTTPResponseHandler.h} +0 -0
- data/ext/iCuke/{iCukeHTTPResponseHandler.m → sdk3.1/iCukeHTTPResponseHandler.m} +0 -0
- data/ext/iCuke/{iCukeHTTPServer.h → sdk3.1/iCukeHTTPServer.h} +0 -0
- data/ext/iCuke/{iCukeHTTPServer.m → sdk3.1/iCukeHTTPServer.m} +0 -0
- data/ext/iCuke/{iCukeServer.h → sdk3.1/iCukeServer.h} +0 -2
- data/ext/iCuke/{iCukeServer.m → sdk3.1/iCukeServer.m} +22 -20
- data/ext/iCuke/{json → sdk3.1/json}/JSON.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/NSObject+SBJSON.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/NSObject+SBJSON.m +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/NSString+SBJSON.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/NSString+SBJSON.m +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJSON.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJSON.m +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJsonBase.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJsonBase.m +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJsonParser.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJsonParser.m +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJsonWriter.h +0 -0
- data/ext/iCuke/{json → sdk3.1/json}/SBJsonWriter.m +0 -0
- data/ext/iCuke/sdk4.0/DefaultsResponse.h +5 -0
- data/ext/iCuke/sdk4.0/DefaultsResponse.m +66 -0
- data/ext/iCuke/sdk4.0/EventResponse.h +5 -0
- data/ext/iCuke/sdk4.0/EventResponse.m +130 -0
- data/ext/iCuke/sdk4.0/ModuleResponse.h +5 -0
- data/ext/iCuke/sdk4.0/ModuleResponse.m +76 -0
- data/ext/iCuke/sdk4.0/Rakefile +20 -0
- data/ext/iCuke/sdk4.0/Recorder.h +17 -0
- data/ext/iCuke/sdk4.0/Recorder.m +90 -0
- data/ext/iCuke/sdk4.0/RecorderResponse.h +6 -0
- data/ext/iCuke/sdk4.0/RecorderResponse.m +68 -0
- data/ext/iCuke/sdk4.0/SynthesizeSingleton.h +68 -0
- data/ext/iCuke/sdk4.0/ViewResponse.h +5 -0
- data/ext/iCuke/sdk4.0/ViewResponse.m +84 -0
- data/ext/iCuke/sdk4.0/Viewer.h +8 -0
- data/ext/iCuke/{Viewer.m → sdk4.0/Viewer.m} +14 -0
- data/ext/iCuke/sdk4.0/iCukeHTTPResponseHandler.h +50 -0
- data/ext/iCuke/sdk4.0/iCukeHTTPResponseHandler.m +381 -0
- data/ext/iCuke/sdk4.0/iCukeHTTPServer.h +53 -0
- data/ext/iCuke/sdk4.0/iCukeHTTPServer.m +365 -0
- data/ext/iCuke/sdk4.0/iCukeServer.h +14 -0
- data/ext/iCuke/sdk4.0/iCukeServer.m +65 -0
- data/ext/iCuke/sdk4.0/json/JSON.h +50 -0
- data/ext/iCuke/sdk4.0/json/NSObject+SBJSON.h +68 -0
- data/ext/iCuke/sdk4.0/json/NSObject+SBJSON.m +53 -0
- data/ext/iCuke/sdk4.0/json/NSString+SBJSON.h +58 -0
- data/ext/iCuke/sdk4.0/json/NSString+SBJSON.m +55 -0
- data/ext/iCuke/sdk4.0/json/SBJSON.h +75 -0
- data/ext/iCuke/sdk4.0/json/SBJSON.m +212 -0
- data/ext/iCuke/sdk4.0/json/SBJsonBase.h +86 -0
- data/ext/iCuke/sdk4.0/json/SBJsonBase.m +78 -0
- data/ext/iCuke/sdk4.0/json/SBJsonParser.h +87 -0
- data/ext/iCuke/sdk4.0/json/SBJsonParser.m +475 -0
- data/ext/iCuke/sdk4.0/json/SBJsonWriter.h +129 -0
- data/ext/iCuke/sdk4.0/json/SBJsonWriter.m +228 -0
- data/features/iphone.feature +15 -0
- data/features/support/env.rb +1 -1
- data/iCuke.gemspec +118 -114
- data/lib/icuke/cucumber.rb +93 -64
- data/lib/icuke/screen.rb +110 -0
- data/lib/icuke/sdk.rb +134 -0
- data/lib/icuke/simulate.rb +9 -5
- data/lib/icuke/simulator.rb +10 -11
- data/lib/icuke/waxsim.rb +36 -0
- data/lib/icuke.rb +2 -1
- metadata +124 -129
- data/app/AlertsViewController.h +0 -59
- data/app/AlertsViewController.m +0 -341
- data/app/AppDelegate.h +0 -60
- data/app/AppDelegate.m +0 -101
- data/app/ButtonsViewController.h +0 -80
- data/app/ButtonsViewController.m +0 -448
- data/app/Constants.h +0 -58
- data/app/ControlsViewController.h +0 -72
- data/app/ControlsViewController.m +0 -379
- data/app/ImagesViewController.h +0 -62
- data/app/ImagesViewController.m +0 -137
- data/app/MainViewController.h +0 -57
- data/app/MainViewController.m +0 -262
- data/app/Picker/CustomPickerDataSource.h +0 -55
- data/app/Picker/CustomPickerDataSource.m +0 -135
- data/app/Picker/CustomView.h +0 -62
- data/app/Picker/CustomView.m +0 -119
- data/app/PickerViewController.h +0 -88
- data/app/PickerViewController.m +0 -402
- data/app/Prefix.pch +0 -5
- data/app/ReadMe.txt +0 -82
- data/app/SearchBarController.h +0 -58
- data/app/SearchBarController.m +0 -105
- data/app/SegmentViewController.h +0 -54
- data/app/SegmentViewController.m +0 -195
- data/app/TextFieldController.h +0 -67
- data/app/TextFieldController.m +0 -342
- data/app/TextViewController.h +0 -57
- data/app/TextViewController.m +0 -164
- data/app/ToolbarViewController.h +0 -74
- data/app/ToolbarViewController.m +0 -303
- data/app/TransitionViewController.h +0 -64
- data/app/TransitionViewController.m +0 -178
- data/app/UICatalog.xcodeproj/project.pbxproj +0 -615
- data/app/WebViewController.h +0 -57
- data/app/WebViewController.m +0 -173
- data/app/en.lproj/AlertsViewController.xib +0 -144
- data/app/en.lproj/ButtonsViewController.xib +0 -147
- data/app/en.lproj/ControlsViewController.xib +0 -147
- data/app/en.lproj/ImagesViewController.xib +0 -264
- data/app/en.lproj/Localizable.strings +0 -41
- data/app/en.lproj/MainWindow.xib +0 -306
- data/app/en.lproj/PickerViewController.xib +0 -415
- data/app/en.lproj/SearchBarController.xib +0 -142
- data/app/en.lproj/SegmentViewController.xib +0 -143
- data/app/en.lproj/TextFieldController.xib +0 -167
- data/app/en.lproj/TextViewController.xib +0 -149
- data/app/en.lproj/ToolbarViewController.xib +0 -491
- data/app/en.lproj/TransitionViewController.xib +0 -255
- data/app/en.lproj/WebViewController.xib +0 -141
- data/app/images/12-6AM.png +0 -0
- data/app/images/12-6PM.png +0 -0
- data/app/images/6-12AM.png +0 -0
- data/app/images/6-12PM.png +0 -0
- data/app/images/Default.png +0 -0
- data/app/images/Icon.png +0 -0
- data/app/images/UIButton_custom.png +0 -0
- data/app/images/blueButton.png +0 -0
- data/app/images/orangeslide.png +0 -0
- data/app/images/scene1.jpg +0 -0
- data/app/images/scene2.jpg +0 -0
- data/app/images/scene3.jpg +0 -0
- data/app/images/scene4.jpg +0 -0
- data/app/images/scene5.jpg +0 -0
- data/app/images/segment_check.png +0 -0
- data/app/images/segment_tools.png +0 -0
- data/app/images/slider_ball.png +0 -0
- data/app/images/whiteButton.png +0 -0
- data/app/main.m +0 -58
- data/features/uicatalog.feature +0 -20
- data/lib/icuke/com.apple.Accessibility.plist +0 -0
- data/lib/icuke/headless.rb +0 -54
- data/lib/icuke/xcode.rb +0 -164
@@ -0,0 +1,203 @@
|
|
1
|
+
#import <QuartzCore/QuartzCore.h>
|
2
|
+
#import <UIKit/UIKit.h>
|
3
|
+
|
4
|
+
#import "Viewer.h"
|
5
|
+
|
6
|
+
static Viewer *sharedViewer = nil;
|
7
|
+
|
8
|
+
@interface NSObject (Accessibility)
|
9
|
+
-(BOOL)_accessibilityIsFrameOutOfBounds;
|
10
|
+
@end
|
11
|
+
|
12
|
+
@interface NSObject (UIAccessibilityViewer)
|
13
|
+
|
14
|
+
-(void)appendToXml:(NSMutableString*)xml;
|
15
|
+
-(void)appendTraitsToXml:(NSMutableString*)xml;
|
16
|
+
-(void)appendFrameToXml:(NSMutableString*)xml;
|
17
|
+
-(void)appendOpenToXml:(NSMutableString*)xml;
|
18
|
+
-(void)appendCloseToXml:(NSMutableString*)xml;
|
19
|
+
-(void)appendChildrenToXml:(NSMutableString*)xml;
|
20
|
+
|
21
|
+
@end
|
22
|
+
|
23
|
+
@implementation NSObject (UIAccessibilityViewer)
|
24
|
+
|
25
|
+
-(void)appendOpenToXml:(NSMutableString*)xml {
|
26
|
+
[xml appendFormat: @"<%@", NSStringFromClass([self class])];
|
27
|
+
if ([self isAccessibilityElement]) {
|
28
|
+
[self appendTraitsToXml: xml];
|
29
|
+
if ([[self accessibilityLabel] length] > 0) {
|
30
|
+
NSString *escaped_label = [self accessibilityLabel];
|
31
|
+
escaped_label = [escaped_label stringByReplacingOccurrencesOfString: @"&" withString: @"&"];
|
32
|
+
escaped_label = [escaped_label stringByReplacingOccurrencesOfString: @"\"" withString: @"""];
|
33
|
+
escaped_label = [escaped_label stringByReplacingOccurrencesOfString: @"'" withString: @"'"];
|
34
|
+
escaped_label = [escaped_label stringByReplacingOccurrencesOfString: @"\\" withString: @"'"];
|
35
|
+
escaped_label = [escaped_label stringByReplacingOccurrencesOfString: @">" withString: @">"];
|
36
|
+
escaped_label = [escaped_label stringByReplacingOccurrencesOfString: @"<" withString: @"<"];
|
37
|
+
[xml appendFormat: @"label=\"%@\" ", escaped_label];
|
38
|
+
}
|
39
|
+
if ([[self accessibilityHint] length] > 0) {
|
40
|
+
[xml appendFormat: @"hint=\"%@\" ", [self accessibilityHint]];
|
41
|
+
}
|
42
|
+
if ([[self accessibilityValue] length] > 0) {
|
43
|
+
NSString *escaped_value = [self accessibilityValue];
|
44
|
+
escaped_value = [escaped_value stringByReplacingOccurrencesOfString: @"&" withString: @"&"];
|
45
|
+
escaped_value = [escaped_value stringByReplacingOccurrencesOfString: @"\"" withString: @"""];
|
46
|
+
escaped_value = [escaped_value stringByReplacingOccurrencesOfString: @"'" withString: @"'"];
|
47
|
+
escaped_value = [escaped_value stringByReplacingOccurrencesOfString: @"\\" withString: @"'"];
|
48
|
+
escaped_value = [escaped_value stringByReplacingOccurrencesOfString: @">" withString: @">"];
|
49
|
+
escaped_value = [escaped_value stringByReplacingOccurrencesOfString: @"<" withString: @"<"];
|
50
|
+
[xml appendFormat: @"value=\"%@\" ", escaped_value];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
[xml appendString: @">"];
|
54
|
+
}
|
55
|
+
|
56
|
+
-(void)appendTraitsToXml:(NSMutableString *)xml {
|
57
|
+
[xml appendString: @" traits=\""];
|
58
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitButton) {
|
59
|
+
[xml appendString: @"button "];
|
60
|
+
}
|
61
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitLink) {
|
62
|
+
[xml appendString: @"link "];
|
63
|
+
}
|
64
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitSearchField) {
|
65
|
+
[xml appendString: @"search_field "];
|
66
|
+
}
|
67
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitImage) {
|
68
|
+
[xml appendString: @"image "];
|
69
|
+
}
|
70
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitSelected) {
|
71
|
+
[xml appendString: @"selected "];
|
72
|
+
}
|
73
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitPlaysSound) {
|
74
|
+
[xml appendString: @"plays_sound "];
|
75
|
+
}
|
76
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitKeyboardKey) {
|
77
|
+
[xml appendString: @"keyboard_key "];
|
78
|
+
}
|
79
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitStaticText) {
|
80
|
+
[xml appendString: @"static_text "];
|
81
|
+
}
|
82
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitSummaryElement) {
|
83
|
+
[xml appendString: @"summary_element "];
|
84
|
+
}
|
85
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitNotEnabled) {
|
86
|
+
[xml appendString: @"not_enabled "];
|
87
|
+
}
|
88
|
+
if ([self accessibilityTraits] & UIAccessibilityTraitUpdatesFrequently) {
|
89
|
+
[xml appendString: @"updates_frequently "];
|
90
|
+
}
|
91
|
+
[xml appendString: @"\" "];
|
92
|
+
}
|
93
|
+
|
94
|
+
-(void)appendFrameToXml:(NSMutableString *)xml {
|
95
|
+
CGRect frame = [self accessibilityFrame];
|
96
|
+
[xml appendFormat: @"<frame x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>",
|
97
|
+
frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
|
98
|
+
}
|
99
|
+
|
100
|
+
-(void)appendCloseToXml:(NSMutableString *)xml {
|
101
|
+
[xml appendFormat: @"</%@>", NSStringFromClass([self class])];
|
102
|
+
}
|
103
|
+
|
104
|
+
-(void)appendChildrenToXml:(NSMutableString *)xml {
|
105
|
+
// Bug that accessibilityElementCount is returning 2147483647 rather than 0?
|
106
|
+
if ([self accessibilityElementCount] != 2147483647) {
|
107
|
+
for (int i = 0; i < [self accessibilityElementCount]; i++) {
|
108
|
+
id accessibilityElement = [self accessibilityElementAtIndex: i];
|
109
|
+
[accessibilityElement appendToXml: xml];
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
-(void)appendToXml:(NSMutableString *)xml {
|
115
|
+
[self appendOpenToXml: xml];
|
116
|
+
[self appendFrameToXml: xml];
|
117
|
+
[self appendChildrenToXml: xml];
|
118
|
+
[self appendCloseToXml: xml];
|
119
|
+
}
|
120
|
+
|
121
|
+
@end
|
122
|
+
|
123
|
+
@implementation UITableView (AccessibilityVisibilityFix)
|
124
|
+
|
125
|
+
-(void)appendChildrenToXml:(NSMutableString *)xml {
|
126
|
+
// Ignore the accessibility interface here because it doesn't allow us a way to tell if a cell is visible.
|
127
|
+
for (UIView *view in [self visibleCells]) {
|
128
|
+
[view appendToXml: xml];
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
@end
|
133
|
+
|
134
|
+
@interface UIView (Viewer)
|
135
|
+
|
136
|
+
-(void)appendToXml:(NSMutableString *)xml;
|
137
|
+
-(void)appendFrameToXml:(NSMutableString *)xml;
|
138
|
+
|
139
|
+
@end
|
140
|
+
|
141
|
+
@implementation UIView (Viewer)
|
142
|
+
|
143
|
+
-(void)appendToXml:(NSMutableString *)xml {
|
144
|
+
[self appendOpenToXml: xml];
|
145
|
+
|
146
|
+
if ([self _accessibilityIsFrameOutOfBounds]) {
|
147
|
+
[xml appendFormat: @"<invisible/>"];
|
148
|
+
}
|
149
|
+
|
150
|
+
[self appendFrameToXml: xml];
|
151
|
+
|
152
|
+
for (UIView *view in self.subviews) {
|
153
|
+
[view appendToXml: xml];
|
154
|
+
}
|
155
|
+
|
156
|
+
[self appendChildrenToXml: xml];
|
157
|
+
[self appendCloseToXml: xml];
|
158
|
+
}
|
159
|
+
|
160
|
+
-(void)appendFrameToXml:(NSMutableString *)xml {
|
161
|
+
CGRect frame;
|
162
|
+
|
163
|
+
if ([self isAccessibilityElement]) {
|
164
|
+
frame = [self accessibilityFrame];
|
165
|
+
} else {
|
166
|
+
frame = [self frame];
|
167
|
+
}
|
168
|
+
[xml appendFormat: @"<frame x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>",
|
169
|
+
frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
|
170
|
+
|
171
|
+
frame = [[[UIApplication sharedApplication] keyWindow] convertRect:self.layer.visibleRect fromView:self];
|
172
|
+
|
173
|
+
[xml appendFormat: @"<visibleFrame x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>",
|
174
|
+
frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
|
175
|
+
}
|
176
|
+
|
177
|
+
@end
|
178
|
+
|
179
|
+
@implementation Viewer
|
180
|
+
|
181
|
+
+(Viewer *)sharedViewer {
|
182
|
+
if (sharedViewer == nil) {
|
183
|
+
sharedViewer = [[super allocWithZone:NULL] init];
|
184
|
+
}
|
185
|
+
return sharedViewer;
|
186
|
+
}
|
187
|
+
|
188
|
+
-(NSString *)screen {
|
189
|
+
NSMutableString *xml = [NSMutableString stringWithString: @"<screen>"];
|
190
|
+
CGRect frame = [[UIScreen mainScreen] applicationFrame];
|
191
|
+
[xml appendFormat: @"<frame x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>",
|
192
|
+
frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
|
193
|
+
|
194
|
+
for (UIWindow *window in [UIApplication sharedApplication].windows) {
|
195
|
+
[window appendToXml: xml];
|
196
|
+
}
|
197
|
+
|
198
|
+
[xml appendString: @"</screen>"];
|
199
|
+
|
200
|
+
return xml;
|
201
|
+
}
|
202
|
+
|
203
|
+
@end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -10,13 +10,12 @@
|
|
10
10
|
#include <unistd.h>
|
11
11
|
#include <stdlib.h>
|
12
12
|
|
13
|
-
static NSAutoreleasePool *pool;
|
14
|
-
|
15
13
|
@implementation iCukeServer
|
16
14
|
|
17
|
-
+ (void)
|
18
|
-
|
19
|
-
|
15
|
+
+ (void)load
|
16
|
+
{
|
17
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
18
|
+
|
20
19
|
[[iCukeHTTPServer sharediCukeHTTPServer] start];
|
21
20
|
|
22
21
|
NSFileManager *fileManager= [[NSFileManager alloc] init];
|
@@ -27,6 +26,7 @@ static NSAutoreleasePool *pool;
|
|
27
26
|
|
28
27
|
paths = [fileManager contentsOfDirectoryAtPath: preferences error: NULL];
|
29
28
|
for (NSString *path in paths) {
|
29
|
+
NSLog(@"Found: %@", path);
|
30
30
|
if (![path hasPrefix: @"."]) {
|
31
31
|
NSLog(@"Removing: %@", path);
|
32
32
|
unlink([[preferences stringByAppendingPathComponent: path] cStringUsingEncoding: [NSString defaultCStringEncoding]]);
|
@@ -34,6 +34,22 @@ static NSAutoreleasePool *pool;
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
37
|
+
// This is a hack, I can't find a nicer way. The iPhone Simulator's
|
38
|
+
// preferences are hidden away from applications. None of the preference APIs
|
39
|
+
// allow access to them.
|
40
|
+
NSString *path = [NSString stringWithFormat: @"/Users/%@/Library/Application Support/iPhone Simulator/%@/Library/Preferences", NSUserName(), [[UIDevice currentDevice] systemVersion]];
|
41
|
+
path = [path stringByAppendingPathComponent: @"com.apple.Accessibility.plist"];
|
42
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile: path];
|
43
|
+
if (!dict) {
|
44
|
+
dict = [NSMutableDictionary dictionaryWithCapacity: 2];
|
45
|
+
}
|
46
|
+
NSNumber *enabled = [NSNumber numberWithBool: YES];
|
47
|
+
[dict setObject: enabled forKey: @"AccessibilityEnabled"];
|
48
|
+
[dict setObject: enabled forKey: @"ApplicationAccessibilityEnabled"];
|
49
|
+
if (![dict writeToFile: path atomically: YES]) {
|
50
|
+
NSLog(@"Failed to write %@ out to %@", dict, path);
|
51
|
+
}
|
52
|
+
|
37
53
|
NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent: @"Documents"];
|
38
54
|
paths = [fileManager contentsOfDirectoryAtPath: documents error: NULL];
|
39
55
|
for (NSString *path in paths) {
|
@@ -42,22 +58,8 @@ static NSAutoreleasePool *pool;
|
|
42
58
|
unlink([[documents stringByAppendingPathComponent: path] cStringUsingEncoding: [NSString defaultCStringEncoding]]);
|
43
59
|
}
|
44
60
|
}
|
45
|
-
|
46
|
-
|
47
|
-
+ (void)stop {
|
61
|
+
|
48
62
|
[pool release];
|
49
63
|
}
|
50
64
|
|
51
65
|
@end
|
52
|
-
|
53
|
-
void start_server(void) __attribute__((constructor));
|
54
|
-
void start_server(void)
|
55
|
-
{
|
56
|
-
[iCukeServer start];
|
57
|
-
}
|
58
|
-
|
59
|
-
void stop_server(void) __attribute__((destructor));
|
60
|
-
void stop_server(void)
|
61
|
-
{
|
62
|
-
[iCukeServer stop];
|
63
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#import "DefaultsResponse.h"
|
2
|
+
#import "iCukeHTTPServer.h"
|
3
|
+
#import "JSON.h"
|
4
|
+
|
5
|
+
@implementation DefaultsResponse
|
6
|
+
+ (void)load
|
7
|
+
{
|
8
|
+
[iCukeHTTPResponseHandler registerHandler:self];
|
9
|
+
}
|
10
|
+
|
11
|
+
+ (BOOL)canHandleRequest:(CFHTTPMessageRef)aRequest
|
12
|
+
method:(NSString *)requestMethod
|
13
|
+
url:(NSURL *)requestURL
|
14
|
+
headerFields:(NSDictionary *)requestHeaderFields
|
15
|
+
{
|
16
|
+
return [requestURL.path isEqualToString:@"/defaults"];
|
17
|
+
}
|
18
|
+
|
19
|
+
- (void)startResponse
|
20
|
+
{
|
21
|
+
NSUserDefaults *user_defaults = [NSUserDefaults standardUserDefaults];
|
22
|
+
NSString *json = [[url query] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
23
|
+
NSData *defaultsData = nil;
|
24
|
+
|
25
|
+
if (!json) {
|
26
|
+
NSDictionary *defaults = [user_defaults dictionaryRepresentation];
|
27
|
+
|
28
|
+
defaultsData = [[defaults JSONRepresentation] dataUsingEncoding:NSUTF8StringEncoding];
|
29
|
+
} else {
|
30
|
+
id parsed_json = [json JSONValue];
|
31
|
+
|
32
|
+
NSEnumerator *enumerator = [parsed_json keyEnumerator];
|
33
|
+
id key;
|
34
|
+
while ((key = [enumerator nextObject])) {
|
35
|
+
[user_defaults setObject: [parsed_json objectForKey: key] forKey: key];
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
CFHTTPMessageRef response = CFHTTPMessageCreateResponse(kCFAllocatorDefault, 200, NULL, kCFHTTPVersion1_1);
|
40
|
+
CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Connection", (CFStringRef)@"close");
|
41
|
+
CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Content-Type", (CFStringRef)@"application/json");
|
42
|
+
|
43
|
+
if (defaultsData)
|
44
|
+
CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Content-Length",
|
45
|
+
(CFStringRef)[NSString stringWithFormat:@"%ld", [defaultsData length]]);
|
46
|
+
|
47
|
+
CFDataRef headerData = CFHTTPMessageCopySerializedMessage(response);
|
48
|
+
|
49
|
+
@try
|
50
|
+
{
|
51
|
+
[fileHandle writeData:(NSData *)headerData];
|
52
|
+
if (defaultsData)
|
53
|
+
[fileHandle writeData:defaultsData];
|
54
|
+
}
|
55
|
+
@catch (NSException *exception)
|
56
|
+
{
|
57
|
+
// Ignore the exception, it normally just means the client
|
58
|
+
// closed the connection from the other end.
|
59
|
+
}
|
60
|
+
@finally
|
61
|
+
{
|
62
|
+
CFRelease(headerData);
|
63
|
+
[server closeHandler:self];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
@end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#import "EventResponse.h"
|
2
|
+
#import "iCukeHTTPServer.h"
|
3
|
+
#import "JSON.h"
|
4
|
+
#import "Recorder.h"
|
5
|
+
|
6
|
+
typedef struct {
|
7
|
+
unsigned char index;
|
8
|
+
unsigned char index2;
|
9
|
+
unsigned char type;
|
10
|
+
unsigned char flags;
|
11
|
+
float sizeX;
|
12
|
+
float sizeY;
|
13
|
+
float x;
|
14
|
+
float y;
|
15
|
+
int x6;
|
16
|
+
} gs_path_info_t;
|
17
|
+
|
18
|
+
typedef struct {
|
19
|
+
int type;
|
20
|
+
short deltaX;
|
21
|
+
short deltaY;
|
22
|
+
float x3;
|
23
|
+
float x4;
|
24
|
+
float pinch1;
|
25
|
+
float pinch2;
|
26
|
+
float averageX;
|
27
|
+
float averageY;
|
28
|
+
unsigned char x9_1;
|
29
|
+
unsigned char pathCount;
|
30
|
+
unsigned char x9_3;
|
31
|
+
unsigned char x9_4;
|
32
|
+
} gs_hand_info_t;
|
33
|
+
|
34
|
+
@implementation EventResponse
|
35
|
+
+ (void)load
|
36
|
+
{
|
37
|
+
[iCukeHTTPResponseHandler registerHandler:self];
|
38
|
+
}
|
39
|
+
|
40
|
+
+ (BOOL)canHandleRequest:(CFHTTPMessageRef)aRequest
|
41
|
+
method:(NSString *)requestMethod
|
42
|
+
url:(NSURL *)requestURL
|
43
|
+
headerFields:(NSDictionary *)requestHeaderFields
|
44
|
+
{
|
45
|
+
return [requestURL.path isEqualToString:@"/event"];
|
46
|
+
}
|
47
|
+
|
48
|
+
- (void)startResponse
|
49
|
+
{
|
50
|
+
NSString *json = [[url query] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
51
|
+
id event_data = [json JSONValue];
|
52
|
+
NSArray *events;
|
53
|
+
|
54
|
+
if ([event_data isKindOfClass:[NSDictionary class]]) {
|
55
|
+
events = [NSArray arrayWithObject: event_data];
|
56
|
+
} else {
|
57
|
+
events = event_data;
|
58
|
+
}
|
59
|
+
|
60
|
+
for (NSMutableDictionary *event in events) {
|
61
|
+
gs_hand_info_t hand_info;
|
62
|
+
|
63
|
+
bzero(&hand_info, sizeof(hand_info));
|
64
|
+
|
65
|
+
NSMutableDictionary *data = [event objectForKey: @"Data"];
|
66
|
+
|
67
|
+
hand_info.type = [[data objectForKey: @"Type"] integerValue];
|
68
|
+
NSDictionary *delta = [data objectForKey: @"Delta"];
|
69
|
+
hand_info.deltaX = [[delta objectForKey: @"X"] shortValue];
|
70
|
+
hand_info.deltaY = [[delta objectForKey: @"Y"] shortValue];
|
71
|
+
hand_info.averageX = [[[delta objectForKey: @"WindowLocation"] objectForKey: @"X"] floatValue];
|
72
|
+
hand_info.averageY = [[[delta objectForKey: @"WindowLocation"] objectForKey: @"Y"] floatValue];
|
73
|
+
|
74
|
+
NSArray *points = [data objectForKey: @"Paths"];
|
75
|
+
|
76
|
+
hand_info.pathCount = (unsigned char)[points count];
|
77
|
+
if (hand_info.type != 1) {
|
78
|
+
hand_info.x9_3 = 0x7c;
|
79
|
+
hand_info.x9_4 = 0x98;
|
80
|
+
}
|
81
|
+
|
82
|
+
NSMutableData *raw_data = [NSMutableData dataWithBytes: &hand_info length: sizeof(hand_info)];
|
83
|
+
|
84
|
+
int index = hand_info.pathCount == 1 ? 2 : 1;
|
85
|
+
|
86
|
+
for (NSDictionary *point in points) {
|
87
|
+
gs_path_info_t path_info;
|
88
|
+
|
89
|
+
bzero(&path_info, sizeof(path_info));
|
90
|
+
|
91
|
+
path_info.index = path_info.index2 = index++;
|
92
|
+
path_info.type = hand_info.type == 6 ? 1 : 2;
|
93
|
+
path_info.flags = hand_info.type == 1 ? 0x43 : 0x3f;
|
94
|
+
path_info.sizeX = [[[point objectForKey: @"Size"] objectForKey: @"X"] floatValue];
|
95
|
+
path_info.sizeY = [[[point objectForKey: @"Size"] objectForKey: @"Y"] floatValue];
|
96
|
+
path_info.x = [[[point objectForKey: @"Location"] objectForKey: @"X"] floatValue];
|
97
|
+
path_info.y = [[[point objectForKey: @"Location"] objectForKey: @"Y"] floatValue];
|
98
|
+
|
99
|
+
[raw_data appendBytes: &path_info length: sizeof(path_info)];
|
100
|
+
}
|
101
|
+
|
102
|
+
[event setObject: raw_data forKey: @"Data"];
|
103
|
+
}
|
104
|
+
|
105
|
+
[[Recorder sharedRecorder] load: events];
|
106
|
+
[[Recorder sharedRecorder] playbackWithDelegate: self doneSelector: @selector(finishResponse)];
|
107
|
+
}
|
108
|
+
|
109
|
+
- (void)finishResponse
|
110
|
+
{
|
111
|
+
CFHTTPMessageRef response = CFHTTPMessageCreateResponse(kCFAllocatorDefault, 200, NULL, kCFHTTPVersion1_1);
|
112
|
+
CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Connection", (CFStringRef)@"close");
|
113
|
+
CFDataRef headerData = CFHTTPMessageCopySerializedMessage(response);
|
114
|
+
|
115
|
+
@try
|
116
|
+
{
|
117
|
+
[fileHandle writeData:(NSData *)headerData];
|
118
|
+
}
|
119
|
+
@catch (NSException *exception)
|
120
|
+
{
|
121
|
+
// Ignore the exception, it normally just means the client
|
122
|
+
// closed the connection from the other end.
|
123
|
+
}
|
124
|
+
@finally
|
125
|
+
{
|
126
|
+
CFRelease(headerData);
|
127
|
+
[server closeHandler:self];
|
128
|
+
}
|
129
|
+
}
|
130
|
+
@end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#import "ModuleResponse.h"
|
2
|
+
#import "iCukeHTTPServer.h"
|
3
|
+
#include <dlfcn.h>
|
4
|
+
|
5
|
+
@implementation ModuleResponse
|
6
|
+
+ (void)load
|
7
|
+
{
|
8
|
+
[iCukeHTTPResponseHandler registerHandler:self];
|
9
|
+
}
|
10
|
+
|
11
|
+
+ (BOOL)canHandleRequest:(CFHTTPMessageRef)aRequest
|
12
|
+
method:(NSString *)requestMethod
|
13
|
+
url:(NSURL *)requestURL
|
14
|
+
headerFields:(NSDictionary *)requestHeaderFields
|
15
|
+
{
|
16
|
+
return [requestURL.path isEqualToString:@"/module"];
|
17
|
+
}
|
18
|
+
|
19
|
+
- (void)startResponse
|
20
|
+
{
|
21
|
+
NSString *module = [[url query] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
22
|
+
|
23
|
+
if (!dlopen([module UTF8String], 0)) {
|
24
|
+
CFHTTPMessageRef response =
|
25
|
+
CFHTTPMessageCreateResponse(
|
26
|
+
kCFAllocatorDefault, 500, NULL, kCFHTTPVersion1_1);
|
27
|
+
CFHTTPMessageSetHeaderFieldValue(
|
28
|
+
response, (CFStringRef)@"Content-Type", (CFStringRef)@"text/plain");
|
29
|
+
CFHTTPMessageSetHeaderFieldValue(
|
30
|
+
response, (CFStringRef)@"Connection", (CFStringRef)@"close");
|
31
|
+
CFHTTPMessageSetBody(
|
32
|
+
response,
|
33
|
+
(CFDataRef)[[NSString stringWithFormat:
|
34
|
+
@"Unable to load module: %@, %s", module, dlerror()]
|
35
|
+
dataUsingEncoding:NSUTF8StringEncoding]);
|
36
|
+
CFDataRef headerData = CFHTTPMessageCopySerializedMessage(response);
|
37
|
+
@try
|
38
|
+
{
|
39
|
+
[fileHandle writeData:(NSData *)headerData];
|
40
|
+
}
|
41
|
+
@catch (NSException *exception)
|
42
|
+
{
|
43
|
+
// Ignore the exception, it normally just means the client
|
44
|
+
// closed the connection from the other end.
|
45
|
+
}
|
46
|
+
@finally
|
47
|
+
{
|
48
|
+
CFRelease(headerData);
|
49
|
+
CFRelease(response);
|
50
|
+
[server closeHandler:self];
|
51
|
+
}
|
52
|
+
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
CFHTTPMessageRef response = CFHTTPMessageCreateResponse(kCFAllocatorDefault, 200, NULL, kCFHTTPVersion1_1);
|
57
|
+
CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Connection", (CFStringRef)@"close");
|
58
|
+
|
59
|
+
CFDataRef headerData = CFHTTPMessageCopySerializedMessage(response);
|
60
|
+
|
61
|
+
@try
|
62
|
+
{
|
63
|
+
[fileHandle writeData:(NSData *)headerData];
|
64
|
+
}
|
65
|
+
@catch (NSException *exception)
|
66
|
+
{
|
67
|
+
// Ignore the exception, it normally just means the client
|
68
|
+
// closed the connection from the other end.
|
69
|
+
}
|
70
|
+
@finally
|
71
|
+
{
|
72
|
+
CFRelease(headerData);
|
73
|
+
[server closeHandler:self];
|
74
|
+
}
|
75
|
+
}
|
76
|
+
@end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'icuke', 'sdk')
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
version = '4.0'
|
5
|
+
ICuke::SDK.use_latest(version)
|
6
|
+
|
7
|
+
rule '.o' => '.m' do |o|
|
8
|
+
sh "#{ICuke::SDK.gcc} -c -o #{o.name} #{o.source}"
|
9
|
+
end
|
10
|
+
|
11
|
+
CLEAN.include('**/*.o')
|
12
|
+
|
13
|
+
file "../#{ICuke::SDK.dylib}" => FileList['**/*.m'].ext('.o') do |t|
|
14
|
+
sh "#{ICuke::SDK.ld} -dynamiclib -o #{t.name} -framework Foundation -framework GraphicsServices -framework UIKit -framework CFNetwork -framework AXRuntime #{t.prerequisites.join(' ')}"
|
15
|
+
end
|
16
|
+
|
17
|
+
CLEAN.include("../#{ICuke::SDK.dylib}")
|
18
|
+
|
19
|
+
task :install => "../#{ICuke::SDK.dylib}"
|
20
|
+
task :default => :install
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
@interface Recorder : NSObject {
|
4
|
+
NSMutableArray* eventList;
|
5
|
+
id playbackDelegate;
|
6
|
+
SEL playbackDoneSelector;
|
7
|
+
}
|
8
|
+
|
9
|
+
+(Recorder *)sharedRecorder;
|
10
|
+
-(void)record;
|
11
|
+
-(void)saveToFile:(NSString*)path;
|
12
|
+
-(void)load:(NSArray*)events;
|
13
|
+
-(void)loadFromFile:(NSString*)path;
|
14
|
+
-(void)playbackWithDelegate:(id)delegate doneSelector:(SEL)selector;
|
15
|
+
-(void)stop;
|
16
|
+
|
17
|
+
@end
|