calios-uia-extension 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/calios-uia-extension.rb +9 -0
- data/lib/calios-uia-extension/uia_alert.rb +32 -0
- data/lib/calios-uia-extension/uia_base.rb +23 -0
- data/lib/calios-uia-extension/uia_popover.rb +18 -0
- data/lib/calios-uia-extension/version.rb +3 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/spec_uia_alert.rb +88 -0
- data/spec/spec_uia_base.rb +57 -0
- data/spec/spec_uia_popover.rb +51 -0
- data/spec/stubs/calabash_cucumber_core_stub.rb +10 -0
- data/spec/stubs/calabash_cucumber_uia_stub.rb +13 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: afb1d699cf345ff257d2858ca30e6f85aa22e9db
|
4
|
+
data.tar.gz: 4e536b0bcd50176ec4b907feedab7b93f883b4fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8fb8157b9eb74196f881f62bd9c11be7cefc350a3415d0d2b244b98abd843d694be773fc04f1a17ff156512f28ebd4765a286bb179c22b1585fb37edf2fe4d7
|
7
|
+
data.tar.gz: ad4093621889c7464d5def8a1e85dd54ac70f40c0a95b8a3692d2aea44489678f44755fb6c7b43e740878a4c357e3e2ad0b93b35fa6a3b017c5b7ad85c168e6d
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'uia_base'
|
2
|
+
|
3
|
+
class UIAAlert < UIABase
|
4
|
+
class << self
|
5
|
+
def visible?
|
6
|
+
res = execute('uia.alert() != null')
|
7
|
+
response(res)
|
8
|
+
end
|
9
|
+
|
10
|
+
def not_visible?
|
11
|
+
not self.visible?
|
12
|
+
end
|
13
|
+
|
14
|
+
def confirm
|
15
|
+
execute('uia.alert().defaultButton().tap()')
|
16
|
+
end
|
17
|
+
|
18
|
+
def cancel
|
19
|
+
execute('uia.alert().buttons()[0].tap()')
|
20
|
+
end
|
21
|
+
|
22
|
+
def button_count
|
23
|
+
res = execute('uia.alert().buttons()')
|
24
|
+
response(res).count
|
25
|
+
end
|
26
|
+
|
27
|
+
def tap(aButton)
|
28
|
+
raise 'invalid parameter' unless aButton.is_a?(String)
|
29
|
+
execute("uia.alert().buttons()['#{aButton}'].tap()")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
include Calabash::Cucumber::Core
|
2
|
+
|
3
|
+
class UIABase
|
4
|
+
class << self
|
5
|
+
def execute(aCommand)
|
6
|
+
Calabash::Cucumber::UIA.uia(aCommand)
|
7
|
+
end
|
8
|
+
|
9
|
+
def response(aHash)
|
10
|
+
aHash['value']
|
11
|
+
end
|
12
|
+
|
13
|
+
def response?(aHash)
|
14
|
+
response(aHash).to_boolean
|
15
|
+
end
|
16
|
+
|
17
|
+
def help
|
18
|
+
public_methods(false)
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :h, :help
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'uia_base'
|
2
|
+
|
3
|
+
class UIAPopover < UIABase
|
4
|
+
class << self
|
5
|
+
def visible?
|
6
|
+
res = execute('uia.window().popover().isVisible()')
|
7
|
+
response?(res)
|
8
|
+
end
|
9
|
+
|
10
|
+
def not_visible?
|
11
|
+
not self.visible?
|
12
|
+
end
|
13
|
+
|
14
|
+
def dismiss
|
15
|
+
execute('uia.window().popover().dismiss()')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/reporters'
|
3
|
+
|
4
|
+
require 'calios-uia-extension'
|
5
|
+
|
6
|
+
require_relative 'stubs/calabash_cucumber_core_stub'
|
7
|
+
require_relative 'stubs/calabash_cucumber_uia_stub'
|
8
|
+
|
9
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
class SpecUIAAlert < Minitest::Spec
|
4
|
+
before do
|
5
|
+
$uia_command = nil
|
6
|
+
$uia_opts = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
# nop
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'UIAAlert' do
|
14
|
+
describe 'UIAAlert.visible?' do
|
15
|
+
it 'should call Calabash uia command with correct parameters and return correct response' do
|
16
|
+
$stub_uia_response =
|
17
|
+
{
|
18
|
+
'status' => 'success',
|
19
|
+
'value' => true,
|
20
|
+
'index' => 19
|
21
|
+
}
|
22
|
+
|
23
|
+
res = UIAAlert.visible?
|
24
|
+
$uia_command.must_equal('uia.alert() != null')
|
25
|
+
res.must_equal(true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'UIAAlert.not_visible?' do
|
30
|
+
it 'should call Calabash uia command with correct parameters and return correct response' do
|
31
|
+
$stub_uia_response =
|
32
|
+
{
|
33
|
+
'status' => 'success',
|
34
|
+
'value' => false,
|
35
|
+
'index' => 19
|
36
|
+
}
|
37
|
+
|
38
|
+
res = UIAAlert.not_visible?
|
39
|
+
$uia_command.must_equal('uia.alert() != null')
|
40
|
+
res.must_equal(true)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'UIAAlert.confirm' do
|
45
|
+
it 'should call Calabash uia command with correct parameters' do
|
46
|
+
UIAAlert.confirm
|
47
|
+
$uia_command.must_equal('uia.alert().defaultButton().tap()')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'UIAAlert.cancel' do
|
52
|
+
it 'should call Calabash uia command with correct parameters' do
|
53
|
+
UIAAlert.cancel
|
54
|
+
$uia_command.must_equal('uia.alert().buttons()[0].tap()')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'UIAAlert.button_count' do
|
59
|
+
it 'should call Calabash uia command with correct parameters and return correct response' do
|
60
|
+
$stub_uia_response =
|
61
|
+
{
|
62
|
+
'status' => 'success',
|
63
|
+
'value' => [
|
64
|
+
'[object UIAButton]',
|
65
|
+
'[object UIAButton]'
|
66
|
+
],
|
67
|
+
'index' => 6
|
68
|
+
}
|
69
|
+
|
70
|
+
res = UIAAlert.button_count
|
71
|
+
$uia_command.must_equal('uia.alert().buttons()')
|
72
|
+
res.must_equal(2)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'UIAAlert.tap' do
|
77
|
+
it 'should raise if called with wrong parameter type' do
|
78
|
+
proc { UIAAlert.tap(1) }.must_raise(RuntimeError)
|
79
|
+
proc { UIAAlert.tap(:Symbol) }.must_raise(RuntimeError)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should call Calabash uia command with correct parameters' do
|
83
|
+
UIAAlert.tap('Cancel')
|
84
|
+
$uia_command.must_equal("uia.alert().buttons()['Cancel'].tap()")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
class SpecUIABase < Minitest::Spec
|
4
|
+
before do
|
5
|
+
$uia_command = nil
|
6
|
+
$uia_opts = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
# nop
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'UIABase' do
|
14
|
+
classes = [UIAAlert, UIAPopover]
|
15
|
+
classes.each do |klass|
|
16
|
+
describe "#{klass}.execute" do
|
17
|
+
it 'should call Calabash uia method with correct parameters' do
|
18
|
+
command = 'uia.alert() != null'
|
19
|
+
klass.execute(command)
|
20
|
+
$uia_command.must_equal(command)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#{klass}.response" do
|
25
|
+
it "should return 'value' from response hash" do
|
26
|
+
$stub_uia_response =
|
27
|
+
{
|
28
|
+
'status' => 'success',
|
29
|
+
'value' => true,
|
30
|
+
'index' => 19
|
31
|
+
}
|
32
|
+
|
33
|
+
command = 'uia.alert() != null'
|
34
|
+
res = klass.execute(command)
|
35
|
+
$uia_command.must_equal(command)
|
36
|
+
klass.response(res).must_equal(true)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#{klass}.response?" do
|
41
|
+
it "should return 'value' converted to boolean from response hash" do
|
42
|
+
$stub_uia_response =
|
43
|
+
{
|
44
|
+
'status' => 'success',
|
45
|
+
'value' => ':nil',
|
46
|
+
'index' => 19
|
47
|
+
}
|
48
|
+
|
49
|
+
command = 'uia.window().popover().isVisible()'
|
50
|
+
res = klass.execute(command)
|
51
|
+
$uia_command.must_equal(command)
|
52
|
+
klass.response?(res).must_equal(false)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
class SpecUIAPopover < Minitest::Spec
|
4
|
+
before do
|
5
|
+
$uia_command = nil
|
6
|
+
$uia_opts = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
# nop
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'UIAPopover' do
|
14
|
+
describe 'UIAPopover.visible?' do
|
15
|
+
it 'should call Calabash uia command with correct parameters and return correct response' do
|
16
|
+
$stub_uia_response =
|
17
|
+
{
|
18
|
+
'status' => 'success',
|
19
|
+
'value' => 1,
|
20
|
+
'index' => 19
|
21
|
+
}
|
22
|
+
|
23
|
+
res = UIAPopover.visible?
|
24
|
+
$uia_command.must_equal('uia.window().popover().isVisible()')
|
25
|
+
res.must_equal(true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'UIAPopover.not_visible?' do
|
30
|
+
it 'should call Calabash uia command with correct parameters and return correct response' do
|
31
|
+
$stub_uia_response =
|
32
|
+
{
|
33
|
+
'status' => 'success',
|
34
|
+
'value' => ':nil',
|
35
|
+
'index' => 19
|
36
|
+
}
|
37
|
+
|
38
|
+
res = UIAPopover.not_visible?
|
39
|
+
$uia_command.must_equal('uia.window().popover().isVisible()')
|
40
|
+
res.must_equal(true)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'UIAPopover.dismiss' do
|
45
|
+
it 'should call Calabash uia command with correct parameters' do
|
46
|
+
UIAPopover.dismiss
|
47
|
+
$uia_command.must_equal('uia.window().popover().dismiss()')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'calabash-cucumber/uia'
|
2
|
+
|
3
|
+
module Calabash::Cucumber::UIA
|
4
|
+
def uia(command,options={})
|
5
|
+
$uia_command = command
|
6
|
+
$uia_opts = options
|
7
|
+
$stub_uia_response
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class CalabashCucumberUIAStubClass
|
12
|
+
include Calabash::Cucumber::UIA
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: calios-uia-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jani Jegoroff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: calabash-cucumber
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.169
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.169
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: to_boolean
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
description: Calabash-ios UIA extension provides convenient metaclasses for UIAutomation
|
84
|
+
commands usage in Calabash.
|
85
|
+
email:
|
86
|
+
- jani.jegoroff@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- lib/calios-uia-extension.rb
|
92
|
+
- lib/calios-uia-extension/uia_alert.rb
|
93
|
+
- lib/calios-uia-extension/uia_base.rb
|
94
|
+
- lib/calios-uia-extension/uia_popover.rb
|
95
|
+
- lib/calios-uia-extension/version.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/spec_uia_alert.rb
|
98
|
+
- spec/spec_uia_base.rb
|
99
|
+
- spec/spec_uia_popover.rb
|
100
|
+
- spec/stubs/calabash_cucumber_core_stub.rb
|
101
|
+
- spec/stubs/calabash_cucumber_uia_stub.rb
|
102
|
+
homepage: http://github.com/JaniJegoroff/calios-uia-extension
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Calabash-ios UIA extension.
|
126
|
+
test_files:
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/spec_uia_alert.rb
|
129
|
+
- spec/spec_uia_base.rb
|
130
|
+
- spec/spec_uia_popover.rb
|
131
|
+
- spec/stubs/calabash_cucumber_core_stub.rb
|
132
|
+
- spec/stubs/calabash_cucumber_uia_stub.rb
|