melomel 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/melomel/bridge/ui.rb +19 -0
- data/lib/melomel/cucumber/alert_steps.rb +26 -15
- data/lib/melomel/cucumber/button_steps.rb +13 -7
- data/lib/melomel/cucumber/color_picker_steps.rb +12 -6
- data/lib/melomel/cucumber/data_grid_steps.rb +50 -40
- data/lib/melomel/cucumber/date_steps.rb +15 -9
- data/lib/melomel/cucumber/list_steps.rb +21 -15
- data/lib/melomel/cucumber/slider_steps.rb +14 -8
- data/lib/melomel/cucumber/text_steps.rb +12 -6
- data/lib/melomel/cucumber.rb +9 -0
- data/lib/melomel/flex.rb +1 -0
- data/lib/melomel/version.rb +1 -1
- metadata +4 -4
data/lib/melomel/bridge/ui.rb
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
# These add-on methods provide ease of use utility methods.
|
2
2
|
module Melomel
|
3
3
|
class Bridge
|
4
|
+
# Blocks until Melomel.busy in the Flash virtual machine is false.
|
5
|
+
#
|
6
|
+
# Returns nothing.
|
7
|
+
def wait()
|
8
|
+
loop do
|
9
|
+
break unless busy!
|
10
|
+
sleep 0.1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Checks if the Flash virtual machine is currently busy. See Melomel#busy
|
15
|
+
# in the Melomel asdocs for more information.
|
16
|
+
#
|
17
|
+
# Returns true if the Flash virtual machine is busy. Otherwise returns
|
18
|
+
# false.
|
19
|
+
def busy!
|
20
|
+
get_class!('Melomel').busy!
|
21
|
+
end
|
22
|
+
|
4
23
|
# Finds a list of display objects matching a class and hash of properties.
|
5
24
|
#
|
6
25
|
# class_name - The type of objects to search for.
|
@@ -1,29 +1,40 @@
|
|
1
1
|
When /^I click the "([^"]*)" button on the alert$/ do |label|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes('alert')
|
4
|
+
alert = Melomel.find!(classes)
|
5
|
+
button = Melomel::Cucumber.find_by_label!('mx.controls.Button', label, alert)
|
6
|
+
button.setFocus()
|
7
|
+
Melomel.click(button)
|
8
|
+
end
|
6
9
|
end
|
7
10
|
|
8
11
|
Then /^I should see an alert$/ do
|
9
|
-
|
10
|
-
|
12
|
+
Melomel::Cucumber.run! do
|
13
|
+
classes = Melomel::Flex.get_component_classes('alert')
|
14
|
+
Melomel.find!(classes)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
Then /^I should see an alert with the title: "([^"]*)"$/ do |title|
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
Melomel::Cucumber.run! do
|
20
|
+
classes = Melomel::Flex.get_component_classes('alert')
|
21
|
+
alert = Melomel.find!(classes)
|
22
|
+
alert.title.should == title
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
Then /^I should see an alert with the message: "([^"]*)"$/ do |message|
|
20
|
-
|
21
|
-
|
22
|
-
|
27
|
+
Melomel::Cucumber.run! do
|
28
|
+
classes = Melomel::Flex.get_component_classes('alert')
|
29
|
+
alert = Melomel.find!(classes)
|
30
|
+
alert.text.should == message
|
31
|
+
end
|
23
32
|
end
|
24
33
|
|
25
34
|
Then /^I should see an alert with the following message:$/ do |message|
|
26
|
-
|
27
|
-
|
28
|
-
|
35
|
+
Melomel::Cucumber.run! do
|
36
|
+
classes = Melomel::Flex.get_component_classes('alert')
|
37
|
+
alert = Melomel.find!(classes)
|
38
|
+
alert.text.should == message
|
39
|
+
end
|
29
40
|
end
|
@@ -1,11 +1,17 @@
|
|
1
|
-
When /^I click the "([^"]*)" (button|check box|radio button)$/ do |name, type|
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
When /^I click the "([^"]*)" (button|check box|radio button|tab)$/ do |name, type|
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes(type)
|
4
|
+
button = Melomel::Cucumber.find_by_label!(classes, name)
|
5
|
+
button.setFocus()
|
6
|
+
Melomel.click(button)
|
7
|
+
end
|
5
8
|
end
|
6
9
|
|
7
10
|
Then /^I should see the "([^"]*)" (button|check box|radio button) (not )?selected$/ do |name, type, neg|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
Melomel::Cucumber.run! do
|
12
|
+
classes = Melomel::Flex.get_component_classes(type)
|
13
|
+
button = Melomel::Cucumber.find_by_label!(classes, name)
|
14
|
+
button.setFocus()
|
15
|
+
button.selected.should == neg.nil?
|
16
|
+
end
|
11
17
|
end
|
@@ -1,12 +1,18 @@
|
|
1
1
|
When /^I set the "([^"]*)" color picker to "#([0-9A-Fa-f]{6})"$/ do |name, color|
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes('color picker')
|
4
|
+
picker = Melomel::Cucumber.find_labeled!(classes, name)
|
5
|
+
picker.setFocus()
|
6
|
+
picker.selectedColor = color.hex
|
7
|
+
end
|
5
8
|
end
|
6
9
|
|
7
10
|
Then /^I should see the "([^"]*)" color picker set to "#([0-9A-Fa-f]{6})"$/ do |name, color|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
Melomel::Cucumber.run! do
|
12
|
+
classes = Melomel::Flex.get_component_classes('color picker')
|
13
|
+
picker = Melomel::Cucumber.find_labeled!(classes, name)
|
14
|
+
picker.setFocus()
|
15
|
+
sprintf('%06X', picker.selectedColor).should == color
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
@@ -1,62 +1,72 @@
|
|
1
1
|
When /^I select "([^"]*)" on the "([^"]*)" data grid$/ do |value, name|
|
2
|
-
|
3
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes('data grid')
|
4
|
+
grid = Melomel::Cucumber.find_labeled!(classes, name)
|
5
|
+
grid.setFocus()
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
# Retrieve data and take off header row
|
8
|
+
data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
# Loop data and check for matches
|
11
|
+
index = nil
|
12
|
+
data.each_index do |i|
|
13
|
+
row = data[i]
|
14
|
+
row.each do |cell|
|
15
|
+
if cell.strip == value
|
16
|
+
index = i
|
17
|
+
break
|
18
|
+
end
|
16
19
|
end
|
17
|
-
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
break unless index.nil?
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
# If we couldn't find a matching cell then throw an error
|
25
|
+
raise "Cannot find '#{value}' on data grid" if index.nil?
|
24
26
|
|
25
|
-
|
27
|
+
grid.selectedIndex = index
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
|
29
32
|
Then /^I should see "([^"]*)" selected on the "([^"]*)" data grid$/ do |value, name|
|
30
|
-
|
31
|
-
|
33
|
+
Melomel::Cucumber.run! do
|
34
|
+
classes = Melomel::Flex.get_component_classes('data grid')
|
35
|
+
grid = Melomel::Cucumber.find_labeled!(classes, name)
|
36
|
+
grid.setFocus()
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
# Retrieve data and take off header row
|
39
|
+
data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
# Loop data and check for matches
|
42
|
+
index = nil
|
43
|
+
data.each_index do |i|
|
44
|
+
row = data[i]
|
45
|
+
row.each do |cell|
|
46
|
+
if cell.strip == value
|
47
|
+
index = i
|
48
|
+
break
|
49
|
+
end
|
44
50
|
end
|
45
|
-
end
|
46
51
|
|
47
|
-
|
48
|
-
|
52
|
+
break unless index.nil?
|
53
|
+
end
|
49
54
|
|
50
|
-
|
55
|
+
grid.selectedIndex.should == index
|
56
|
+
end
|
51
57
|
end
|
52
58
|
|
53
59
|
Then /^I should see the following data in the "([^"]*)" data grid:$/ do |name, table|
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
Melomel::Cucumber.run! do
|
61
|
+
classes = Melomel::Flex.get_component_classes('data grid')
|
62
|
+
grid = Melomel::Cucumber.find_labeled!(classes, name)
|
63
|
+
grid.setFocus()
|
64
|
+
|
65
|
+
data = Melomel::Cucumber.get_grid_data(grid)
|
57
66
|
|
58
|
-
|
59
|
-
|
67
|
+
# Trim whitespace
|
68
|
+
data.each {|row| row.each {|cell| cell.strip!}}
|
60
69
|
|
61
|
-
|
70
|
+
table.diff!(data)
|
71
|
+
end
|
62
72
|
end
|
@@ -1,16 +1,22 @@
|
|
1
1
|
When /^I set the "([^"]*)" (date chooser|date field) to "(\d{1,2}\/\d{1,2}\/\d{4})"$/ do |name, type, date_string|
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes(type)
|
4
|
+
component = Melomel::Cucumber.find_labeled!(classes, name)
|
5
|
+
component.setFocus()
|
6
|
+
component.selectedDate = Melomel::Date.parse(date_string)
|
7
|
+
end
|
5
8
|
end
|
6
9
|
|
7
10
|
Then /^I should see the "([^"]*)" (date chooser|date field) set to "(\d{1,2}\/\d{1,2}\/\d{4})"$/ do |name, type, date_string|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
Melomel::Cucumber.run! do
|
12
|
+
classes = Melomel::Flex.get_component_classes(type)
|
13
|
+
component = Melomel::Cucumber.find_labeled!(classes, name)
|
14
|
+
date = Melomel::Date.parse(date_string)
|
15
|
+
component.setFocus()
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
component.selectedDate.should_not be_nil
|
18
|
+
date.should_not be_nil
|
19
|
+
component.selectedDate.toLocaleDateString().should == date.toLocaleDateString()
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
@@ -1,24 +1,30 @@
|
|
1
1
|
When /^I select "([^"]*)" on the "([^"]*)" (combo box|list)$/ do |value, name, type|
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes(type)
|
4
|
+
list = Melomel::Cucumber.find_labeled!(classes, name)
|
5
|
+
list.setFocus()
|
6
|
+
labels = Melomel.items_to_labels!(list, list.dataProvider)
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
# Loop over labels and set the selected index when we find a match
|
9
|
+
index = nil
|
10
|
+
labels.length.times do |i|
|
11
|
+
if labels[i] == value
|
12
|
+
index = i
|
13
|
+
end
|
11
14
|
end
|
12
|
-
|
13
|
-
raise "Cannot find '#{value}' on #{type}" if index.nil?
|
15
|
+
raise "Cannot find '#{value}' on #{type}" if index.nil?
|
14
16
|
|
15
|
-
|
17
|
+
list.selectedIndex = index
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
Then /^I should see "([^"]*)" selected on the "([^"]*)" (combo box|list)$/ do |value, name, type|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
Melomel::Cucumber.run! do
|
23
|
+
classes = Melomel::Flex.get_component_classes(type)
|
24
|
+
list = Melomel::Cucumber.find_labeled!(classes, name)
|
25
|
+
list.setFocus()
|
26
|
+
label = list.itemToLabel(list.selectedItem)
|
27
|
+
label.should == value
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
@@ -1,14 +1,20 @@
|
|
1
1
|
When /^I set the "([^"]*)" (slider) to "([^"]*)"$/ do |name, type, value|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes(type)
|
4
|
+
slider = Melomel::Cucumber.find_labeled!(classes, name)
|
5
|
+
slider.setFocus()
|
6
|
+
value = value.index('.') ? value.to_f : value.to_i
|
7
|
+
slider.value = value
|
8
|
+
end
|
6
9
|
end
|
7
10
|
|
8
11
|
Then /^I should see the "([^"]*)" (slider) set to "([^"]*)"$/ do |name, type, value|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
Melomel::Cucumber.run! do
|
13
|
+
classes = Melomel::Flex.get_component_classes(type)
|
14
|
+
slider = Melomel::Cucumber.find_labeled!(classes, name)
|
15
|
+
slider.setFocus()
|
16
|
+
value = value.index('.') ? value.to_f : value.to_i
|
17
|
+
slider.value.should == value
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
@@ -1,11 +1,17 @@
|
|
1
1
|
When /^I type "([^"]*)" in the "([^"]*)" (text field|text area)$/ do |text, name, type|
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
Melomel::Cucumber.run! do
|
3
|
+
classes = Melomel::Flex.get_component_classes(type)
|
4
|
+
component = Melomel::Cucumber.find_labeled!(classes, name)
|
5
|
+
component.setFocus()
|
6
|
+
component.text = text
|
7
|
+
end
|
5
8
|
end
|
6
9
|
|
7
10
|
Then /^I should see "([^"]*)" in the "([^"]*)" (text field|text area|label)$/ do |text, name, type|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
Melomel::Cucumber.run! do
|
12
|
+
classes = Melomel::Flex.get_component_classes(type)
|
13
|
+
component = Melomel::Cucumber.find_labeled!(classes, name)
|
14
|
+
component.setFocus()
|
15
|
+
component.text.should == text
|
16
|
+
end
|
11
17
|
end
|
data/lib/melomel/cucumber.rb
CHANGED
@@ -5,6 +5,15 @@ Dir.glob(File.dirname(__FILE__) + '/cucumber/*', &method(:require))
|
|
5
5
|
# This class holds utility methods for running Cucumber steps.
|
6
6
|
module Melomel
|
7
7
|
class Cucumber
|
8
|
+
# A wrapper for Melomel actions that automatically waits until the Flash
|
9
|
+
# virtual machine is not busy before continuing.
|
10
|
+
#
|
11
|
+
# Returns nothing.
|
12
|
+
def self.run!
|
13
|
+
Melomel.wait()
|
14
|
+
yield
|
15
|
+
end
|
16
|
+
|
8
17
|
# Finds a component by id.
|
9
18
|
#
|
10
19
|
# class_name - The class or classes to match on.
|
data/lib/melomel/flex.rb
CHANGED
@@ -35,6 +35,7 @@ module Melomel
|
|
35
35
|
when 'progress bar' then ['mx.controls.ProgressBar']
|
36
36
|
when 'radio button' then ['mx.controls.RadioButton', 'spark.components.RadioButton']
|
37
37
|
when 'rich text area' then ['mx.controls.RichTextEditor', 'spark.components.RichEditableText']
|
38
|
+
when 'tab' then ['mx.controls.tabBarClasses.Tab']
|
38
39
|
when 'text field' then ['mx.controls.TextInput', 'spark.components.TextInput']
|
39
40
|
when 'text area' then ['mx.controls.TextArea', 'spark.components.TextArea']
|
40
41
|
when 'tool tip' then ['mx.controls.ToolTip']
|
data/lib/melomel/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: melomel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Johnson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-14 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|