calios-uikit-extension 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a0c169ce6665d79228f6335ef2a8f885012d2454
4
+ data.tar.gz: 9cc5ed7134cd85282e63cef1d06f95b0351b358f
5
+ SHA512:
6
+ metadata.gz: b6d0718ce495ea8e411a883a8ff2a799f9ec89db510f19dd04746510275527977f0161299c1c92ea5a24f9154170ef1ca395c1d5969bbb6da6998c6fd1c6a63e
7
+ data.tar.gz: b96430fb51ee14345694780e2a069368fa4f0ebd3661372b334d5d6aba40e089266c1b607ec6dd2ecf0844cb75b14b605b364d0776d976ecc0deffcbebec4a9a
@@ -0,0 +1,66 @@
1
+ include Calabash::Cucumber::Core
2
+
3
+ class UIBase
4
+ class << self
5
+ def class_name
6
+ name
7
+ end
8
+
9
+ def touch(aIdOrIndex=nil)
10
+ q = self.parse_query(aIdOrIndex)
11
+ Calabash::Cucumber::Core.touch(q)
12
+ end
13
+
14
+ alias_method :tap, :touch
15
+
16
+ def double_tap(aIdOrIndex=nil)
17
+ q = self.parse_query(aIdOrIndex)
18
+ Calabash::Cucumber::Core.double_tap(q)
19
+ end
20
+
21
+ def property(*aParams)
22
+ Calabash::Cucumber::Core.query(self.class_name, *aParams)
23
+ end
24
+
25
+ alias_method :prop, :property
26
+ alias_method :p, :property
27
+
28
+ def query(aIdOrIndex=nil)
29
+ q = parse_query(aIdOrIndex)
30
+ Calabash::Cucumber::Core.query(q)
31
+ end
32
+
33
+ alias_method :q, :query
34
+
35
+ def flash(aIdOrIndex=nil)
36
+ q = parse_query(aIdOrIndex)
37
+ Calabash::Cucumber::Core.flash(q)
38
+ end
39
+
40
+ alias_method :f, :flash
41
+
42
+ def help
43
+ public_methods(false)
44
+ end
45
+
46
+ alias_method :h, :help
47
+
48
+ def parse_query(aIdOrIndex)
49
+ raise_if_invalid(aIdOrIndex)
50
+
51
+ if aIdOrIndex.nil?
52
+ qStr = "#{self.class_name}"
53
+ else
54
+ qStr = aIdOrIndex.is_a?(String) ? "#{self.class_name} marked:'#{aIdOrIndex}'" : "#{self.class_name} index:#{aIdOrIndex}"
55
+ end
56
+
57
+ qStr
58
+ end
59
+
60
+ private
61
+
62
+ def raise_if_invalid(aParam)
63
+ raise('invalid parameter') unless aParam.nil? || aParam.is_a?(String) || aParam.is_a?(Integer)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,12 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UIButton < UIBase
4
+ class << self
5
+ def text(aIdOrIndex=nil)
6
+ q = self.parse_query(aIdOrIndex)
7
+ Calabash::Cucumber::Core.query(q, :currentTitle).first
8
+ end
9
+
10
+ alias_method :tap, :touch
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UICollectionView < UIBase
4
+ class << self
5
+ def number_of_items_in_section(aSection=0)
6
+ Calabash::Cucumber::Core.query("#{self.class_name}", numberOfItemsInSection:aSection).first
7
+ end
8
+
9
+ def scroll_to_item(aItem, aSection, aScrollPosition)
10
+ scroll_to_collection_view_item(aItem, aSection, {scroll_position: aScrollPosition})
11
+ end
12
+
13
+ def scroll(aDirection)
14
+ Calabash::Cucumber::Core.scroll(self.class_name, aDirection)
15
+ end
16
+
17
+ def empty?(aIdOrIndex=nil)
18
+ q = self.parse_query(aIdOrIndex)
19
+ Calabash::Cucumber::Core.query(q).empty?
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UICollectionViewCell < UIBase
4
+ class << self
5
+ def count
6
+ Calabash::Cucumber::Core.query("#{self.class_name}").count
7
+ end
8
+
9
+ def selected?(aIdOrIndex=nil)
10
+ q = self.parse_query(aIdOrIndex)
11
+ Calabash::Cucumber::Core.query(q, :isSelected).first.to_boolean
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UILabel < UIBase
4
+ class << self
5
+ def text(aIdOrIndex=nil)
6
+ q = self.parse_query(aIdOrIndex)
7
+ Calabash::Cucumber::Core.query(q, :text).first
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UISwitch < UIBase
4
+ class << self
5
+ def on?(aIdOrIndex=nil)
6
+ q = self.parse_query(aIdOrIndex)
7
+ Calabash::Cucumber::Core.query(q, :isOn).first.to_boolean
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UITableView < UIBase
4
+ class << self
5
+ def scroll(aDirection)
6
+ Calabash::Cucumber::Core.scroll(self.class_name, aDirection)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UITableViewCell < UIBase
4
+ class << self
5
+ def count
6
+ Calabash::Cucumber::Core.query("#{self.class_name}").count
7
+ end
8
+
9
+ def text(aIdOrIndex=nil)
10
+ q = self.parse_query(aIdOrIndex)
11
+ Calabash::Cucumber::Core.query(q, :text).first
12
+ end
13
+
14
+ def selected?(aIdOrIndex=nil)
15
+ q = self.parse_query(aIdOrIndex)
16
+ Calabash::Cucumber::Core.query(q, :isSelected).first.to_boolean
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UITextField < UIBase
4
+ class << self
5
+ def text(aIdOrIndex=nil)
6
+ q = self.parse_query(aIdOrIndex)
7
+ Calabash::Cucumber::Core.query(q, :text).first
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'ui_base'
2
+
3
+ class UIView < UIBase
4
+ class << self
5
+ # Nothing here yet
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ require 'calabash-cucumber/core'
2
+
3
+ require 'to_boolean'
4
+
5
+ require 'calios-uikit-extension/ui_base'
6
+ require 'calios-uikit-extension/ui_button'
7
+ require 'calios-uikit-extension/ui_collection_view'
8
+ require 'calios-uikit-extension/ui_collection_view_cell'
9
+ require 'calios-uikit-extension/ui_label'
10
+ require 'calios-uikit-extension/ui_switch'
11
+ require 'calios-uikit-extension/ui_table_view'
12
+ require 'calios-uikit-extension/ui_table_view_cell'
13
+ require 'calios-uikit-extension/ui_text_field'
14
+ require 'calios-uikit-extension/ui_view'
@@ -0,0 +1,8 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/reporters'
3
+
4
+ require 'calios-uikit-extension'
5
+
6
+ require_relative 'stubs/calabash_cucumber_core_stub'
7
+
8
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
@@ -0,0 +1,66 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUIBase < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UIBase' do
14
+ describe 'UIBase.raise_if_invalid' do
15
+ it 'should raise' do
16
+ proc { UIButton.text(:symbol) }.must_raise(RuntimeError)
17
+ proc { UIButton.touch(:symbol) }.must_raise(RuntimeError)
18
+ proc { UICollectionView.empty?(:symbol) }.must_raise(RuntimeError)
19
+ proc { UICollectionViewCell.selected?(:symbol) }.must_raise(RuntimeError)
20
+ proc { UICollectionViewCell.touch(:symbol) }.must_raise(RuntimeError)
21
+ proc { UICollectionViewCell.double_tap(:symbol) }.must_raise(RuntimeError)
22
+ proc { UILabel.text(:symbol) }.must_raise(RuntimeError)
23
+ proc { UILabel.touch(:symbol) }.must_raise(RuntimeError)
24
+ proc { UISwitch.on?(:symbol) }.must_raise(RuntimeError)
25
+ proc { UISwitch.touch(:symbol) }.must_raise(RuntimeError)
26
+ proc { UITableViewCell.text(:symbol) }.must_raise(RuntimeError)
27
+ proc { UITableViewCell.selected?(:symbol) }.must_raise(RuntimeError)
28
+ proc { UITableViewCell.touch(:symbol) }.must_raise(RuntimeError)
29
+ proc { UITextField.text(:symbol) }.must_raise(RuntimeError)
30
+ proc { UITextField.touch(:symbol) }.must_raise(RuntimeError)
31
+ end
32
+ end
33
+
34
+ describe 'UIBase.parse_query' do
35
+ it 'should parse query' do
36
+ UIButton.parse_query(nil).must_equal('UIButton')
37
+ UIButton.parse_query(0).must_equal('UIButton index:0')
38
+ UIButton.parse_query('myId').must_equal("UIButton marked:'myId'")
39
+
40
+ UICollectionView.parse_query(nil).must_equal('UICollectionView')
41
+ UICollectionView.parse_query(0).must_equal('UICollectionView index:0')
42
+ UICollectionView.parse_query('myId').must_equal("UICollectionView marked:'myId'")
43
+
44
+ UICollectionViewCell.parse_query(nil).must_equal('UICollectionViewCell')
45
+ UICollectionViewCell.parse_query(0).must_equal('UICollectionViewCell index:0')
46
+ UICollectionViewCell.parse_query('myId').must_equal("UICollectionViewCell marked:'myId'")
47
+
48
+ UILabel.parse_query(nil).must_equal('UILabel')
49
+ UILabel.parse_query(0).must_equal('UILabel index:0')
50
+ UILabel.parse_query('myId').must_equal("UILabel marked:'myId'")
51
+
52
+ UISwitch.parse_query(nil).must_equal('UISwitch')
53
+ UISwitch.parse_query(0).must_equal('UISwitch index:0')
54
+ UISwitch.parse_query('myId').must_equal("UISwitch marked:'myId'")
55
+
56
+ UITableViewCell.parse_query(nil).must_equal('UITableViewCell')
57
+ UITableViewCell.parse_query(0).must_equal('UITableViewCell index:0')
58
+ UITableViewCell.parse_query('myId').must_equal("UITableViewCell marked:'myId'")
59
+
60
+ UITextField.parse_query(nil).must_equal('UITextField')
61
+ UITextField.parse_query(0).must_equal('UITextField index:0')
62
+ UITextField.parse_query('myId').must_equal("UITextField marked:'myId'")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,89 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUIButton < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UIButton' do
14
+ describe 'UIButton.class_name' do
15
+ it 'should return class name' do
16
+ UIButton.class_name.must_equal('UIButton')
17
+ end
18
+ end
19
+
20
+ describe 'UIButton.text' do
21
+ it 'should call Calabash query method with correct parameters' do
22
+ $stub_query_response = %w(abc def ghi)
23
+
24
+ UIButton.text.must_equal('abc')
25
+ $uiquery.must_equal("#{UIButton.class_name}")
26
+ $args.first.must_equal(:currentTitle)
27
+
28
+ UIButton.text(0).must_equal('abc')
29
+ $uiquery.must_equal("#{UIButton.class_name} index:0")
30
+ $args.first.must_equal(:currentTitle)
31
+
32
+ UIButton.text('myId').must_equal('abc')
33
+ $uiquery.must_equal("#{UIButton.class_name} marked:'myId'")
34
+ $args.first.must_equal(:currentTitle)
35
+ end
36
+ end
37
+
38
+ describe 'UIButton.touch and aliases' do
39
+ it 'should call Calabash touch method with correct parameters' do
40
+ UIButton.touch
41
+ $uiquery.must_equal("#{UIButton.class_name}")
42
+
43
+ UIButton.touch(0)
44
+ $uiquery.must_equal("#{UIButton.class_name} index:0")
45
+
46
+ UIButton.touch('myId')
47
+ $uiquery.must_equal("#{UIButton.class_name} marked:'myId'")
48
+
49
+ UIButton.tap
50
+ $uiquery.must_equal("#{UIButton.class_name}")
51
+
52
+ UIButton.tap(0)
53
+ $uiquery.must_equal("#{UIButton.class_name} index:0")
54
+
55
+ UIButton.tap('myId')
56
+ $uiquery.must_equal("#{UIButton.class_name} marked:'myId'")
57
+ end
58
+ end
59
+
60
+ describe 'UIButton.double_tap' do
61
+ it 'should call Calabash double_tap method with correct parameters' do
62
+ UIButton.double_tap
63
+ $uiquery.must_equal(UIButton.class_name)
64
+
65
+ UIButton.double_tap(0)
66
+ $uiquery.must_equal("#{UIButton.class_name} index:0")
67
+
68
+ UIButton.double_tap('myId')
69
+ $uiquery.must_equal("#{UIButton.class_name} marked:'myId'")
70
+ end
71
+ end
72
+
73
+ describe 'UIButton.property and aliases' do
74
+ it 'should call Calabash query method with correct parameters' do
75
+ UIButton.property(:finland)
76
+ $uiquery.must_equal("#{UIButton.class_name}")
77
+ $args.first.must_equal(:finland)
78
+
79
+ UIButton.prop(:finland)
80
+ $uiquery.must_equal("#{UIButton.class_name}")
81
+ $args.first.must_equal(:finland)
82
+
83
+ UIButton.p(:finland)
84
+ $uiquery.must_equal("#{UIButton.class_name}")
85
+ $args.first.must_equal(:finland)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,133 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUICollectionView < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $direction = nil
7
+ $item = nil
8
+ $section = nil
9
+ $args = nil
10
+ $opts = {}
11
+ end
12
+
13
+ after do
14
+ # nop
15
+ end
16
+
17
+ describe 'UICollectionView' do
18
+ describe 'UICollectionView.class_name' do
19
+ it 'should return class name' do
20
+ UICollectionView.class_name.must_equal('UICollectionView')
21
+ end
22
+ end
23
+
24
+ describe 'UICollectionView.number_of_items_in_section' do
25
+ it 'should call Calabash query method with correct parameters' do
26
+ $stub_query_response = [10, 20, 30]
27
+
28
+ UICollectionView.number_of_items_in_section.must_equal(10)
29
+ $uiquery.must_equal(UICollectionView.class_name)
30
+ $args.first.must_equal({:numberOfItemsInSection=>0})
31
+
32
+ UICollectionView.number_of_items_in_section(0).must_equal(10)
33
+ $uiquery.must_equal(UICollectionView.class_name)
34
+ $args.first.must_equal({:numberOfItemsInSection=>0})
35
+
36
+ UICollectionView.number_of_items_in_section(1).must_equal(10)
37
+ $uiquery.must_equal(UICollectionView.class_name)
38
+ $args.first.must_equal({:numberOfItemsInSection=>1})
39
+ end
40
+ end
41
+
42
+ describe 'UICollectionView.scroll_to_item' do
43
+ it 'should call Calabash scroll_to_collection_view_item method with correct parameters' do
44
+ key = :scroll_position
45
+ params = [[0, 0, :top], [1, 1, :bottom], [0, 1, :center]]
46
+
47
+ params.each do |(item, section, direction)|
48
+ UICollectionView.scroll_to_item(item, section, direction)
49
+ $item.must_equal(item)
50
+ $section.must_equal(section)
51
+ $opts.has_key?(key).must_equal(true)
52
+ $opts[key].must_equal(direction)
53
+ end
54
+ end
55
+ end
56
+
57
+ describe 'UICollectionView.scroll' do
58
+ it 'should call Calabash scroll method with correct parameters' do
59
+ directions = [:up, :down, :left, :right]
60
+
61
+ directions.each do |value|
62
+ UICollectionView.scroll(value)
63
+ $uiquery.must_equal(UICollectionView.class_name)
64
+ $direction.must_equal(value)
65
+ end
66
+ end
67
+ end
68
+
69
+ describe 'UICollectionView.empty?' do
70
+ it 'should call Calabash query method with correct parameters' do
71
+ UICollectionView.empty?.must_equal(false)
72
+ $uiquery.must_equal("#{UICollectionView.class_name}")
73
+
74
+ UICollectionView.empty?(0).must_equal(false)
75
+ $uiquery.must_equal("#{UICollectionView.class_name} index:0")
76
+
77
+ UICollectionView.empty?('myId').must_equal(false)
78
+ $uiquery.must_equal("#{UICollectionView.class_name} marked:'myId'")
79
+ end
80
+ end
81
+
82
+ describe 'UICollectionView.touch and aliases' do
83
+ it 'should call Calabash touch method with correct parameters' do
84
+ UICollectionView.touch
85
+ $uiquery.must_equal("#{UICollectionView.class_name}")
86
+
87
+ UICollectionView.touch(0)
88
+ $uiquery.must_equal("#{UICollectionView.class_name} index:0")
89
+
90
+ UICollectionView.touch('myId')
91
+ $uiquery.must_equal("#{UICollectionView.class_name} marked:'myId'")
92
+
93
+ UICollectionView.tap
94
+ $uiquery.must_equal("#{UICollectionView.class_name}")
95
+
96
+ UICollectionView.tap(0)
97
+ $uiquery.must_equal("#{UICollectionView.class_name} index:0")
98
+
99
+ UICollectionView.tap('myId')
100
+ $uiquery.must_equal("#{UICollectionView.class_name} marked:'myId'")
101
+ end
102
+ end
103
+
104
+ describe 'UICollectionView.double_tap' do
105
+ it 'should call Calabash double_tap method with correct parameters' do
106
+ UICollectionView.double_tap
107
+ $uiquery.must_equal(UICollectionView.class_name)
108
+
109
+ UICollectionView.double_tap(0)
110
+ $uiquery.must_equal("#{UICollectionView.class_name} index:0")
111
+
112
+ UICollectionView.double_tap('myId')
113
+ $uiquery.must_equal("#{UICollectionView.class_name} marked:'myId'")
114
+ end
115
+ end
116
+
117
+ describe 'UICollectionView.property and aliases' do
118
+ it 'should call Calabash query method with correct parameters' do
119
+ UICollectionView.property(:myParam)
120
+ $uiquery.must_equal("#{UICollectionView.class_name}")
121
+ $args.first.must_equal(:myParam)
122
+
123
+ UICollectionView.prop(:myParam)
124
+ $uiquery.must_equal("#{UICollectionView.class_name}")
125
+ $args.first.must_equal(:myParam)
126
+
127
+ UICollectionView.p(:myParam)
128
+ $uiquery.must_equal("#{UICollectionView.class_name}")
129
+ $args.first.must_equal(:myParam)
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,93 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUICollectionViewCell < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UICollectionViewCell' do
14
+ describe 'UICollectionViewCell.class_name' do
15
+ it 'should return class name' do
16
+ UICollectionViewCell.class_name.must_equal('UICollectionViewCell')
17
+ end
18
+ end
19
+
20
+ describe 'UICollectionViewCell.selected?' do
21
+ it 'should call Calabash query method with correct parameters' do
22
+ $stub_query_response = [false, true]
23
+ ret = UICollectionViewCell.selected?
24
+ ret.must_equal(false)
25
+ $uiquery.must_equal("#{UICollectionViewCell.class_name}")
26
+ $args.first.must_equal(:isSelected)
27
+
28
+ $stub_query_response = [false, true]
29
+ ret = UICollectionViewCell.selected?(0)
30
+ ret.must_equal(false)
31
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} index:0")
32
+ $args.first.must_equal(:isSelected)
33
+
34
+ $stub_query_response = [true, false]
35
+ ret = UICollectionViewCell.selected?('myId')
36
+ ret.must_equal(true)
37
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} marked:'myId'")
38
+ $args.first.must_equal(:isSelected)
39
+ end
40
+ end
41
+
42
+ describe 'UICollectionViewCell.touch and aliases' do
43
+ it 'should call Calabash touch method with correct parameters' do
44
+ UICollectionViewCell.touch
45
+ $uiquery.must_equal("#{UICollectionViewCell.class_name}")
46
+
47
+ UICollectionViewCell.touch(0)
48
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} index:0")
49
+
50
+ UICollectionViewCell.touch('myId')
51
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} marked:'myId'")
52
+
53
+ UICollectionViewCell.tap
54
+ $uiquery.must_equal("#{UICollectionViewCell.class_name}")
55
+
56
+ UICollectionViewCell.tap(0)
57
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} index:0")
58
+
59
+ UICollectionViewCell.tap('myId')
60
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} marked:'myId'")
61
+ end
62
+ end
63
+
64
+ describe 'UICollectionViewCell.double_tap' do
65
+ it 'should call Calabash double_tap method with correct parameters' do
66
+ UICollectionViewCell.double_tap
67
+ $uiquery.must_equal(UICollectionViewCell.class_name)
68
+
69
+ UICollectionViewCell.double_tap(0)
70
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} index:0")
71
+
72
+ UICollectionViewCell.double_tap('myId')
73
+ $uiquery.must_equal("#{UICollectionViewCell.class_name} marked:'myId'")
74
+ end
75
+ end
76
+
77
+ describe 'UICollectionViewCell.property and aliases' do
78
+ it 'should call Calabash query method with correct parameters' do
79
+ UICollectionViewCell.property(:varkaus)
80
+ $uiquery.must_equal("#{UICollectionViewCell.class_name}")
81
+ $args.first.must_equal(:varkaus)
82
+
83
+ UICollectionViewCell.prop(:varkaus)
84
+ $uiquery.must_equal("#{UICollectionViewCell.class_name}")
85
+ $args.first.must_equal(:varkaus)
86
+
87
+ UICollectionViewCell.p(:varkaus)
88
+ $uiquery.must_equal("#{UICollectionViewCell.class_name}")
89
+ $args.first.must_equal(:varkaus)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,89 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUILabel < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UILabel' do
14
+ describe 'UILabel.class_name' do
15
+ it 'should return class name' do
16
+ UILabel.class_name.must_equal('UILabel')
17
+ end
18
+ end
19
+
20
+ describe 'UILabel.text' do
21
+ it 'should call Calabash query method with correct parameters' do
22
+ $stub_query_response = %w(abc def ghi)
23
+
24
+ UILabel.text.must_equal('abc')
25
+ $uiquery.must_equal("#{UILabel.class_name}")
26
+ $args.first.must_equal(:text)
27
+
28
+ UILabel.text(0).must_equal('abc')
29
+ $uiquery.must_equal("#{UILabel.class_name} index:0")
30
+ $args.first.must_equal(:text)
31
+
32
+ UILabel.text('myId').must_equal('abc')
33
+ $uiquery.must_equal("#{UILabel.class_name} marked:'myId'")
34
+ $args.first.must_equal(:text)
35
+ end
36
+ end
37
+
38
+ describe 'UILabel.touch and aliases' do
39
+ it 'should call Calabash touch method with correct parameters' do
40
+ UILabel.touch
41
+ $uiquery.must_equal("#{UILabel.class_name}")
42
+
43
+ UILabel.touch(0)
44
+ $uiquery.must_equal("#{UILabel.class_name} index:0")
45
+
46
+ UILabel.touch('myId')
47
+ $uiquery.must_equal("#{UILabel.class_name} marked:'myId'")
48
+
49
+ UILabel.tap
50
+ $uiquery.must_equal("#{UILabel.class_name}")
51
+
52
+ UILabel.tap(0)
53
+ $uiquery.must_equal("#{UILabel.class_name} index:0")
54
+
55
+ UILabel.tap('myId')
56
+ $uiquery.must_equal("#{UILabel.class_name} marked:'myId'")
57
+ end
58
+ end
59
+
60
+ describe 'UILabel.double_tap' do
61
+ it 'should call Calabash double_tap method with correct parameters' do
62
+ UILabel.double_tap
63
+ $uiquery.must_equal(UILabel.class_name)
64
+
65
+ UILabel.double_tap(0)
66
+ $uiquery.must_equal("#{UILabel.class_name} index:0")
67
+
68
+ UILabel.double_tap('myId')
69
+ $uiquery.must_equal("#{UILabel.class_name} marked:'myId'")
70
+ end
71
+ end
72
+
73
+ describe 'UILabel.property and aliases' do
74
+ it 'should call Calabash query method with correct parameters' do
75
+ UILabel.property(:kuopio)
76
+ $uiquery.must_equal("#{UILabel.class_name}")
77
+ $args.first.must_equal(:kuopio)
78
+
79
+ UILabel.prop(:kuopio)
80
+ $uiquery.must_equal("#{UILabel.class_name}")
81
+ $args.first.must_equal(:kuopio)
82
+
83
+ UILabel.p(:kuopio)
84
+ $uiquery.must_equal("#{UILabel.class_name}")
85
+ $args.first.must_equal(:kuopio)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,93 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUISwitch < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UISwitch' do
14
+ describe 'UISwitch.class_name' do
15
+ it 'should return class name' do
16
+ UISwitch.class_name.must_equal('UISwitch')
17
+ end
18
+ end
19
+
20
+ describe 'UISwitch.on?' do
21
+ it 'should call Calabash query method with correct parameters' do
22
+ $stub_query_response = [false, true]
23
+ ret = UISwitch.on?
24
+ ret.must_equal(false)
25
+ $uiquery.must_equal("#{UISwitch.class_name}")
26
+ $args.first.must_equal(:isOn)
27
+
28
+ $stub_query_response = [false, true]
29
+ ret = UISwitch.on?(0)
30
+ ret.must_equal(false)
31
+ $uiquery.must_equal("#{UISwitch.class_name} index:0")
32
+ $args.first.must_equal(:isOn)
33
+
34
+ $stub_query_response = [true, false]
35
+ ret = UISwitch.on?('myId')
36
+ ret.must_equal(true)
37
+ $uiquery.must_equal("#{UISwitch.class_name} marked:'myId'")
38
+ $args.first.must_equal(:isOn)
39
+ end
40
+ end
41
+
42
+ describe 'UISwitch.touch and aliases' do
43
+ it 'should call Calabash touch method with correct parameters' do
44
+ UISwitch.touch
45
+ $uiquery.must_equal("#{UISwitch.class_name}")
46
+
47
+ UISwitch.touch(0)
48
+ $uiquery.must_equal("#{UISwitch.class_name} index:0")
49
+
50
+ UISwitch.touch('myId')
51
+ $uiquery.must_equal("#{UISwitch.class_name} marked:'myId'")
52
+
53
+ UISwitch.tap
54
+ $uiquery.must_equal("#{UISwitch.class_name}")
55
+
56
+ UISwitch.tap(0)
57
+ $uiquery.must_equal("#{UISwitch.class_name} index:0")
58
+
59
+ UISwitch.tap('myId')
60
+ $uiquery.must_equal("#{UISwitch.class_name} marked:'myId'")
61
+ end
62
+ end
63
+
64
+ describe 'UISwitch.double_tap' do
65
+ it 'should call Calabash double_tap method with correct parameters' do
66
+ UISwitch.double_tap
67
+ $uiquery.must_equal(UISwitch.class_name)
68
+
69
+ UISwitch.double_tap(0)
70
+ $uiquery.must_equal("#{UISwitch.class_name} index:0")
71
+
72
+ UISwitch.double_tap('myId')
73
+ $uiquery.must_equal("#{UISwitch.class_name} marked:'myId'")
74
+ end
75
+ end
76
+
77
+ describe 'UISwitch.property and aliases' do
78
+ it 'should call Calabash query method with correct parameters' do
79
+ UISwitch.property(:oulu)
80
+ $uiquery.must_equal("#{UISwitch.class_name}")
81
+ $args.first.must_equal(:oulu)
82
+
83
+ UISwitch.prop(:oulu)
84
+ $uiquery.must_equal("#{UISwitch.class_name}")
85
+ $args.first.must_equal(:oulu)
86
+
87
+ UISwitch.p(:oulu)
88
+ $uiquery.must_equal("#{UISwitch.class_name}")
89
+ $args.first.must_equal(:oulu)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,83 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUITableView < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $direction = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UITableView' do
14
+ describe 'UITableView.class_name' do
15
+ it 'should return class name' do
16
+ UITableView.class_name.must_equal('UITableView')
17
+ end
18
+ end
19
+
20
+ describe 'UITableView.scroll' do
21
+ it 'should call Calabash scroll method with correct parameters' do
22
+ directions = [:up, :down, :left, :right]
23
+
24
+ directions.each do |value|
25
+ UITableView.scroll(value)
26
+ $uiquery.must_equal(UITableView.class_name)
27
+ $direction.must_equal(value)
28
+ end
29
+ end
30
+ end
31
+
32
+ describe 'UITableView.touch and aliases' do
33
+ it 'should call Calabash touch method with correct parameters' do
34
+ UITableView.touch
35
+ $uiquery.must_equal("#{UITableView.class_name}")
36
+
37
+ UITableView.touch(0)
38
+ $uiquery.must_equal("#{UITableView.class_name} index:0")
39
+
40
+ UITableView.touch('myId')
41
+ $uiquery.must_equal("#{UITableView.class_name} marked:'myId'")
42
+
43
+ UITableView.tap
44
+ $uiquery.must_equal("#{UITableView.class_name}")
45
+
46
+ UITableView.tap(0)
47
+ $uiquery.must_equal("#{UITableView.class_name} index:0")
48
+
49
+ UITableView.tap('myId')
50
+ $uiquery.must_equal("#{UITableView.class_name} marked:'myId'")
51
+ end
52
+ end
53
+
54
+ describe 'UITableView.double_tap' do
55
+ it 'should call Calabash double_tap method with correct parameters' do
56
+ UITableView.double_tap
57
+ $uiquery.must_equal(UITableView.class_name)
58
+
59
+ UITableView.double_tap(0)
60
+ $uiquery.must_equal("#{UITableView.class_name} index:0")
61
+
62
+ UITableView.double_tap('myId')
63
+ $uiquery.must_equal("#{UITableView.class_name} marked:'myId'")
64
+ end
65
+ end
66
+
67
+ describe 'UITableView.property and aliases' do
68
+ it 'should call Calabash query method with correct parameters' do
69
+ UITableView.property(:salmiakki)
70
+ $uiquery.must_equal("#{UITableView.class_name}")
71
+ $args.first.must_equal(:salmiakki)
72
+
73
+ UITableView.prop(:salmiakki)
74
+ $uiquery.must_equal("#{UITableView.class_name}")
75
+ $args.first.must_equal(:salmiakki)
76
+
77
+ UITableView.p(:salmiakki)
78
+ $uiquery.must_equal("#{UITableView.class_name}")
79
+ $args.first.must_equal(:salmiakki)
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,95 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUITableViewCell < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UITableViewCell' do
14
+ describe 'UITableViewCell.class_name' do
15
+ it 'should return class name' do
16
+ UITableViewCell.class_name.must_equal('UITableViewCell')
17
+ end
18
+ end
19
+
20
+ describe 'UITableViewCell.selected?' do
21
+ it 'should call Calabash query method with correct parameters' do
22
+ $stub_query_response = [false, true]
23
+ ret = UITableViewCell.selected?
24
+ ret.must_equal(false)
25
+ $uiquery.must_equal("#{UITableViewCell.class_name}")
26
+ $args.first.must_equal(:isSelected)
27
+
28
+ $stub_query_response = [false, true]
29
+ ret = UITableViewCell.selected?(0)
30
+ ret.must_equal(false)
31
+ $uiquery.must_equal("#{UITableViewCell.class_name} index:0")
32
+ $args.first.must_equal(:isSelected)
33
+
34
+ $stub_query_response = [true, false]
35
+ ret = UITableViewCell.selected?('myId')
36
+ ret.must_equal(true)
37
+ $uiquery.must_equal("#{UITableViewCell.class_name} marked:'myId'")
38
+ $args.first.must_equal(:isSelected)
39
+ end
40
+ end
41
+
42
+ describe 'UITableViewCell.text' do
43
+ it 'should call Calabash query method with correct parameters' do
44
+ $stub_query_response = %w(abc def ghi)
45
+
46
+ UITableViewCell.text.must_equal('abc')
47
+ $uiquery.must_equal("#{UITableViewCell.class_name}")
48
+ $args.first.must_equal(:text)
49
+
50
+ UITableViewCell.text(0).must_equal('abc')
51
+ $uiquery.must_equal("#{UITableViewCell.class_name} index:0")
52
+ $args.first.must_equal(:text)
53
+
54
+ UITableViewCell.text('myId').must_equal('abc')
55
+ $uiquery.must_equal("#{UITableViewCell.class_name} marked:'myId'")
56
+ $args.first.must_equal(:text)
57
+ end
58
+ end
59
+
60
+ describe 'UITableViewCell.touch and aliases' do
61
+ it 'should call Calabash touch method with correct parameters' do
62
+ UITableViewCell.touch
63
+ $uiquery.must_equal("#{UITableViewCell.class_name}")
64
+
65
+ UITableViewCell.touch(0)
66
+ $uiquery.must_equal("#{UITableViewCell.class_name} index:0")
67
+
68
+ UITableViewCell.touch('myId')
69
+ $uiquery.must_equal("#{UITableViewCell.class_name} marked:'myId'")
70
+
71
+ UITableViewCell.tap
72
+ $uiquery.must_equal("#{UITableViewCell.class_name}")
73
+
74
+ UITableViewCell.tap(0)
75
+ $uiquery.must_equal("#{UITableViewCell.class_name} index:0")
76
+
77
+ UITableViewCell.tap('myId')
78
+ $uiquery.must_equal("#{UITableViewCell.class_name} marked:'myId'")
79
+ end
80
+ end
81
+
82
+ describe 'UITableViewCell.double_tap' do
83
+ it 'should call Calabash double_tap method with correct parameters' do
84
+ UITableViewCell.double_tap
85
+ $uiquery.must_equal(UITableViewCell.class_name)
86
+
87
+ UITableViewCell.double_tap(0)
88
+ $uiquery.must_equal("#{UITableViewCell.class_name} index:0")
89
+
90
+ UITableViewCell.double_tap('myId')
91
+ $uiquery.must_equal("#{UITableViewCell.class_name} marked:'myId'")
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,89 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class SpecUITextField < Minitest::Spec
4
+ before do
5
+ $uiquery = nil
6
+ $args = nil
7
+ end
8
+
9
+ after do
10
+ # nop
11
+ end
12
+
13
+ describe 'UITextField' do
14
+ describe 'UITextField.class_name' do
15
+ it 'should return class name' do
16
+ UITextField.class_name.must_equal('UITextField')
17
+ end
18
+ end
19
+
20
+ describe 'UITextField.text' do
21
+ it 'should call Calabash query method with correct parameters' do
22
+ $stub_query_response = %w(abc def ghi)
23
+
24
+ UITextField.text.must_equal('abc')
25
+ $uiquery.must_equal("#{UITextField.class_name}")
26
+ $args.first.must_equal(:text)
27
+
28
+ UITextField.text(0).must_equal('abc')
29
+ $uiquery.must_equal("#{UITextField.class_name} index:0")
30
+ $args.first.must_equal(:text)
31
+
32
+ UITextField.text('myId').must_equal('abc')
33
+ $uiquery.must_equal("#{UITextField.class_name} marked:'myId'")
34
+ $args.first.must_equal(:text)
35
+ end
36
+ end
37
+
38
+ describe 'UITextField.touch and aliases' do
39
+ it 'should call Calabash touch method with correct parameters' do
40
+ UITextField.touch
41
+ $uiquery.must_equal("#{UITextField.class_name}")
42
+
43
+ UITextField.touch(0)
44
+ $uiquery.must_equal("#{UITextField.class_name} index:0")
45
+
46
+ UITextField.touch('myId')
47
+ $uiquery.must_equal("#{UITextField.class_name} marked:'myId'")
48
+
49
+ UITextField.tap
50
+ $uiquery.must_equal("#{UITextField.class_name}")
51
+
52
+ UITextField.tap(0)
53
+ $uiquery.must_equal("#{UITextField.class_name} index:0")
54
+
55
+ UITextField.tap('myId')
56
+ $uiquery.must_equal("#{UITextField.class_name} marked:'myId'")
57
+ end
58
+ end
59
+
60
+ describe 'UITextField.double_tap' do
61
+ it 'should call Calabash double_tap method with correct parameters' do
62
+ UITextField.double_tap
63
+ $uiquery.must_equal(UITextField.class_name)
64
+
65
+ UITextField.double_tap(0)
66
+ $uiquery.must_equal("#{UITextField.class_name} index:0")
67
+
68
+ UITextField.double_tap('myId')
69
+ $uiquery.must_equal("#{UITextField.class_name} marked:'myId'")
70
+ end
71
+ end
72
+
73
+ describe 'UITextField.property and aliases' do
74
+ it 'should call Calabash query method with correct parameters' do
75
+ UITextField.property(:saimi)
76
+ $uiquery.must_equal("#{UITextField.class_name}")
77
+ $args.first.must_equal(:saimi)
78
+
79
+ UITextField.prop(:saimi)
80
+ $uiquery.must_equal("#{UITextField.class_name}")
81
+ $args.first.must_equal(:saimi)
82
+
83
+ UITextField.p(:saimi)
84
+ $uiquery.must_equal("#{UITextField.class_name}")
85
+ $args.first.must_equal(:saimi)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,39 @@
1
+ require 'calabash-cucumber/core'
2
+
3
+ module Calabash::Cucumber::Core
4
+ def query(uiquery, *args)
5
+ $uiquery = uiquery
6
+ $args = args
7
+ $stub_query_response
8
+ end
9
+
10
+ def flash(uiquery, *args)
11
+ $uiquery = uiquery
12
+ $args = args
13
+ end
14
+
15
+ def scroll(uiquery, direction)
16
+ $uiquery = uiquery
17
+ $direction = direction
18
+ end
19
+
20
+ def scroll_to_collection_view_item(item, section, opts={})
21
+ $item = item
22
+ $section = section
23
+ $opts = opts
24
+ end
25
+
26
+ def touch(uiquery, opts={})
27
+ $uiquery = uiquery
28
+ $opts = opts
29
+ end
30
+
31
+ def double_tap(uiquery, opts={})
32
+ $uiquery = uiquery
33
+ $opts = opts
34
+ end
35
+ end
36
+
37
+ class CalabashCucumberCoreStubClass
38
+ include Calabash::Cucumber::Core
39
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calios-uikit-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-15 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 UIKit extension provides convenient metaclasses for Calabash
84
+ usage.
85
+ email:
86
+ - jani.jegoroff@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - lib/calios-uikit-extension.rb
92
+ - lib/calios-uikit-extension/ui_base.rb
93
+ - lib/calios-uikit-extension/ui_button.rb
94
+ - lib/calios-uikit-extension/ui_collection_view.rb
95
+ - lib/calios-uikit-extension/ui_collection_view_cell.rb
96
+ - lib/calios-uikit-extension/ui_label.rb
97
+ - lib/calios-uikit-extension/ui_switch.rb
98
+ - lib/calios-uikit-extension/ui_table_view.rb
99
+ - lib/calios-uikit-extension/ui_table_view_cell.rb
100
+ - lib/calios-uikit-extension/ui_text_field.rb
101
+ - lib/calios-uikit-extension/ui_view.rb
102
+ - spec/spec_helper.rb
103
+ - spec/spec_ui_base.rb
104
+ - spec/spec_ui_button.rb
105
+ - spec/spec_ui_collection_view.rb
106
+ - spec/spec_ui_collection_view_cell.rb
107
+ - spec/spec_ui_label.rb
108
+ - spec/spec_ui_switch.rb
109
+ - spec/spec_ui_table_view.rb
110
+ - spec/spec_ui_table_view_cell.rb
111
+ - spec/spec_ui_text_field.rb
112
+ - spec/stubs/calabash_cucumber_core_stub.rb
113
+ homepage: http://github.com/JaniJegoroff/calios-uikit-extension
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.2.2
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Calabash-ios UIKit extension.
137
+ test_files:
138
+ - spec/spec_helper.rb
139
+ - spec/spec_ui_base.rb
140
+ - spec/spec_ui_button.rb
141
+ - spec/spec_ui_collection_view.rb
142
+ - spec/spec_ui_collection_view_cell.rb
143
+ - spec/spec_ui_label.rb
144
+ - spec/spec_ui_switch.rb
145
+ - spec/spec_ui_table_view.rb
146
+ - spec/spec_ui_table_view_cell.rb
147
+ - spec/spec_ui_text_field.rb
148
+ - spec/stubs/calabash_cucumber_core_stub.rb