cukunity 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/.document +5 -0
  2. data/.gitmodules +0 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +60 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +214 -0
  8. data/Rakefile +51 -0
  9. data/Unity/Assets/Demo/Art/Buttons/down.png +0 -0
  10. data/Unity/Assets/Demo/Art/Buttons/down.png.meta +28 -0
  11. data/Unity/Assets/Demo/Art/Buttons/left.png +0 -0
  12. data/Unity/Assets/Demo/Art/Buttons/left.png.meta +28 -0
  13. data/Unity/Assets/Demo/Art/Buttons/ok.png +0 -0
  14. data/Unity/Assets/Demo/Art/Buttons/ok.png.meta +28 -0
  15. data/Unity/Assets/Demo/Art/Buttons/options.png +0 -0
  16. data/Unity/Assets/Demo/Art/Buttons/options.png.meta +28 -0
  17. data/Unity/Assets/Demo/Art/Buttons/play.png +0 -0
  18. data/Unity/Assets/Demo/Art/Buttons/play.png.meta +28 -0
  19. data/Unity/Assets/Demo/Art/Buttons/quit.png +0 -0
  20. data/Unity/Assets/Demo/Art/Buttons/quit.png.meta +28 -0
  21. data/Unity/Assets/Demo/Art/Buttons/retry.png +0 -0
  22. data/Unity/Assets/Demo/Art/Buttons/retry.png.meta +28 -0
  23. data/Unity/Assets/Demo/Art/Buttons/right.png +0 -0
  24. data/Unity/Assets/Demo/Art/Buttons/right.png.meta +28 -0
  25. data/Unity/Assets/Demo/Art/Buttons/up.png +0 -0
  26. data/Unity/Assets/Demo/Art/Buttons/up.png.meta +28 -0
  27. data/Unity/Assets/Demo/Art/Buttons.meta +2 -0
  28. data/Unity/Assets/Demo/Art/clear.png +0 -0
  29. data/Unity/Assets/Demo/Art/clear.png.meta +28 -0
  30. data/Unity/Assets/Demo/Art/options.png +0 -0
  31. data/Unity/Assets/Demo/Art/options.png.meta +28 -0
  32. data/Unity/Assets/Demo/Art/sokoban.png +0 -0
  33. data/Unity/Assets/Demo/Art/sokoban.png.meta +28 -0
  34. data/Unity/Assets/Demo/Art.meta +2 -0
  35. data/Unity/Assets/Demo/Cubes/CrateCube.mat +0 -0
  36. data/Unity/Assets/Demo/Cubes/CrateCube.mat.meta +2 -0
  37. data/Unity/Assets/Demo/Cubes/CrateCube.prefab +0 -0
  38. data/Unity/Assets/Demo/Cubes/CrateCube.prefab.meta +2 -0
  39. data/Unity/Assets/Demo/Cubes/FloorCube.mat +0 -0
  40. data/Unity/Assets/Demo/Cubes/FloorCube.mat.meta +2 -0
  41. data/Unity/Assets/Demo/Cubes/FloorCube.prefab +0 -0
  42. data/Unity/Assets/Demo/Cubes/FloorCube.prefab.meta +2 -0
  43. data/Unity/Assets/Demo/Cubes/GoalCube.mat +0 -0
  44. data/Unity/Assets/Demo/Cubes/GoalCube.mat.meta +2 -0
  45. data/Unity/Assets/Demo/Cubes/GoalCube.prefab +0 -0
  46. data/Unity/Assets/Demo/Cubes/GoalCube.prefab.meta +2 -0
  47. data/Unity/Assets/Demo/Cubes/PlayerCube.mat +0 -0
  48. data/Unity/Assets/Demo/Cubes/PlayerCube.mat.meta +2 -0
  49. data/Unity/Assets/Demo/Cubes/PlayerCube.prefab +0 -0
  50. data/Unity/Assets/Demo/Cubes/PlayerCube.prefab.meta +2 -0
  51. data/Unity/Assets/Demo/Cubes/WallCube.mat +0 -0
  52. data/Unity/Assets/Demo/Cubes/WallCube.mat.meta +2 -0
  53. data/Unity/Assets/Demo/Cubes/WallCube.prefab +0 -0
  54. data/Unity/Assets/Demo/Cubes/WallCube.prefab.meta +2 -0
  55. data/Unity/Assets/Demo/Cubes.meta +2 -0
  56. data/Unity/Assets/Demo/Resources/MainMenu.prefab +0 -0
  57. data/Unity/Assets/Demo/Resources/MainMenu.prefab.meta +2 -0
  58. data/Unity/Assets/Demo/Resources/OptionsMenu.prefab +0 -0
  59. data/Unity/Assets/Demo/Resources/OptionsMenu.prefab.meta +2 -0
  60. data/Unity/Assets/Demo/Resources.meta +2 -0
  61. data/Unity/Assets/Demo/Scripts/CameraController.js +18 -0
  62. data/Unity/Assets/Demo/Scripts/CameraController.js.meta +2 -0
  63. data/Unity/Assets/Demo/Scripts/EnterPlayerName.js +21 -0
  64. data/Unity/Assets/Demo/Scripts/EnterPlayerName.js.meta +2 -0
  65. data/Unity/Assets/Demo/Scripts/GameLeftButton.js +18 -0
  66. data/Unity/Assets/Demo/Scripts/GameLeftButton.js.meta +2 -0
  67. data/Unity/Assets/Demo/Scripts/GameQuitButton.js +6 -0
  68. data/Unity/Assets/Demo/Scripts/GameQuitButton.js.meta +2 -0
  69. data/Unity/Assets/Demo/Scripts/GameRetryButton.js +7 -0
  70. data/Unity/Assets/Demo/Scripts/GameRetryButton.js.meta +2 -0
  71. data/Unity/Assets/Demo/Scripts/GameRightButton.js +18 -0
  72. data/Unity/Assets/Demo/Scripts/GameRightButton.js.meta +2 -0
  73. data/Unity/Assets/Demo/Scripts/GameUpButton.js +18 -0
  74. data/Unity/Assets/Demo/Scripts/GameUpButton.js.meta +2 -0
  75. data/Unity/Assets/Demo/Scripts/OnTouchGUIElementDown.js +34 -0
  76. data/Unity/Assets/Demo/Scripts/OnTouchGUIElementDown.js.meta +2 -0
  77. data/Unity/Assets/Demo/Scripts/PlayerData.js +3 -0
  78. data/Unity/Assets/Demo/Scripts/PlayerData.js.meta +2 -0
  79. data/Unity/Assets/Demo/Scripts/SokobanController.js +240 -0
  80. data/Unity/Assets/Demo/Scripts/SokobanController.js.meta +2 -0
  81. data/Unity/Assets/Demo/Scripts/TakeScreenShot.js +26 -0
  82. data/Unity/Assets/Demo/Scripts/TakeScreenShot.js.meta +2 -0
  83. data/Unity/Assets/Demo/Scripts/TitleOptionsButton.js +8 -0
  84. data/Unity/Assets/Demo/Scripts/TitleOptionsButton.js.meta +2 -0
  85. data/Unity/Assets/Demo/Scripts/TitleOptionsOkButton.js +8 -0
  86. data/Unity/Assets/Demo/Scripts/TitleOptionsOkButton.js.meta +2 -0
  87. data/Unity/Assets/Demo/Scripts/TitlePlayButton.js +6 -0
  88. data/Unity/Assets/Demo/Scripts/TitlePlayButton.js.meta +2 -0
  89. data/Unity/Assets/Demo/Scripts/TitleQuitButton.js +7 -0
  90. data/Unity/Assets/Demo/Scripts/TitleQuitButton.js.meta +2 -0
  91. data/Unity/Assets/Demo/Scripts/UpdateMovesLabel.js +26 -0
  92. data/Unity/Assets/Demo/Scripts/UpdateMovesLabel.js.meta +2 -0
  93. data/Unity/Assets/Demo/Scripts/UpdatePlayerName.js +14 -0
  94. data/Unity/Assets/Demo/Scripts/UpdatePlayerName.js.meta +2 -0
  95. data/Unity/Assets/Demo/Scripts.meta +2 -0
  96. data/Unity/Assets/Demo/demo_game.unity +0 -0
  97. data/Unity/Assets/Demo/demo_game.unity.meta +2 -0
  98. data/Unity/Assets/Demo/demo_title.unity +0 -0
  99. data/Unity/Assets/Demo/demo_title.unity.meta +2 -0
  100. data/Unity/Assets/Demo.meta +2 -0
  101. data/Unity/Assets/Plugins/CukunityInstance.prefab +0 -0
  102. data/Unity/Assets/Plugins/CukunityInstance.prefab.meta +2 -0
  103. data/Unity/Assets/Plugins/CukunityServer.cs +871 -0
  104. data/Unity/Assets/Plugins/CukunityServer.cs.meta +2 -0
  105. data/Unity/Assets/Plugins/JsonFx.Json.dll +0 -0
  106. data/Unity/Assets/Plugins/JsonFx.Json.dll.meta +2 -0
  107. data/Unity/Assets/Plugins/iOS/CukunityServer.mm +242 -0
  108. data/Unity/Assets/Plugins/iOS/CukunityServer.mm.meta +2 -0
  109. data/Unity/Assets/Plugins/iOS.meta +2 -0
  110. data/Unity/Assets/Plugins.meta +2 -0
  111. data/Unity/Library/AudioManager.asset +0 -0
  112. data/Unity/Library/BuildSettings.asset +0 -0
  113. data/Unity/Library/DynamicsManager.asset +0 -0
  114. data/Unity/Library/EditorBuildSettings.asset +0 -0
  115. data/Unity/Library/EditorSettings.asset +0 -0
  116. data/Unity/Library/EditorUserBuildSettings.asset +0 -0
  117. data/Unity/Library/EditorUserSettings.asset +0 -0
  118. data/Unity/Library/InputManager.asset +0 -0
  119. data/Unity/Library/InspectorExpandedItems.asset +0 -0
  120. data/Unity/Library/MonoManager.asset +0 -0
  121. data/Unity/Library/NetworkManager.asset +0 -0
  122. data/Unity/Library/ProjectSettings.asset +0 -0
  123. data/Unity/Library/QualitySettings.asset +0 -0
  124. data/Unity/Library/TagManager.asset +0 -0
  125. data/Unity/Library/TimeManager.asset +0 -0
  126. data/Unity/ProjectSettings/AudioManager.asset +0 -0
  127. data/Unity/ProjectSettings/DynamicsManager.asset +0 -0
  128. data/Unity/ProjectSettings/EditorBuildSettings.asset +0 -0
  129. data/Unity/ProjectSettings/EditorSettings.asset +0 -0
  130. data/Unity/ProjectSettings/InputManager.asset +0 -0
  131. data/Unity/ProjectSettings/NavMeshLayers.asset +0 -0
  132. data/Unity/ProjectSettings/NetworkManager.asset +0 -0
  133. data/Unity/ProjectSettings/ProjectSettings.asset +0 -0
  134. data/Unity/ProjectSettings/QualitySettings.asset +0 -0
  135. data/Unity/ProjectSettings/TagManager.asset +0 -0
  136. data/Unity/ProjectSettings/TimeManager.asset +0 -0
  137. data/VERSION +1 -0
  138. data/bin/cukunity +7 -0
  139. data/cukunity.gemspec +298 -0
  140. data/features/get_scene_command.feature +39 -0
  141. data/features/i18n/ja/sokoban_clear.feature +109 -0
  142. data/features/install.feature +23 -0
  143. data/features/keyboard_input.feature +26 -0
  144. data/features/load_level_command.feature +36 -0
  145. data/features/run.feature +33 -0
  146. data/features/select_visible.feature +29 -0
  147. data/features/support/env.rb +11 -0
  148. data/features/touch_input.feature +96 -0
  149. data/lib/cukunity/cli/argument_parser.rb +103 -0
  150. data/lib/cukunity/cli/bootstrap_command.rb +39 -0
  151. data/lib/cukunity/cli/doctor_command.rb +150 -0
  152. data/lib/cukunity/cli/features_command.rb +35 -0
  153. data/lib/cukunity/cli/main.rb +18 -0
  154. data/lib/cukunity/cli/options.rb +8 -0
  155. data/lib/cukunity/cli.rb +11 -0
  156. data/lib/cukunity/cucumber/step_definitions/get_scene_command_steps.rb +37 -0
  157. data/lib/cukunity/cucumber/step_definitions/i18n/ja/get_scene_command_steps.rb +37 -0
  158. data/lib/cukunity/cucumber/step_definitions/i18n/ja/install_steps.rb +25 -0
  159. data/lib/cukunity/cucumber/step_definitions/i18n/ja/keyboard_input_steps.rb +17 -0
  160. data/lib/cukunity/cucumber/step_definitions/i18n/ja/load_level_command_steps.rb +17 -0
  161. data/lib/cukunity/cucumber/step_definitions/i18n/ja/run_steps.rb +25 -0
  162. data/lib/cukunity/cucumber/step_definitions/i18n/ja/select_visible_steps.rb +9 -0
  163. data/lib/cukunity/cucumber/step_definitions/i18n/ja/touch_input_steps.rb +19 -0
  164. data/lib/cukunity/cucumber/step_definitions/i18n/ja.rb +9 -0
  165. data/lib/cukunity/cucumber/step_definitions/install_steps.rb +33 -0
  166. data/lib/cukunity/cucumber/step_definitions/keyboard_input_steps.rb +13 -0
  167. data/lib/cukunity/cucumber/step_definitions/load_level_command_steps.rb +17 -0
  168. data/lib/cukunity/cucumber/step_definitions/run_steps.rb +32 -0
  169. data/lib/cukunity/cucumber/step_definitions/select_visible_steps.rb +15 -0
  170. data/lib/cukunity/cucumber/step_definitions/touch_input_steps.rb +18 -0
  171. data/lib/cukunity/cucumber/support/platform_helpers.rb +105 -0
  172. data/lib/cukunity/cucumber/support/spec_helpers.rb +21 -0
  173. data/lib/cukunity/cucumber/support/transforms.rb +5 -0
  174. data/lib/cukunity/cucumber/support/unity_helpers.rb +35 -0
  175. data/lib/cukunity/cucumber.rb +28 -0
  176. data/lib/cukunity/drivers/android/app.rb +43 -0
  177. data/lib/cukunity/drivers/android/appkiller/.gitignore +9 -0
  178. data/lib/cukunity/drivers/android/appkiller/AndroidManifest.xml +17 -0
  179. data/lib/cukunity/drivers/android/appkiller/ant.properties +17 -0
  180. data/lib/cukunity/drivers/android/appkiller/build.xml +85 -0
  181. data/lib/cukunity/drivers/android/appkiller/proguard.cfg +40 -0
  182. data/lib/cukunity/drivers/android/appkiller/project.properties +11 -0
  183. data/lib/cukunity/drivers/android/appkiller/res/layout/main.xml +13 -0
  184. data/lib/cukunity/drivers/android/appkiller/res/values/strings.xml +4 -0
  185. data/lib/cukunity/drivers/android/appkiller/src/cukunity/appkiller/AppKiller.java +29 -0
  186. data/lib/cukunity/drivers/android/keyboard_input.rb +149 -0
  187. data/lib/cukunity/drivers/android/keycodes.rb +531 -0
  188. data/lib/cukunity/drivers/android/monkey_client.rb +65 -0
  189. data/lib/cukunity/drivers/android/process.rb +103 -0
  190. data/lib/cukunity/drivers/android/touch_input.rb +24 -0
  191. data/lib/cukunity/drivers/android/tunnel_client_methods.rb +22 -0
  192. data/lib/cukunity/drivers/android/unity_client.rb +27 -0
  193. data/lib/cukunity/drivers/android/utils.rb +50 -0
  194. data/lib/cukunity/drivers/android.rb +9 -0
  195. data/lib/cukunity/drivers/iOS/app.rb +32 -0
  196. data/lib/cukunity/drivers/iOS/keyboard_input.rb +104 -0
  197. data/lib/cukunity/drivers/iOS/process.rb +42 -0
  198. data/lib/cukunity/drivers/iOS/touch_input.rb +18 -0
  199. data/lib/cukunity/drivers/iOS/tunnel_client_methods.rb +27 -0
  200. data/lib/cukunity/drivers/iOS/uiautomation.rb +97 -0
  201. data/lib/cukunity/drivers/iOS/uiautomation_master.rb +152 -0
  202. data/lib/cukunity/drivers/iOS/uiautomation_slave.js +238 -0
  203. data/lib/cukunity/drivers/iOS/uiautomation_slave.rb +41 -0
  204. data/lib/cukunity/drivers/iOS/unity_client.rb +27 -0
  205. data/lib/cukunity/drivers/iOS/utils.rb +46 -0
  206. data/lib/cukunity/drivers/iOS.rb +9 -0
  207. data/lib/cukunity/exceptions.rb +24 -0
  208. data/lib/cukunity/keyboard_input_methods.rb +35 -0
  209. data/lib/cukunity/request_line_response_client_methods.rb +80 -0
  210. data/lib/cukunity/tasks/cucumber.rake +22 -0
  211. data/lib/cukunity/touch_input_methods.rb +19 -0
  212. data/lib/cukunity/unity/client_methods.rb +46 -0
  213. data/lib/cukunity/unity/command_facade.rb +67 -0
  214. data/lib/cukunity/unity/component.rb +39 -0
  215. data/lib/cukunity/unity/gameobject.rb +53 -0
  216. data/lib/cukunity/unity/hint.rb +27 -0
  217. data/lib/cukunity/unity/json_container.rb +48 -0
  218. data/lib/cukunity/unity/level.rb +6 -0
  219. data/lib/cukunity/unity/scene.rb +18 -0
  220. data/lib/cukunity/unity/screen.rb +45 -0
  221. data/lib/cukunity/unity/screen_hint_methods.rb +61 -0
  222. data/lib/cukunity/unity/text_hint_methods.rb +17 -0
  223. data/lib/cukunity/unity.rb +11 -0
  224. data/lib/cukunity/utils.rb +56 -0
  225. data/lib/cukunity.rb +19 -0
  226. metadata +411 -0
@@ -0,0 +1,150 @@
1
+ require 'rbconfig'
2
+
3
+ module Cukunity
4
+ module CLI
5
+ class DoctorCommand
6
+ def initialize(parser)
7
+ @parser = parser
8
+ end
9
+
10
+ def execute
11
+ check_ruby
12
+ check_cucumber
13
+ check_ios if @parser.options.ios
14
+ check_android if @parser.options.android
15
+ end
16
+
17
+ private
18
+ def check_platform(platform)
19
+ puts '==>'.blue + " Checking #{platform}"
20
+ end
21
+
22
+ def check_ok(item, path)
23
+ puts '===>'.blue + " #{item} (#{path.green})"
24
+ end
25
+
26
+ def check_error(item, path, solution)
27
+ $stdout.puts '===>'.red + " #{item} (#{path.red})"
28
+ solution.each_line do |line|
29
+ $stdout.puts '::::: '.red + " #{line}"
30
+ end
31
+ end
32
+
33
+ def check_ruby
34
+ check_platform('Ruby')
35
+ ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
36
+ if RbConfig::CONFIG['MAJOR'].to_i < 1 or RbConfig::CONFIG['MAJOR'].to_i <= 1 and
37
+ RbConfig::CONFIG['MINOR'].to_i < 9
38
+ solution = <<-eos
39
+
40
+ Please install Ruby 1.9.x or above using RVM by following the instructions
41
+ at http://beginrescueend.com .
42
+
43
+ eos
44
+
45
+ check_error(ruby, 'Ruby 1.8.x and below is not supported.', solution.gsub(/^ +/, ''))
46
+ else
47
+ check_ok('Ruby', ruby)
48
+ end
49
+ end
50
+
51
+ def check_cucumber
52
+ check_platform('Cucumber')
53
+
54
+ check_file 'cucumber', <<-eos
55
+
56
+ Please install cucumber gem from a terminal by executing:
57
+
58
+ # gem install cucumber
59
+
60
+ or, if you use bundler, just add the following to your Gemfile:
61
+
62
+ gem 'cucumber'
63
+
64
+ eos
65
+ end
66
+
67
+ def check_ios
68
+ check_platform('iOS')
69
+
70
+ check_file 'mobiledevice', <<-eos
71
+
72
+ Please install "mobiledevice" from http://github.com/imkira/mobiledevice
73
+ from a terminal by executing:
74
+
75
+ # git clone git://github.com/imkira/mobiledevice.git
76
+ # cd mobiledevice
77
+ # rake install
78
+
79
+ eos
80
+
81
+ check_file 'instruments', <<-eos
82
+
83
+ Please install XCode 4.2 or above from https://developer.apple.com/xcode/ .
84
+
85
+ eos
86
+
87
+ check_file ['/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate'], <<-eos
88
+
89
+ Please install XCode 4.2 or above from https://developer.apple.com/xcode/ .
90
+ Also, make sure you have iOS 5 SDK installed.
91
+
92
+ eos
93
+ end
94
+
95
+ def check_android
96
+ check_platform('Android')
97
+
98
+ check_file 'android', <<-eos
99
+
100
+ Please install the "Android SDK" from http://developer.android.com/sdk/ .
101
+
102
+ If you use "brew" ( http://mxcl.github.com/homebrew/ ), you can install it with:
103
+ # brew install android-sdk
104
+
105
+ eos
106
+
107
+ ['adb', 'aapt'].each do |tool|
108
+ check_file tool, <<-eos
109
+
110
+ Please install the "Android SDK tools" from the "Android SDK Manager".
111
+
112
+ You can launch the manager from a terminal by executing:
113
+ # android
114
+
115
+ Within the manager, you can install the "Android SDK Tools" package from Google.
116
+
117
+ After installation, make sure "platform-tools" folder is in your PATH environment.
118
+
119
+ eos
120
+ end
121
+ end
122
+
123
+ def check_file(items, solution)
124
+ items = [items] unless items.is_a? Array
125
+ items.each do |item|
126
+ full_path = env_path(item)
127
+ full_path = File.expand_path(item) unless full_path
128
+ if full_path and File.exists?(full_path)
129
+ if File.file?(full_path)
130
+ check_ok(item, full_path)
131
+ return
132
+ end
133
+ check_error(item, 'Found expecting a file', solution.gsub(/^ +/, ''))
134
+ else
135
+ end
136
+ end
137
+ check_error(items.join(' , '), 'Not found', solution.gsub(/^ +/, ''))
138
+ end
139
+
140
+ def env_path(path)
141
+ ENV['PATH'].split(':').each do |dir|
142
+ if File.exists?(File.join(dir, path))
143
+ return File.expand_path(File.join(dir, path))
144
+ end
145
+ end
146
+ nil
147
+ end
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,35 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+
4
+ module Cukunity
5
+ module CLI
6
+ class FeaturesCommand
7
+ def initialize(parser)
8
+ @parser = parser
9
+ end
10
+
11
+ def execute
12
+ path = @parser.remaining_args.first
13
+ if path.nil?
14
+ path = Dir.pwd
15
+ path = File.join(path, 'features') if File.directory?(File.join(path, 'features'))
16
+ end
17
+ if @parser.options.ios
18
+ if @parser.options.android
19
+ abort 'You cannot test both iOS and Android simultaneously. ' \
20
+ 'Please disable one of the platforms by using ' \
21
+ '--no-ios or --no-android'
22
+ end
23
+ platform_flags = '~@android,@ios'
24
+ elsif @parser.options.android
25
+ platform_flags = '~@ios,@android'
26
+ else
27
+ abort 'You should specify which platform you want to test by specifying ' \
28
+ 'either --ios or --android'
29
+ end
30
+ cukunity = File.expand_path(File.join(File.dirname(__FILE__), '..', 'cucumber.rb'))
31
+ system %Q[cucumber --require "#{cukunity}" --require "#{path}" --format pretty -t "#{platform_flags}"]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module Cukunity
2
+ module CLI
3
+ class Main
4
+ def self.execute!(args = ARGV)
5
+ new(args).execute
6
+ end
7
+
8
+ def initialize(args)
9
+ @args = args.dup
10
+ end
11
+
12
+ def execute
13
+ command = Cukunity::CLI::ArgumentParser.parse(@args)
14
+ command.execute unless command.nil?
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require 'ostruct'
2
+
3
+ module Cukunity
4
+ module CLI
5
+ class Options < OpenStruct
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'term/ansicolor'
3
+ class String
4
+ include Term::ANSIColor
5
+ end
6
+ require 'cukunity/cli/main'
7
+ require 'cukunity/cli/options'
8
+ require 'cukunity/cli/argument_parser'
9
+ require 'cukunity/cli/doctor_command'
10
+ require 'cukunity/cli/bootstrap_command'
11
+ require 'cukunity/cli/features_command'
@@ -0,0 +1,37 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Then /^I should( not)? have an? (\w+) (?:named|called|component on|on) "([^"]*)"$/ do |negation, type, name|
4
+ set_current_gameobject(gameobject(name))
5
+ if type == 'GameObject'
6
+ should !negation, current_gameobject, be_nil
7
+ elsif !negation or !current_gameobject.nil?
8
+ should negation, current_gameobject, have_component(:type => type)
9
+ set_current_component(current_gameobject.component(:type => type))
10
+ should !negation, current_component, be_nil
11
+ end
12
+ end
13
+
14
+ Then /^I should( not)? have a "([^"]*)"$/ do |negation, name|
15
+ step %[I should#{negation} have a GameObject named "#{name}"]
16
+ end
17
+
18
+ Then /^it should( not)? have an? (\w+)(?: component)$/ do |negation, type|
19
+ should !negation, current_gameobject.component(:type => type), be_nil
20
+ end
21
+
22
+ Then /^it should( not)? have (?:a )property (?:named|called) "(\w+)"$/ do |negation, name|
23
+ should negation, current_object.has_property?(name), be_true
24
+ end
25
+
26
+ Then /^it should( not)? have "(\w+)"(?: property)? (?:as|equal to) "([^"]*)"$/ do |negation, name, value|
27
+ step %Q[it should have a property named "#{name}"] unless negation
28
+ should negation, current_object.property(name).to_s, eql(value)
29
+ end
30
+
31
+ Then /^it should( not)? have (\w+)(?: property)? (?:as|equal to) "([^"]*)"$/ do |negation, name, value|
32
+ step %Q[it should have "#{name}" property equal to "#{value}"]
33
+ end
34
+
35
+ Then /^it should( not)? be "([^"]*)"$/ do |negation, bool_name|
36
+ should negation, current_object.property(bool_name), eql(true)
37
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Then /^"([^"]*)"という(\w+)が存在してい(る|ない)(?:こと)?$/ do |name, type, negation|
4
+ step %[I should#{negation} have a #{type} named "#{name}"]
5
+ end
6
+
7
+ Then /^"([^"]*)"が存在してい(る|ない)(?:こと)?$/ do |name, negation|
8
+ step %[I should#{negation} have a GameObject named "#{name}"]
9
+ end
10
+
11
+ Then /^その中に(\w+)(?:コンポーネント)?が存在してい(る|ない)(?:こと)?$/ do |type, negation|
12
+ step %[it should#{negation} have a #{type} component]
13
+ end
14
+
15
+ Then /^その中に(\w+)というプロパティーが存在してい(る|ない)(?:こと)?$/ do |name, negation|
16
+ step %[it should#{negation} have a property named "#{name}"]
17
+ end
18
+
19
+ Then /^その中に"(\w+)"というプロパティーが存在してい(る|ない)(?:こと)?$/ do |name, negation|
20
+ step %[it should#{negation} have a property named "#{name}"]
21
+ end
22
+
23
+ Then /^その中に(\w+)(?:というプロパティー)?が"([^"]*)"(?:と|に)一致してい(る|ない)(?:こと)?$/ do |name, value, negation|
24
+ step %Q[it should#{negation} have "#{name}" property equal to "#{value}"]
25
+ end
26
+
27
+ Then /^その中に"(\w+)"(?:というプロパティー)?が"([^"]*)"(?:と|に)一致してい(る|ない)(?:こと)?$/ do |name, value, negation|
28
+ step %Q[it should#{negation} have "#{name}" property equal to "#{value}"]
29
+ end
30
+
31
+ Then /^その中に"(\w+)"(?:というプロパティー)?が有効になってい(る|ない)(?:こと)?$/ do |bool_name, negation|
32
+ step %Q[it should#{negation} be "#{bool_name}"]
33
+ end
34
+
35
+ Then /^その中に(\w+)(?:というプロパティー)?が有効になってい(る|ない)(?:こと)?$/ do |bool_name, negation|
36
+ step %Q[it should#{negation} be "#{bool_name}"]
37
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Given /^"([^"]*)"(?:から)?(?:アプリ|ゲーム)を(再)?インストール(?:している)?$/ do |path, reinstall|
4
+ step %Q[I #{reinstall}install the app "#{path}"]
5
+ end
6
+
7
+ Given /^(?:その|同)?(?:アプリ|ゲーム)を(再)?インストール(?:している)?$/ do |reinstall|
8
+ step %Q[I #{reinstall}install the app "#{current_app}"]
9
+ end
10
+
11
+ Given /^"([^"]*)"(?:アプリ|ゲーム)をアンインストール(?:している)?$/ do |path|
12
+ step %Q[I uninstall the app "#{path}"]
13
+ end
14
+
15
+ Given /^(?:その|同)?(?:アプリ|ゲーム)をアンインストール(?:している)?$/ do
16
+ step %Q[I uninstall the app "#{current_app}"]
17
+ end
18
+
19
+ Then /^"([^"]*)"(?:アプリ|ゲーム)がいインストールされていい(る|ない)(?:こと)?$/ do |path, negation|
20
+ step %Q[the app "#{path}" should#{negation} be installed]
21
+ end
22
+
23
+ Then /^(?:その|同)?(?:アプリ|ゲーム)がインストールされてい(る|ない)(?:こと)?$/ do |negation|
24
+ step %Q[the app "#{current_app}" should#{negation} be installed]
25
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ When /^(?:"([^"]*)"という入力方法で)?"([^"]*)"と入力(?:したら)?$/ do |method, text|
4
+ if method.nil?
5
+ step %Q[I type "#{text}"]
6
+ else
7
+ step %Q[I type "#{text}" using "#{method}"]
8
+ end
9
+ end
10
+
11
+ When /^(?:"([^"]*)"という入力方法で)?"([^"]*)"と加えて入力(?:したら)?$/ do |method, text|
12
+ if method.nil?
13
+ step %Q[I append "#{text}"]
14
+ else
15
+ step %Q[I append "#{text}" using "#{method}"]
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Given /^レベル"([^"]*)"をロード(?:している)?$/ do |name|
4
+ step %Q[I load "#{name}" level]
5
+ end
6
+
7
+ Given /^レベル(\d+)をロード(?:している)?$/ do |number|
8
+ step %Q[I load level #{number}]
9
+ end
10
+
11
+ Then /^レベル"([^"]*)"が(?:ロード|再生)されてい(る|ない)(?:こと)?$/ do |name, negation|
12
+ step %Q[it should#{negation} be playing "#{name}" level]
13
+ end
14
+
15
+ Then /^レベル(\d+)が(?:ロード|再生)されてい(る|ない)(?:こと)?$/ do |number, negation|
16
+ step %Q[it should#{negation} be playing level #{number}]
17
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Given /^"([^"]*)"(?:から)?(?:アプリ|ゲーム)を(再)?起動(?:している)?$/ do |path, relaunch|
4
+ step %Q[I #{relaunch}launch the app "#{path}"]
5
+ end
6
+
7
+ Given /^(?:その|同)?(?:アプリ|ゲーム)を(再)?起動(?:している)?$/ do |relaunch|
8
+ step %Q[I #{relaunch}launch the app "#{current_app}"]
9
+ end
10
+
11
+ Then /^"([^"]*)"(?:アプリ|ゲーム)が(?:実行|動作)してい(る|ない)(?:こと)?$/ do |path, negation|
12
+ step %Q[the app "#{path}" should#{negation} be running]
13
+ end
14
+
15
+ Then /^(?:その|同)?(?:アプリ|ゲーム)が(?:実行|動作)してい(る|ない)(?:こと)?$/ do |negation|
16
+ step %Q[the app "#{current_app}" should#{negation} be running]
17
+ end
18
+
19
+ Then /^"([^"]*)"(?:アプリ|ゲーム)がフォアグラウンドで(?:実行|動作)してい(る|ない)(?:こと)?$/ do |path, negation|
20
+ step %Q[the app "#{path}" should#{negation} be running on foreground]
21
+ end
22
+
23
+ Then /^(?:その|同)?(?:アプリ|ゲーム)がフォアグラウンドで(?:実行|動作)してい(る|ない)(?:こと)?$/ do |negation|
24
+ step %Q[the app "#{current_app}" should#{negation} be running on foreground]
25
+ end
@@ -0,0 +1,9 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Then /^"([^"]*)"(?:というGameObject)?を表示してい(る|ない)(?:こと)?$/ do |name, negation|
4
+ step %Q[I should#{negation} see "#{name}"]
5
+ end
6
+
7
+ Then /^"([^"]*)"と表示してい(る|ない)(?:こと)?$/ do |text, negation|
8
+ step %Q[I should#{negation} read "#{text}"]
9
+ end
@@ -0,0 +1,19 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ # FIXME:
4
+ When /^I tap the screen(down up|down and up| down| up)? at coordinates (\d+), (\d+)$/ do |type, x, y|
5
+ type = (type || ' down and up').strip.gsub(/ /, '_').downcase
6
+ screen.tap :x => x.to_i, :y => y.to_i
7
+ end
8
+
9
+ When /^"([^"]*)"をタップ(?:して|したら)?((?:\d+(?:\.\d+)?)秒待ったら)?$/ do |name, time|
10
+ if time.nil?
11
+ step %Q[I tap "#{name}"]
12
+ else
13
+ step %Q[I tap "#{name}" and wait #{time} seconds]
14
+ end
15
+ end
16
+
17
+ When /^タップした後に発生する遅延時間を((?:\d+(?:\.\d+)?)秒)に変更(?:したら)?$/ do |time|
18
+ step %Q[I set the default tap delay to #{time} seconds]
19
+ end
@@ -0,0 +1,9 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Transform /^(る|ない)$/ do |negation|
4
+ /^(ない)$/.match(negation) ? ' not' : nil
5
+ end
6
+
7
+ Transform /^(\d+(?:\.\d+)?)秒/ do |time|
8
+ time.to_f
9
+ end
@@ -0,0 +1,33 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Given /^I (re)?install the (?:app|game)(?: from)? "([^"]*)"$/ do |reinstall, path|
4
+ set_current_app(path)
5
+ if not installed?(current_app)
6
+ install(current_app)
7
+ elsif reinstall
8
+ uninstall(current_app)
9
+ install(current_app)
10
+ end
11
+ end
12
+
13
+ Given /^I (re)?install it$/ do |reinstall|
14
+ step %Q[I #{reinstall}install the app "#{current_app}"]
15
+ end
16
+
17
+ Given /^I uninstall the (?:app|game) "([^"]*)"$/ do |path|
18
+ set_current_app(path)
19
+ uninstall(current_app) if installed?(current_app)
20
+ end
21
+
22
+ Given /^I uninstall it$/ do
23
+ step %Q[I uninstall the app "#{current_app}"]
24
+ end
25
+
26
+ Then /^the (?:app|game) "([^"]*)" should( not)? be installed$/ do |path, negation|
27
+ set_current_app(path)
28
+ should negation, app, be_installed(current_app)
29
+ end
30
+
31
+ Then /^it should( not)? be installed$/ do |negation|
32
+ step %Q[the app "#{current_app}" should#{negation} be installed]
33
+ end
@@ -0,0 +1,13 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ When /^I type "([^"]*)"(?: using "([^"]*)")?$/ do |text, method|
4
+ keyboard.open(:clear => true, :method => method) do |k|
5
+ k.type_text text
6
+ end
7
+ end
8
+
9
+ When /^I append "([^"]*)"(?: using "([^"]*)")?$/ do |text, method|
10
+ keyboard.open(:clear => false, :method => method) do |k|
11
+ k.type_text text
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Given /^I load(?: the)? "([^"]*)" level$/ do |name|
4
+ load_level(name)
5
+ end
6
+
7
+ Given /^I load level (\d+)$/ do |number|
8
+ load_level(number.to_i)
9
+ end
10
+
11
+ Then /^it should( not)? be playing(?: the)? "([^"]*)" level$/ do |negation, name|
12
+ should_equal negation, level.name, name
13
+ end
14
+
15
+ Then /^it should( not)? be playing level (\d+)$/ do |negation, number|
16
+ should_equal negation, level.number, number.to_i
17
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Given /^I (re)?(?:launch|run) the app "([^"]*)"$/ do |relaunch, path|
4
+ set_current_app(path)
5
+ if not running?(current_app)
6
+ launch(current_app)
7
+ elsif relaunch
8
+ relaunch(current_app)
9
+ end
10
+ end
11
+
12
+ Given /^I (re)?launch it$/ do |relaunch|
13
+ step %Q[I #{relaunch}launch the app "#{current_app}"]
14
+ end
15
+
16
+ Then /^the app "([^"]*)" should( not)? be running$/ do |path, negation|
17
+ set_current_app(path)
18
+ should negation, process, be_running(current_app)
19
+ end
20
+
21
+ Then /^it should( not)? be running$/ do |negation|
22
+ step %Q[the app "#{current_app}" should#{negation} be running]
23
+ end
24
+
25
+ Then /^the app "([^"]*)" should( not)? be running on (?:foreground|screen)$/ do |path, negation|
26
+ set_current_app(path)
27
+ should negation, process, be_foreground(current_app)
28
+ end
29
+
30
+ Then /^it should( not)? be running on (?:foreground|screen)$/ do |negation|
31
+ step %Q[the app "#{current_app}" should#{negation} be running on foreground]
32
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ Then /^I should( not)? see "([^"]*)"$/ do |negation, name|
4
+ screenable = hint(:type => 'screen') do |hint|
5
+ hint.gameobject.name == name and hint.on_screen?
6
+ end
7
+ should !negation, screenable, be_nil
8
+ end
9
+
10
+ Then /^I should( not)? read "([^"]*)"$/ do |negation, text|
11
+ textual = hint(:type => 'text') do |hint|
12
+ hint.reads_as?(text)
13
+ end
14
+ should !negation, textual, be_nil
15
+ end
@@ -0,0 +1,18 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ When /^I tap the screen(down up|down and up| down| up)? at coordinates (\d+), (\d+)$/ do |type, x, y|
4
+ type = (type || ' down and up').strip.gsub(/ /, '_').downcase
5
+ screen.tap :x => x.to_i, :y => y.to_i
6
+ end
7
+
8
+ When /^I tap "([^"]*)"(?: and wait ((?:\d+(?:\.\d+)?)\s*s(?:ecs?|econds?)))?$/ do |name, time|
9
+ screenable = hint(:type => 'screen') do |hint|
10
+ hint.gameobject.name == name and hint.on_screen?
11
+ end
12
+ should 'not', screenable, be_nil
13
+ screenable.tap :wait => (time || touch.default_tap_delay).to_f
14
+ end
15
+
16
+ When /^I set the default tap (?:wait|delay) to ((?:\d+(?:\.\d+)?)\s*s(?:ecs?|econds?))$/ do |time|
17
+ touch.set_default_tap_delay(time.to_f)
18
+ end
@@ -0,0 +1,105 @@
1
+ module Cukunity
2
+ module PlatformHelpers
3
+ extend Forwardable
4
+ def_delegator :app, :install
5
+ def_delegator :app, :uninstall
6
+ def_delegator :app, :installed
7
+ def_delegator :app, :installed?
8
+ def_delegator :process, :launch
9
+ def_delegator :process, :running
10
+ def_delegator :process, :foreground
11
+ def_delegator :process, :foreground?
12
+ def_delegator :process, :running?
13
+ def_delegator :process, :pids
14
+ def_delegator :process, :relaunch
15
+ def_delegator :input, :touch_screen
16
+ def_delegator :keyboard, :keyboard
17
+
18
+ def current_app
19
+ raise Exception::InvalidApp.new if @current_app.nil?
20
+ @current_app
21
+ end
22
+
23
+ def current_app=(path)
24
+ case File.extname(path).downcase
25
+ when '.app'
26
+ set_current_app_ios(path)
27
+ when '.apk'
28
+ set_current_app_android(path)
29
+ else
30
+ # @ios is defined as a tag?
31
+ tags = @@__tags__
32
+ if tags.include?('@ios') or tags.include?('@~android')
33
+ path = set_current_app_ios("#{path}.app")
34
+ # @android is defined as a tag?
35
+ elsif tags.include?('@android') or tags.include?('@~ios')
36
+ path = set_current_app_android("#{path}.apk")
37
+ else
38
+ raise Exception::InvalidApp.new(path)
39
+ end
40
+ end
41
+ @current_app = path
42
+ end
43
+
44
+ def set_current_app(path)
45
+ self.current_app = path
46
+ end
47
+
48
+ def platform_defined?
49
+ not @platform.nil?
50
+ end
51
+
52
+ def app
53
+ raise Exception::UnspecifiedPlatform.new if @platform.nil?
54
+ @platform::App
55
+ end
56
+
57
+ def process
58
+ raise Exception::UnspecifiedPlatform.new if @platform.nil?
59
+ @platform::Process
60
+ end
61
+
62
+ def touch
63
+ raise Exception::UnspecifiedPlatform.new if @platform.nil?
64
+ @platform::TouchInput
65
+ end
66
+
67
+ def keyboard
68
+ raise Exception::UnspecifiedPlatform.new if @platform.nil?
69
+ @platform::KeyboardInput
70
+ end
71
+
72
+ def self.__tags__=(tags)
73
+ @@__tags__ = tags
74
+ end
75
+
76
+ private
77
+ def set_current_app_ios(path)
78
+ raise Exception::InvalidApp.new(path) unless File.directory?(path)
79
+ @platform = Cukunity::IOS
80
+ path
81
+ end
82
+
83
+ def set_current_app_android(path)
84
+ raise Exception::InvalidApp.new(path) unless File.file?(path)
85
+ @platform = Cukunity::Android
86
+ path
87
+ end
88
+ end
89
+ end
90
+
91
+ World(Cukunity::PlatformHelpers)
92
+
93
+ AfterConfiguration do |config|
94
+ # FIXME: we should not use an undocumented/deprecated member.
95
+ # gherkin's tag_expressions method does not allow us to inspect the list
96
+ # of defined tags or to eval against a subset of tags.
97
+ # If the user defines new tags we would't know about as a consequence
98
+ # tag_expressions.eval(_the_tags_we_know_) will probably fail.
99
+ # Therefore, we access @options[:tag_expressions] directly.
100
+ options = config.instance_variable_get('@options')
101
+ tags = options[:tag_expressions].inject([]) do |tags, tag|
102
+ tags += tag.split(/\s*,\s*/)
103
+ end
104
+ Cukunity::PlatformHelpers.__tags__ = tags
105
+ end