testautoi 0.9.127

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 (121) hide show
  1. data/.gitignore +4 -0
  2. data/CHANGES.txt +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +8 -0
  5. data/Rakefile +2 -0
  6. data/bin/CalabashSetup +0 -0
  7. data/bin/cal.xcconfig +3 -0
  8. data/bin/calabash-ios +79 -0
  9. data/bin/calabash-ios-build.rb +110 -0
  10. data/bin/calabash-ios-generate.rb +26 -0
  11. data/bin/calabash-ios-helpers.rb +130 -0
  12. data/bin/calabash-ios-setup.rb +334 -0
  13. data/bin/calabash-ios-sim.rb +149 -0
  14. data/calabash-cucumber.gemspec +29 -0
  15. data/doc/calabash-ios-help.txt +73 -0
  16. data/epl-v10.html +261 -0
  17. data/features-skeleton/.irbrc +23 -0
  18. data/features-skeleton/irb_ios4.sh +2 -0
  19. data/features-skeleton/irb_ios5.sh +2 -0
  20. data/features-skeleton/my_first.feature +12 -0
  21. data/features-skeleton/step_definitions/calabash_steps.rb +1 -0
  22. data/features-skeleton/step_definitions/my_first_steps.rb +4 -0
  23. data/features-skeleton/support/env.rb +1 -0
  24. data/features-skeleton/support/hooks.rb +0 -0
  25. data/features-skeleton/support/launch.rb +77 -0
  26. data/features/step_definitions/calabash_steps.rb +439 -0
  27. data/lib/calabash-cucumber.rb +7 -0
  28. data/lib/calabash-cucumber/calabash_steps.rb +1 -0
  29. data/lib/calabash-cucumber/core.rb +553 -0
  30. data/lib/calabash-cucumber/cucumber.rb +8 -0
  31. data/lib/calabash-cucumber/ibase.rb +45 -0
  32. data/lib/calabash-cucumber/keyboard_helpers.rb +124 -0
  33. data/lib/calabash-cucumber/launch/simulator_helper.rb +297 -0
  34. data/lib/calabash-cucumber/location.rb +26 -0
  35. data/lib/calabash-cucumber/operations.rb +162 -0
  36. data/lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64 +51 -0
  37. data/lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64 +51 -0
  38. data/lib/calabash-cucumber/resources/cell_swipe_ios5_ipad.base64 +74 -0
  39. data/lib/calabash-cucumber/resources/cell_swipe_ios5_iphone.base64 +74 -0
  40. data/lib/calabash-cucumber/resources/pinch_in_ios4_ipad.base64 +104 -0
  41. data/lib/calabash-cucumber/resources/pinch_in_ios4_iphone.base64 +104 -0
  42. data/lib/calabash-cucumber/resources/pinch_in_ios5_ipad.base64 +144 -0
  43. data/lib/calabash-cucumber/resources/pinch_in_ios5_iphone.base64 +144 -0
  44. data/lib/calabash-cucumber/resources/pinch_in_ios6_ipad.base64 +70 -0
  45. data/lib/calabash-cucumber/resources/pinch_in_ios6_iphone.base64 +70 -0
  46. data/lib/calabash-cucumber/resources/pinch_out_ios5_ipad.base64 +207 -0
  47. data/lib/calabash-cucumber/resources/pinch_out_ios5_iphone.base64 +207 -0
  48. data/lib/calabash-cucumber/resources/pinch_out_ios6_ipad.base64 +96 -0
  49. data/lib/calabash-cucumber/resources/pinch_out_ios6_iphone.base64 +96 -0
  50. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_ipad.base64 +2 -0
  51. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_iphone.base64 +2 -0
  52. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_ipad.base64 +2 -0
  53. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_iphone.base64 +2 -0
  54. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_ipad.base64 +2 -0
  55. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_iphone.base64 +2 -0
  56. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_ipad.base64 +2 -0
  57. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_iphone.base64 +2 -0
  58. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_ipad.base64 +2 -0
  59. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_iphone.base64 +2 -0
  60. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_ipad.base64 +2 -0
  61. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_iphone.base64 +2 -0
  62. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_ipad.base64 +2 -0
  63. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_iphone.base64 +2 -0
  64. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_ipad.base64 +2 -0
  65. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_iphone.base64 +2 -0
  66. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_ipad.base64 +2 -0
  67. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_iphone.base64 +2 -0
  68. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_ipad.base64 +2 -0
  69. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_iphone.base64 +2 -0
  70. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_ipad.base64 +2 -0
  71. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_iphone.base64 +2 -0
  72. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_ipad.base64 +2 -0
  73. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_iphone.base64 +2 -0
  74. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_ipad.base64 +2 -0
  75. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_iphone.base64 +2 -0
  76. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_ipad.base64 +2 -0
  77. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_iphone.base64 +2 -0
  78. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_ipad.base64 +2 -0
  79. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_iphone.base64 +2 -0
  80. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_ipad.base64 +2 -0
  81. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_iphone.base64 +2 -0
  82. data/lib/calabash-cucumber/resources/swipe_down_ios5_ipad.base64 +18 -0
  83. data/lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64 +18 -0
  84. data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_ipad.base64 +15 -0
  85. data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_iphone.base64 +15 -0
  86. data/lib/calabash-cucumber/resources/swipe_left_ios4_ipad.base64 +18 -0
  87. data/lib/calabash-cucumber/resources/swipe_left_ios4_iphone.base64 +18 -0
  88. data/lib/calabash-cucumber/resources/swipe_left_ios5_ipad.base64 +17 -0
  89. data/lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64 +17 -0
  90. data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_ipad.base64 +17 -0
  91. data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_iphone.base64 +17 -0
  92. data/lib/calabash-cucumber/resources/swipe_right_ios4_ipad.base64 +13 -0
  93. data/lib/calabash-cucumber/resources/swipe_right_ios4_iphone.base64 +13 -0
  94. data/lib/calabash-cucumber/resources/swipe_right_ios5_ipad.base64 +17 -0
  95. data/lib/calabash-cucumber/resources/swipe_right_ios5_iphone.base64 +17 -0
  96. data/lib/calabash-cucumber/resources/swipe_up_ios5_ipad.base64 +34 -0
  97. data/lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64 +34 -0
  98. data/lib/calabash-cucumber/resources/touch_done_ios4_ipad.base64 +7 -0
  99. data/lib/calabash-cucumber/resources/touch_done_ios4_iphone.base64 +9 -0
  100. data/lib/calabash-cucumber/resources/touch_done_ios5_ipad.base64 +7 -0
  101. data/lib/calabash-cucumber/resources/touch_done_ios5_iphone.base64 +9 -0
  102. data/lib/calabash-cucumber/resources/touch_ios4_ipad.base64 +9 -0
  103. data/lib/calabash-cucumber/resources/touch_ios4_iphone.base64 +9 -0
  104. data/lib/calabash-cucumber/resources/touch_ios5_ipad.base64 +9 -0
  105. data/lib/calabash-cucumber/resources/touch_ios5_iphone.base64 +9 -0
  106. data/lib/calabash-cucumber/resources/wheel_down_ios4_ipad.base64 +159 -0
  107. data/lib/calabash-cucumber/resources/wheel_down_ios4_iphone.base64 +159 -0
  108. data/lib/calabash-cucumber/resources/wheel_down_ios5_ipad.base64 +156 -0
  109. data/lib/calabash-cucumber/resources/wheel_down_ios5_iphone.base64 +156 -0
  110. data/lib/calabash-cucumber/resources/wheel_up_ios4_ipad.base64 +166 -0
  111. data/lib/calabash-cucumber/resources/wheel_up_ios4_iphone.base64 +166 -0
  112. data/lib/calabash-cucumber/resources/wheel_up_ios5_ipad.base64 +156 -0
  113. data/lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64 +156 -0
  114. data/lib/calabash-cucumber/tests_helpers.rb +136 -0
  115. data/lib/calabash-cucumber/version.rb +6 -0
  116. data/lib/calabash-cucumber/wait_helpers.rb +149 -0
  117. data/scripts/data/.GlobalPreferences.plist +0 -0
  118. data/scripts/data/clients.plist +0 -0
  119. data/scripts/data/com.apple.Accessibility.plist +0 -0
  120. data/scripts/reset_simulator.scpt +0 -0
  121. metadata +319 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg
2
+ Markdown.pl
3
+ .idea
4
+ Gemfile.lock
data/CHANGES.txt ADDED
@@ -0,0 +1 @@
1
+ 1.0.0: Initial calabash release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in calabash-ios-cucumber.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ calabash-cucumber
2
+ Copyright (c) Karl Krukow. All rights reserved.
3
+ The use and distribution terms for this software are covered by the
4
+ Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5
+ which can be found in the file epl-v10.html at the root of this distribution.
6
+ By using this software in any fashion, you are agreeing to be bound by
7
+ the terms of this license.
8
+ You must not remove this notice, or any other, from this software.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/CalabashSetup ADDED
Binary file
data/bin/cal.xcconfig ADDED
@@ -0,0 +1,3 @@
1
+ INSTALL_PATH = /./
2
+
3
+ OTHER_LDFLAGS = $(inherited) -force_load $(SRCROOT)/calabash.framework/calabash -framework CFNetwork -lstdc++
data/bin/calabash-ios ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+ require 'cfpropertylist'
6
+ require 'rexml/document'
7
+
8
+
9
+ require File.join(File.dirname(__FILE__),"calabash-ios-helpers")
10
+ require File.join(File.dirname(__FILE__),"calabash-ios-generate")
11
+ require File.join(File.dirname(__FILE__),"calabash-ios-setup")
12
+ require File.join(File.dirname(__FILE__),"calabash-ios-sim")
13
+ require File.join(File.dirname(__FILE__),"calabash-ios-build")
14
+
15
+ @features_dir = File.join(FileUtils.pwd, "features")
16
+ @source_dir = File.join(File.dirname(__FILE__), '..', 'features-skeleton')
17
+ @script_dir = File.join(File.dirname(__FILE__), '..', 'scripts')
18
+
19
+ if (ARGV.length == 0)
20
+ print_usage
21
+ exit 0
22
+ end
23
+ cmd = ARGV.shift
24
+ if cmd == 'help'
25
+ print_help
26
+ exit 0
27
+ elsif cmd == 'gen'
28
+ calabash_scaffold
29
+ exit 0
30
+ elsif cmd == 'console'
31
+ console
32
+ exit 0
33
+ elsif cmd == 'build'
34
+ build
35
+ exit 0
36
+ elsif cmd == 'run'
37
+ run
38
+ exit 0
39
+ elsif cmd == 'download'
40
+ calabash_download(ARGV)
41
+ exit 0
42
+ elsif cmd == 'setup'
43
+ calabash_setup(ARGV)
44
+ exit 0
45
+ elsif cmd == 'check'
46
+ validate_setup(ARGV)
47
+ exit 0
48
+ elsif cmd == 'submit'
49
+ calabash_submit(ARGV)
50
+ exit 0
51
+ elsif cmd == 'version'
52
+ require 'calabash-cucumber'
53
+ puts Calabash::Cucumber::VERSION
54
+ exit 0
55
+ elsif cmd == 'sim'
56
+ if ARGV.length == 0
57
+ print_usage
58
+ exit 0
59
+ end
60
+ subcmd = ARGV.shift
61
+
62
+ if subcmd == 'reset'
63
+ calabash_sim_reset
64
+ elsif subcmd == 'acc'
65
+ calabash_sim_accessibility
66
+ elsif subcmd == 'location'
67
+ calabash_sim_location(ARGV)
68
+ elsif subcmd == 'locale'
69
+ calabash_sim_locale(ARGV)
70
+ elsif subcmd == 'device'
71
+ calabash_sim_device(ARGV)
72
+ else
73
+ print_usage
74
+ end
75
+ else
76
+ print_usage
77
+ end
78
+
79
+
@@ -0,0 +1,110 @@
1
+ def ensure_build_dir(options={:build_dir => "Calabash"})
2
+ if !File.exist?(options[:build_dir])
3
+ FileUtils.mkdir_p options[:build_dir]
4
+ end
5
+ end
6
+
7
+ def build(options={:build_dir=>"Calabash",
8
+ :configuration => "Debug",
9
+ :sdk => "iphonesimulator",
10
+ :dstroot => "Calabash/build",
11
+ :wrapper_name => "Calabash.app"})
12
+ #Follow Pete's .xcconfig-based approach with zero-config
13
+
14
+ ensure_build_dir(options)
15
+
16
+ if !File.exists?("#{options[:build_dir]}/cal.xcconfig")
17
+ FileUtils.cp(File.join(File.dirname(__FILE__),"cal.xcconfig"),"#{options[:build_dir]}/cal.xcconfig")
18
+ end
19
+
20
+ cmd=["xcodebuild"]
21
+ cmd << %Q[-xcconfig "#{options[:build_dir]}/cal.xcconfig"]
22
+ cmd << "install"
23
+
24
+ (options[:target] || []).each do |tgt|
25
+ options << %Q[-target "#{tgt}"]
26
+ end
27
+
28
+ cmd << "-configuration"
29
+ cmd << %Q["#{options[:configuration]}"]
30
+
31
+ cmd << "-sdk"
32
+ cmd << %Q["#{options[:sdk]}"]
33
+
34
+ cmd << %Q[DSTROOT="#{options[:dstroot]}"]
35
+
36
+ cmd << %Q[WRAPPER_NAME="#{options[:wrapper_name]}"]
37
+
38
+ res =nil
39
+ msg("Calabash Build") do
40
+ cmd_s = cmd.join(" ")
41
+ puts cmd_s
42
+ res=system(cmd_s)
43
+ end
44
+ res
45
+ end
46
+
47
+ def console(options={:script => "irb_ios5.sh"})
48
+ path = File.join(@source_dir,".irbrc")
49
+ if File.exists?(".irbrc")
50
+ old_str = File.read(".irbrc")
51
+ new_str = File.read(path)
52
+ if old_str != new_str
53
+ puts "Moving old .irbrc file to .irbrc.old"
54
+ FileUtils.mv(".irbrc", ".irbrc.old")
55
+ puts "Copying calabash-ios .irbrc file to current directory..."
56
+ FileUtils.cp(path, ".")
57
+ end
58
+ else
59
+ puts "Copying calabash-ios .irbrc file to current directory..."
60
+ FileUtils.cp(path, ".")
61
+ end
62
+
63
+ if !File.exists?(options[:script])
64
+ puts "Copying calabash-ios #{options[:script]} file to current directory..."
65
+ FileUtils.cp(File.join(@source_dir,options[:script]), ".")
66
+ end
67
+ puts "Running irb with ./.irbrc..."
68
+ system("./#{options[:script]}")
69
+ end
70
+
71
+
72
+ def run(options={:build_dir=>"Calabash",
73
+ :configuration => "Debug",
74
+ :sdk => "iphonesimulator",
75
+ :dstroot => "Calabash/build",
76
+ :wrapper_name => "Calabash.app"})
77
+ if ENV['NO_DOWNLOAD'] != "1"
78
+ if !File.directory?("calabash.framework")
79
+ calabash_download(ARGV)
80
+ end
81
+ end
82
+
83
+ if ENV['NO_BUILD'] != "1"
84
+ if !build(options)
85
+ msg("Error") do
86
+ puts "Build failed. Please consult logs. Aborting."
87
+ exit(false)
88
+ end
89
+ end
90
+ end
91
+
92
+ if ENV["NO_GEN"] != "1"
93
+ if !File.directory?("features")
94
+ calabash_scaffold
95
+ else
96
+ msg("Info") do
97
+ puts "Detected features folder, will not generate..."
98
+ end
99
+ end
100
+ end
101
+
102
+ default_path = "#{options[:dstroot]}/#{options[:wrapper_name]}"
103
+ cmd = %Q[APP_BUNDLE_PATH="#{ENV['APP_BUNDLE_PATH'] || default_path}" cucumber]
104
+ msg("Info") do
105
+ puts "Running command:"
106
+ puts cmd
107
+ end
108
+ system(cmd)
109
+ puts "Done..."
110
+ end
@@ -0,0 +1,26 @@
1
+
2
+ def calabash_scaffold
3
+ if File.exists?(@features_dir)
4
+ puts "A features directory already exists. Stopping..."
5
+ #puts "Run calabash-ios update for update instructions."
6
+ exit 1
7
+ end
8
+ msg("Question") do
9
+ puts "I'm about to create a subdirectory called features."
10
+ puts "features will contain all your calabash tests."
11
+ puts "Please hit return to confirm that's what you want."
12
+ end
13
+ exit 2 unless STDIN.gets.chomp == ''
14
+
15
+ FileUtils.cp_r(@source_dir, @features_dir)
16
+ FileUtils.mv "#{@features_dir}/.irbrc", "."
17
+ FileUtils.mv "#{@features_dir}/irb_ios4.sh", "."
18
+ FileUtils.mv "#{@features_dir}/irb_ios5.sh", "."
19
+
20
+ msg("Info") do
21
+ puts "Features subdirectory created. \n"
22
+ puts "Make sure you've build your -cal scheme in XCode and "
23
+ puts "try executing \n\ncucumber"
24
+ end
25
+
26
+ end
@@ -0,0 +1,130 @@
1
+ require 'tempfile'
2
+ require 'json'
3
+
4
+
5
+ def msg(title, &block)
6
+ puts "\n" + "-"*10 + title + "-"*10
7
+ block.call
8
+ puts "-"*10 + "-------" + "-"*10 + "\n"
9
+ end
10
+
11
+
12
+ def print_usage
13
+ puts <<EOF
14
+ Usage: calabash-ios <command> [<args>]
15
+ where <command> can be one of
16
+ help
17
+ prints more detailed help information.
18
+ gen
19
+ generate a features folder structure.
20
+ console
21
+ starts an interactive console to interact with your app via Calabash
22
+ setup [<path>]
23
+ setup your XCode project for calabash-ios (EXPERIMENTAL)
24
+ download
25
+ downloads latest compatible version of calabash.framework
26
+ check [{<path to .ipa>|<path to .app>}]
27
+ check whether an app or ipa is linked with calabash.framework (EXPERIMENTAL)
28
+ sim locale <lang> [<region>]
29
+ change locale and regional settings in all iOS Simulators
30
+ sim location {on|off} <bundleid>
31
+ set allow location on/off for current project or bundleid
32
+ sim reset
33
+ reset content and settings in all iOS Simulators
34
+ sim acc
35
+ enable accessibility in all iOS Simulators
36
+ sim device {iPad|iPad_Retina|iPhone|iPhone_Retina|iPhone_Retina_4inch}
37
+ change the default iOS Simulator device.
38
+ EOF
39
+ end
40
+
41
+ def print_help
42
+ file = File.join(File.dirname(__FILE__), '..', 'doc', 'calabash-ios-help.txt')
43
+ system("less #{file}")
44
+ end
45
+
46
+ def ensure_correct_path(args)
47
+ dir_to_search = nil
48
+ if args.length == 1
49
+ dir_to_search = args[0]
50
+ if not File.directory?(dir_to_search)
51
+ puts "Path: #{dir_to_search} is not a directory."
52
+ puts "It should be your project directory (i.e., the one containing your <projectname.xcodeproject>)."
53
+ exit 1
54
+ end
55
+ else
56
+ dir_to_search = "."
57
+ end
58
+
59
+ project_files = Dir.foreach(dir_to_search).find_all { |x| /\.xcodeproj$/.match(x) }
60
+ if project_files.empty?
61
+ puts "Found no *.xcodeproj files in dir #{dir_to_search}."
62
+ exit 1
63
+ end
64
+ if project_files.count > 1
65
+ puts "Found several *.xcodeproj files in dir #{dir_to_search}."
66
+ puts "Found: #{project_files.join("\n")}"
67
+ puts "We don't yet support this. Please setup calabash manually."
68
+ exit 1
69
+ end
70
+ return dir_to_search,project_files
71
+ end
72
+
73
+
74
+ def is_json?(str)
75
+ str[0..0] == '{'
76
+ end
77
+
78
+ def calabash_submit(args)
79
+ if args.size < 2
80
+ msg("Error") do
81
+ puts "You must supply at path to ipa and secret."
82
+ end
83
+ exit 1
84
+ end
85
+
86
+ ipa_file = args[0]
87
+ if not File.exists?(ipa_file)
88
+ msg("Error") do
89
+ puts "Unable to find .ipa at '#{ipa_file}'"
90
+ end
91
+ exit 1
92
+ end
93
+
94
+ secret = args[1]
95
+
96
+ archive_path = "#{Tempfile.new("archive").path}.zip"
97
+
98
+ feature_path = "features"
99
+ if args.length == 3
100
+ msg("Error") do
101
+ puts "Not implemented: You can't supply a path to features folder yet."
102
+ puts "You should cd into your project folder containing your features folder"
103
+ puts "and then run this command again"
104
+ end
105
+ exit 1
106
+ end
107
+ system ("zip -r -o #{archive_path} #{feature_path}")
108
+
109
+
110
+
111
+ url = ENV['SUBMIT_URL'] || "https://www.lesspainful.com/cmd_upload"
112
+
113
+ msg("Info") do
114
+ puts "Uploading ipa and features to #{url}"
115
+ end
116
+ result = `curl -F "secret=#{secret}" -F "app=@#{ipa_file}" -F "env=@#{archive_path}" #{url}`
117
+
118
+ if is_json? result
119
+ json_result = JSON.parse(result)
120
+ puts "Test status is '#{json_result['status']}"
121
+ puts "Test id is '#{json_result['id']}"
122
+ puts "You can see the test result here: #{json_result['url']}"
123
+ puts "You can pull the status by using this command:"
124
+ puts "curl -F \"secret=#{secret}\" -F \"id=#{json_result['id']}\" https://www.lesspainful.com/cmd_status"
125
+ else
126
+ puts result
127
+ end
128
+
129
+ end
130
+
@@ -0,0 +1,334 @@
1
+ require "calabash-cucumber/version"
2
+ require 'rexml/rexml'
3
+ require "rexml/document"
4
+
5
+
6
+ def detect_accessibility_support
7
+ dirs = Dir.glob(File.join(File.expand_path("~/Library"),"Application Support","iPhone Simulator","*.*","Library","Preferences"))
8
+ dirs.each do |sim_pref_dir|
9
+ fp = File.expand_path("#{sim_pref_dir}/com.apple.Accessibility.plist")
10
+ out = `defaults read "#{fp}" ApplicationAccessibilityEnabled`
11
+
12
+ if not(File.exists?(fp)) || out.split("\n")[0] == "0"
13
+ msg("Warn") do
14
+ puts "Accessibility is not enabled for simulator: #{sim_pref_dir}"
15
+ puts "Enabled accessibility as described here:"
16
+ puts "https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide"
17
+ puts "Alternatively run command:"
18
+ puts "calabash-ios sim acc"
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+
25
+ def calabash_setup(args)
26
+ puts "Checking if Xcode is running..."
27
+ res = `ps x -o pid,command | grep -v grep | grep Contents/MacOS/Xcode`
28
+ if res==""
29
+ puts "Xcode not running."
30
+ project_name, project_path, xpath = find_project_files(args)
31
+ setup_project(project_name, project_path, xpath)
32
+
33
+ detect_accessibility_support
34
+
35
+ msg("Setup done") do
36
+
37
+ puts "Please validate by running the -cal target"
38
+ puts "from Xcode."
39
+ puts "When starting the iOS Simulator using the"
40
+ puts "new -cal target, you should see:\n\n"
41
+ puts ' "Started LPHTTP server on port 37265"'
42
+ puts "\nin the application log in Xcode."
43
+ puts "\n\n"
44
+ puts "After validating, you can generate a features folder:"
45
+ puts "Go to your project (the dir containing the .xcodeproj file)."
46
+ puts "Then run calabash-ios gen"
47
+ puts "(if you don't already have a features folder)."
48
+ end
49
+
50
+ else
51
+ puts "Xcode is running. We'll be changing the project file so we'd better stop it."
52
+ puts "Please stop XCode and run setup again"
53
+ exit(0)
54
+ end
55
+ end
56
+
57
+ def find_project_files(args)
58
+ dir_to_search, project_files = ensure_correct_path(args)
59
+
60
+ xc_project_file = project_files[0]
61
+ project_name = xc_project_file.split(".xcodeproj")[0]
62
+ puts "Found Project: #{project_name}"
63
+ pbx_dir = "#{dir_to_search}/#{xc_project_file}"
64
+ pbx_files = Dir.foreach(pbx_dir).find_all { |x| /\.pbxproj$/.match(x) }
65
+ if pbx_files.empty?
66
+ puts "Found no *.pbxproj files in dir #{xc_project_file}."
67
+ puts "Please setup calabash manually."
68
+ exit 1
69
+ elsif pbx_files.count > 1
70
+ puts "Found several *.pbxproj files in dir #{xc_project_file}."
71
+ puts "Found: #{pbx_files.join("\n")}"
72
+ puts "We don't yet support this. Please setup calabash manually."
73
+ exit 1
74
+ end
75
+
76
+ return project_name, dir_to_search, File.expand_path("#{dir_to_search}/#{xc_project_file}")
77
+ end
78
+
79
+ def calabash_download(args)
80
+ download_calabash(File.expand_path("."))
81
+ end
82
+
83
+ def has_proxy?
84
+ ENV['http_proxy'] ? true : false
85
+ end
86
+
87
+ def proxy
88
+ url_parts = URI.split(ENV['http_proxy'])
89
+ [url_parts[2], url_parts[3]]
90
+ end
91
+
92
+ def download_calabash(project_path)
93
+ file = 'calabash.framework'
94
+ ##Download calabash.framework
95
+ if not File.directory?(File.join(project_path, file))
96
+ msg("Info") do
97
+ zip_file = "calabash.framework-#{ENV['FRAMEWORK_VERSION']||Calabash::Cucumber::FRAMEWORK_VERSION}.zip"
98
+ puts "Did not find calabash.framework. I'll download it...'"
99
+ puts "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}"
100
+ require 'uri'
101
+
102
+ uri = URI.parse "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}"
103
+ success = false
104
+ if has_proxy?
105
+ proxy_url = proxy
106
+ connection = Net::HTTP::Proxy(proxy_url[0], proxy_url[1])
107
+ else
108
+ connection = Net::HTTP
109
+ end
110
+ begin
111
+ connection.start(uri.host, uri.port) do |http|
112
+ request = Net::HTTP::Get.new uri.request_uri
113
+
114
+ http.request request do |response|
115
+ if response.code == '200'
116
+ open zip_file, 'wb' do |io|
117
+ response.read_body do |chunk|
118
+ print "."
119
+ io.write chunk
120
+ end
121
+ end
122
+ success = true
123
+ else
124
+ puts "Got bad response code #{response.code}."
125
+ puts "Aborting..."
126
+ end
127
+ end
128
+ end
129
+ rescue SocketError => e
130
+ msg("Error") do
131
+ puts "Exception: #{e}"
132
+ puts "Unable to download Calabash. Please check connection."
133
+ end
134
+ exit 1
135
+ end
136
+ if success
137
+ puts "\nDownload done: #{file}. Unzipping..."
138
+ if not system("unzip -C -K -o -q -d #{project_path} #{zip_file} -x __MACOSX/* calabash.framework/.DS_Store")
139
+ msg("Error") do
140
+ puts "Unable to unzip file: #{zip_file}"
141
+ puts "You must install manually."
142
+ end
143
+ exit 1
144
+ end
145
+ FileUtils.rm(zip_file)
146
+ else
147
+ exit 0
148
+ end
149
+ end
150
+ else
151
+ msg("Info") do
152
+ puts "Found calabash.framework in #{File.expand_path(project_path)}."
153
+ puts "Shall I delete it and download the latest matching version?"
154
+ puts "Please answer yes (y) or no (n)"
155
+ answer = STDIN.gets.chomp
156
+ if (answer == 'yes' or answer == 'y')
157
+ FileUtils.rm_r File.join(project_path, file)
158
+ return download_calabash(project_path)
159
+ else
160
+ puts "Not downloading..."
161
+ end
162
+ end
163
+ end
164
+ file
165
+ end
166
+
167
+ def setup_project(project_name, project_path, path)
168
+ ##Ensure exists and parse
169
+ proj_file = "#{path}/project.pbxproj"
170
+ if not File.exists?(proj_file)
171
+ msg("Error") do
172
+ puts "Directory #{path} doesn't contain #{proj_file}"
173
+ end
174
+ exit 1
175
+ end
176
+
177
+ pwd = FileUtils.pwd
178
+ FileUtils.cd project_path
179
+ ##Backup
180
+ if File.exists? "#{proj_file}.bak"
181
+ msg("Error") do
182
+ puts "Backup file already exists. #{proj_file}.bak"
183
+ puts "For safety, I won't overwrite this file."
184
+ puts "You must manually move this file, if you want to"
185
+ puts "Run calabash-ios setup again."
186
+ end
187
+ exit 1
188
+ end
189
+
190
+ file = download_calabash(project_path)
191
+
192
+ msg("Info") do
193
+ puts "Setting up project file for calabash-ios."
194
+ end
195
+
196
+
197
+ FileUtils.cd pwd
198
+
199
+ ##Backup
200
+ msg("Info") do
201
+ puts "Making backup of project file: #{proj_file}"
202
+ FileUtils.cp(proj_file, "#{proj_file}.bak")
203
+ puts "Saved as #{proj_file}.bak"
204
+ end
205
+
206
+ path_to_setup = File.join(File.dirname(__FILE__), 'CalabashSetup')
207
+ setup_cmd = %Q[#{path_to_setup} "#{path}" "#{project_name}"]
208
+ system(setup_cmd)
209
+
210
+ end
211
+
212
+
213
+
214
+ require 'calabash-cucumber/launch/simulator_helper'
215
+ def validate_setup(args)
216
+ if args.length > 0
217
+ if args[0].end_with?(".ipa")
218
+ validate_ipa(args[0])
219
+ elsif args[0].end_with?(".app")
220
+ validate_app(args[0])
221
+ else
222
+ msg("Error") do
223
+ puts "File should end with .app or .ipa"
224
+ end
225
+ exit 1
226
+ end
227
+ else
228
+ dd_dir = Calabash::Cucumber::SimulatorHelper.derived_data_dir_for_project
229
+ if not dd_dir
230
+ puts "Unable to find iOS project."
231
+ puts "You should run this command from an iOS project directory."
232
+ exit 1
233
+ end
234
+ app_bundles = Dir.glob(File.join(dd_dir, "Build", "Products", "*", "*.app"))
235
+ sim_dirs = Dir.glob(File.join(dd_dir, "Build", "Products", "Debug-iphonesimulator", "*.app"))
236
+ sim_dirs = sim_dirs.concat(Dir.glob(File.join(dd_dir, "Build", "Products", "Calabash-iphonesimulator", "*.app")))
237
+ if sim_dirs.empty?
238
+ msg = ["Have you built your app for simulator?"]
239
+ msg << "You should build the -cal target and your normal target"
240
+ msg << "(with configuration Debug)."
241
+ msg << "Searched dir: #{dd_dir}/Build/Products"
242
+ msg("Error") do
243
+ puts msg.join("\n")
244
+ end
245
+ exit 1
246
+ elsif sim_dirs.count != 2
247
+ msg = ["Have you built your app for simulator?"]
248
+ msg << "You should build the -cal target and your normal target"
249
+ msg << "(with configuration Debug)."
250
+ msg << "Searched dir: #{dd_dir}/Build/Products"
251
+ msg("Error") do
252
+ puts msg.join("\n")
253
+ end
254
+ exit 1
255
+ end
256
+ out_debug = `otool "#{sim_dirs[0]}"/* -o 2> /dev/null | grep CalabashServer`
257
+ out_cal = `otool "#{sim_dirs[1]}"/* -o 2> /dev/null | grep CalabashServer 2> /dev/null`
258
+ ok = (not /CalabashServer/.match(out_debug)) and /CalabashServer/.match(out_cal)
259
+ if ok
260
+ msg("OK") do
261
+ puts "Your configuration seems ok."
262
+ puts "app in directory:"
263
+ puts sim_dirs[0]
264
+ puts "does not have calabash.framework linked in."
265
+ puts "directory:"
266
+ puts sim_dirs[1]
267
+ puts "does."
268
+ end
269
+ else
270
+ msg("Fail") do
271
+ puts "Your configuration looks bad."
272
+ if (not /CalabashServer/.match(out_debug))
273
+ puts "WARNING: You Debug build seems to be linking with Calabash."
274
+ puts "You should restore your xcodeproject file from backup."
275
+ else
276
+ puts "app in directory"
277
+ puts sim_dirs[1]
278
+ puts "does not have calabash.framework linked in."
279
+ end
280
+ end
281
+ end
282
+ end
283
+
284
+
285
+ end
286
+
287
+ def validate_ipa(ipa)
288
+ require 'tmpdir'
289
+ fail = false
290
+ Dir.mktmpdir do |dir|
291
+ if not system("unzip -C -K -o -q -d #{dir} #{ipa}")
292
+ msg("Error") do
293
+ puts "Unable to unzip ipa: #{ipa}"
294
+ end
295
+ Dir
296
+ fail = true
297
+ end
298
+
299
+ app_dir = Dir.foreach("#{dir}/Payload").find {|d| /\.app$/.match(d)}
300
+ app = app_dir.split(".")[0]
301
+ res = `otool "#{File.expand_path(dir)}/Payload/#{app_dir}/#{app}" -o 2> /dev/null | grep CalabashServer`
302
+ msg("Info") do
303
+ if /CalabashServer/.match(res)
304
+ puts "Ipa: #{ipa} *contains* calabash.framework"
305
+ else
306
+ puts "Ipa: #{ipa} *does not contain* calabash.framework"
307
+ end
308
+ end
309
+
310
+ end
311
+ if fail
312
+ exit(1)
313
+ end
314
+
315
+ end
316
+
317
+ def validate_app(app)
318
+ if not File.directory?app
319
+ msg("Error") do
320
+ puts "Path: #{app} is not a directory."
321
+ end
322
+ exit 1
323
+ end
324
+ out = `otool "#{File.expand_path(app)}"/* -o 2> /dev/null | grep CalabashServer`
325
+
326
+ msg("Info") do
327
+ if /CalabashServer/.match(out)
328
+ puts "App: #{app} *contains* calabash.framework"
329
+ else
330
+ puts "App: #{app} *does not contain* calabash.framework"
331
+ end
332
+ end
333
+
334
+ end