honeydew 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/README.md +1 -4
  2. data/Rakefile +2 -2
  3. data/{server → android-server}/.gitignore +0 -0
  4. data/{server → android-server}/pom.xml +5 -5
  5. data/{server → android-server}/repo/com/google/android/uiautomator/4.1.1.4/_maven.repositories +0 -0
  6. data/{server → android-server}/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.jar +0 -0
  7. data/{server → android-server}/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.pom +0 -0
  8. data/{server → android-server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.jar +0 -0
  9. data/{server → android-server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.pom +0 -0
  10. data/{server → android-server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/maven-metadata-local.xml +0 -0
  11. data/{server → android-server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/_maven.repositories +0 -0
  12. data/{server → android-server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.jar +0 -0
  13. data/{server → android-server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.pom +0 -0
  14. data/{server → android-server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/maven-metadata-local.xml +0 -0
  15. data/{server → android-server}/repo/commons-jxpath/commons-jxpath/maven-metadata-local.xml +0 -0
  16. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/Action.java +1 -1
  17. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/ActionsExecutor.java +2 -2
  18. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/Command.java +1 -1
  19. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/Result.java +1 -1
  20. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/TestRunner.java +3 -3
  21. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/Click.java +3 -3
  22. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/ClickAndWaitForNewWindow.java +3 -3
  23. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/DumpWindowHierarchy.java +3 -3
  24. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/HasSettingsMenuItem.java +4 -4
  25. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/InspectOptionInSettingsMenu.java +2 -2
  26. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/IsButtonPresent.java +3 -3
  27. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/IsChildCountEqualTo.java +3 -3
  28. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/IsElementWithNestedTextPresent.java +3 -3
  29. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/IsOptionInSettingsMenuDisabled.java +1 -1
  30. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/IsOptionInSettingsMenuEnabled.java +1 -1
  31. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/IsTextPresent.java +3 -3
  32. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/LaunchApp.java +3 -3
  33. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/LaunchHome.java +3 -3
  34. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/LongClick.java +3 -3
  35. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/PressBack.java +3 -3
  36. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/PressEnter.java +4 -4
  37. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/SelectFromAppsList.java +3 -3
  38. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/SelectMenuInSettings.java +3 -3
  39. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/SetText.java +3 -3
  40. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/SetTextByIndex.java +2 -2
  41. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/SetTextByLabel.java +3 -3
  42. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/Unlock.java +3 -3
  43. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/actions/WakeUp.java +4 -4
  44. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/httpd/NanoHTTPD.java +2 -2
  45. data/{server/src/main/java/com/amplify/honeydew → android-server/src/main/java/com/uiautomator_cucumber/android_server}/httpd/RemoteCommandReceiver.java +5 -5
  46. data/example/Gemfile +3 -3
  47. data/honeydew.gemspec +6 -7
  48. data/lib/honeydew/device.rb +12 -3
  49. data/lib/honeydew/device_actions.rb +62 -61
  50. data/lib/honeydew/device_commands.rb +3 -3
  51. data/lib/honeydew/device_matchers.rb +14 -36
  52. data/lib/honeydew/hooks.rb +0 -0
  53. data/lib/honeydew/step_definitions.rb +75 -0
  54. data/lib/honeydew/version.rb +1 -1
  55. data/lib/honeydew.rb +2 -2
  56. data/lib/tasks/honeydew.rake +7 -0
  57. data/spec/honeydew/device_matchers_spec.rb +42 -21
  58. data/spec/honeydew/device_spec.rb +35 -37
  59. metadata +68 -57
@@ -4,146 +4,147 @@ module Honeydew
4
4
  module DeviceActions
5
5
  include Honeydew::DeviceCommands
6
6
 
7
- def click_button button_text
8
- perform_action :click, :text => button_text, :type => 'Button'
7
+ def click_button(button_text)
8
+ perform_action :action => 'click', :arguments => {:text => button_text, :type => 'Button'}
9
9
  end
10
10
 
11
- def click_button_and_wait button_text
12
- perform_action :click_and_wait_for_new_window, :text => button_text, :type => 'Button'
11
+ def click_button_and_wait(button_text)
12
+ perform_action :action => 'click_and_wait_for_new_window', :arguments => {:text => button_text, :type => 'Button'}
13
13
  end
14
14
 
15
- def click_text text
16
- perform_action :click, :text => text, :type => 'TextView'
15
+ def click_text(text)
16
+ perform_action :action => 'click', :arguments => {:text => text, :type => 'TextView'}
17
17
  end
18
18
 
19
- def click_text_and_wait text
20
- perform_action :click_and_wait_for_new_window, :text => text, :type => 'TextView'
19
+ def click_text_and_wait(text)
20
+ perform_action :action => 'click_and_wait_for_new_window', :arguments => {:text => text, :type => 'TextView'}
21
21
  end
22
22
 
23
- def click_element element_description
24
- perform_action :click, :description => element_description
23
+ def click_element(element_description)
24
+ perform_action :action => 'click', :arguments => {:description => element_description}
25
25
  end
26
26
 
27
- def click_element_and_wait element_description
28
- perform_action :click_and_wait_for_new_window, :description => element_description
27
+ def click_element_and_wait(element_description)
28
+ perform_action :action => 'click_and_wait_for_new_window', :arguments => {:description => element_description}
29
29
  end
30
30
 
31
31
  def fill_in field_description, options = {with: ''}
32
- perform_action :set_text, :description => field_description, :text => options[:with]
32
+ perform_action :action => 'set_text', :arguments => {:description => field_description, :text => options[:with]}
33
33
  end
34
34
 
35
35
  def fill_in_by_label field_label, options = {with: ''}
36
- perform_action :set_text_by_label, :label => field_label, :text => options[:with]
36
+ perform_action :action => 'set_text_by_label', :arguments => {:label => field_label, :text => options[:with]}
37
37
  end
38
38
 
39
39
  def fill_in_by_index index, options = {with: ''}
40
- perform_action :set_text_by_index, :index => index, :text => options[:with]
40
+ perform_action :action => 'set_text_by_index', :arguments => {:index => index, :text => options[:with]}
41
41
  end
42
42
 
43
43
  def launch_home
44
- perform_action :launch_home
44
+ perform_action :action => 'launch_home'
45
45
  end
46
46
 
47
- def launch_settings_app app_name
48
- perform_action :select_from_apps_list, :appName => app_name
47
+ def launch_settings_app(app_name)
48
+ perform_action :action => 'select_from_apps_list', :arguments => {:appName => app_name}
49
49
  end
50
50
 
51
- def launch_application application_name
52
- perform_action :launch_app, :appName => application_name, :attempts => 3
51
+ def launch_application(application_name)
52
+ perform_action :action => 'launch_app', :arguments => {:appName => application_name}, :attempts => 3
53
53
  end
54
54
 
55
- def long_click_element element_description
56
- perform_action :long_click, :description => element_description
55
+ def long_click_element(element_description)
56
+ perform_action :action => 'long_click', :arguments => {:description => element_description}
57
57
  end
58
58
 
59
- def launch_settings_item item_name
60
- perform_action :select_menu_in_settings, :menuName => item_name
59
+ def launch_settings_item(item_name)
60
+ perform_action :action => 'select_menu_in_settings', :arguments => {:menuName => item_name}
61
61
  end
62
62
 
63
+
63
64
  def press_back
64
- perform_action :press_back
65
+ perform_action :action => 'press_back'
65
66
  end
66
67
 
67
68
  def press_enter
68
- perform_action :press_enter
69
+ perform_action :action => 'press_enter'
69
70
  end
70
71
 
71
72
  def unlock
72
- perform_action :unlock
73
+ perform_action :action => 'unlock'
73
74
  end
74
75
 
75
76
  def wake_up
76
- perform_action :wake_up
77
+ perform_action :action => 'wake_up'
77
78
  end
78
79
 
79
- def perform_assertion action, arguments = {}, options = {}
80
- response = perform_action action, arguments, options
81
- response['success']
82
- rescue
83
- end
80
+ def perform_action(options)
81
+ ensure_tablet_ready
84
82
 
85
- def perform_action action, arguments = {}, options = {}
86
- timeout = options[:timeout]
83
+ command = options.slice(:action, :arguments)
84
+ timeout = options[:retry_until]
87
85
  attempts = options[:attempts]
88
86
 
89
- if timeout
90
- retry_until_timeout timeout, action, arguments
91
- elsif attempts
92
- retry_until_success attempts, action, arguments
93
- else
94
- execute_command action, arguments
95
- end
87
+ response =
88
+ if timeout
89
+ retry_until_timeout(timeout, command)
90
+ elsif attempts
91
+ retry_until_success(attempts, command)
92
+ else
93
+ execute_command(command)
94
+ end
95
+ log_action(command, response)
96
+ raise "Device: #{serial} :Action #{options} failed." unless response['success']
97
+ response
96
98
  end
97
99
 
98
100
  private
99
101
 
100
- def retry_until_success attempts, action, arguments
102
+ def retry_until_success(attempts, command)
101
103
  completed = false
102
104
  response = nil
103
105
  tries = 0
104
- until completed || tries >= attempts do
105
- response = execute_command action, arguments
106
+ until completed || (tries >= attempts) do
107
+ response = execute_command(command)
106
108
  completed = response['success']
107
109
  return response if completed
108
110
  tries += 1
109
111
  sleep 1
110
112
  end
111
- raise "Device: #{serial} : All #{attempts} attempts failed while performing #{action}, with arguments: #{arguments}"
113
+ log_action(command, response)
114
+ raise "Device: #{serial} : All #{attempts} attempts failed while performing #{command[:action]}, with arguments: #{command[:arguments]}"
112
115
  end
113
116
 
114
- def retry_until_timeout timeout, action, arguments
117
+ def retry_until_timeout(timeout, command)
115
118
  completed = false
116
119
  response = nil
117
120
  Timeout.timeout(timeout.to_i) do
118
121
  until completed do
119
122
  sleep 1
120
- response = execute_command action, arguments
123
+ response = execute_command(command)
121
124
  completed = response['success']
122
125
  end
123
126
  end
124
127
  return response
125
128
  rescue Timeout::Error
126
- raise "Device: #{serial} :Timeout while performing #{action}, with arguments: #{arguments}"
129
+ log_action(command, response)
130
+ raise "Device: #{serial} :Timeout while performing #{command[:action]}, with arguments: #{command[:arguments]}"
127
131
  end
128
132
 
129
- def execute_command action, arguments
130
- ensure_tablet_ready
131
-
132
- log "Device: #{serial} : executing command #{action} with arguments #{arguments}"
133
-
134
- command = stringify_keys(command: {action: action, arguments: arguments})
135
- response = RestClient.get device_endpoint, :params => command
133
+ def execute_command(command)
134
+ response = RestClient.get(device_endpoint, :params => stringify_keys(:command => command))
135
+ JSON.parse(response)
136
+ end
136
137
 
138
+ def log_action(command, response)
139
+ log "Device: #{serial} : executing command: #{command}"
137
140
  log "Device: #{serial} : responded with: #{response}"
138
-
139
- JSON.parse response
140
141
  end
141
142
 
142
- def stringify_keys arguments
143
- JSON.parse arguments.to_json
143
+ def stringify_keys(options)
144
+ JSON.parse(options.to_json)
144
145
  end
145
146
 
146
- def log message
147
+ def log(message)
147
148
  puts message
148
149
  end
149
150
  end
@@ -6,7 +6,7 @@ module Honeydew
6
6
  end
7
7
 
8
8
  def dump_window_hierarchy(local_path)
9
- path_in_device = perform_action('dump_window_hierarchy')['description']
9
+ path_in_device = perform_action(:action => 'dump_window_hierarchy')['description']
10
10
  adb "pull #{path_in_device} #{local_path}"
11
11
  end
12
12
 
@@ -41,7 +41,7 @@ module Honeydew
41
41
  def start_automation_server
42
42
  Thread.new do
43
43
  adb "push #{automation_server_jar_path} /data/local/tmp"
44
- adb "shell uiautomator runtest #{automation_test_jar_name} -c com.amplify.honeydew_server.TestRunner"
44
+ adb "shell uiautomator runtest #{automation_test_jar_name} -c com.uiautomator_cucumber.android_server.TestRunner"
45
45
  log "Device: #{serial} initiated the start of automation server"
46
46
  end
47
47
  at_exit do
@@ -81,4 +81,4 @@ module Honeydew
81
81
  end
82
82
 
83
83
  end
84
- end
84
+ end
@@ -1,54 +1,36 @@
1
1
  module Honeydew
2
2
  module DeviceMatchers
3
+
3
4
  def has_text?(text, timeout = Honeydew.config.timeout)
4
- perform_assertion :is_text_present,
5
- {:text => text},
6
- :timeout => timeout
5
+ perform_action :action => 'is_text_present', :arguments => {:text => text}, :retry_until => timeout
7
6
  end
8
7
 
9
8
  def has_element_with_description?(description, timeout = Honeydew.config.timeout)
10
- perform_assertion :is_text_present,
11
- {:description => description},
12
- :timeout => timeout
9
+ perform_action :action => 'is_text_present', :arguments => {:description => description}, :retry_until => timeout
13
10
  end
14
11
 
15
12
  def has_edit_text?(text, timeout = Honeydew.config.timeout)
16
- perform_assertion :is_text_present,
17
- {:text => text, :type => 'EditText'},
18
- :timeout => timeout
13
+ perform_action :action => 'is_text_present', :arguments => {:text => text, :type => 'EditText'}, :retry_until => timeout
19
14
  end
20
15
 
21
16
  def has_textview_text?(text, timeout = Honeydew.config.timeout)
22
- perform_assertion :is_text_present,
23
- {:text => text, :type => 'TextView'},
24
- :timeout => timeout
17
+ perform_action :action => 'is_text_present', :arguments => {:text => text, :type => 'TextView'}, :retry_until => timeout
25
18
  end
26
19
 
27
- def has_textview_with_text_and_description?(text, description, timeout = Honeydew.config.timeout)
28
- perform_assertion :is_text_present,
29
- {:text => text, :description => description, :type => 'TextView'},
30
- :timeout => timeout
20
+ def has_textview_with_text_and_description?(text, description, timeout=Honeydew.config.timeout)
21
+ perform_action :action => 'is_text_present', :arguments => {:text => text, :description => description, :type => 'TextView'}, :retry_until => timeout
31
22
  end
32
23
 
33
24
  def has_button?(button_text, timeout = Honeydew.config.timeout)
34
- perform_assertion :is_button_present,
35
- {:text => button_text},
36
- :timeout => timeout
25
+ perform_action(:action => 'is_button_present', :arguments => {:text => button_text}, :retry_until => timeout)
37
26
  end
38
27
 
39
28
  def has_child_count?(parent_element_description, child_element_description, child_count, timeout = Honeydew.config.timeout)
40
- perform_assertion :is_child_count_equal_to,
41
- {:parent_description => parent_element_description,
42
- :child_description => child_element_description,
43
- :child_count => child_count},
44
- :timeout => timeout
29
+ perform_action(:action => 'is_child_count_equal_to', :arguments => {:parent_description => parent_element_description, :child_description => child_element_description, :child_count => child_count}, :retry_until => timeout)
45
30
  end
46
31
 
47
32
  def has_element_with_nested_text?(parent_description, child_text, timeout = Honeydew.config.timeout)
48
- perform_assertion :is_element_with_nested_text_present,
49
- {:parent_description => parent_description,
50
- :child_text => child_text},
51
- :timeout => timeout
33
+ perform_action(:action => 'is_element_with_nested_text_present', :arguments => {:parent_description => parent_description, :child_text => child_text}, :retry_until => timeout)
52
34
  end
53
35
 
54
36
  def has_app_installed?(package_name)
@@ -56,19 +38,15 @@ module Honeydew
56
38
  end
57
39
 
58
40
  def is_option_in_setting_enabled?(item_name, option_names)
59
- perform_assertion :is_option_in_settings_menu_enabled,
60
- :menuName => item_name, :optionNames => option_names
41
+ perform_action :action => 'is_option_in_settings_menu_enabled', :arguments => {:menuName => item_name, :optionNames => option_names}
61
42
  end
62
43
 
63
44
  def is_option_in_setting_disabled?(item_name, option_names)
64
- perform_assertion :is_option_in_settings_menu_disabled,
65
- :menuName => item_name, :optionNames => option_names
45
+ perform_action :action => 'is_option_in_settings_menu_disabled', :arguments => {:menuName => item_name, :optionNames => option_names}
66
46
  end
67
47
 
68
48
  def has_settings_menu_item?(item_name, timeout = 10)
69
- perform_assertion :has_settings_menu_item,
70
- {:menuName => item_name},
71
- :timeout => timeout
49
+ perform_action(:action => 'has_settings_menu_item', :arguments => {:menuName => item_name}, :retry_until => timeout)
72
50
  end
73
51
  end
74
- end
52
+ end
File without changes
@@ -0,0 +1,75 @@
1
+ Given /^I unlock$/ do
2
+ Honeydew.current_device.unlock
3
+ end
4
+
5
+ Given /^I launch app "(.*?)"$/ do |app_name|
6
+ Honeydew.current_device.launch_application app_name
7
+ end
8
+
9
+ Given /^I launch home$/ do
10
+ Honeydew.current_device.launch_home
11
+ end
12
+
13
+ When /^I press back$/ do
14
+ Honeydew.current_device.press_back
15
+ end
16
+
17
+ Given /^I select "(.*?)" in the Settings view$/ do |menu_item|
18
+ Honeydew.current_device.launch_settings_item menu_item
19
+ end
20
+
21
+ Given /^I select app "(.*?)" from the Apps list in the Settings view$/ do |app_name|
22
+ Honeydew.current_device.launch_settings_app app_name
23
+ end
24
+
25
+ Given /^I should see text containing "(.*?)"$/ do |expected_text|
26
+ Honeydew.current_device.should have_textview_text expected_text
27
+ end
28
+
29
+ Given /^I enter text "(.*?)" into field with description "(.*?)"$/ do |text, field_description|
30
+ Honeydew.current_device.fill_in field_description, with: text
31
+ end
32
+
33
+ Given /^I press the "(.*?)" button$/ do |button_text|
34
+ Honeydew.current_device.click_button button_text
35
+ end
36
+
37
+ Given /^I press the "(.*?)" text$/ do |text|
38
+ Honeydew.current_device.click_text text
39
+ end
40
+
41
+ Given /^I press the element with description "(.*?)"$/ do |element_description|
42
+ Honeydew.current_device.click_element element_description
43
+ end
44
+
45
+ Given /^I long press the element with description "(.*?)"$/ do |element_description|
46
+ Honeydew.current_device.long_click_element element_description
47
+ end
48
+
49
+ When /^I wait up to (\d+) seconds for "(.*?)" to appear$/ do |timeout, text|
50
+ Honeydew.current_device.should have_textview_text text, timeout
51
+ end
52
+
53
+ When /^I wait up to (\d+) seconds for "(.*?)" to appear in edit text$/ do |timeout, text|
54
+ Honeydew.current_device.should have_edit_text text, timeout
55
+ end
56
+
57
+ Given /I uninstall the app "(.*?)" using ADB$/ do |pacakge_name|
58
+ Honeydew.current_device.uninstall_app pacakge_name
59
+ end
60
+
61
+ Given /I install the app "(.*?)" using ADB$/ do |apk_location|
62
+ Honeydew.current_device.install_app apk_location
63
+ end
64
+
65
+ Given /I reboot the device using ADB$/ do
66
+ Honeydew.current_device.reboot
67
+ end
68
+
69
+ Then /I see the app "(.*?)" installed using ADB$/ do |package_name|
70
+ Honeydew.current_device.should have_app_installed package_name
71
+ end
72
+
73
+ Then /I should see a button "(.*?)" with (package|description) as "(.*?)"$/ do |button_text, condition, package_name|
74
+ Honeydew.current_device.should have_button button_text
75
+ end
@@ -1,3 +1,3 @@
1
1
  module Honeydew
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
data/lib/honeydew.rb CHANGED
@@ -3,8 +3,8 @@ require 'bundler/setup'
3
3
  require 'restclient'
4
4
  require 'active_support/core_ext'
5
5
 
6
- require 'honeydew/version'
7
- require 'honeydew/device'
6
+ require "honeydew/version"
7
+ require "honeydew/device"
8
8
 
9
9
  module Honeydew
10
10
  class Configuration
@@ -0,0 +1,7 @@
1
+ require 'honeydew'
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new(:honeydew, 'Run honeydew cucumber tests') do |t|
5
+ t.profile = 'honeydew'
6
+ t.cucumber_opts = "--tags @honeydew"
7
+ end
@@ -1,37 +1,58 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Honeydew::DeviceMatchers do
4
- let(:device) do
5
- Class.new do
6
- include Honeydew::DeviceMatchers
7
- def perform_assertion; end
8
- end.new
4
+
5
+ class DeviceTest
6
+ include Honeydew::DeviceMatchers
7
+ def perform_action; end
9
8
  end
10
9
 
11
- describe '#has_textview_text' do
12
- let(:text) { 'some text' }
10
+ let (:device) { DeviceTest.new }
11
+
12
+ describe "#has_textview_text" do
13
+ let (:text) { "some text" }
14
+
15
+ it "should perform action for is_text_present" do
16
+ device.should_receive(:perform_action).with(hash_including({action: "is_text_present"}))
17
+
18
+ device.has_textview_text? text
19
+ end
20
+
21
+ it "should retry for a default timeout" do
22
+ device.should_receive(:perform_action).with(hash_including({retry_until: Honeydew.config.timeout}))
23
+
24
+ device.has_textview_text? text
25
+ end
13
26
 
14
- it 'should perform action for is_text_present' do
15
- device.should_receive(:perform_assertion)
16
- .with(:is_text_present,
17
- hash_including(text: text, type: 'TextView'),
18
- timeout: Honeydew.config.timeout)
27
+ it "should pass the arguments for the text view" do
28
+ device.should_receive(:perform_action).with(hash_including({arguments: { text: text, type: 'TextView'}}))
19
29
 
20
30
  device.has_textview_text? text
21
31
  end
32
+
22
33
  end
23
34
 
24
- describe '#has_textview_with_text_and_description' do
25
- let(:text) { 'some text' }
26
- let(:description) { 'some description' }
35
+ describe "#has_textview_with_text_and_description" do
36
+ let (:text) { "some text" }
37
+ let (:description) { "some description" }
38
+
39
+ it "should perform action for is_text_present" do
40
+ device.should_receive(:perform_action).with(hash_including({action: "is_text_present"}))
41
+
42
+ device.has_textview_with_text_and_description? text, description
43
+ end
44
+
45
+ it "should retry for a default timeout" do
46
+ device.should_receive(:perform_action).with(hash_including({retry_until: Honeydew.config.timeout}))
27
47
 
28
- it 'performs the is_text_present action' do
29
- device.should_receive(:perform_assertion)
30
- .with(:is_text_present,
31
- hash_including(text: text, type: 'TextView'),
32
- timeout: Honeydew.config.timeout)
48
+ device.has_textview_with_text_and_description? text, description
49
+ end
50
+
51
+ it "should pass the arguments for the text view" do
52
+ device.should_receive(:perform_action).with(hash_including({arguments: { text: text, description: description, type: 'TextView'}}))
33
53
 
34
54
  device.has_textview_with_text_and_description? text, description
35
55
  end
56
+
36
57
  end
37
- end
58
+ end
@@ -1,68 +1,66 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Honeydew::Device, :silence_puts do
4
- let(:response) { '{"success": true }' }
5
- let(:device) { Honeydew::Device.new('ABC123DEF') }
6
- let(:device_end_point) do
7
- "http://127.0.0.1:#{device.port}"
8
- end
4
+ let(:response) { "{ \"success\": true }" }
5
+ let(:command) { {"action" => '', "arguments" => {}} }
6
+ let(:serial) { "ABC123DEF" }
9
7
 
10
8
  before do
11
- RestClient.stub(:get).and_return(response)
9
+ @device = Honeydew::Device.new serial
10
+ @device_end_point = "http://127.0.0.1:#{@device.port}"
11
+ RestClient.stub(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
12
12
  end
13
13
 
14
- describe '#contains_textview_text?' do
15
- let(:text) { 'Ok' }
16
- let(:command) do
17
- {'action' => 'is_text_present',
18
- 'arguments' => {'text' => text, 'type' => 'TextView'}}
19
- end
14
+ describe "contains_textview_text?" do
15
+ let(:text) { "Ok" }
16
+ let(:command) { {"action" => 'is_text_present', "arguments" => {"text" => text, "type" => 'TextView'}} }
20
17
 
21
- it 'should make the call with command is_text_present' do
22
- RestClient.should_receive(:get).with(device_end_point, params: {'command' => command})
23
- device.contains_textview_text?(text)
18
+ it "should make the call with command is_text_present" do
19
+ RestClient.should_receive(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
20
+ @device.contains_textview_text?(text)
24
21
  end
25
22
 
26
- context 'on successful response' do
27
- let(:response) { '{ "success": true }' }
23
+ context "on successful response" do
24
+ let(:response) { "{ \"success\": true }" }
28
25
 
29
- it 'should return true' do
30
- device.contains_textview_text?(text).should be_true
26
+ it "should return true" do
27
+ @device.contains_textview_text?(text).should be_true
31
28
  end
32
29
  end
33
30
 
34
- context 'on failure response' do
35
- let(:response) { '{ "success": false }' }
31
+ context "on failure response" do
32
+ let(:response) { "{ \"success\": false }" }
36
33
 
37
- it 'should return false' do
38
- device.contains_textview_text?(text).should be_false
34
+ it "should return false" do
35
+ @device.contains_textview_text?(text).should be_false
39
36
  end
40
37
  end
41
38
  end
42
39
 
43
- describe '#contains_button?' do
44
- let(:text) { 'Ok' }
45
- let(:command) { {'action' => 'is_button_present', 'arguments' => {'text' => text}} }
40
+ describe "contains_button?" do
41
+ let(:text) { "Ok" }
42
+ let(:command) { {"action" => 'is_button_present', "arguments" => {"text" => text}} }
46
43
 
47
- it 'should make the call with command is_button_present' do
48
- RestClient.should_receive(:get).with(device_end_point, params: {'command' => command})
49
- device.contains_button?(text)
44
+ it "should make the call with command is_button_present" do
45
+ RestClient.should_receive(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
46
+ @device.contains_button?(text)
50
47
  end
51
48
 
52
- context 'on successful response' do
53
- let(:response) { '{ "success": true }' }
49
+ context "on successful response" do
50
+ let(:response) { "{ \"success\": true }" }
54
51
 
55
- it 'should return true' do
56
- device.contains_button?(text).should be_true
52
+ it "should return true" do
53
+ @device.contains_button?(text).should be_true
57
54
  end
58
55
  end
59
56
 
60
- context 'on failure response' do
61
- let(:response) { '{ "success": false }' }
57
+ context "on failure response" do
58
+ let(:response) { "{ \"success\": false }" }
62
59
 
63
- it 'should return false' do
64
- device.contains_button?(text).should be_false
60
+ it "should return false" do
61
+ @device.contains_button?(text).should be_false
65
62
  end
66
63
  end
67
64
  end
65
+
68
66
  end