Class: Frank::CLI
Constant Summary
collapse
- WITHOUT_SERVER =
"without-cocoa-http-server"
- WITHOUT_ASYNC_SOCKET =
"without-cocoa-async-socket"
- WITHOUT_LUMBERJACK =
"without-cocoa-lumberjack"
- XCODEBUILD_OPTIONS =
%w{workspace project scheme target configuration}
- WITHOUT_DEPS =
'without-dependencies'
Frank::Cucumber::WaitHelper::POLL_SLEEP, Frank::Cucumber::WaitHelper::TIMEOUT
Instance Attribute Summary
#application_path, #sdk, #version
Class Method Summary
collapse
Instance Method Summary
collapse
#enforce, #launch_app, #launch_ios_app, #launch_mac_app, #path_is_mac_app, #quit_mac_app_if_running, #relaunch_mac_app, #simulator_client, #simulator_direct_client
#accessibility_frame, #app_exec, #base_server_url, #check_element_does_not_exist, #check_element_does_not_exist_or_is_not_visible, #check_element_exists, #check_element_exists_and_is_visible, #check_navigation_title_with_text_exists, #check_view_with_mark_does_not_exist, #check_view_with_mark_exists, #drag_with_initial_delay, #element_exists, #element_is_not_hidden, #fill_in, #frank_server, #frankly_current_orientation, #frankly_device_name, #frankly_dump, #frankly_is_accessibility_enabled, #frankly_map, #frankly_oriented_landscape?, #frankly_oriented_portrait?, #frankly_os_version, #frankly_ping, #frankly_screenshot, #frankly_set_orientation, #get_selector_quote, #is_ipad, #is_iphone, #is_mac, #navigation_title_with_text_exists, #selector_engine, test_on_physical_device_via_bonjour, #test_on_physical_device_with_ip, #touch, use_shelley_from_now_on, #view_with_mark_exists, #wait_for_element_to_exist, #wait_for_element_to_exist_and_then_touch_it, #wait_for_element_to_not_exist, #wait_for_frank_to_come_up, #wait_for_nothing_to_be_animating
#set_location
#press_home_on_simulator, #quit_double_simulator, #quit_simulator, #rotate_simulator_left, #rotate_simulator_right, #shake_simulator, #simulate_hardware_keyboard, #simulate_memory_warning, #simulator_hardware_menu_press, #simulator_reset_data, #start_recording, #stop_recording, #toggle_call_status_bar
#double_tap, #double_tap_point, #drag_thumb_in_slider, #drag_thumb_in_slider_with_default_duration, #tap_and_hold, #tap_and_hold_point
#scroll_table_view, #scroll_view_to_bottom, #scroll_view_to_position, #scroll_view_to_top
#type_into_keyboard, #type_shortcut
wait_until
Class Method Details
.source_root ⇒ Object
17
18
19
|
# File 'lib/frank-cucumber/cli.rb', line 17
def self.source_root
File.join( File.dirname(__FILE__), '..','..','frank-skeleton' )
end
|
Instance Method Details
#authorize ⇒ Object
227
228
229
230
|
# File 'lib/frank-cucumber/cli.rb', line 227
def authorize
bundle_id = get_mac_bundle_id
run %Q|sudo sqlite3 /Library/Application\\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access values ('kTCCServiceAccessibility', '#{bundle_id}', 0, 1, 0, NULL);"|
end
|
#build(*args) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/frank-cucumber/cli.rb', line 76
def build(*args)
clean = !options['noclean']
use_plugins = !options['no-plugins']
exclude_dependencies = options[WITHOUT_DEPS] || []
in_root do
unless File.directory? 'Frank'
if yes? "You don't appear to have set up a Frank directory for this project. Would you like me to set that up now? Type 'y' or 'yes' if so."
invoke :skeleton
else
say "OK, in that case there's not much I can do for now. Whenever you change your mind and want to get your project setup with Frank simply run `frank setup` from the root of your project directory."
say "Bye bye for now!"
exit 11
end
end
end
static_bundle = 'frank_static_resources.bundle'
if clean
remove_dir build_output_dir
end
build_steps = 'build'
if clean
build_steps = 'clean ' + build_steps
end
plugins = use_plugins ? gather_plugins : []
say "Detected plugins: #{plugins.map {|p| p.name}.join(', ')}" unless plugins.empty?
say "Excluding plugin dependencies: #{exclude_dependencies.join(', ')}" unless exclude_dependencies.empty?
plugins.each {|plugin| plugin.write_xcconfig(exclude_dependencies)}
xcconfig_data = Frank::Plugins::Plugin.generate_core_xcconfig(plugins)
xcconfig_file = 'Frank/frank.xcconfig'
File.open(xcconfig_file,'w') {|f| f.write(xcconfig_data) }
= XCODEBUILD_OPTIONS.map{ |o| "-#{o} \"#{options[o]}\"" if options[o] and (o != "target" or options['workspace'] == nil)}.compact.join(' ')
if options['scheme'] || options['configuration']
separate_configuration_option = ""
else
separate_configuration_option = "-configuration Debug"
end
xcodebuild_args = args.join(" ")
if options['mac']
run %Q|xcodebuild -xcconfig #{xcconfig_file} #{build_steps} #{extra_opts} #{separate_configuration_option} DEPLOYMENT_LOCATION=YES DSTROOT="#{build_output_dir}" FRANK_LIBRARY_SEARCH_PATHS="#{frank_lib_search_paths}" #{xcodebuild_args}|
else
+= " -arch #{options['arch']}"
run %Q|xcodebuild -xcconfig #{xcconfig_file} #{build_steps} #{extra_opts} #{separate_configuration_option} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO DEPLOYMENT_LOCATION=YES DSTROOT="#{build_output_dir}" FRANK_LIBRARY_SEARCH_PATHS="#{frank_lib_search_paths}" #{xcodebuild_args}|
end
exit $?.exitstatus if not $?.success?
app = Dir.glob("#{build_output_dir}/*.app").delete_if { |x| x =~ /\/#{app_bundle_name}$/ }
app = app.first
FileUtils.cp_r("#{app}/.", frankified_app_dir)
if options['mac']
in_root do
FileUtils.cp_r(
File.join( 'Frank',static_bundle),
File.join( frankified_app_dir, "Contents", "Resources", static_bundle )
)
end
else
fix_frankified_apps_bundle_identifier
in_root do
FileUtils.cp_r(
File.join( 'Frank',static_bundle),
File.join( frankified_app_dir, static_bundle )
)
end
end
end
|
#build_and_launch ⇒ Object
162
163
164
165
|
# File 'lib/frank-cucumber/cli.rb', line 162
def build_and_launch
invoke :build
invoke :launch
end
|
#console ⇒ Object
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/frank-cucumber/cli.rb', line 206
def console
begin
require 'pry'
rescue LoadError
say 'The Frank console requires the pry gem.'
say 'Simply run `sudo gem install pry` (the `sudo` bit might be optional), and then try again. Thanks!'
exit 41
end
Frank::Cucumber::FrankHelper.use_shelley_from_now_on
console = Frank::Console.new
Frank::Cucumber::FrankHelper.test_on_physical_device_via_bonjour if options[:bonjour]
Frank::Cucumber::FrankHelper.server_base_url = options[:server] if options[:server]
if console.check_for_running_app
console.pry
end
end
|
#deauthorize ⇒ Object
233
234
235
236
|
# File 'lib/frank-cucumber/cli.rb', line 233
def deauthorize
bundle_id = get_mac_bundle_id
run %Q|sudo sqlite3 /Library/Application\\ Support/com.apple.TCC/TCC.db "DELETE FROM access WHERE client = '#{bundle_id}'"|
end
|
#inspect ⇒ Object
198
199
200
201
|
# File 'lib/frank-cucumber/cli.rb', line 198
def inspect
run 'open http://localhost:37265'
end
|
#launch ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/frank-cucumber/cli.rb', line 171
def launch
$DEBUG = options[:debug]
version = case options[:idiom].downcase
when 'iphone'
'iphone'
when 'ipad'
'ipad'
else
say "idiom must be either iphone or ipad. You supplied '#{options[:idiom]}'", :red
exit 10
end
in_root do
unless File.exists? frankified_app_dir
say "A Frankified version of the app doesn't appear to have been built. Building one now"
say "..."
invoke :build
end
say "LAUNCHING APP..."
launch_app(frankified_app_dir, options[:sdk], version, false)
end
end
|
#setup ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/frank-cucumber/cli.rb', line 37
def setup
@libs = %w(Shelley CocoaAsyncSocket CocoaLumberjack CocoaHTTPServer Frank)
@libsMac = %w(ShelleyMac CocoaAsyncSocketMac CocoaLumberjackMac CocoaHTTPServerMac FrankMac)
@libs -= %w(CocoaHTTPServer) if options[WITHOUT_SERVER]
@libsMac -= %w(CocoaHTTPServerMac) if options[WITHOUT_SERVER]
@libs -= %w(CocoaAsyncSocket) if options[WITHOUT_ASYNC_SOCKET]
@libsMac -= %w(CocoaAsyncSocketMac) if options[WITHOUT_ASYNC_SOCKET]
@libs -= %w(CocoaLumberjack) if options[WITHOUT_LUMBERJACK]
@libsMac -= %w(CocoaLumberjackMac) if options[WITHOUT_LUMBERJACK]
directory ".", "Frank"
Frankifier.frankify!( File.expand_path('.'), :build_config => options[:build_configuration], :target => options[:target], :project => options[:project] )
end
|
#skeleton ⇒ Object
23
24
25
|
# File 'lib/frank-cucumber/cli.rb', line 23
def skeleton
invoke :setup
end
|
#update ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/frank-cucumber/cli.rb', line 53
def update
%w{libFrank.a libCocoaAsyncSocket.a libCocoaLumberjack.a libCocoaHTTPServer.a libShelley.a libFrankMac.a libShelleyMac.a libCocoaAsyncSocketMac.a libCocoaLumberjackMac.a libCocoaHTTPServerMac.a}.each do |f|
copy_file f, File.join( 'Frank', f ), :force => true
end
directory( 'frank_static_resources.bundle', 'Frank/frank_static_resources.bundle', :force => true )
if yes? "\nOne or more static libraries may have been updated. For these changes to take effect the 'frankified_build' directory must be cleaned. Would you like me to do that now? Type 'y' or 'yes' to delete the contents of frankified_build."
remove_file('Frank/frankified_build')
end
end
|