melomel 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- classes = Melomel::Flex.get_component_classes('alert')
3
- alert = Melomel.find!(classes)
4
- button = Melomel::Cucumber.find_by_label!('mx.controls.Button', label, alert)
5
- Melomel.click(button)
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
- classes = Melomel::Flex.get_component_classes('alert')
10
- Melomel.find!(classes)
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
- classes = Melomel::Flex.get_component_classes('alert')
15
- alert = Melomel.find!(classes)
16
- alert.title.should == title
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
- classes = Melomel::Flex.get_component_classes('alert')
21
- alert = Melomel.find!(classes)
22
- alert.text.should == message
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
- classes = Melomel::Flex.get_component_classes('alert')
27
- alert = Melomel.find!(classes)
28
- alert.text.should == message
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
- classes = Melomel::Flex.get_component_classes(type)
3
- button = Melomel::Cucumber.find_by_label!(classes, name)
4
- Melomel.click(button)
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
- classes = Melomel::Flex.get_component_classes(type)
9
- button = Melomel::Cucumber.find_by_label!(classes, name)
10
- button.selected.should == neg.nil?
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
- classes = Melomel::Flex.get_component_classes('color picker')
3
- picker = Melomel::Cucumber.find_labeled!(classes, name)
4
- picker.selectedColor = color.hex
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
- classes = Melomel::Flex.get_component_classes('color picker')
9
- picker = Melomel::Cucumber.find_labeled!(classes, name)
10
- sprintf('%06X', picker.selectedColor).should == color
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
- classes = Melomel::Flex.get_component_classes('data grid')
3
- grid = Melomel::Cucumber.find_labeled!(classes, name)
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
- # Retrieve data and take off header row
6
- data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
7
+ # Retrieve data and take off header row
8
+ data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
7
9
 
8
- # Loop data and check for matches
9
- index = nil
10
- data.each_index do |i|
11
- row = data[i]
12
- row.each do |cell|
13
- if cell.strip == value
14
- index = i
15
- break
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
- break unless index.nil?
20
- end
21
+ break unless index.nil?
22
+ end
21
23
 
22
- # If we couldn't find a matching cell then throw an error
23
- raise "Cannot find '#{value}' on data grid" if index.nil?
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
- grid.selectedIndex = index
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
- classes = Melomel::Flex.get_component_classes('data grid')
31
- grid = Melomel::Cucumber.find_labeled!(classes, name)
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
- # Retrieve data and take off header row
34
- data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
38
+ # Retrieve data and take off header row
39
+ data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
35
40
 
36
- # Loop data and check for matches
37
- index = nil
38
- data.each_index do |i|
39
- row = data[i]
40
- row.each do |cell|
41
- if cell.strip == value
42
- index = i
43
- break
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
- break unless index.nil?
48
- end
52
+ break unless index.nil?
53
+ end
49
54
 
50
- grid.selectedIndex.should == index
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
- classes = Melomel::Flex.get_component_classes('data grid')
55
- grid = Melomel::Cucumber.find_labeled!(classes, name)
56
- data = Melomel::Cucumber.get_grid_data(grid)
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
- # Trim whitespace
59
- data.each {|row| row.each {|cell| cell.strip!}}
67
+ # Trim whitespace
68
+ data.each {|row| row.each {|cell| cell.strip!}}
60
69
 
61
- table.diff!(data)
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
- classes = Melomel::Flex.get_component_classes(type)
3
- component = Melomel::Cucumber.find_labeled!(classes, name)
4
- component.selectedDate = Melomel::Date.parse(date_string)
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
- classes = Melomel::Flex.get_component_classes(type)
9
- component = Melomel::Cucumber.find_labeled!(classes, name)
10
- date = Melomel::Date.parse(date_string)
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
- component.selectedDate.should_not be_nil
13
- date.should_not be_nil
14
- component.selectedDate.toLocaleDateString().should == date.toLocaleDateString()
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
- classes = Melomel::Flex.get_component_classes(type)
3
- list = Melomel::Cucumber.find_labeled!(classes, name)
4
- labels = Melomel.items_to_labels!(list, list.dataProvider)
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
- # Loop over labels and set the selected index when we find a match
7
- index = nil
8
- labels.length.times do |i|
9
- if labels[i] == value
10
- index = i
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
- end
13
- raise "Cannot find '#{value}' on #{type}" if index.nil?
15
+ raise "Cannot find '#{value}' on #{type}" if index.nil?
14
16
 
15
- list.selectedIndex = index
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
- classes = Melomel::Flex.get_component_classes(type)
20
- list = Melomel::Cucumber.find_labeled!(classes, name)
21
- label = list.itemToLabel(list.selectedItem)
22
- label.should == value
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
- classes = Melomel::Flex.get_component_classes(type)
3
- slider = Melomel::Cucumber.find_labeled!(classes, name)
4
- value = value.index('.') ? value.to_f : value.to_i
5
- slider.value = value
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
- classes = Melomel::Flex.get_component_classes(type)
10
- slider = Melomel::Cucumber.find_labeled!(classes, name)
11
- value = value.index('.') ? value.to_f : value.to_i
12
- slider.value.should == value
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
- classes = Melomel::Flex.get_component_classes(type)
3
- component = Melomel::Cucumber.find_labeled!(classes, name)
4
- component.text = text
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
- classes = Melomel::Flex.get_component_classes(type)
9
- component = Melomel::Cucumber.find_labeled!(classes, name)
10
- component.text.should == text
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
@@ -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']
@@ -1,3 +1,3 @@
1
1
  module Melomel
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
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: 11
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.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-08 00:00:00 -06:00
18
+ date: 2010-10-14 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency