mohawk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +1 -0
- data/Changelog +3 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +18 -0
- data/cucumber.yml +1 -0
- data/features/button.feature +10 -0
- data/features/checkbox.feature +12 -0
- data/features/combo_box.feature +19 -0
- data/features/fado.feature +5 -0
- data/features/radio.feature +5 -0
- data/features/step_definitions/button_steps.rb +15 -0
- data/features/step_definitions/checkbox_steps.rb +19 -0
- data/features/step_definitions/combo_box_steps.rb +20 -0
- data/features/step_definitions/fado_steps.rb +7 -0
- data/features/step_definitions/radio_steps.rb +7 -0
- data/features/step_definitions/text_steps.rb +11 -0
- data/features/support/WindowsForms.exe +0 -0
- data/features/support/env.rb +17 -0
- data/features/support/screens/main_screen.rb +10 -0
- data/features/support/string.rb +5 -0
- data/features/text.feature +10 -0
- data/lib/mohawk/accessors/button.rb +18 -0
- data/lib/mohawk/accessors/checkbox.rb +22 -0
- data/lib/mohawk/accessors/combo.rb +22 -0
- data/lib/mohawk/accessors/radio.rb +17 -0
- data/lib/mohawk/accessors/text.rb +21 -0
- data/lib/mohawk/accessors.rb +63 -0
- data/lib/mohawk/adapters/uia_adapter.rb +31 -0
- data/lib/mohawk/navigation.rb +9 -0
- data/lib/mohawk/version.rb +3 -0
- data/lib/mohawk.rb +28 -0
- data/mohawk.gemspec +24 -0
- data/spec/lib/mohawk/accessors/button_spec.rb +41 -0
- data/spec/lib/mohawk/accessors/checkbox_spec.rb +43 -0
- data/spec/lib/mohawk/accessors/combo_spec.rb +55 -0
- data/spec/lib/mohawk/accessors/radio_spec.rb +31 -0
- data/spec/lib/mohawk/accessors/text_spec.rb +38 -0
- data/spec/lib/mohawk_spec.rb +30 -0
- data/spec/spec_helper.rb +5 -0
- metadata +158 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: ruby
|
data/Changelog
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Levi Wilson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Mohawk
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/leviwilson/mohawk.png)](https://travis-ci.org/leviwilson/mohawk)
|
4
|
+
|
5
|
+
A gem to assist in building page-object like structures for testing Windows applications.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'mohawk'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mohawk
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
26
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'cucumber'
|
5
|
+
require 'cucumber/rake/task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
8
|
+
spec.ruby_opts = "-I lib:spec"
|
9
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
10
|
+
spec.rspec_opts = "--color -f documentation"
|
11
|
+
end
|
12
|
+
task :spec
|
13
|
+
|
14
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
15
|
+
t.profile = 'default'
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :spec
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --no-source --color --format pretty
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Working with button controls
|
2
|
+
|
3
|
+
Scenario: Clicking buttons
|
4
|
+
When I click the "Data Entry Form" button
|
5
|
+
Then I should see the "DataEntryForm" window
|
6
|
+
|
7
|
+
Scenario: Getting button values
|
8
|
+
When I look at the value of the "Data Entry Form button" control
|
9
|
+
Then the value should be "Data Entry Form"
|
10
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Working with checkbox controls
|
2
|
+
|
3
|
+
Scenario: Setting the checkbox
|
4
|
+
When I check the "first checkbox"
|
5
|
+
Then the "first checkbox" should be checked
|
6
|
+
|
7
|
+
Scenario: Clearing the checkbox
|
8
|
+
When I uncheck the "first checkbox"
|
9
|
+
Then the "first checkbox" should not be checked
|
10
|
+
|
11
|
+
Scenario: Getting the value of the checkbox
|
12
|
+
Then I know that the "first checkbox" value is "checkBox"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Working with combo boxes
|
2
|
+
|
3
|
+
Scenario: Selecting items by index
|
4
|
+
When I select index "2" from the "fruits" combo box
|
5
|
+
Then the "Coconut" option should be selected in the "fruits" combo box
|
6
|
+
|
7
|
+
Scenario: Selecting items by value
|
8
|
+
When I select the value "Orange" from the "fruits" combo box
|
9
|
+
Then the "Orange" option should be selected in the "fruits" combo box
|
10
|
+
|
11
|
+
Scenario: Getting the available options
|
12
|
+
When I look at the options for the "fruits" combo box"
|
13
|
+
Then I should see the following options:
|
14
|
+
| Option |
|
15
|
+
| Apple |
|
16
|
+
| Caimito |
|
17
|
+
| Coconut |
|
18
|
+
| Orange |
|
19
|
+
| Passion Fruit |
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^I click the "(.*?)" button$/ do |name|
|
2
|
+
on(MainScreen).send "#{name.to_field}_button"
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should see the "(.*?)" window$/ do |window_title|
|
6
|
+
RAutomation::Window.new(:title => window_title).wait_until_exists
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^I look at the value of the "(.*?)" control$/ do |name|
|
10
|
+
@last_value = on(MainScreen).send "#{name.to_field}_value"
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^the value should be "(.*?)"$/ do |value|
|
14
|
+
@last_value.should eq(value)
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
When /^I check the "(.*?)"$/ do |name|
|
2
|
+
on(MainScreen).send "#{name.to_field}=", true
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I uncheck the "(.*?)"$/ do |name|
|
6
|
+
on(MainScreen).send "#{name.to_field}=", false
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the "(.*?)" should be checked$/ do |name|
|
10
|
+
on(MainScreen).send("#{name.to_field}").should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^the "(.*?)" should not be checked$/ do |name|
|
14
|
+
on(MainScreen).send("#{name.to_field}").should be_false
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^I know that the "(.*?)" value is "(.*?)"$/ do |name, expected_value|
|
18
|
+
on(MainScreen).send("#{name.to_field}_value").should eq(expected_value)
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
When /^I select index "(.*?)" from the "(.*?)" combo box$/ do |index, name|
|
2
|
+
on(MainScreen).send "#{name.to_field}=", index.to_i
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I select the value "(.*?)" from the "(.*?)" combo box$/ do |index, name|
|
6
|
+
on(MainScreen).send "#{name.to_field}=", index
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the "(.*?)" option should be selected in the "(.*?)" combo box$/ do |value, name|
|
10
|
+
on(MainScreen).send("#{name.to_field}").should eq(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I look at the options for the "(.*?)" combo box"$/ do |name|
|
14
|
+
@options = on(MainScreen).send("#{name.to_field}_options")
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^I should see the following options:$/ do |table|
|
18
|
+
expected_options = table.hashes.map {|row| row["Option"] }
|
19
|
+
@options.should eq(expected_options)
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
When /^I set the "(.*)" to the value "(.*)"$/ do |name, value|
|
2
|
+
on(MainScreen).send "#{name.to_field}=", value
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I clear the "(.*)"$/ do |name|
|
6
|
+
on(MainScreen).send "clear_#{name.to_field}"
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the "(.*)" should be "(.*)"$/ do |name, value|
|
10
|
+
on(MainScreen).send("#{name.to_field}").should eq(value)
|
11
|
+
end
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
|
2
|
+
|
3
|
+
require 'rspec-expectations'
|
4
|
+
require 'childprocess'
|
5
|
+
require 'mohawk'
|
6
|
+
|
7
|
+
World(Mohawk::Navigation)
|
8
|
+
|
9
|
+
Before do
|
10
|
+
@process = ChildProcess.build('features\\support\\WindowsForms.exe')
|
11
|
+
@process.start
|
12
|
+
RAutomation::WaitHelper.wait_until {RAutomation::Window.new(:pid => @process.pid).present?}
|
13
|
+
end
|
14
|
+
|
15
|
+
After do
|
16
|
+
@process.stop
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class MainScreen
|
2
|
+
include Mohawk
|
3
|
+
window(:title => /MainFormWindow/)
|
4
|
+
|
5
|
+
text(:text_field, :id => "textField")
|
6
|
+
button(:data_entry_form_button, :value => "Data Entry Form")
|
7
|
+
combo_box(:fruits, :id => "FruitsComboBox")
|
8
|
+
checkbox(:first_checkbox, :id => "checkBox")
|
9
|
+
radio(:first_radio, :id => "radioButton1")
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Working with text controls
|
2
|
+
|
3
|
+
Scenario: Setting and getting text
|
4
|
+
When I set the "text field" to the value "Some text"
|
5
|
+
Then the "text field" should be "Some text"
|
6
|
+
|
7
|
+
Scenario: Clearing text
|
8
|
+
When I set the "text field" to the value "Text to be cleared"
|
9
|
+
And I clear the "text field"
|
10
|
+
Then the "text field" should be ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Accessors
|
3
|
+
class Button
|
4
|
+
def initialize(adapter, locator)
|
5
|
+
@button = adapter.window.button(locator)
|
6
|
+
end
|
7
|
+
|
8
|
+
def click(&block)
|
9
|
+
@button.click &block if block
|
10
|
+
@button.click {true} unless block
|
11
|
+
end
|
12
|
+
|
13
|
+
def value
|
14
|
+
@button.value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Accessors
|
3
|
+
class CheckBox
|
4
|
+
def initialize(adapter, locator)
|
5
|
+
@checkbox = adapter.window.checkbox(locator)
|
6
|
+
end
|
7
|
+
|
8
|
+
def checked?
|
9
|
+
@checkbox.set?
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_check(should_check)
|
13
|
+
@checkbox.set if should_check
|
14
|
+
@checkbox.clear unless should_check
|
15
|
+
end
|
16
|
+
|
17
|
+
def value
|
18
|
+
@checkbox.value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Accessors
|
3
|
+
class Combo
|
4
|
+
def initialize(adapter, locator)
|
5
|
+
@combo = adapter.window.select_list(locator)
|
6
|
+
end
|
7
|
+
|
8
|
+
def value
|
9
|
+
@combo.value
|
10
|
+
end
|
11
|
+
|
12
|
+
def set(value)
|
13
|
+
@combo.select value if value.instance_of? Fixnum
|
14
|
+
@combo.set value if value.instance_of? String
|
15
|
+
end
|
16
|
+
|
17
|
+
def options
|
18
|
+
@combo.options.map &:text
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Accessors
|
3
|
+
class Text
|
4
|
+
def initialize(adapter, locator)
|
5
|
+
@text = adapter.window.text_field(locator)
|
6
|
+
end
|
7
|
+
|
8
|
+
def value
|
9
|
+
@text.value
|
10
|
+
end
|
11
|
+
|
12
|
+
def set(text)
|
13
|
+
@text.set text
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear
|
17
|
+
@text.clear
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Accessors
|
3
|
+
def window(locator)
|
4
|
+
define_method("which_window") do
|
5
|
+
locator
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def text(name, locator)
|
10
|
+
define_method("#{name}") do
|
11
|
+
adapter.text(locator).value
|
12
|
+
end
|
13
|
+
define_method("#{name}=") do |text|
|
14
|
+
adapter.text(locator).set text
|
15
|
+
end
|
16
|
+
define_method("clear_#{name}") do
|
17
|
+
adapter.text(locator).clear
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def button(name, locator)
|
22
|
+
define_method("#{name}") do |&block|
|
23
|
+
adapter.button(locator).click &block
|
24
|
+
end
|
25
|
+
define_method("#{name}_value") do
|
26
|
+
adapter.button(locator).value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def combo_box(name, locator)
|
31
|
+
define_method("#{name}") do
|
32
|
+
adapter.combo(locator).value
|
33
|
+
end
|
34
|
+
define_method("#{name}=") do |item|
|
35
|
+
adapter.combo(locator).set item
|
36
|
+
end
|
37
|
+
define_method("#{name}_options") do
|
38
|
+
adapter.combo(locator).options
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def checkbox(name, locator)
|
43
|
+
define_method("#{name}") do
|
44
|
+
adapter.checkbox(locator).checked?
|
45
|
+
end
|
46
|
+
define_method("#{name}=") do |should_check|
|
47
|
+
adapter.checkbox(locator).set_check should_check
|
48
|
+
end
|
49
|
+
define_method("#{name}_value") do
|
50
|
+
adapter.checkbox(locator).value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def radio(name, locator)
|
55
|
+
define_method("#{name}") do
|
56
|
+
adapter.radio(locator).set
|
57
|
+
end
|
58
|
+
define_method("#{name}?") do
|
59
|
+
adapter.radio(locator).set?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Mohawk
|
2
|
+
module Adapters
|
3
|
+
class UiaAdapter
|
4
|
+
attr_reader :window
|
5
|
+
|
6
|
+
def initialize(locator)
|
7
|
+
@window = RAutomation::Window.new(locator.merge(:adapter => :ms_uia))
|
8
|
+
end
|
9
|
+
|
10
|
+
def combo(locator)
|
11
|
+
Mohawk::Accessors::Combo.new(self, locator)
|
12
|
+
end
|
13
|
+
|
14
|
+
def checkbox(locator)
|
15
|
+
Mohawk::Accessors::CheckBox.new(self, locator)
|
16
|
+
end
|
17
|
+
|
18
|
+
def text(locator)
|
19
|
+
Mohawk::Accessors::Text.new(self, locator)
|
20
|
+
end
|
21
|
+
|
22
|
+
def button(locator)
|
23
|
+
Mohawk::Accessors::Button.new(self, locator)
|
24
|
+
end
|
25
|
+
|
26
|
+
def radio(locator)
|
27
|
+
Mohawk::Accessors::Radio.new(self, locator)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/mohawk.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "rautomation"
|
2
|
+
require "mohawk/version"
|
3
|
+
require "mohawk/accessors"
|
4
|
+
require "mohawk/accessors/button"
|
5
|
+
require "mohawk/accessors/checkbox"
|
6
|
+
require "mohawk/accessors/combo"
|
7
|
+
require "mohawk/accessors/radio"
|
8
|
+
require "mohawk/accessors/text"
|
9
|
+
require "mohawk/navigation"
|
10
|
+
require "mohawk/adapters/uia_adapter"
|
11
|
+
|
12
|
+
module Mohawk
|
13
|
+
|
14
|
+
attr_reader :adapter
|
15
|
+
|
16
|
+
def self.included(cls)
|
17
|
+
cls.extend Mohawk::Accessors
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@adapter = Mohawk::Adapters::UiaAdapter.new(which_window)
|
22
|
+
end
|
23
|
+
|
24
|
+
def exist?
|
25
|
+
adapter.window.exist?
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/mohawk.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mohawk/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "mohawk"
|
8
|
+
gem.version = Mohawk::VERSION
|
9
|
+
gem.authors = ["Levi Wilson"]
|
10
|
+
gem.email = ["levi@leviwilson.com"]
|
11
|
+
gem.description = %q{High level wrapper around windows applications}
|
12
|
+
gem.summary = %q{High level wrapper around windows applications}
|
13
|
+
gem.homepage = "http://github.com/leviwilson/mohawk"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'rautomation'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'childprocess'
|
23
|
+
gem.add_development_dependency 'rspec'
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ButtonScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:id => nil)
|
6
|
+
|
7
|
+
button(:easy, :id => "easyButton")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Mohawk::Accessors::Button do
|
11
|
+
let(:screen) { ButtonScreen.new }
|
12
|
+
let(:window) { double("RAutomation Window") }
|
13
|
+
let(:button_field) { double("Button Field") }
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
RAutomation::Window.stub(:new).and_return(window)
|
17
|
+
window.should_receive(:button).with(:id => "easyButton").and_return(button_field)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "accessing buttons" do
|
21
|
+
|
22
|
+
it "clicks buttons" do
|
23
|
+
button_field.should_receive(:click).and_yield
|
24
|
+
screen.easy
|
25
|
+
end
|
26
|
+
|
27
|
+
it "clicks buttons and yields to a block" do
|
28
|
+
button_field.should_receive(:click).and_yield
|
29
|
+
result = false
|
30
|
+
screen.easy do
|
31
|
+
result = true
|
32
|
+
end
|
33
|
+
result.should be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "knows the value of the button" do
|
37
|
+
button_field.should_receive(:value).and_return "Button Value"
|
38
|
+
screen.easy_value.should eq("Button Value")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class CheckboxScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:id => nil)
|
6
|
+
|
7
|
+
checkbox(:check_yourself, :id => "checkboxId")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Mohawk::Accessors::CheckBox do
|
11
|
+
let(:screen) { CheckboxScreen.new }
|
12
|
+
let(:window) { double("RAutomation Window") }
|
13
|
+
let(:checkbox_field) { double("CheckBox Field") }
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
RAutomation::Window.stub(:new).and_return(window)
|
17
|
+
window.should_receive(:checkbox).with(:id => "checkboxId").and_return(checkbox_field)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "accessing checkbox controls" do
|
21
|
+
|
22
|
+
it "knows if something is checked" do
|
23
|
+
checkbox_field.should_receive(:set?).and_return(true)
|
24
|
+
screen.check_yourself.should be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can get the text of the checkbox" do
|
28
|
+
checkbox_field.should_receive(:value).and_return("CheckBox Text")
|
29
|
+
screen.check_yourself_value.should eq("CheckBox Text")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can check items" do
|
33
|
+
checkbox_field.should_receive(:set)
|
34
|
+
screen.check_yourself = true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can uncheck items" do
|
38
|
+
checkbox_field.should_receive(:clear)
|
39
|
+
screen.check_yourself = false
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ComboBoxScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:id => nil)
|
6
|
+
|
7
|
+
combo_box(:nacho_combos, :id => "comboBoxId")
|
8
|
+
end
|
9
|
+
|
10
|
+
class Option
|
11
|
+
def initialize(text)
|
12
|
+
@text = text
|
13
|
+
end
|
14
|
+
|
15
|
+
def text
|
16
|
+
@text
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Mohawk::Accessors::Combo do
|
21
|
+
let(:screen) { ComboBoxScreen.new }
|
22
|
+
let(:window) { double("RAutomation Window") }
|
23
|
+
let(:combo_box_field) { double("ComboBox Field") }
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
RAutomation::Window.stub(:new).and_return(window)
|
27
|
+
window.should_receive(:select_list).with(:id => "comboBoxId").and_return(combo_box_field)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "accessing combo box controls" do
|
31
|
+
|
32
|
+
it "knows the current selected item" do
|
33
|
+
combo_box_field.should_receive(:value).and_return("Selected Item")
|
34
|
+
screen.nacho_combos.should eq("Selected Item")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "selects items by index" do
|
38
|
+
combo_box_field.should_receive(:select).with(3)
|
39
|
+
screen.nacho_combos = 3
|
40
|
+
end
|
41
|
+
|
42
|
+
it "selects items by value" do
|
43
|
+
combo_box_field.should_receive(:set).with("Desired Value")
|
44
|
+
screen.nacho_combos = "Desired Value"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "is aware of the available options" do
|
48
|
+
options = [Option.new("first"), Option.new("second"), Option.new("third")]
|
49
|
+
combo_box_field.should_receive(:options).and_return(options)
|
50
|
+
screen.nacho_combos_options.should eq(["first", "second", "third"])
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class RadioScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:id => nil)
|
6
|
+
|
7
|
+
radio(:radio_radio, :id => "radioId")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Mohawk::Accessors::Radio do
|
11
|
+
let(:screen) { RadioScreen.new }
|
12
|
+
let(:window) { double("RAutomation Window") }
|
13
|
+
let(:radio_control) { double("Elvis Costello's Radio Radio") }
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
RAutomation::Window.stub(:new).and_return(window)
|
17
|
+
window.should_receive(:radio).with(:id => "radioId").and_return(radio_control)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "working with radio controls" do
|
21
|
+
it "can set the radio control" do
|
22
|
+
radio_control.should_receive(:set)
|
23
|
+
screen.radio_radio
|
24
|
+
end
|
25
|
+
|
26
|
+
it "knows if the radio is selected" do
|
27
|
+
radio_control.should_receive(:set?)
|
28
|
+
screen.radio_radio?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TextScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:id => nil)
|
6
|
+
|
7
|
+
text(:text_id, :id => "textId")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Mohawk::Accessors::Text do
|
11
|
+
let(:screen) { TextScreen.new }
|
12
|
+
let(:window) { double("RAutomation Window") }
|
13
|
+
let(:text_field) { double("Text Field") }
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
RAutomation::Window.stub(:new).and_return(window)
|
17
|
+
window.should_receive(:text_field).with(:id => "textId").and_return(text_field)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "accessing text controls" do
|
21
|
+
|
22
|
+
it "sets the text" do
|
23
|
+
text_field.should_receive(:set).with("the text value")
|
24
|
+
screen.text_id = "the text value"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "retrieves the text" do
|
28
|
+
text_field.should_receive(:value).and_return("the text")
|
29
|
+
screen.text_id.should eq("the text")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "clears the text" do
|
33
|
+
text_field.should_receive(:clear)
|
34
|
+
screen.clear_text_id
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestScreen
|
4
|
+
include Mohawk
|
5
|
+
window(:title => "Some Window Title")
|
6
|
+
|
7
|
+
text(:text_id, :id => "textId")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Mohawk do
|
11
|
+
let(:screen) { TestScreen.new }
|
12
|
+
let(:window) { double('RAutomation Window') }
|
13
|
+
|
14
|
+
it "uses the uia adapter by default" do
|
15
|
+
RAutomation::Window.should_receive(:new).with(:title => "Some Window Title", :adapter => :ms_uia).and_return(window)
|
16
|
+
TestScreen.new
|
17
|
+
end
|
18
|
+
|
19
|
+
context "using the UI Automation adapter" do
|
20
|
+
before(:each) do
|
21
|
+
RAutomation::Window.stub(:new).and_return(window)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "knows if a window exists" do
|
25
|
+
window.should_receive(:exist?)
|
26
|
+
screen.exist?
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mohawk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Levi Wilson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rautomation
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: childprocess
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: High level wrapper around windows applications
|
63
|
+
email:
|
64
|
+
- levi@leviwilson.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- Changelog
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- cucumber.yml
|
77
|
+
- features/button.feature
|
78
|
+
- features/checkbox.feature
|
79
|
+
- features/combo_box.feature
|
80
|
+
- features/fado.feature
|
81
|
+
- features/radio.feature
|
82
|
+
- features/step_definitions/button_steps.rb
|
83
|
+
- features/step_definitions/checkbox_steps.rb
|
84
|
+
- features/step_definitions/combo_box_steps.rb
|
85
|
+
- features/step_definitions/fado_steps.rb
|
86
|
+
- features/step_definitions/radio_steps.rb
|
87
|
+
- features/step_definitions/text_steps.rb
|
88
|
+
- features/support/WindowsForms.exe
|
89
|
+
- features/support/env.rb
|
90
|
+
- features/support/screens/main_screen.rb
|
91
|
+
- features/support/string.rb
|
92
|
+
- features/text.feature
|
93
|
+
- lib/mohawk.rb
|
94
|
+
- lib/mohawk/accessors.rb
|
95
|
+
- lib/mohawk/accessors/button.rb
|
96
|
+
- lib/mohawk/accessors/checkbox.rb
|
97
|
+
- lib/mohawk/accessors/combo.rb
|
98
|
+
- lib/mohawk/accessors/radio.rb
|
99
|
+
- lib/mohawk/accessors/text.rb
|
100
|
+
- lib/mohawk/adapters/uia_adapter.rb
|
101
|
+
- lib/mohawk/navigation.rb
|
102
|
+
- lib/mohawk/version.rb
|
103
|
+
- mohawk.gemspec
|
104
|
+
- spec/lib/mohawk/accessors/button_spec.rb
|
105
|
+
- spec/lib/mohawk/accessors/checkbox_spec.rb
|
106
|
+
- spec/lib/mohawk/accessors/combo_spec.rb
|
107
|
+
- spec/lib/mohawk/accessors/radio_spec.rb
|
108
|
+
- spec/lib/mohawk/accessors/text_spec.rb
|
109
|
+
- spec/lib/mohawk_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
homepage: http://github.com/leviwilson/mohawk
|
112
|
+
licenses: []
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 1.8.24
|
132
|
+
signing_key:
|
133
|
+
specification_version: 3
|
134
|
+
summary: High level wrapper around windows applications
|
135
|
+
test_files:
|
136
|
+
- features/button.feature
|
137
|
+
- features/checkbox.feature
|
138
|
+
- features/combo_box.feature
|
139
|
+
- features/fado.feature
|
140
|
+
- features/radio.feature
|
141
|
+
- features/step_definitions/button_steps.rb
|
142
|
+
- features/step_definitions/checkbox_steps.rb
|
143
|
+
- features/step_definitions/combo_box_steps.rb
|
144
|
+
- features/step_definitions/fado_steps.rb
|
145
|
+
- features/step_definitions/radio_steps.rb
|
146
|
+
- features/step_definitions/text_steps.rb
|
147
|
+
- features/support/WindowsForms.exe
|
148
|
+
- features/support/env.rb
|
149
|
+
- features/support/screens/main_screen.rb
|
150
|
+
- features/support/string.rb
|
151
|
+
- features/text.feature
|
152
|
+
- spec/lib/mohawk/accessors/button_spec.rb
|
153
|
+
- spec/lib/mohawk/accessors/checkbox_spec.rb
|
154
|
+
- spec/lib/mohawk/accessors/combo_spec.rb
|
155
|
+
- spec/lib/mohawk/accessors/radio_spec.rb
|
156
|
+
- spec/lib/mohawk/accessors/text_spec.rb
|
157
|
+
- spec/lib/mohawk_spec.rb
|
158
|
+
- spec/spec_helper.rb
|