iCuke 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/.gitignore +13 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +69 -0
  4. data/Rakefile +80 -0
  5. data/VERSION +1 -0
  6. data/app/iCuke/.gitignore +1 -0
  7. data/app/iCuke/Classes/FlipsideView.h +13 -0
  8. data/app/iCuke/Classes/FlipsideView.m +32 -0
  9. data/app/iCuke/Classes/FlipsideViewController.h +25 -0
  10. data/app/iCuke/Classes/FlipsideViewController.m +54 -0
  11. data/app/iCuke/Classes/MainView.h +15 -0
  12. data/app/iCuke/Classes/MainView.m +32 -0
  13. data/app/iCuke/Classes/MainViewController.h +16 -0
  14. data/app/iCuke/Classes/MainViewController.m +86 -0
  15. data/app/iCuke/Classes/iCukeAppDelegate.h +20 -0
  16. data/app/iCuke/Classes/iCukeAppDelegate.m +33 -0
  17. data/app/iCuke/FlipsideView.xib +444 -0
  18. data/app/iCuke/MainView.xib +520 -0
  19. data/app/iCuke/MainWindow.xib +355 -0
  20. data/app/iCuke/SniffingView.h +20 -0
  21. data/app/iCuke/SniffingView.m +191 -0
  22. data/app/iCuke/iCuke-Info.plist +30 -0
  23. data/app/iCuke/iCuke.xcodeproj/project.pbxproj +313 -0
  24. data/app/iCuke/iCuke_Prefix.pch +14 -0
  25. data/app/iCuke/main.m +16 -0
  26. data/ext/iCuke/.gitignore +2 -0
  27. data/ext/iCuke/DefaultsResponse.h +5 -0
  28. data/ext/iCuke/DefaultsResponse.m +67 -0
  29. data/ext/iCuke/EventResponse.h +5 -0
  30. data/ext/iCuke/EventResponse.m +122 -0
  31. data/ext/iCuke/Rakefile +22 -0
  32. data/ext/iCuke/Recorder.h +15 -0
  33. data/ext/iCuke/Recorder.m +85 -0
  34. data/ext/iCuke/RecorderResponse.h +5 -0
  35. data/ext/iCuke/RecorderResponse.m +59 -0
  36. data/ext/iCuke/SynthesizeSingleton.h +68 -0
  37. data/ext/iCuke/ViewResponse.h +5 -0
  38. data/ext/iCuke/ViewResponse.m +84 -0
  39. data/ext/iCuke/Viewer.h +8 -0
  40. data/ext/iCuke/Viewer.m +153 -0
  41. data/ext/iCuke/iCukeHTTPResponseHandler.h +50 -0
  42. data/ext/iCuke/iCukeHTTPResponseHandler.m +381 -0
  43. data/ext/iCuke/iCukeHTTPServer.h +53 -0
  44. data/ext/iCuke/iCukeHTTPServer.m +365 -0
  45. data/ext/iCuke/iCukeServer.h +16 -0
  46. data/ext/iCuke/iCukeServer.m +46 -0
  47. data/ext/iCuke/json/JSON.h +50 -0
  48. data/ext/iCuke/json/NSObject+SBJSON.h +68 -0
  49. data/ext/iCuke/json/NSObject+SBJSON.m +53 -0
  50. data/ext/iCuke/json/NSString+SBJSON.h +58 -0
  51. data/ext/iCuke/json/NSString+SBJSON.m +55 -0
  52. data/ext/iCuke/json/SBJSON.h +75 -0
  53. data/ext/iCuke/json/SBJSON.m +212 -0
  54. data/ext/iCuke/json/SBJsonBase.h +86 -0
  55. data/ext/iCuke/json/SBJsonBase.m +78 -0
  56. data/ext/iCuke/json/SBJsonParser.h +87 -0
  57. data/ext/iCuke/json/SBJsonParser.m +475 -0
  58. data/ext/iCuke/json/SBJsonWriter.h +129 -0
  59. data/ext/iCuke/json/SBJsonWriter.m +228 -0
  60. data/features/icuke.feature +17 -0
  61. data/features/support/env.rb +3 -0
  62. data/iCuke.gemspec +113 -0
  63. data/lib/icuke/cucumber.rb +211 -0
  64. data/lib/icuke/simulate.rb +132 -0
  65. data/lib/icuke/simulator.rb +107 -0
  66. data/lib/icuke.rb +1 -0
  67. metadata +163 -0
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## SVN
5
+
6
+ .svn
7
+
8
+ ## PROJECT::GENERAL
9
+ rdoc
10
+ pkg
11
+
12
+ ## PROJECT::SPECIFIC
13
+ events.plist
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Unboxed Consulting
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,69 @@
1
+ = iCuke
2
+
3
+ iCuke allows you to test an iPhone application with cucumber. It provides a selection of step definitions similar to
4
+ those provided for testing web applications.
5
+
6
+ == Usage
7
+
8
+ Install the gem and load the iCuke step definitions in a cucumber support file:
9
+
10
+ require 'icuke/cucumber'
11
+
12
+ Write some scenarios like:
13
+
14
+ Background:
15
+ Given "iCuke" from "app/iCuke/iCuke.xcodeproj" is loaded in the simulator
16
+
17
+ Scenario: User views the About screen
18
+ When I tap "About"
19
+ Then I should see "Author:"
20
+
21
+ == How it works
22
+
23
+ iCuke uses applescript to drive Xcode in order to launch your application into the iPhone Simulator. A preload library
24
+ is used to add a HTTP server into your application.
25
+
26
+ The HTTP server allows us to see an XML version of the iPhone's screen, and to emulate taps/swipes etc.
27
+
28
+ iCuke should not require any code changes to your application to work, however, it relies on accessibility information
29
+ to function sensibly. If your accessibility information is not accurate, iCuke may not work as expected.
30
+
31
+ == Bugs
32
+
33
+ iCuke does not currently automate enabling the Accessibility Inspecter, which is required to be running for iCuke to
34
+ function. I am still deciding how best to achieve this is in a reliable fashion.
35
+
36
+ iCuke does not support testing applications on real devices, because I don't know of a way get a preload library to load
37
+ on the device.
38
+
39
+ iCuke does not support drags, scrolling or pinches yet. They'll be here soon!
40
+
41
+ iCuke compiles against the 3.1.2 SDK. I'm not sure how to make that configurable as the compilation is done at gem
42
+ install time.
43
+
44
+ == Contributors
45
+
46
+ * Nigel Taylor
47
+ * Aslak Hellesøy
48
+ * Dominic Baggott
49
+
50
+ == Thanks
51
+
52
+ Thanks go to the people who's work iCuke is based on:
53
+
54
+ * Matt Gallagher
55
+ * Ian Dees
56
+
57
+ == Note on Patches/Pull Requests
58
+
59
+ * Fork the project.
60
+ * Make your feature addition or bug fix.
61
+ * Add tests for it. This is important so I don't break it in a
62
+ future version unintentionally.
63
+ * Commit, do not mess with rakefile, version, or history.
64
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
65
+ * Send me a pull request. Bonus points for topic branches.
66
+
67
+ == Copyright
68
+
69
+ Copyright (c) 2010 Unboxed Consulting. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,80 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "iCuke"
8
+ gem.summary = %Q{Cucumber support for iPhone applications}
9
+ gem.description = %Q{Cucumber support for iPhone applications}
10
+ gem.email = "rob@the-it-refinery.co.uk"
11
+ gem.homepage = "http://github.com/unboxed/iCuke"
12
+ gem.authors = ["Rob Holland"]
13
+ gem.add_development_dependency "cucumber", ">= 0"
14
+ gem.add_dependency "rb-appscript", ">= 0"
15
+ gem.add_dependency "httparty", ">= 0"
16
+ gem.extensions = ['ext/iCuke/Rakefile']
17
+ gem.files += ['ext/iCuke/libicuke.dylib']
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ file 'app/iCuke/build/Debug-iphonesimulator/iCuke.app/iCuke' do
25
+ sh 'cd app/iCuke && xcodebuild -target iCuke -configuration Debug -sdk iphonesimulator3.1.2'
26
+ end
27
+ task :app => 'app/iCuke/build/Debug-iphonesimulator/iCuke.app/iCuke'
28
+ task :features => :app
29
+
30
+ task :lib do
31
+ sh 'cd ext/iCuke && rake'
32
+ end
33
+
34
+ begin
35
+ require 'cucumber/rake/task'
36
+ Cucumber::Rake::Task.new(:features)
37
+
38
+ task :features => :check_dependencies
39
+ task :features => [:app, :lib]
40
+ rescue LoadError
41
+ task :features do
42
+ abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
43
+ end
44
+ end
45
+
46
+ task :default => :features
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "iCuke #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
58
+ task :launch => [:app, :lib] do
59
+ require 'lib/icuke/simulator'
60
+
61
+ simulator = ICuke::Simulator.new
62
+ simulator.launch File.expand_path('app/iCuke/build/Debug-iphonesimulator/iCuke.app'),
63
+ :env => { 'DYLD_INSERT_LIBRARIES' => File.expand_path(File.dirname(__FILE__) + '/ext/iCuke/libicuke.dylib') }
64
+ end
65
+
66
+ task :replay => :launch do
67
+ simulator = ICuke::Simulator.new
68
+ simulator.load(File.expand_path(File.dirname(__FILE__) + '/events.plist'))
69
+ simulator.play
70
+ end
71
+
72
+ task :debug => [:app, :lib] do
73
+ require 'lib/icuke/simulator'
74
+
75
+ simulator = ICuke::Simulator.new
76
+ simulator.launch File.expand_path('app/iCuke/build/Debug-iphonesimulator/iCuke.app'),
77
+ :env => { 'DYLD_INSERT_LIBRARIES' => File.expand_path(File.dirname(__FILE__) + '/ext/iCuke/libicuke.dylib') },
78
+ :debugger => true
79
+ puts `ps aux|grep [i]Cuke.app/iCuke`
80
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.5
@@ -0,0 +1 @@
1
+ build
@@ -0,0 +1,13 @@
1
+ //
2
+ // FlipsideView.h
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ @interface FlipsideView : UIView {
10
+
11
+ }
12
+
13
+ @end
@@ -0,0 +1,32 @@
1
+ //
2
+ // FlipsideView.m
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import "FlipsideView.h"
10
+
11
+ @implementation FlipsideView
12
+
13
+
14
+ - (id)initWithFrame:(CGRect)frame {
15
+ if (self = [super initWithFrame:frame]) {
16
+ // Initialization code
17
+ }
18
+ return self;
19
+ }
20
+
21
+
22
+ - (void)drawRect:(CGRect)rect {
23
+ // Drawing code
24
+ }
25
+
26
+
27
+ - (void)dealloc {
28
+ [super dealloc];
29
+ }
30
+
31
+
32
+ @end
@@ -0,0 +1,25 @@
1
+ //
2
+ // FlipsideViewController.h
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ @protocol FlipsideViewControllerDelegate;
10
+
11
+
12
+ @interface FlipsideViewController : UIViewController {
13
+ id <FlipsideViewControllerDelegate> delegate;
14
+ }
15
+
16
+ @property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate;
17
+ - (IBAction)done;
18
+
19
+ @end
20
+
21
+
22
+ @protocol FlipsideViewControllerDelegate
23
+ - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;
24
+ @end
25
+
@@ -0,0 +1,54 @@
1
+ //
2
+ // FlipsideViewController.m
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import "FlipsideViewController.h"
10
+
11
+
12
+ @implementation FlipsideViewController
13
+
14
+ @synthesize delegate;
15
+
16
+
17
+ - (void)viewDidLoad {
18
+ [super viewDidLoad];
19
+ self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
20
+ }
21
+
22
+
23
+ - (IBAction)done {
24
+ [self.delegate flipsideViewControllerDidFinish:self];
25
+ }
26
+
27
+
28
+ /*
29
+ // Override to allow orientations other than the default portrait orientation.
30
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
31
+ // Return YES for supported orientations
32
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
33
+ }
34
+ */
35
+
36
+ - (void)didReceiveMemoryWarning {
37
+ // Releases the view if it doesn't have a superview.
38
+ [super didReceiveMemoryWarning];
39
+
40
+ // Release any cached data, images, etc that aren't in use.
41
+ }
42
+
43
+ - (void)viewDidUnload {
44
+ // Release any retained subviews of the main view.
45
+ // e.g. self.myOutlet = nil;
46
+ }
47
+
48
+
49
+ - (void)dealloc {
50
+ [super dealloc];
51
+ }
52
+
53
+
54
+ @end
@@ -0,0 +1,15 @@
1
+ //
2
+ // MainView.h
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ @interface MainView : UIView {
12
+
13
+ }
14
+
15
+ @end
@@ -0,0 +1,32 @@
1
+ //
2
+ // MainView.m
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import "MainView.h"
10
+
11
+ @implementation MainView
12
+
13
+
14
+ - (id)initWithFrame:(CGRect)frame {
15
+ if (self = [super initWithFrame:frame]) {
16
+ // Initialization code
17
+ }
18
+ return self;
19
+ }
20
+
21
+
22
+ - (void)drawRect:(CGRect)rect {
23
+ // Drawing code
24
+ }
25
+
26
+
27
+ - (void)dealloc {
28
+ [super dealloc];
29
+ }
30
+
31
+
32
+ @end
@@ -0,0 +1,16 @@
1
+ //
2
+ // MainViewController.h
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import "FlipsideViewController.h"
10
+
11
+ @interface MainViewController : UIViewController <FlipsideViewControllerDelegate> {
12
+ }
13
+
14
+ - (IBAction)showInfo;
15
+
16
+ @end
@@ -0,0 +1,86 @@
1
+ //
2
+ // MainViewController.m
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import "MainViewController.h"
10
+ #import "MainView.h"
11
+
12
+
13
+ @implementation MainViewController
14
+
15
+
16
+ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
17
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
18
+ // Custom initialization
19
+ }
20
+ return self;
21
+ }
22
+
23
+
24
+ /*
25
+ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
26
+ - (void)viewDidLoad {
27
+ [super viewDidLoad];
28
+ }
29
+ */
30
+
31
+
32
+ /*
33
+ // Override to allow orientations other than the default portrait orientation.
34
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
35
+ // Return YES for supported orientations
36
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
37
+ }
38
+ */
39
+
40
+
41
+ - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
42
+
43
+ [self dismissModalViewControllerAnimated:YES];
44
+ }
45
+
46
+
47
+ - (IBAction)showInfo {
48
+
49
+ FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
50
+ controller.delegate = self;
51
+
52
+ controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
53
+ [self presentModalViewController:controller animated:YES];
54
+
55
+ [controller release];
56
+ }
57
+
58
+
59
+
60
+ /*
61
+ // Override to allow orientations other than the default portrait orientation.
62
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
63
+ // Return YES for supported orientations
64
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
65
+ }
66
+ */
67
+
68
+ - (void)didReceiveMemoryWarning {
69
+ // Releases the view if it doesn't have a superview.
70
+ [super didReceiveMemoryWarning];
71
+
72
+ // Release any cached data, images, etc that aren't in use.
73
+ }
74
+
75
+ - (void)viewDidUnload {
76
+ // Release any retained subviews of the main view.
77
+ // e.g. self.myOutlet = nil;
78
+ }
79
+
80
+
81
+ - (void)dealloc {
82
+ [super dealloc];
83
+ }
84
+
85
+
86
+ @end
@@ -0,0 +1,20 @@
1
+ //
2
+ // iCukeAppDelegate.h
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ @class MainViewController;
10
+
11
+ @interface iCukeAppDelegate : NSObject <UIApplicationDelegate> {
12
+ UIWindow *window;
13
+ MainViewController *mainViewController;
14
+ }
15
+
16
+ @property (nonatomic, retain) IBOutlet UIWindow *window;
17
+ @property (nonatomic, retain) MainViewController *mainViewController;
18
+
19
+ @end
20
+
@@ -0,0 +1,33 @@
1
+ //
2
+ // iCukeAppDelegate.m
3
+ // iCuke
4
+ //
5
+ // Created by Rob Holland on 02/03/2010.
6
+ // Copyright The IT Refinery 2010. All rights reserved.
7
+ //
8
+
9
+ #import "iCukeAppDelegate.h"
10
+ #import "MainViewController.h"
11
+
12
+ @implementation iCukeAppDelegate
13
+
14
+ @synthesize window;
15
+ @synthesize mainViewController;
16
+
17
+ - (void)applicationDidFinishLaunching:(UIApplication *)application {
18
+ MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
19
+ self.mainViewController = aController;
20
+ [aController release];
21
+
22
+ mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
23
+ [window addSubview:[mainViewController view]];
24
+ [window makeKeyAndVisible];
25
+ }
26
+
27
+ - (void)dealloc {
28
+ [mainViewController release];
29
+ [window release];
30
+ [super dealloc];
31
+ }
32
+
33
+ @end