gxt-widgets 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/.travis.yml +1 -1
  2. data/features/gxt_basic_tree.feature +56 -0
  3. data/features/gxt_grid.feature +16 -16
  4. data/features/gxt_grid_with_grouping.feature +37 -15
  5. data/features/step_definitions/gxt_grid_steps.rb +5 -5
  6. data/features/step_definitions/gxt_grid_with_grouping_steps.rb +58 -0
  7. data/features/step_definitions/gxt_tree_steps.rb +46 -0
  8. data/features/support/pages/basic_tree_example.rb +9 -0
  9. data/features/support/pages/grouping_grid_example.rb +3 -0
  10. data/features/support/pages/gxt_examples_page.rb +2 -0
  11. data/gxt-widget.gemspec +1 -1
  12. data/lib/gxt-widgets.rb +4 -0
  13. data/lib/gxt-widgets/gxt_basic_tree.rb +56 -0
  14. data/lib/gxt-widgets/gxt_grid.rb +2 -10
  15. data/lib/gxt-widgets/gxt_grid_group.rb +44 -0
  16. data/lib/gxt-widgets/gxt_grid_row.rb +3 -0
  17. data/lib/gxt-widgets/gxt_group_column_menu.rb +8 -0
  18. data/lib/gxt-widgets/gxt_grouping_grid.rb +53 -0
  19. data/lib/gxt-widgets/modules/groupable_column.rb +12 -0
  20. data/lib/gxt-widgets/platforms/selenium_webdriver/gxt_grid.rb +2 -8
  21. data/lib/gxt-widgets/platforms/selenium_webdriver/gxt_grouping_grid.rb +18 -0
  22. data/lib/gxt-widgets/platforms/selenium_webdriver/row_container.rb +22 -0
  23. data/lib/gxt-widgets/platforms/watir_webdriver/gxt_grid.rb +2 -19
  24. data/lib/gxt-widgets/platforms/watir_webdriver/gxt_grouping_grid.rb +16 -0
  25. data/lib/gxt-widgets/platforms/watir_webdriver/row_container.rb +31 -0
  26. data/lib/gxt-widgets/row_container.rb +28 -0
  27. data/lib/gxt-widgets/version.rb +1 -1
  28. data/spec/gxt-widgets/gxt_grid_row_spec.rb +1 -1
  29. metadata +21 -11
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
5
+ - 2.0.0
6
6
  before_install:
7
7
  - "export DISPLAY=:99.0"
8
8
  - "sh -e /etc/init.d/xvfb start"
@@ -0,0 +1,56 @@
1
+ Feature: Gxt Basic Tree
2
+ In order to interact with trees
3
+ Testers need to be able to search and navigate trees
4
+
5
+ Background:
6
+ Given I am on the Gxt Examples page
7
+ And I have the Basic Tree opened
8
+
9
+ Scenario: Retrieve a tree
10
+ When I retrieve a GxtTree widget
11
+ Then I should know it is visible
12
+
13
+ @watir_only
14
+ Scenario: Determine if a tree exists
15
+ When I retrieve a GxtTree widget
16
+ Then I should know it exists
17
+
18
+ Scenario: Count the number top level elements
19
+ When I get the top level tree nodes
20
+ Then the count should be 3
21
+
22
+ Scenario: Expand the first element
23
+ When I retrieve a GxtTree widget
24
+ And I expand the "General Administration" tree node
25
+ Then The "General Manager" node should be visible
26
+ And The "Executive" node should be visible
27
+
28
+ Scenario: Expand an element to the second level
29
+ When I retrieve a GxtTree widget
30
+ And I expand the "General Administration" tree node
31
+ And I expand the "General Manager" tree node
32
+ Then The "Hollie Voss" node should be visible
33
+
34
+ Scenario: Click on the joint to expand a node
35
+ Given I retrieve a GxtTree widget
36
+ And the "Information Technology" node is collapsed
37
+ When I click on the node joint
38
+ Then the node should be expanded
39
+
40
+ Scenario: Click on the joint to collapse a node
41
+ Given I retrieve a GxtTree widget
42
+ And the "Information Technology" node is expanded
43
+ When I click on the node joint
44
+ Then the node should be collapsed
45
+
46
+ Scenario: double-click on the label to collapse a node
47
+ Given I retrieve a GxtTree widget
48
+ And the "Information Technology" node is expanded
49
+ When I double-click on the node
50
+ Then the node should be collapsed
51
+
52
+ Scenario: double-click on the label to expand a node
53
+ Given I retrieve a GxtTree widget
54
+ And the "Information Technology" node is collapsed
55
+ When I double-click on the node
56
+ Then the node should be expanded
@@ -8,16 +8,16 @@ Feature: Gxt Grid
8
8
  And I have the Basic Grid opened
9
9
 
10
10
  Scenario: Retrieve a table
11
- When I retrieve a GxtGrid widget
11
+ When I retrieve a GxtHeaderGrid widget
12
12
  Then I should know it is visible
13
13
 
14
14
  @watir_only
15
15
  Scenario: Determine if a table exists
16
- When I retrieve a GxtGrid widget
16
+ When I retrieve a GxtHeaderGrid widget
17
17
  Then I should know it exists
18
18
 
19
19
  Scenario: Retrieve the data from a table
20
- When I retrieve a GxtGrid widget
20
+ When I retrieve a GxtHeaderGrid widget
21
21
  Then the data for row "1" should be "Hollie Voss" and "General Administration"
22
22
  And the table should have "13" rows
23
23
  And row "1" should have "5" columns
@@ -25,61 +25,61 @@ Feature: Gxt Grid
25
25
  And the data for the last row should be "Buster misjenou" and "Accounts"
26
26
 
27
27
  Scenario: Retrieve data from a table using a row header
28
- When I retrieve a GxtGrid widget
28
+ When I retrieve a GxtHeaderGrid widget
29
29
  Then the data for row "Gail Horton" should be "Gail Horton" and "Marketing"
30
30
 
31
31
  Scenario: Retrieve data from a table using a partial row header
32
- When I retrieve a GxtGrid widget
32
+ When I retrieve a GxtHeaderGrid widget
33
33
  Then the data for row "Newman" should be "Dirk Newman" and "Information Technology"
34
34
 
35
35
  Scenario: Retrieve data from a table using a row header in the 2nd column
36
- When I retrieve a GxtGrid widget
36
+ When I retrieve a GxtHeaderGrid widget
37
37
  Then the data for row "General Administration" should be "Hollie Voss" and "General Administration"
38
38
 
39
39
  Scenario: Retrieve data from a table using a partial row header in the 2nd column
40
- When I retrieve a GxtGrid widget
40
+ When I retrieve a GxtHeaderGrid widget
41
41
  Then the data for row "Administration" should be "Hollie Voss" and "General Administration"
42
42
 
43
43
  Scenario: Retrieve data from a table using a column header
44
- When I retrieve a GxtGrid widget
44
+ When I retrieve a GxtHeaderGrid widget
45
45
  Then the data for column "Slary" and row "2" should be "120000.00"
46
46
 
47
47
  Scenario: Retrieve data from a table using a partial column header
48
- When I retrieve a GxtGrid widget
48
+ When I retrieve a GxtHeaderGrid widget
49
49
  Then the data for column "esignation" and row "2" should be "CTO"
50
50
 
51
51
  Scenario: Retrieve data from a table using both headers
52
- When I retrieve a GxtGrid widget
52
+ When I retrieve a GxtHeaderGrid widget
53
53
  Then the data for row "Emerson Milton" and column "Department" should be "Information Technology"
54
54
 
55
55
  Scenario: Retrieve data from a table with an incorrect row header
56
- When I retrieve a GxtGrid widget
56
+ When I retrieve a GxtHeaderGrid widget
57
57
  Then the data for row "Data20" should be nil
58
58
 
59
59
  Scenario: Retrieve data from a table with an incorrect column header
60
- When I retrieve a GxtGrid widget
60
+ When I retrieve a GxtHeaderGrid widget
61
61
  Then the data for row "Chad Andrews" and column "Data20" should be nil
62
62
 
63
63
  Scenario: Sort Ascending by Employee Name
64
- When I retrieve a GxtGrid widget
64
+ When I retrieve a GxtHeaderGrid widget
65
65
  And I open the "Employee Name" column menu
66
66
  And I sort ascending
67
67
  Then the data for the second row should be "Bell Snedden" and "Information Technology"
68
68
 
69
69
  Scenario: Sort Descending by Employee Name
70
- When I retrieve a GxtGrid widget
70
+ When I retrieve a GxtHeaderGrid widget
71
71
  And I open the "Employee Name" column menu
72
72
  And I sort descending
73
73
  Then the data for the second row should be "Hollie Voss" and "General Administration"
74
74
 
75
75
  Scenario: Deselect a column from the Column Menu
76
- When I retrieve a GxtGrid widget
76
+ When I retrieve a GxtHeaderGrid widget
77
77
  And I open the "Department" column menu
78
78
  And I deselect the "Department" column
79
79
  Then The "Department" column should not appear in the table
80
80
 
81
81
  Scenario: Deselect then select a column from the Column Menu
82
- Given I retrieve a GxtGrid widget
82
+ Given I retrieve a GxtHeaderGrid widget
83
83
  And I open the "Department" column menu
84
84
  And I deselect the "Department" column
85
85
  And The "Department" column should not appear in the table
@@ -1,4 +1,3 @@
1
- @ignore
2
1
  Feature: Gxt Grid With Grouping
3
2
  As a Gxt Developer
4
3
  I want to control a Gxt Grid with grouping using a Widget
@@ -12,36 +11,59 @@ Feature: Gxt Grid With Grouping
12
11
  Scenario: I should know the group headings and count
13
12
  Then The grid should contain 4 groups
14
13
  And The group headings should contain
15
- |Accounts|General Administration|Information Technology|Marketing|
14
+ |Heading|
15
+ |Department: Accounts (1 Item)|
16
+ |Department: General Administration (1 Item)|
17
+ |Department: Information Technology (7 Items)|
18
+ |Department: Marketing (3 Items)|
19
+
16
20
 
17
21
  Scenario: I should be able to collapse a group
18
22
  When The "Information Technology" Group is expanded
19
- And I collapse the "Information Technology" group
23
+ And I collapse the group
20
24
  Then The rows should not be visible
21
25
 
22
26
  Scenario: I should be able to expand a group
23
27
  When The "Information Technology" Group is collapsed
24
- And I expand the "Information Technology" group
28
+ And I expand the group
25
29
  Then the rows should be visible
26
30
 
27
31
  Scenario: I should be able to sort (ascending) groups by the grouping column
28
- When The data is grouped by "Department"
29
- And I sort the "Department" column Ascending
32
+ When I open the "Department" column menu
33
+ And I select Group By This Field
34
+ And I open the "Department" column menu
35
+ And I sort ascending
30
36
  Then the group headings should contain in order
31
37
  |Accounts|General Administration|Information Technology|Marketing|
32
38
 
33
39
  Scenario: I should be able to sort (descending) groups by the grouping column
34
- When The data is grouped by "Department"
35
- And I sort the "Department" column Descending
36
- Then the group headings should contain in order
37
- |Marketing|Information Technology|General Administration|Accounts|
38
-
39
- Scenario: I should be able to use the column menu to change the grouping field
40
- When I click on the "Designation" column drop down menu
41
- And I select "Group By This Field"
40
+ When I open the "Department" column menu
41
+ And I select Group By This Field
42
+ And I open the "Department" column menu
43
+ And I sort descending
44
+ And The group headings should contain
45
+ |Heading|
46
+ |Department: Accounts (1 Item)|
47
+ |Department: General Administration (1 Item)|
48
+ |Department: Information Technology (7 Items)|
49
+ |Department: Marketing (3 Items)|
50
+
51
+
52
+ Scenario: I should be able to use the column menu to change the grouping field
53
+ When I open the "Department" column menu
54
+ And I select Group By This Field
55
+ When I open the "Designation" column menu
56
+ And I select Group By This Field
42
57
  Then The grid should contain 7 groups
43
58
  And The group headings should contain
44
- |CTO|Executive|Executive Director|General Manager|Project Manager|S/W Engineer|Senior S/W Engineer|
59
+ |Heading|
60
+ |Designation: CTO (1 Item)|
61
+ |Designation: Executive (3 Items)|
62
+ |Designation: Executive Director (1 Item)|
63
+ |Designation: General Manager (1 Item)|
64
+ |Designation: Project Manager (1 Item)|
65
+ |Designation: S/W Engineer (3 Items)|
66
+ |Designation: Senior S/W Engineer (2 Items)|
45
67
 
46
68
 
47
69
 
@@ -3,12 +3,12 @@ When /^I have the Basic Grid opened$/ do
3
3
  @page = BasicGridExample.new(@browser)
4
4
  end
5
5
 
6
- When /^I retrieve a GxtGrid widget$/ do
6
+ When /^I retrieve a GxtHeaderGrid widget$/ do
7
7
  @element = @page.grid_element
8
8
  end
9
9
 
10
10
 
11
- When /^the GxtGrid should have "(\d+)" rows$/ do |rows|
11
+ When /^the GxtHeaderGrid should have "(\d+)" rows$/ do |rows|
12
12
  @element.rows.should == rows.to_i
13
13
  end
14
14
 
@@ -28,15 +28,15 @@ Then /^the cell data should be '([^"]*)'$/ do |expected|
28
28
  @cell_data.should == expected
29
29
  end
30
30
 
31
- When /^I retrieve a GxtGrid widget by "([^\"]*)"$/ do |how|
31
+ When /^I retrieve a GxtHeaderGrid widget by "([^\"]*)"$/ do |how|
32
32
  @element = @page.send "table_#{how}_element"
33
33
  end
34
34
 
35
- When /^I retrieve a GxtGrid widget by "([^\"]*)" and "([^\"]*)"$/ do |param1, param2|
35
+ When /^I retrieve a GxtHeaderGrid widget by "([^\"]*)" and "([^\"]*)"$/ do |param1, param2|
36
36
  @element = @page.send "table_#{param1}_#{param2}_element"
37
37
  end
38
38
 
39
- When /^I retrieve a GxtGrid widget while the script is executing$/ do
39
+ When /^I retrieve a GxtHeaderGrid widget while the script is executing$/ do
40
40
  @element = @page.table_element(:id => 'table_id')
41
41
  end
42
42
 
@@ -5,4 +5,62 @@ end
5
5
 
6
6
  When /^I retrieve a GxtGroupingGrid widget$/ do
7
7
  @element = @page.grouping_grid_element
8
+ end
9
+
10
+ Then /^The grid should contain (\d+) groups$/ do |group_count|
11
+ @element.groups.size.should == group_count.to_i
12
+ end
13
+
14
+ When /^The group headings should contain$/ do |table|
15
+ found = false
16
+ @element.groups.each do |heading|
17
+ first_column = table.rows.map {|row| row[0]}
18
+ first_column.should include heading.name
19
+ end
20
+ end
21
+
22
+ When /^The "([^"]*)" Group is expanded$/ do |group|
23
+ @group = @element.group(group)
24
+ @group.expand
25
+ @group.should be_expanded
26
+ end
27
+
28
+ When /^I collapse the group$/ do
29
+ @group.collapse
30
+ @group.should be_collapsed
31
+ end
32
+
33
+ Then /^The rows should not be visible$/ do
34
+ @group.should be_collapsed
35
+ @group.each do |row|
36
+ row.should_not be_visible
37
+ end
38
+ end
39
+
40
+ When /^The "([^"]*)" Group is collapsed$/ do |group|
41
+ @group = @element.group(group)
42
+ @group.collapse
43
+ @group.should be_collapsed
44
+ end
45
+
46
+ When /^I expand the group$/ do
47
+ @group.expand
48
+ @group.should be_expanded
49
+ end
50
+
51
+ Then /^the rows should be visible$/ do
52
+ @group.should be_expanded
53
+ @group.each do |row|
54
+ row.should be_visible
55
+ end
56
+ end
57
+
58
+ Then /^the group headings should contain in order$/ do |table|
59
+ (1..table.rows.size).each do |index|
60
+ table.rows[index][0].should include @element.group(index).heading.name
61
+ end
62
+ end
63
+
64
+ When /^I select Group By This Field$/ do
65
+ @page.column_menu_element.group_by_this_field
8
66
  end
@@ -0,0 +1,46 @@
1
+ When /^I have the Basic Tree opened$/ do
2
+ @page.basic_tree_element.click
3
+ @page = BasicTreeExample.new(@browser)
4
+ end
5
+ When /^I retrieve a GxtTree widget$/ do
6
+ @element = @page.basic_tree_element
7
+ end
8
+ When /^I get the top level tree nodes$/ do
9
+ @element = @page.basic_tree_element
10
+ end
11
+ Then /^the count should be (\d+)$/ do |expected_count|
12
+ @element.child_nodes.size.should == expected_count.to_i
13
+ end
14
+ When /^I expand the "([^"]*)" tree node$/ do |node_name|
15
+ @element.node(node_name).expand
16
+ end
17
+ Then /^The "([^"]*)" node should be visible$/ do |node_name|
18
+ @element.node(node_name).should be_visible
19
+ end
20
+ Given /^the "([^"]*)" node is collapsed$/ do |node_name|
21
+ @element = @page.basic_tree_element.node(node_name)
22
+ @element.collapse
23
+ end
24
+ When /^I click on the node joint$/ do
25
+ @element.joint.click
26
+ end
27
+ Then /^the node should be expanded$/ do
28
+ @element.should be_expanded
29
+ @element.child_nodes.each do |node|
30
+ node.should be_visible
31
+ end
32
+ end
33
+ Given /^the "([^"]*)" node is expanded$/ do |node_name|
34
+ @element = @page.basic_tree_element.node(node_name)
35
+ @element.expand
36
+ end
37
+ Then /^the node should be collapsed$/ do
38
+ @element.should be_collapsed
39
+ @element.child_nodes.each do |node|
40
+ node.should_not be_visible
41
+ end
42
+ end
43
+ When /^I double-click on the node$/ do
44
+ @element.click
45
+ @element.double_click
46
+ end
@@ -0,0 +1,9 @@
1
+ class BasicTreeExample
2
+ include PageObject
3
+
4
+ TREE_CONTAINER_CLASS = 'x-tree3-node-ct'
5
+ button(:expand, :text=>'Expand All')
6
+ button(:collapse, :text=>'Collapse All')
7
+
8
+ gxt_basic_tree(:basic_tree, :xpath=>"//div[contains(@class,'#{TREE_CONTAINER_CLASS}')]")
9
+ end
@@ -1,5 +1,8 @@
1
1
  class GroupingGridExample
2
2
  include PageObject
3
3
 
4
+ gxt_grouping_grid(:grouping_grid, :class => "x-grid3")
5
+ gxt_group_column_menu(:column_menu, :xpath=>"//div[contains(@class,' x-menu-list')]")
6
+ gxt_column_selection_menu(:column_selection_menu, :xpath=>"(//div[contains(@class,'x-menu-list') and not(contains(@class, 'x-menu-list-item'))])[2]")
4
7
 
5
8
  end
@@ -6,4 +6,6 @@ class GxtExamplesPage
6
6
  div(:basic_grid, :class => "label_basic_grid")
7
7
  div(:local_pagination, :class => "label_paging_grid")
8
8
  div(:grouping_grid, :class => "label_grouping_grid")
9
+ div(:basic_tree, :class => "label_basic_tree")
10
+
9
11
  end
data/gxt-widget.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency 'page-object', '>= 0.8.2'
22
+ s.add_dependency 'page-object', '>= 0.9.1'
23
23
 
24
24
  s.add_development_dependency 'rspec', '>= 2.12.0'
25
25
  s.add_development_dependency 'cucumber', '< 1.2.0'
data/lib/gxt-widgets.rb CHANGED
@@ -7,8 +7,12 @@ require 'gxt-widgets/gxt_grid_header_row'
7
7
  require 'gxt-widgets/gxt_header_cell'
8
8
  require 'gxt-widgets/modules/selectable_column'
9
9
  require 'gxt-widgets/modules/sortable_column'
10
+ require 'gxt-widgets/modules/groupable_column'
10
11
  require 'gxt-widgets/gxt_column_menu'
11
12
  require 'gxt-widgets/gxt_column_selection_menu'
13
+ require 'gxt-widgets/gxt_grouping_grid'
14
+ require 'gxt-widgets/gxt_group_column_menu'
15
+ require 'gxt-widgets/gxt_basic_tree'
12
16
 
13
17
  module GxtWidgets
14
18
 
@@ -0,0 +1,56 @@
1
+ require 'watir-webdriver'
2
+ require 'page-object/platforms/watir_webdriver/table'
3
+ require 'gxt-widgets/row_container'
4
+ module GxtWidgets
5
+ class GxtBasicTree < PageObject::Elements::Div
6
+
7
+ PageObject.register_widget :gxt_basic_tree, GxtBasicTree, 'div'
8
+
9
+ def child_nodes
10
+ self.gxt_basic_tree_elements(:xpath=>".//child::div[contains(@class,'x-tree3-node')]")
11
+ end
12
+
13
+ def name
14
+ node_contents.span_element(:class=>"x-tree3-node-text").text
15
+ end
16
+
17
+ def node(node_name)
18
+ node_index = child_nodes.find_index do |node|
19
+ node.name == node_name
20
+ end
21
+ child_nodes[node_index]
22
+ end
23
+
24
+ def joint
25
+ node_contents.image_element(:xpath=>".//img[contains(@class,'x-tree3-node-joint')]")
26
+ end
27
+
28
+ def expand
29
+ joint.click unless self.expanded?
30
+ end
31
+
32
+ def expanded?
33
+ self.node_container.visible?
34
+ end
35
+
36
+
37
+ def collapse
38
+ joint.click unless self.collapsed?
39
+ end
40
+
41
+ def collapsed?
42
+ !self.node_container.visible?
43
+ end
44
+
45
+
46
+
47
+ def node_contents
48
+ self.div_element(:xpath=>".//div[contains(@class,'x-tree3-el')]")
49
+ end
50
+
51
+ def node_container
52
+ self.div_element(:xpath=>".//div[contains(@class,'x-tree3-node-ct')]")
53
+ end
54
+
55
+ end
56
+ end
@@ -1,19 +1,11 @@
1
1
  require 'watir-webdriver'
2
2
  require 'page-object/platforms/watir_webdriver/table'
3
+ require 'gxt-widgets/row_container'
3
4
  module GxtWidgets
4
- class GxtGrid < PageObject::Elements::Table
5
+ class GxtGrid < GxtWidgets::RowContainer
5
6
 
6
7
  PageObject.register_widget :gxt_grid, GxtGrid, 'div'
7
8
 
8
- protected
9
- def child_xpath
10
- ".//descendant::tr"
11
- end
12
-
13
- def initialize_row(row_element, platform)
14
- Object::GxtWidgets::GxtGridRow.new(row_element, self, platform)
15
- end
16
-
17
9
  def initialize_header(header_element, platform)
18
10
  Object::GxtWidgets::GxtGridHeaderRow.new(header_element, self, platform)
19
11
  end
@@ -0,0 +1,44 @@
1
+ require 'watir-webdriver'
2
+ require 'page-object/platforms/watir_webdriver/table'
3
+ module GxtWidgets
4
+ class GxtGridGroup < GxtWidgets::RowContainer
5
+
6
+ attr_reader :container
7
+
8
+ def name
9
+ group_title.text
10
+ end
11
+
12
+ def expanded?
13
+ not collapsed?
14
+ end
15
+
16
+ def collapsed?
17
+ attribute(:class).include? "x-grid-group-collapsed"
18
+ end
19
+
20
+ def expand
21
+ group_title.click unless expanded?
22
+ end
23
+
24
+ def collapse
25
+ group_title.click if expanded?
26
+ end
27
+
28
+ def initialize(element, container, platform)
29
+ @element = element
30
+ @container = container
31
+ include_platform_for platform
32
+ end
33
+
34
+ @protected
35
+ def group_title
36
+ div_element(:class=>'x-grid-group-hd')
37
+ end
38
+
39
+ def initialize_row(row_element, platform)
40
+ Object::GxtWidgets::GxtGridRow.new(row_element, container, platform)
41
+ end
42
+
43
+ end
44
+ end
@@ -9,6 +9,9 @@ module GxtWidgets
9
9
  include_platform_for platform
10
10
  end
11
11
 
12
+ def parent
13
+
14
+ end
12
15
  protected
13
16
 
14
17
  def initialize_cell(row_element, platform)
@@ -0,0 +1,8 @@
1
+ module GxtWidgets
2
+ class GxtGroupColumnMenu < GxtWidgets::GxtColumnMenu
3
+ include ::GxtWidgets::GroupableColumn
4
+
5
+ PageObject.register_widget(:gxt_group_column_menu, GxtGroupColumnMenu, 'div')
6
+
7
+ end
8
+ end
@@ -0,0 +1,53 @@
1
+ require 'watir-webdriver'
2
+ require 'page-object/platforms/watir_webdriver/table'
3
+ require 'gxt-widgets/gxt_grid_group'
4
+ require 'gxt-widgets/platforms/selenium_webdriver/gxt_grouping_grid'
5
+ require 'gxt-widgets/platforms/watir_webdriver/gxt_grouping_grid'
6
+
7
+ module GxtWidgets
8
+ class GxtGroupingGrid < GxtWidgets::GxtGrid
9
+
10
+ PageObject.register_widget :gxt_grouping_grid, GxtGroupingGrid, 'div'
11
+ attr_reader :current_platform
12
+
13
+ def initialize(element, platform)
14
+ super(element,platform)
15
+ @current_platform = platform
16
+ end
17
+
18
+ def groups
19
+ get_groups.map do |group|
20
+ initialize_group(group, @current_platform)
21
+ end
22
+ end
23
+
24
+ def group(group_index)
25
+ group_index = find_group_index_by_title(group_index, groups) if group_index.kind_of?(String)
26
+ return nil unless group_index
27
+ groups[group_index]
28
+ end
29
+
30
+ def initialize_group(group_element, platform)
31
+ Object::GxtWidgets::GxtGridGroup.new(group_element, self, platform)
32
+ end
33
+
34
+
35
+ def find_group_index_by_title(group_name, group_elements)
36
+ group_elements.find_index { |grp|
37
+ grp.name.include? group_name }
38
+ end
39
+
40
+ def include_platform_for platform
41
+ super
42
+ if platform[:platform] == :watir_webdriver
43
+ require 'gxt-widgets/platforms/watir_webdriver/gxt_grid'
44
+ self.class.send :include, GxtWidgets::Platforms::WatirWebDriver::GxtGroupingGrid
45
+ elsif platform[:platform] == :selenium_webdriver
46
+ require 'gxt-widgets/platforms/selenium_webdriver/gxt_grid'
47
+ self.class.send :include, GxtWidgets::Platforms::SeleniumWebDriver::GxtGroupingGrid
48
+ else
49
+ raise ArgumentError, "expect platform to be :watir_webdriver or :selenium_webdriver"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,12 @@
1
+ module GxtWidgets
2
+ module GroupableColumn
3
+ def group_by_this_field
4
+ link_element(:text=>"Group By This Field").click
5
+ end
6
+
7
+ def show_in_groups
8
+ link_element(:text=>"Show In Groups").click
9
+ end
10
+ end
11
+ end
12
+
@@ -1,17 +1,11 @@
1
1
  require "gxt-widgets/gxt_grid_row"
2
2
  require 'gxt-widgets/gxt_grid_header_row'
3
+ require 'gxt-widgets/platforms/selenium_webdriver/row_container'
3
4
  module GxtWidgets
4
5
  module Platforms
5
6
  module SeleniumWebDriver
6
7
  module GxtGrid
7
- include PageObject::Platforms::SeleniumWebDriver::Table
8
-
9
- def [](idx)
10
- eles = table_rows
11
- idx = find_index_by_title(idx, eles) if idx.kind_of?(String)
12
- return nil unless idx
13
- initialize_row(eles[idx], :platform => :selenium_webdriver)
14
- end
8
+ include GxtWidgets::Platforms::SeleniumWebDriver::RowContainer
15
9
 
16
10
  def header
17
11
  initialize_header(table_rows[0], :platform => :selenium_webdriver)
@@ -0,0 +1,18 @@
1
+ require "page-object/platforms/selenium_webdriver/table_row"
2
+ require 'gxt-widgets/platforms/selenium_webdriver/row_container'
3
+ module GxtWidgets
4
+ module Platforms
5
+ module SeleniumWebDriver
6
+ module GxtGroupingGrid
7
+ include GxtWidgets::Platforms::SeleniumWebDriver::RowContainer
8
+
9
+ private
10
+
11
+ def get_groups
12
+ element.find_elements(:xpath, "//div[contains(@class, 'x-grid-group ')]")
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require "gxt-widgets/gxt_grid_row"
2
+ require 'gxt-widgets/gxt_grid_header_row'
3
+ require 'page-object/platforms/selenium_webdriver/table'
4
+ module GxtWidgets
5
+ module Platforms
6
+ module SeleniumWebDriver
7
+ module RowContainer
8
+ include PageObject::Platforms::SeleniumWebDriver::Table
9
+
10
+ def [](idx)
11
+ eles = table_rows
12
+ idx = find_index_by_title(idx, eles) if idx.kind_of?(String)
13
+ return nil unless idx
14
+ initialize_row(eles[idx], :platform => :selenium_webdriver)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+
@@ -1,32 +1,15 @@
1
1
  require "gxt-widgets/gxt_grid_row"
2
2
  require 'gxt-widgets/gxt_grid_header_row'
3
+ require 'gxt-widgets/platforms/watir_webdriver/row_container'
3
4
  module GxtWidgets
4
5
  module Platforms
5
6
  module WatirWebDriver
6
7
  module GxtGrid
7
- include PageObject::Platforms::WatirWebDriver::Table
8
-
9
- def [](idx)
10
- idx = find_index_by_title(idx) if idx.kind_of?(String)
11
- return nil unless idx
12
- initialize_row(row_collection[idx], :platform => :watir_webdriver)
13
- end
8
+ include GxtWidgets::Platforms::WatirWebDriver::RowContainer
14
9
 
15
10
  def header
16
11
  initialize_header(row_collection[0], :platform => :watir_webdriver)
17
12
  end
18
-
19
- private
20
-
21
- def find_index_by_title(row_title)
22
- row_collection.find_index do |row|
23
- row.cells.any? { |col| col.text.include? row_title }
24
- end
25
- end
26
-
27
- def row_collection
28
- element.trs(:xpath => child_xpath)
29
- end
30
13
  end
31
14
  end
32
15
  end
@@ -0,0 +1,16 @@
1
+ require 'gxt-widgets/platforms/watir_webdriver/row_container'
2
+ module GxtWidgets
3
+ module Platforms
4
+ module WatirWebDriver
5
+ module GxtGroupingGrid
6
+ include GxtWidgets::Platforms::WatirWebDriver::RowContainer
7
+
8
+ private
9
+ def get_groups
10
+ element.divs(:xpath, "//div[contains(@class, 'x-grid-group ')]")
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ require "gxt-widgets/gxt_grid_row"
2
+ require 'gxt-widgets/gxt_grid_header_row'
3
+ module GxtWidgets
4
+ module Platforms
5
+ module WatirWebDriver
6
+ module RowContainer
7
+ include PageObject::Platforms::WatirWebDriver::Table
8
+
9
+ def [](idx)
10
+ idx = find_index_by_title(idx) if idx.kind_of?(String)
11
+ return nil unless idx
12
+ initialize_row(row_collection[idx], :platform => :watir_webdriver)
13
+ end
14
+
15
+ private
16
+
17
+ def find_index_by_title(row_title)
18
+ row_collection.find_index do |row|
19
+ row.cells.any? { |col| col.text.include? row_title }
20
+ end
21
+ end
22
+
23
+ def row_collection
24
+ element.trs(:xpath => child_xpath)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+
@@ -0,0 +1,28 @@
1
+ require 'watir-webdriver'
2
+ require 'page-object/platforms/watir_webdriver/table'
3
+ module GxtWidgets
4
+ class RowContainer < PageObject::Elements::Table
5
+
6
+ protected
7
+ def child_xpath
8
+ ".//descendant::tr"
9
+ end
10
+
11
+ def initialize_row(row_element, platform)
12
+ Object::GxtWidgets::GxtGridRow.new(row_element, self, platform)
13
+ end
14
+
15
+ def include_platform_for platform
16
+ super
17
+ if platform[:platform] == :watir_webdriver
18
+ require 'gxt-widgets/platforms/watir_webdriver/row_container'
19
+ self.class.send :include, GxtWidgets::Platforms::WatirWebDriver::RowContainer
20
+ elsif platform[:platform] == :selenium_webdriver
21
+ require 'gxt-widgets/platforms/selenium_webdriver/row_container'
22
+ self.class.send :include, GxtWidgets::Platforms::SeleniumWebDriver::RowContainer
23
+ else
24
+ raise ArgumentError, "expect platform to be :watir_webdriver or :selenium_webdriver"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,4 +1,4 @@
1
1
  module GxtWidgets
2
2
  # @private
3
- VERSION = "0.1"
3
+ VERSION = "0.2"
4
4
  end
@@ -17,7 +17,7 @@ describe GxtWidgets::GxtGridRow do
17
17
  table_row[0].should be_instance_of PageObject::Elements::TableCell
18
18
  end
19
19
 
20
- it "should retrun the number of columns" do
20
+ it "should return the number of columns" do
21
21
  table_row = GxtWidgets::GxtGridRow.new(table_row_driver, table, :platform => :selenium_webdriver)
22
22
  table_row_driver.should_receive(:find_elements).with(:xpath, ".//child::td|th").and_return(table_row_driver)
23
23
  table_row_driver.should_receive(:size).and_return(3)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gxt-widgets
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-27 00:00:00.000000000 Z
13
+ date: 2013-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: page-object
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.8.2
22
+ version: 0.9.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 0.8.2
30
+ version: 0.9.1
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rspec
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +138,7 @@ files:
138
138
  - Gemfile
139
139
  - Rakefile
140
140
  - cucumber.yml
141
+ - features/gxt_basic_tree.feature
141
142
  - features/gxt_grid.feature
142
143
  - features/gxt_grid_with_grouping.feature
143
144
  - features/gxt_pager.feature
@@ -145,30 +146,42 @@ files:
145
146
  - features/step_definitions/gxt_grid_steps.rb
146
147
  - features/step_definitions/gxt_grid_with_grouping_steps.rb
147
148
  - features/step_definitions/gxt_pager_steps.rb
149
+ - features/step_definitions/gxt_tree_steps.rb
148
150
  - features/support/env.rb
149
151
  - features/support/hooks.rb
150
152
  - features/support/pages/basic_grid_example.rb
153
+ - features/support/pages/basic_tree_example.rb
151
154
  - features/support/pages/grouping_grid_example.rb
152
155
  - features/support/pages/gxt_examples_page.rb
153
156
  - features/support/pages/local_pagination_example.rb
154
157
  - features/support/persistent_browser.rb
155
158
  - gxt-widget.gemspec
156
159
  - lib/gxt-widgets.rb
160
+ - lib/gxt-widgets/gxt_basic_tree.rb
157
161
  - lib/gxt-widgets/gxt_column_menu.rb
158
162
  - lib/gxt-widgets/gxt_column_selection_menu.rb
159
163
  - lib/gxt-widgets/gxt_grid.rb
164
+ - lib/gxt-widgets/gxt_grid_group.rb
160
165
  - lib/gxt-widgets/gxt_grid_header_row.rb
161
166
  - lib/gxt-widgets/gxt_grid_row.rb
167
+ - lib/gxt-widgets/gxt_group_column_menu.rb
168
+ - lib/gxt-widgets/gxt_grouping_grid.rb
162
169
  - lib/gxt-widgets/gxt_header_cell.rb
163
170
  - lib/gxt-widgets/gxt_pager.rb
171
+ - lib/gxt-widgets/modules/groupable_column.rb
164
172
  - lib/gxt-widgets/modules/selectable_column.rb
165
173
  - lib/gxt-widgets/modules/sortable_column.rb
166
174
  - lib/gxt-widgets/platforms/selenium_webdriver/gxt_grid.rb
167
175
  - lib/gxt-widgets/platforms/selenium_webdriver/gxt_grid_header_row.rb
168
176
  - lib/gxt-widgets/platforms/selenium_webdriver/gxt_grid_row.rb
177
+ - lib/gxt-widgets/platforms/selenium_webdriver/gxt_grouping_grid.rb
178
+ - lib/gxt-widgets/platforms/selenium_webdriver/row_container.rb
169
179
  - lib/gxt-widgets/platforms/watir_webdriver/gxt_grid.rb
170
180
  - lib/gxt-widgets/platforms/watir_webdriver/gxt_grid_header_row.rb
171
181
  - lib/gxt-widgets/platforms/watir_webdriver/gxt_grid_row.rb
182
+ - lib/gxt-widgets/platforms/watir_webdriver/gxt_grouping_grid.rb
183
+ - lib/gxt-widgets/platforms/watir_webdriver/row_container.rb
184
+ - lib/gxt-widgets/row_container.rb
172
185
  - lib/gxt-widgets/version.rb
173
186
  - readme.md
174
187
  - spec/gxt-widgets/gxt_grid_row_spec.rb
@@ -185,25 +198,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
198
  - - ! '>='
186
199
  - !ruby/object:Gem::Version
187
200
  version: '0'
188
- segments:
189
- - 0
190
- hash: -3067973274556583158
191
201
  required_rubygems_version: !ruby/object:Gem::Requirement
192
202
  none: false
193
203
  requirements:
194
204
  - - ! '>='
195
205
  - !ruby/object:Gem::Version
196
206
  version: '0'
197
- segments:
198
- - 0
199
- hash: -3067973274556583158
200
207
  requirements: []
201
208
  rubyforge_project: gxt-widgets
202
- rubygems_version: 1.8.25
209
+ rubygems_version: 1.8.24
203
210
  signing_key:
204
211
  specification_version: 3
205
212
  summary: PageObject Widgets to simplify testing GXT applications
206
213
  test_files:
214
+ - features/gxt_basic_tree.feature
207
215
  - features/gxt_grid.feature
208
216
  - features/gxt_grid_with_grouping.feature
209
217
  - features/gxt_pager.feature
@@ -211,9 +219,11 @@ test_files:
211
219
  - features/step_definitions/gxt_grid_steps.rb
212
220
  - features/step_definitions/gxt_grid_with_grouping_steps.rb
213
221
  - features/step_definitions/gxt_pager_steps.rb
222
+ - features/step_definitions/gxt_tree_steps.rb
214
223
  - features/support/env.rb
215
224
  - features/support/hooks.rb
216
225
  - features/support/pages/basic_grid_example.rb
226
+ - features/support/pages/basic_tree_example.rb
217
227
  - features/support/pages/grouping_grid_example.rb
218
228
  - features/support/pages/gxt_examples_page.rb
219
229
  - features/support/pages/local_pagination_example.rb