mohawk 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +4 -0
- data/features/step_definitions/tabs_steps.rb +23 -0
- data/features/support/WindowsForms.exe +0 -0
- data/features/support/screens/about_screen.rb +1 -0
- data/features/tabs.feature +22 -0
- data/lib/mohawk/accessors/tabs.rb +30 -0
- data/lib/mohawk/accessors.rb +23 -0
- data/lib/mohawk/adapters/uia_adapter.rb +4 -0
- data/lib/mohawk/version.rb +1 -1
- data/mohawk.gemspec +1 -1
- data/spec/lib/mohawk/accessors/tabs_spec.rb +58 -0
- metadata +11 -4
data/Changelog
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
Given(/^we are looking at the about screen$/) do
|
2
|
+
on(MainScreen).about
|
3
|
+
end
|
4
|
+
|
5
|
+
Then(/^we know that the currently selected tab is "([^"]*)"$/) do |expected_tab|
|
6
|
+
on(AboutScreen).tab.should eq(expected_tab)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then(/^we know that the available tabs are "([^"]*)"$/) do |tabs|
|
10
|
+
on(AboutScreen).tab_items.should eq(tabs.split(', '))
|
11
|
+
end
|
12
|
+
|
13
|
+
When(/^we select the tab at index "([^"]*)"$/) do |tab_index|
|
14
|
+
on(AboutScreen).tab = tab_index.to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
When(/^we select the tab with the text "([^"]*)"$/) do |which|
|
18
|
+
on(AboutScreen).tab = which
|
19
|
+
end
|
20
|
+
|
21
|
+
When(/^we select the tab with the regex "([^"]*)"$/) do |which_regex|
|
22
|
+
on(AboutScreen).tab = /#{which_regex}/
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: Working with tab controls
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given we are looking at the about screen
|
5
|
+
|
6
|
+
Scenario: Getting the currently selected tab
|
7
|
+
Then we know that the currently selected tab is "Info"
|
8
|
+
|
9
|
+
Scenario: Getting the available tabs
|
10
|
+
Then we know that the available tabs are "Info, Other Info"
|
11
|
+
|
12
|
+
Scenario: Selecting tabs by index
|
13
|
+
When we select the tab at index "1"
|
14
|
+
Then we know that the currently selected tab is "Other Info"
|
15
|
+
|
16
|
+
Scenario: Selecting tabs by their values
|
17
|
+
When we select the tab with the text "Other Info"
|
18
|
+
Then we know that the currently selected tab is "Other Info"
|
19
|
+
|
20
|
+
Scenario: Selecting tabs by a regex
|
21
|
+
When we select the tab with the regex "[Oo]ther?\sInfo$"
|
22
|
+
Then we know that the currently selected tab is "Other Info"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Accessors
|
3
|
+
class Tabs
|
4
|
+
attr_reader :view
|
5
|
+
|
6
|
+
def initialize(adapter, locator)
|
7
|
+
@view = adapter.window.tab_control(locator)
|
8
|
+
end
|
9
|
+
|
10
|
+
def value
|
11
|
+
view.value
|
12
|
+
end
|
13
|
+
|
14
|
+
def selected_tab=(which)
|
15
|
+
case which
|
16
|
+
when String
|
17
|
+
view.set(which)
|
18
|
+
when Regexp
|
19
|
+
view.set items.find {|t| t.match which }
|
20
|
+
else
|
21
|
+
view.select(which)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def items
|
26
|
+
@view.items.map(&:text)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/mohawk/accessors.rb
CHANGED
@@ -291,6 +291,29 @@ module Mohawk
|
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
+
# Generates methods for working with tab controls
|
295
|
+
#
|
296
|
+
# @example
|
297
|
+
# tabs(:tab, :id => "tableId")
|
298
|
+
# # will generate 'tab', 'tab=' and 'tab_items' methods to get the current tab,
|
299
|
+
# # set the currently selected tab (Fixnum, String or RegEx) and to get the
|
300
|
+
# # available tabs to be selected
|
301
|
+
#
|
302
|
+
# @param [String] the name used for the generated methods
|
303
|
+
# @param [Hash] locator for how the tab control is found
|
304
|
+
#
|
305
|
+
def tabs(name, locator)
|
306
|
+
define_method(name) do
|
307
|
+
adapter.tab_control(locator).value
|
308
|
+
end
|
309
|
+
define_method("#{name}=") do |which|
|
310
|
+
adapter.tab_control(locator).selected_tab = which
|
311
|
+
end
|
312
|
+
define_method("#{name}_items") do
|
313
|
+
adapter.tab_control(locator).items
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
294
317
|
def control(name, locator)
|
295
318
|
define_method("#{name}_value") do
|
296
319
|
adapter.value_control(locator).value
|
@@ -73,6 +73,10 @@ module Mohawk
|
|
73
73
|
@controls[locator] ||= Mohawk::Accessors::Control.new(self, merge(locator))
|
74
74
|
end
|
75
75
|
|
76
|
+
def tab_control(locator)
|
77
|
+
Mohawk::Accessors::Tabs.new(self, merge(locator))
|
78
|
+
end
|
79
|
+
|
76
80
|
private
|
77
81
|
def merge(locator)
|
78
82
|
locator = locator.merge(:children_only => true) if @only_search_children
|
data/lib/mohawk/version.rb
CHANGED
data/mohawk.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency 'rautomation', '~> 0.
|
21
|
+
gem.add_dependency 'rautomation', '~> 0.10.0'
|
22
22
|
gem.add_dependency 'require_all'
|
23
23
|
gem.add_dependency 'page_navigation', '>= 0.7'
|
24
24
|
gem.add_dependency 'childprocess', '~> 0.3.9'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TabsScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:id => 123)
|
6
|
+
|
7
|
+
tabs(:tab, :id => 'tabsId')
|
8
|
+
end
|
9
|
+
|
10
|
+
class TabItem
|
11
|
+
attr_reader :text, :index
|
12
|
+
def initialize(text, index)
|
13
|
+
@text, @index = text, index
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Mohawk::Accessors::Tabs do
|
18
|
+
let(:window) { double('RAutomation Window') }
|
19
|
+
let(:tab_control) { double('RAutomation TabControl') }
|
20
|
+
subject { TabsScreen.new }
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
RAutomation::Window.stub(:new).and_return(window)
|
24
|
+
window.should_receive(:tab_control).with(:id => 'tabsId').and_return(tab_control)
|
25
|
+
end
|
26
|
+
|
27
|
+
def tabs_are(*tabs)
|
28
|
+
expected = tabs.each_with_index.map {|t, i| TabItem.new(t, i) }
|
29
|
+
tab_control.should_receive(:items).and_return(expected)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'knows the currently selected tab' do
|
33
|
+
tab_control.should_receive(:value).and_return('Current Tab')
|
34
|
+
|
35
|
+
subject.tab.should eq('Current Tab')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'knows the available tabs' do
|
39
|
+
tabs_are('first', 'second')
|
40
|
+
subject.tab_items.should eq(['first', 'second'])
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can select tabs by index' do
|
44
|
+
tab_control.should_receive(:select).with(1)
|
45
|
+
subject.tab = 1
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'can select tabs by value' do
|
49
|
+
tab_control.should_receive(:set).with('The Tab')
|
50
|
+
subject.tab = 'The Tab'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'can select tabs by regex' do
|
54
|
+
tabs_are('Something', 'With the Number 7')
|
55
|
+
tab_control.should_receive(:set).with('With the Number 7')
|
56
|
+
subject.tab = /\d+/
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mohawk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rautomation
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.10.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.10.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: require_all
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -257,6 +257,7 @@ files:
|
|
257
257
|
- features/step_definitions/navigation_steps.rb
|
258
258
|
- features/step_definitions/radio_steps.rb
|
259
259
|
- features/step_definitions/table_steps.rb
|
260
|
+
- features/step_definitions/tabs_steps.rb
|
260
261
|
- features/step_definitions/text_steps.rb
|
261
262
|
- features/step_definitions/tree_view_steps.rb
|
262
263
|
- features/support/FizzWare.NBuilder.dll
|
@@ -294,6 +295,7 @@ files:
|
|
294
295
|
- features/support/screens/screen_with_container.rb
|
295
296
|
- features/support/string.rb
|
296
297
|
- features/table.feature
|
298
|
+
- features/tabs.feature
|
297
299
|
- features/text.feature
|
298
300
|
- features/tree_view.feature
|
299
301
|
- lib/mohawk.rb
|
@@ -308,6 +310,7 @@ files:
|
|
308
310
|
- lib/mohawk/accessors/radio.rb
|
309
311
|
- lib/mohawk/accessors/table.rb
|
310
312
|
- lib/mohawk/accessors/table_row.rb
|
313
|
+
- lib/mohawk/accessors/tabs.rb
|
311
314
|
- lib/mohawk/accessors/text.rb
|
312
315
|
- lib/mohawk/accessors/tree_view.rb
|
313
316
|
- lib/mohawk/adapters/uia_adapter.rb
|
@@ -325,6 +328,7 @@ files:
|
|
325
328
|
- spec/lib/mohawk/accessors/menu_spec.rb
|
326
329
|
- spec/lib/mohawk/accessors/radio_spec.rb
|
327
330
|
- spec/lib/mohawk/accessors/table_spec.rb
|
331
|
+
- spec/lib/mohawk/accessors/tabs_spec.rb
|
328
332
|
- spec/lib/mohawk/accessors/text_spec.rb
|
329
333
|
- spec/lib/mohawk/accessors/tree_view_spec.rb
|
330
334
|
- spec/lib/mohawk/adapters/uia_adapter_spec.rb
|
@@ -379,6 +383,7 @@ test_files:
|
|
379
383
|
- features/step_definitions/navigation_steps.rb
|
380
384
|
- features/step_definitions/radio_steps.rb
|
381
385
|
- features/step_definitions/table_steps.rb
|
386
|
+
- features/step_definitions/tabs_steps.rb
|
382
387
|
- features/step_definitions/text_steps.rb
|
383
388
|
- features/step_definitions/tree_view_steps.rb
|
384
389
|
- features/support/FizzWare.NBuilder.dll
|
@@ -416,6 +421,7 @@ test_files:
|
|
416
421
|
- features/support/screens/screen_with_container.rb
|
417
422
|
- features/support/string.rb
|
418
423
|
- features/table.feature
|
424
|
+
- features/tabs.feature
|
419
425
|
- features/text.feature
|
420
426
|
- features/tree_view.feature
|
421
427
|
- spec/ffi_stub.rb
|
@@ -428,6 +434,7 @@ test_files:
|
|
428
434
|
- spec/lib/mohawk/accessors/menu_spec.rb
|
429
435
|
- spec/lib/mohawk/accessors/radio_spec.rb
|
430
436
|
- spec/lib/mohawk/accessors/table_spec.rb
|
437
|
+
- spec/lib/mohawk/accessors/tabs_spec.rb
|
431
438
|
- spec/lib/mohawk/accessors/text_spec.rb
|
432
439
|
- spec/lib/mohawk/accessors/tree_view_spec.rb
|
433
440
|
- spec/lib/mohawk/adapters/uia_adapter_spec.rb
|