iCuke 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.gitmodules +1 -1
  2. data/Gemfile +12 -0
  3. data/Gemfile.lock +41 -0
  4. data/README.markdown +126 -0
  5. data/Rakefile +34 -12
  6. data/VERSION +1 -1
  7. data/bin/icuke +12 -10
  8. data/ext/Rakefile +6 -0
  9. data/ext/iCuke/{sdk3.1/DefaultsResponse.h → DefaultsResponse.h} +0 -0
  10. data/ext/iCuke/{sdk3.1/DefaultsResponse.m → DefaultsResponse.m} +0 -0
  11. data/ext/iCuke/{sdk3.1/EventResponse.h → EventResponse.h} +0 -0
  12. data/ext/iCuke/{sdk3.1/EventResponse.m → EventResponse.m} +0 -0
  13. data/ext/iCuke/{sdk3.1/ModuleResponse.h → ModuleResponse.h} +0 -0
  14. data/ext/iCuke/{sdk3.1/ModuleResponse.m → ModuleResponse.m} +0 -0
  15. data/ext/iCuke/{sdk3.1/QuitResponse.h → QuitResponse.h} +0 -0
  16. data/ext/iCuke/{sdk3.1/QuitResponse.m → QuitResponse.m} +0 -0
  17. data/ext/iCuke/Rakefile +14 -13
  18. data/ext/iCuke/{sdk3.1/Recorder.h → Recorder.h} +0 -0
  19. data/ext/iCuke/{sdk3.1/Recorder.m → Recorder.m} +0 -0
  20. data/ext/iCuke/{sdk3.1/RecorderResponse.h → RecorderResponse.h} +0 -0
  21. data/ext/iCuke/{sdk3.1/RecorderResponse.m → RecorderResponse.m} +0 -0
  22. data/ext/iCuke/{sdk3.1/SynthesizeSingleton.h → SynthesizeSingleton.h} +0 -0
  23. data/ext/iCuke/{sdk3.1/ViewResponse.h → ViewResponse.h} +0 -0
  24. data/ext/iCuke/{sdk3.1/ViewResponse.m → ViewResponse.m} +0 -0
  25. data/ext/iCuke/{sdk3.1/Viewer.h → Viewer.h} +0 -0
  26. data/ext/iCuke/{sdk4.0/Viewer.m → Viewer.m} +0 -0
  27. data/ext/iCuke/{sdk3.1/iCukeHTTPResponseHandler.h → iCukeHTTPResponseHandler.h} +0 -0
  28. data/ext/iCuke/{sdk3.1/iCukeHTTPResponseHandler.m → iCukeHTTPResponseHandler.m} +0 -0
  29. data/ext/iCuke/{sdk3.1/iCukeHTTPServer.h → iCukeHTTPServer.h} +0 -0
  30. data/ext/iCuke/{sdk4.0/iCukeHTTPServer.m → iCukeHTTPServer.m} +4 -2
  31. data/ext/iCuke/{sdk3.1/iCukeServer.h → iCukeServer.h} +0 -0
  32. data/ext/iCuke/{sdk3.1/iCukeServer.m → iCukeServer.m} +0 -0
  33. data/ext/iCuke/{sdk3.1/json → json}/JSON.h +0 -0
  34. data/ext/iCuke/{sdk3.1/json → json}/NSObject+SBJSON.h +0 -0
  35. data/ext/iCuke/{sdk3.1/json → json}/NSObject+SBJSON.m +0 -0
  36. data/ext/iCuke/{sdk3.1/json → json}/NSString+SBJSON.h +0 -0
  37. data/ext/iCuke/{sdk3.1/json → json}/NSString+SBJSON.m +0 -0
  38. data/ext/iCuke/{sdk3.1/json → json}/SBJSON.h +0 -0
  39. data/ext/iCuke/{sdk3.1/json → json}/SBJSON.m +0 -0
  40. data/ext/iCuke/{sdk3.1/json → json}/SBJsonBase.h +0 -0
  41. data/ext/iCuke/{sdk3.1/json → json}/SBJsonBase.m +0 -0
  42. data/ext/iCuke/{sdk3.1/json → json}/SBJsonParser.h +0 -0
  43. data/ext/iCuke/{sdk3.1/json → json}/SBJsonParser.m +0 -0
  44. data/ext/iCuke/{sdk3.1/json → json}/SBJsonWriter.h +0 -0
  45. data/ext/iCuke/{sdk3.1/json → json}/SBJsonWriter.m +0 -0
  46. data/features/starting_project.feature +18 -0
  47. data/features/step_definitions/shell.rb +41 -0
  48. data/features/support/env.rb +2 -0
  49. data/features/support/environment.rb +40 -0
  50. data/features/supported_sdks.feature +12 -0
  51. data/iCuke.gemspec +149 -161
  52. data/lib/icuke/configuration.rb +19 -0
  53. data/lib/icuke/core_ext.rb +27 -0
  54. data/lib/icuke/cucumber.rb +29 -265
  55. data/lib/icuke/cucumber_compat.rb +4 -0
  56. data/lib/icuke/icuke_world.rb +149 -0
  57. data/lib/icuke/sdk.rb +5 -13
  58. data/lib/icuke/simulator_driver.rb +201 -0
  59. data/lib/icuke/waxsim.rb +47 -9
  60. data/spec/cucumber_spec.rb +130 -0
  61. data/spec/fixtures/controls_page.xml +252 -0
  62. data/spec/process_spec.rb +76 -0
  63. data/spec/screen_spec.rb +173 -0
  64. data/spec/simulate_spec.rb +75 -0
  65. data/spec/simulator_spec.rb +28 -0
  66. data/spec/spec.opts +2 -0
  67. data/spec/spec_helper.rb +67 -0
  68. metadata +222 -121
  69. data/.gitignore +0 -15
  70. data/README.rdoc +0 -68
  71. data/ext/WaxSim/Simulator.h +0 -31
  72. data/ext/WaxSim/Simulator.m +0 -131
  73. data/ext/WaxSim/WaxSim.m +0 -110
  74. data/ext/WaxSim/WaxSim.xcodeproj/project.pbxproj +0 -238
  75. data/ext/WaxSim/WaxSim_Prefix.pch +0 -7
  76. data/ext/WaxSim/build/Release/waxsim +0 -0
  77. data/ext/WaxSim/build/Release/waxsim.dSYM/Contents/Info.plist +0 -20
  78. data/ext/WaxSim/build/Release/waxsim.dSYM/Contents/Resources/DWARF/waxsim +0 -0
  79. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/Objects-normal/x86_64/Simulator.o +0 -0
  80. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/Objects-normal/x86_64/WaxSim.o +0 -0
  81. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/Objects-normal/x86_64/waxsim.LinkFileList +0 -2
  82. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/WaxSim.dep +0 -6
  83. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/WaxSim~.dep +0 -6
  84. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/build-state.dat +0 -227
  85. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/build-state~.dat +0 -227
  86. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-all-target-headers.hmap +0 -0
  87. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-generated-files.hmap +0 -0
  88. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-own-target-headers.hmap +0 -0
  89. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim-project-headers.hmap +0 -0
  90. data/ext/WaxSim/build/WaxSim.build/Release/WaxSim.build/waxsim.hmap +0 -0
  91. data/ext/WaxSim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +0 -126
  92. data/ext/iCuke/sdk3.1/Rakefile +0 -20
  93. data/ext/iCuke/sdk3.1/Viewer.m +0 -203
  94. data/ext/iCuke/sdk3.1/iCukeHTTPServer.m +0 -365
  95. data/ext/iCuke/sdk4.0/DefaultsResponse.h +0 -5
  96. data/ext/iCuke/sdk4.0/DefaultsResponse.m +0 -66
  97. data/ext/iCuke/sdk4.0/EventResponse.h +0 -5
  98. data/ext/iCuke/sdk4.0/EventResponse.m +0 -130
  99. data/ext/iCuke/sdk4.0/ModuleResponse.h +0 -5
  100. data/ext/iCuke/sdk4.0/ModuleResponse.m +0 -76
  101. data/ext/iCuke/sdk4.0/QuitResponse.h +0 -5
  102. data/ext/iCuke/sdk4.0/QuitResponse.m +0 -23
  103. data/ext/iCuke/sdk4.0/Rakefile +0 -20
  104. data/ext/iCuke/sdk4.0/Recorder.h +0 -17
  105. data/ext/iCuke/sdk4.0/Recorder.m +0 -90
  106. data/ext/iCuke/sdk4.0/RecorderResponse.h +0 -6
  107. data/ext/iCuke/sdk4.0/RecorderResponse.m +0 -68
  108. data/ext/iCuke/sdk4.0/SynthesizeSingleton.h +0 -68
  109. data/ext/iCuke/sdk4.0/ViewResponse.h +0 -5
  110. data/ext/iCuke/sdk4.0/ViewResponse.m +0 -84
  111. data/ext/iCuke/sdk4.0/Viewer.h +0 -8
  112. data/ext/iCuke/sdk4.0/iCukeHTTPResponseHandler.h +0 -50
  113. data/ext/iCuke/sdk4.0/iCukeHTTPResponseHandler.m +0 -381
  114. data/ext/iCuke/sdk4.0/iCukeHTTPServer.h +0 -53
  115. data/ext/iCuke/sdk4.0/iCukeServer.h +0 -14
  116. data/ext/iCuke/sdk4.0/iCukeServer.m +0 -65
  117. data/ext/iCuke/sdk4.0/json/JSON.h +0 -50
  118. data/ext/iCuke/sdk4.0/json/NSObject+SBJSON.h +0 -68
  119. data/ext/iCuke/sdk4.0/json/NSObject+SBJSON.m +0 -53
  120. data/ext/iCuke/sdk4.0/json/NSString+SBJSON.h +0 -58
  121. data/ext/iCuke/sdk4.0/json/NSString+SBJSON.m +0 -55
  122. data/ext/iCuke/sdk4.0/json/SBJSON.h +0 -75
  123. data/ext/iCuke/sdk4.0/json/SBJSON.m +0 -212
  124. data/ext/iCuke/sdk4.0/json/SBJsonBase.h +0 -86
  125. data/ext/iCuke/sdk4.0/json/SBJsonBase.m +0 -78
  126. data/ext/iCuke/sdk4.0/json/SBJsonParser.h +0 -87
  127. data/ext/iCuke/sdk4.0/json/SBJsonParser.m +0 -475
  128. data/ext/iCuke/sdk4.0/json/SBJsonWriter.h +0 -129
  129. data/ext/iCuke/sdk4.0/json/SBJsonWriter.m +0 -228
@@ -1,5 +0,0 @@
1
- #import "iCukeHTTPResponseHandler.h"
2
-
3
- @interface DefaultsResponse : iCukeHTTPResponseHandler {
4
- }
5
- @end
@@ -1,66 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- #import "iCukeHTTPResponseHandler.h"
2
-
3
- @interface EventResponse : iCukeHTTPResponseHandler {
4
- }
5
- @end
@@ -1,130 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- #import "iCukeHTTPResponseHandler.h"
2
-
3
- @interface ModuleResponse : iCukeHTTPResponseHandler {
4
- }
5
- @end
@@ -1,76 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- #import "iCukeHTTPResponseHandler.h"
2
-
3
- @interface QuitResponse : iCukeHTTPResponseHandler {
4
- }
5
- @end
@@ -1,23 +0,0 @@
1
- #import "QuitResponse.h"
2
- #import "iCukeHTTPServer.h"
3
- #import "JSON.h"
4
-
5
- @implementation QuitResponse
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:@"/quit"];
17
- }
18
-
19
- - (void)startResponse
20
- {
21
- exit(0);
22
- }
23
- @end
@@ -1,20 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,90 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- #import "Recorder.h"
4
- #import "Viewer.h"
5
-
6
- @interface UIApplication (Recording)
7
-
8
- -(void)_addRecorder:(id)recorder;
9
- -(void)_removeRecorder:(id)recorder;
10
- -(void)_playbackEvents:(NSArray*)events atPlaybackRate:(float)playbackRate messageWhenDone:(id)target withSelector:(SEL)selector;
11
-
12
- @end
13
-
14
- static Recorder *sharedRecorder = nil;
15
-
16
- @implementation Recorder
17
-
18
- +(Recorder *)sharedRecorder {
19
- if (sharedRecorder == nil) {
20
- sharedRecorder = [[super allocWithZone:NULL] init];
21
- }
22
- return sharedRecorder;
23
- }
24
-
25
- -(id)init {
26
- self = [super init];
27
-
28
- eventList = [[NSMutableArray alloc] init];
29
-
30
- return self;
31
- }
32
-
33
- -(void)dealloc {
34
- [eventList release];
35
- [super dealloc];
36
- }
37
-
38
- -(void)record {
39
- [eventList removeAllObjects];
40
-
41
- NSLog(@"Starting recording");
42
-
43
- [[UIApplication sharedApplication] _addRecorder: self];
44
- }
45
-
46
- -(void)saveToFile:(NSString*)path {
47
- NSLog(@"Saving events to file: %@", path);
48
-
49
- [eventList writeToFile: path atomically: YES];
50
- }
51
-
52
- -(void)stop {
53
- NSLog(@"Stopping recording");
54
-
55
- [[UIApplication sharedApplication] _removeRecorder: self];
56
- }
57
-
58
- -(void)recordApplicationEvent:(NSDictionary*)event {
59
- NSLog(@"Recorded event: %@", event);
60
-
61
- [eventList addObject:event];
62
- }
63
-
64
- -(void)load:(NSArray*)events {
65
- NSLog(@"Loading events");
66
-
67
- [eventList setArray: events];
68
- }
69
-
70
- -(void)loadFromFile:(NSString*)path {
71
- NSLog(@"Loading events from file: %@", path);
72
-
73
- [eventList setArray: [NSMutableArray arrayWithContentsOfFile: path]];
74
- }
75
-
76
- -(void)playbackWithDelegate: (id)delegate doneSelector:(SEL)doneSelector {
77
- NSLog(@"Playback");
78
-
79
- playbackDelegate = delegate;
80
- playbackDoneSelector = doneSelector;
81
-
82
- [[UIApplication sharedApplication] _playbackEvents: eventList atPlaybackRate: 1.0f messageWhenDone: self withSelector: @selector(playbackDone:)];
83
- }
84
-
85
- -(void)playbackDone:(NSDictionary *)details {
86
- NSLog(@"Playback complete");
87
- [playbackDelegate performSelector: playbackDoneSelector];
88
- }
89
-
90
- @end