under-os 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +16 -0
- data/README.md +70 -0
- data/Rakefile +24 -0
- data/app/config.rb +4 -0
- data/app/layouts/alerts.html +8 -0
- data/app/layouts/calculator.html +26 -0
- data/app/layouts/collections.html +7 -0
- data/app/layouts/home.html +14 -0
- data/app/layouts/http.html +8 -0
- data/app/layouts/inputs.html +44 -0
- data/app/layouts/lockers.html +6 -0
- data/app/layouts/navbar.html +9 -0
- data/app/layouts/scrolls.html +42 -0
- data/app/layouts/sidebars.html +17 -0
- data/app/pages/alerts_page.rb +14 -0
- data/app/pages/calculator_page.rb +36 -0
- data/app/pages/collections_page.rb +9 -0
- data/app/pages/home_page.rb +11 -0
- data/app/pages/http_page.rb +33 -0
- data/app/pages/inputs_page.rb +9 -0
- data/app/pages/lockers_page.rb +16 -0
- data/app/pages/navbar_page.rb +19 -0
- data/app/pages/scrolls_page.rb +5 -0
- data/app/pages/sidebars_page.rb +42 -0
- data/app/pages/stuff_page.rb +35 -0
- data/app/styles/application.css +25 -0
- data/app/styles/calculator.css +37 -0
- data/app/styles/collections.css +19 -0
- data/app/styles/home.css +0 -0
- data/app/styles/http.css +24 -0
- data/app/styles/inputs.css +47 -0
- data/app/styles/scrolls.css +67 -0
- data/app/styles/sidebars.css +19 -0
- data/lib/assets/fontawesome-webfont.ttf +0 -0
- data/lib/assets/under-os.css +115 -0
- data/lib/under-os.rb +9 -1
- data/lib/under_os/app.rb +33 -0
- data/lib/under_os/color.rb +176 -0
- data/lib/under_os/config.rb +28 -1
- data/lib/under_os/core/kernel.rb +16 -0
- data/lib/under_os/core/numeric.rb +23 -0
- data/lib/under_os/core/string.rb +40 -0
- data/lib/under_os/delegate.rb +3 -2
- data/lib/under_os/events.rb +85 -0
- data/lib/under_os/file.rb +110 -0
- data/lib/under_os/history.rb +50 -0
- data/lib/under_os/http/receiver.rb +44 -0
- data/lib/under_os/http/request.rb +89 -0
- data/lib/under_os/http/response.rb +24 -0
- data/lib/under_os/http/session.rb +49 -0
- data/lib/under_os/http.rb +5 -0
- data/lib/under_os/page/builder.rb +96 -0
- data/lib/under_os/page/layout.rb +43 -0
- data/lib/under_os/page/matcher.rb +83 -0
- data/lib/under_os/page/stylesheet.rb +67 -0
- data/lib/under_os/page.rb +153 -0
- data/lib/under_os/parser/css.rb +37 -0
- data/lib/under_os/parser/html.rb +97 -0
- data/lib/under_os/parser.rb +24 -0
- data/lib/under_os/point.rb +47 -0
- data/lib/under_os/screen.rb +9 -0
- data/lib/under_os/timer.rb +65 -0
- data/lib/under_os/ui/alert.rb +52 -0
- data/lib/under_os/ui/button.rb +22 -0
- data/lib/under_os/ui/collection/cell.rb +21 -0
- data/lib/under_os/ui/collection/delegate.rb +68 -0
- data/lib/under_os/ui/collection/item.rb +32 -0
- data/lib/under_os/ui/collection/layout.rb +43 -0
- data/lib/under_os/ui/collection/styles.rb +15 -0
- data/lib/under_os/ui/collection.rb +63 -0
- data/lib/under_os/ui/icon/awesome.rb +376 -0
- data/lib/under_os/ui/icon/engine.rb +10 -0
- data/lib/under_os/ui/icon.rb +42 -0
- data/lib/under_os/ui/image.rb +30 -0
- data/lib/under_os/ui/input.rb +41 -0
- data/lib/under_os/ui/label.rb +21 -0
- data/lib/under_os/ui/locker.rb +42 -0
- data/lib/under_os/ui/navbar.rb +115 -0
- data/lib/under_os/ui/progress.rb +17 -0
- data/lib/under_os/ui/scroll.rb +41 -0
- data/lib/under_os/ui/select.rb +98 -0
- data/lib/under_os/ui/sidebar.rb +45 -0
- data/lib/under_os/ui/slider.rb +49 -0
- data/lib/under_os/ui/spinner.rb +23 -0
- data/lib/under_os/ui/style/fonts.rb +60 -0
- data/lib/under_os/ui/style/margins.rb +160 -0
- data/lib/under_os/ui/style/outlining.rb +98 -0
- data/lib/under_os/ui/style/positioning.rb +169 -0
- data/lib/under_os/ui/style.rb +21 -0
- data/lib/under_os/ui/switch.rb +29 -0
- data/lib/under_os/ui/textarea.rb +14 -0
- data/lib/under_os/ui/utils/animation.rb +99 -0
- data/lib/under_os/ui/utils/commons.rb +70 -0
- data/lib/under_os/ui/utils/dimensions.rb +37 -0
- data/lib/under_os/ui/utils/editable.rb +43 -0
- data/lib/under_os/ui/utils/events.rb +75 -0
- data/lib/under_os/ui/utils/manipulation.rb +44 -0
- data/lib/under_os/ui/utils/position.rb +21 -0
- data/lib/under_os/ui/utils/size.rb +21 -0
- data/lib/under_os/ui/utils/styles.rb +89 -0
- data/lib/under_os/ui/utils/traversing.rb +44 -0
- data/lib/under_os/ui/utils/wrap.rb +77 -0
- data/lib/under_os/ui/view.rb +31 -0
- data/lib/under_os/ui.rb +3 -0
- data/lib/under_os.rb +2 -2
- data/resources/Default-568h@2x.png +0 -0
- data/resources/test.png +0 -0
- data/spec/assets/app.css +13 -0
- data/spec/assets/test.css +7 -0
- data/spec/assets/test.html +3 -0
- data/spec/assets/test_page.rb +2 -0
- data/spec/lib/core/numeric_spec.rb +37 -0
- data/spec/lib/core/string_spec.rb +87 -0
- data/spec/lib/under_os/color_spec.rb +133 -0
- data/spec/lib/under_os/events_spec.rb +71 -0
- data/spec/lib/under_os/file_spec.rb +98 -0
- data/spec/lib/under_os/page/builder_spec.rb +128 -0
- data/spec/lib/under_os/page/layout_spec.rb +18 -0
- data/spec/lib/under_os/page/matcher_spec.rb +154 -0
- data/spec/lib/under_os/page/stylesheet_spec.rb +83 -0
- data/spec/lib/under_os/page_spec.rb +5 -0
- data/spec/lib/under_os/parser/css_spec.rb +77 -0
- data/spec/lib/under_os/parser/html_spec.rb +152 -0
- data/spec/lib/under_os/parser_spec.rb +16 -0
- data/spec/lib/under_os/point_spec.rb +54 -0
- data/spec/lib/under_os/screen_spec.rb +11 -0
- data/spec/lib/under_os/timer_spec.rb +93 -0
- data/spec/lib/under_os/ui/button_spec.rb +5 -0
- data/spec/lib/under_os/ui/collection_spec.rb +19 -0
- data/spec/lib/under_os/ui/icon_spec.rb +26 -0
- data/spec/lib/under_os/ui/image_spec.rb +39 -0
- data/spec/lib/under_os/ui/input_spec.rb +77 -0
- data/spec/lib/under_os/ui/label_spec.rb +22 -0
- data/spec/lib/under_os/ui/locker_spec.rb +31 -0
- data/spec/lib/under_os/ui/progress_spec.rb +31 -0
- data/spec/lib/under_os/ui/scroll_spec.rb +40 -0
- data/spec/lib/under_os/ui/select_spec.rb +131 -0
- data/spec/lib/under_os/ui/sidebar_spec.rb +35 -0
- data/spec/lib/under_os/ui/slider_spec.rb +65 -0
- data/spec/lib/under_os/ui/spinner_spec.rb +57 -0
- data/spec/lib/under_os/ui/style/fonts_spec.rb +73 -0
- data/spec/lib/under_os/ui/style/margins_spec.rb +106 -0
- data/spec/lib/under_os/ui/style/outlining_spec.rb +69 -0
- data/spec/lib/under_os/ui/style/positioning_spec.rb +69 -0
- data/spec/lib/under_os/ui/style_spec.rb +19 -0
- data/spec/lib/under_os/ui/switch_spec.rb +56 -0
- data/spec/lib/under_os/ui/textarea_spec.rb +30 -0
- data/spec/lib/under_os/ui/utils/commons_spec.rb +81 -0
- data/spec/lib/under_os/ui/utils/manipulation_spec.rb +130 -0
- data/spec/lib/under_os/ui/utils/styles_spec.rb +140 -0
- data/spec/lib/under_os/ui/utils/traversing_spec.rb +124 -0
- data/spec/lib/under_os/ui/utils/wrap_spec.rb +69 -0
- data/spec/lib/under_os/ui/view_spec.rb +39 -0
- data/under-os.gemspec +32 -0
- metadata +225 -11
- data/lib/under_os/application.rb +0 -16
- data/lib/under_os/window.rb +0 -5
@@ -0,0 +1,131 @@
|
|
1
|
+
describe UnderOs::UI::Select do
|
2
|
+
before do
|
3
|
+
@select = UnderOs::UI::Select.new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
it "should make select instances" do
|
8
|
+
@select.class.should == UnderOs::UI::Select
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should wrap UIPickerView" do
|
12
|
+
@select._.class.should == UIPickerView
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have tag SELECT" do
|
16
|
+
@select.tagName.should == 'SELECT'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should accept 'options' option" do
|
20
|
+
select = UnderOs::UI::Select.new(options: {
|
21
|
+
'1' => 'One', '2' => 'Two', '3' => 'Three'
|
22
|
+
})
|
23
|
+
|
24
|
+
select.options.should == {
|
25
|
+
'1' => 'One', '2' => 'Two', '3' => 'Three'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should accept 'value' option" do
|
30
|
+
select = UnderOs::UI::Select.new(value: 1)
|
31
|
+
select.value.should == '1'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#optgroups' do
|
36
|
+
it "should return an empty list by default" do
|
37
|
+
@select.optgroups.should == [{}]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should allow to assign groups" do
|
41
|
+
@select.optgroups = [
|
42
|
+
{'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
|
43
|
+
]
|
44
|
+
|
45
|
+
@select.optgroups.should == [
|
46
|
+
{'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should convert keys to strings and skip nils" do
|
51
|
+
@select.optgroups = [{
|
52
|
+
nil => 'One', :'2' => 'Two', :'3' => nil
|
53
|
+
}]
|
54
|
+
|
55
|
+
@select.optgroups.should == [{'2' => 'Two'}]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#options' do
|
60
|
+
it "should return an empty hash by default" do
|
61
|
+
@select.options.should == {}
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should allow to set new options" do
|
65
|
+
@select.options = {
|
66
|
+
'1' => 'One', '2' => 'Two', '3' => 'Three'
|
67
|
+
}
|
68
|
+
|
69
|
+
@select.options.should == {
|
70
|
+
'1' => 'One', '2' => 'Two', '3' => 'Three'
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should overwrite the optgroups" do
|
75
|
+
@select.options = {
|
76
|
+
'1' => 'One', '2' => 'Two', '3' => 'Three'
|
77
|
+
}
|
78
|
+
|
79
|
+
@select.optgroups.should == [{
|
80
|
+
'1' => 'One', '2' => 'Two', '3' => 'Three'
|
81
|
+
}]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#value' do
|
86
|
+
it "should return nil when nothing was set" do
|
87
|
+
@select.value.should == nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should return an empty list if several optgroups were set" do
|
91
|
+
@select.optgroups = [
|
92
|
+
{'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
|
93
|
+
]
|
94
|
+
|
95
|
+
@select.value.should == []
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should allow to set values for single selects" do
|
99
|
+
@select.value = 'one'
|
100
|
+
@select.value.should == 'one'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should allow to set values for multi-selects" do
|
104
|
+
@select.optgroups = [{'1' => 'One'}, {'2' => 'Two'}]
|
105
|
+
@select.value = ['1', '2']
|
106
|
+
@select.value.should == ['1', '2']
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should convert all values to strings" do
|
110
|
+
@select.value = 1
|
111
|
+
@select.value.should == '1'
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should emit the 'change' event if value was changed" do
|
115
|
+
@changed = false
|
116
|
+
@select.on(:change) { @changed = true }
|
117
|
+
@select.value = 'new'
|
118
|
+
@changed.should == true
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should not emit the 'change' event if the same value was assigned" do
|
122
|
+
@select.value = 'same'
|
123
|
+
|
124
|
+
@changed = false
|
125
|
+
@select.on(:change) { @changed = true }
|
126
|
+
@select.value = 'same'
|
127
|
+
|
128
|
+
@changed.should == false
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe UnderOs::UI::Sidebar do
|
2
|
+
before do
|
3
|
+
@sidebar = UnderOs::UI::Sidebar.new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
it "should build sidebars" do
|
8
|
+
@sidebar.class.should == UnderOs::UI::Sidebar
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should wrap up a normal UIView" do
|
12
|
+
@sidebar._.class.should == UIView
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have the 'SIDEBAR' tag" do
|
16
|
+
@sidebar.tagName.should == "SIDEBAR"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should accept the 'location' option" do
|
20
|
+
sidebar = UnderOs::UI::Sidebar.new(location: :left)
|
21
|
+
sidebar.location.should == :left
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#location' do
|
26
|
+
it "should return :bottom by default" do
|
27
|
+
@sidebar.location.should == :bottom
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept other values" do
|
31
|
+
@sidebar.location = 'top'
|
32
|
+
@sidebar.location.should == :top
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
describe UnderOs::UI::Slider do
|
2
|
+
before do
|
3
|
+
@slider = UnderOs::UI::Slider.new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
it "should spawn new sliders" do
|
8
|
+
@slider.class.should == UnderOs::UI::Slider
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should wrap the UISlider class" do
|
12
|
+
@slider._.class.should == UISlider
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should assign correct tag name" do
|
16
|
+
@slider.tagName.should == 'SLIDER'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should accept the 'value' option" do
|
20
|
+
slider = UnderOs::UI::Slider.new(value: 0.4)
|
21
|
+
slider.value.should == 0.4
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should accept the 'min' option" do
|
25
|
+
slider = UnderOs::UI::Slider.new(min: 4)
|
26
|
+
slider.min.should == 4
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should accept the 'max' option" do
|
30
|
+
slider = UnderOs::UI::Slider.new(max: 4)
|
31
|
+
slider.max.should == 4
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#value' do
|
36
|
+
it "should assign the value property correctly" do
|
37
|
+
@slider.value = 0.25
|
38
|
+
@slider._.value.should == 0.25
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#min' do
|
43
|
+
it "should assign the minimal value boundaries correctly" do
|
44
|
+
@slider.min = -10
|
45
|
+
@slider._.minimumValue.should == -10
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return the minimum value as it is" do
|
49
|
+
@slider.min = -20
|
50
|
+
@slider.min.should == -20
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#max' do
|
55
|
+
it "should assign the maximal value boundaries correctly" do
|
56
|
+
@slider.max = -10
|
57
|
+
@slider._.maximumValue.should == -10
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return the maximum value as it is" do
|
61
|
+
@slider.max = -20
|
62
|
+
@slider.max.should == -20
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
describe UnderOs::UI::Spinner do
|
2
|
+
before do
|
3
|
+
@spinner = UnderOs::UI::Spinner.new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe 'constructor' do
|
7
|
+
it "should build a spinner" do
|
8
|
+
@spinner.class.should == UnderOs::UI::Spinner
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should wrap the UIActivityIndicatorView" do
|
12
|
+
@spinner._.class.should == UIActivityIndicatorView
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have the correct tag name" do
|
16
|
+
@spinner.tagName.should == 'SPINNER'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should make it spin" do
|
20
|
+
@spinner.visible.should == true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#show' do
|
25
|
+
# it "should start the spinner" do
|
26
|
+
# @spinner.show
|
27
|
+
# @spinner._.isAnimating.should == 1
|
28
|
+
# end
|
29
|
+
|
30
|
+
it "should return the spinner back" do
|
31
|
+
@spinner.should.be.same_as @spinner
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#hide' do
|
36
|
+
# it "should stop the spinner" do
|
37
|
+
# @spinner.hide
|
38
|
+
# @spinner._.isAnimating.should == 0
|
39
|
+
# end
|
40
|
+
|
41
|
+
it "should return the spinner instance back" do
|
42
|
+
@spinner.hide.should.be.same_as @spinner
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#hidden' do
|
47
|
+
# it "should return false when the spinner is active" do
|
48
|
+
# @spinner.show
|
49
|
+
# @spinner.hidden.should == false
|
50
|
+
# end
|
51
|
+
|
52
|
+
# it "should return true when the spinner is inactive" do
|
53
|
+
# @spinner.hide
|
54
|
+
# @spinner.hidden.should == true
|
55
|
+
# end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
describe UnderOs::UI::Style::Fonts do
|
2
|
+
before do
|
3
|
+
@view = UnderOs::UI::View.new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe 'text-align' do
|
7
|
+
|
8
|
+
it "should not crash when called on unsupported elements" do
|
9
|
+
@view.style.textAlign = 'left'
|
10
|
+
true.should == true
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'with a label' do
|
14
|
+
before do
|
15
|
+
@view = UnderOs::UI::Label.new(text: "Hello")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should allow to align the text to the left" do
|
19
|
+
@view.style.textAlign = 'left'
|
20
|
+
@view._.textAlignment.should == NSTextAlignmentLeft
|
21
|
+
@view.style.textAlign.should == 'left'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should allow to align the text to the right" do
|
25
|
+
@view.style.textAlign = 'right'
|
26
|
+
@view._.textAlignment.should == NSTextAlignmentRight
|
27
|
+
@view.style.textAlign.should == 'right'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should allow to align the text to the center" do
|
31
|
+
@view.style.textAlign = 'center'
|
32
|
+
@view._.textAlignment.should == NSTextAlignmentCenter
|
33
|
+
@view.style.textAlign.should == 'center'
|
34
|
+
end
|
35
|
+
|
36
|
+
# it "should allow to align the text to fill the size" do
|
37
|
+
# @view.style.textAlign = 'justify'
|
38
|
+
# @view._.textAlignment.should == NSTextAlignmentJustified
|
39
|
+
# @view.style.textAlign.should == 'justify'
|
40
|
+
# end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'with a button' do
|
44
|
+
before do
|
45
|
+
@view = UnderOs::UI::Button.new(text: "Hello")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should allow to align the text to the left" do
|
49
|
+
@view.style.textAlign = 'left'
|
50
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentLeft
|
51
|
+
@view.style.textAlign.should == 'left'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should allow to align the text to the right" do
|
55
|
+
@view.style.textAlign = 'right'
|
56
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentRight
|
57
|
+
@view.style.textAlign.should == 'right'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should allow to align the text to the center" do
|
61
|
+
@view.style.textAlign = 'center'
|
62
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentCenter
|
63
|
+
@view.style.textAlign.should == 'center'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow to align the text to fill the size" do
|
67
|
+
@view.style.textAlign = 'justify'
|
68
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentFill
|
69
|
+
@view.style.textAlign.should == 'justify'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
describe UnderOs::UI::Style::Margins do
|
2
|
+
before do
|
3
|
+
@view = UnderOs::UI::View.new
|
4
|
+
@style = @view.style
|
5
|
+
end
|
6
|
+
|
7
|
+
describe '#display' do
|
8
|
+
it "should return :block by default" do
|
9
|
+
@view.style.display.should == :block
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should understand the 'none' value" do
|
13
|
+
@view.style.display = 'none'
|
14
|
+
@view.hidden.should == true
|
15
|
+
@view.style.display.should == :none
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should understand the 'block' value" do
|
19
|
+
@view.style.display = 'block'
|
20
|
+
@view.visible.should == true
|
21
|
+
@view.style.display.should == :block
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#margin' do
|
26
|
+
it "should return an array of zeros by default" do
|
27
|
+
@style.margin.should == [0, 0, 0, 0]
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should accept simple numbers' do
|
31
|
+
@style.margin = 10
|
32
|
+
@style.margin.should == [10, 10, 10, 10]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should accept arrays" do
|
36
|
+
@style.margin = [20]
|
37
|
+
@style.margin.should == [20, 20, 20, 20]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should accept two dim arrays" do
|
41
|
+
@style.margin = [10, 20]
|
42
|
+
@style.margin.should == [10, 20, 10, 20]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should accept four dims arrays" do
|
46
|
+
@style.margin = [10, 20, 30, 40]
|
47
|
+
@style.margin.should == [10, 20, 30, 40]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should accept single value strings" do
|
51
|
+
@style.margin = '10px'
|
52
|
+
@style.margin.should == [10, 10, 10, 10]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should accept two value strings" do
|
56
|
+
@style.margin = '10px 20'
|
57
|
+
@style.margin.should == [10, 20, 10, 20]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should accept the four values strings" do
|
61
|
+
@style.margin = '10px 20 30px 40'
|
62
|
+
@style.margin.should == [10, 20, 30, 40]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#padding' do
|
67
|
+
it "should return an array of zeros by default" do
|
68
|
+
@style.padding.should == [0, 0, 0, 0]
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should accept simple numbers' do
|
72
|
+
@style.padding = 10
|
73
|
+
@style.padding.should == [10, 10, 10, 10]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should accept arrays" do
|
77
|
+
@style.padding = [20]
|
78
|
+
@style.padding.should == [20, 20, 20, 20]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should accept two dim arrays" do
|
82
|
+
@style.padding = [10, 20]
|
83
|
+
@style.padding.should == [10, 20, 10, 20]
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should accept four dims arrays" do
|
87
|
+
@style.padding = [10, 20, 30, 40]
|
88
|
+
@style.padding.should == [10, 20, 30, 40]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should accept single value strings" do
|
92
|
+
@style.padding = '10px'
|
93
|
+
@style.padding.should == [10, 10, 10, 10]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should accept two value strings" do
|
97
|
+
@style.padding = '10px 20'
|
98
|
+
@style.padding.should == [10, 20, 10, 20]
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should accept the four values strings" do
|
102
|
+
@style.padding = '10px 20 30px 40'
|
103
|
+
@style.padding.should == [10, 20, 30, 40]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
describe UnderOs::UI::Style::Outlining do
|
2
|
+
before do
|
3
|
+
@view = UnderOs::UI::View.new
|
4
|
+
@style = @view.style
|
5
|
+
end
|
6
|
+
|
7
|
+
describe '#borderRadius' do
|
8
|
+
it "should allow to set it" do
|
9
|
+
@style.borderRadius = 10
|
10
|
+
@style.borderRadius.should == 10
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should change the view's layout property" do
|
14
|
+
@style.borderRadius = 20
|
15
|
+
@view._.clipsToBounds.should == true
|
16
|
+
@view._.layer.cornerRadius.should == 20
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#color' do
|
21
|
+
describe 'buttons' do
|
22
|
+
before do
|
23
|
+
@button = UnderOs::UI::Button.new
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should allow to set the colors" do
|
27
|
+
@button.style.color = UIColor.redColor
|
28
|
+
@button._.titleColorForState(UIControlStateNormal).should == UIColor.redColor
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return the curent button color" do
|
32
|
+
@button.style.color = UIColor.yellowColor
|
33
|
+
@button.style.color.should == UIColor.yellowColor
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'label' do
|
38
|
+
before do
|
39
|
+
@label = UnderOs::UI::Label.new
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should change the text color" do
|
43
|
+
@label.style.color = UIColor.redColor
|
44
|
+
@label._.textColor.should == UIColor.redColor
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return the current text color" do
|
48
|
+
@label.style.color = UIColor.yellowColor
|
49
|
+
@label.style.color.should == UIColor.yellowColor
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'spinner' do
|
54
|
+
before do
|
55
|
+
@spinner = UnderOs::UI::Spinner.new
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should change the color of the spinner" do
|
59
|
+
@spinner.style.color = UIColor.redColor
|
60
|
+
@spinner._.color.should == UIColor.redColor
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should return the current spinner color" do
|
64
|
+
@spinner.style.color = UIColor.yellowColor
|
65
|
+
@spinner.style.color.should == UIColor.yellowColor
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
describe UnderOs::UI::Style::Positioning do
|
2
|
+
before do
|
3
|
+
@view = UnderOs::UI::View.new
|
4
|
+
@style = @view.style
|
5
|
+
end
|
6
|
+
|
7
|
+
describe '#contentWidth' do
|
8
|
+
before do
|
9
|
+
@view = UnderOs::UI::Scroll.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should allow to set the content sizes" do
|
13
|
+
@view.style.contentWidth = 100
|
14
|
+
@view.style.contentHeight = 200
|
15
|
+
|
16
|
+
@view.style.contentWidth.should == 100
|
17
|
+
@view.style.contentHeight.should == 200
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#zIndex' do
|
22
|
+
it "should return 0 by default" do
|
23
|
+
@view.style.zIndex.should == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should allow to change it" do
|
27
|
+
@view.style.zIndex = 100
|
28
|
+
@view.style.zIndex.should == 100
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'scroller related styles' do
|
33
|
+
before do
|
34
|
+
@view = UnderOs::UI::Scroll.new
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#overflow' do
|
38
|
+
it "accepts 'visible'" do
|
39
|
+
@view.style.overflow = 'visible'
|
40
|
+
@view.style.overflowX.should == :visible
|
41
|
+
@view.style.overflowY.should == :visible
|
42
|
+
end
|
43
|
+
|
44
|
+
it "accepts 'hidden'" do
|
45
|
+
@view.style.overflow = :hidden
|
46
|
+
@view.style.overflowX.should == :hidden
|
47
|
+
@view.style.overflowY.should == :hidden
|
48
|
+
end
|
49
|
+
|
50
|
+
it "accepts 'x'" do
|
51
|
+
@view.style.overflow = 'x'
|
52
|
+
@view.style.overflowX.should == :visible
|
53
|
+
@view.style.overflowY.should == :hidden
|
54
|
+
end
|
55
|
+
|
56
|
+
it "accepts 'y'" do
|
57
|
+
@view.style.overflow = 'y'
|
58
|
+
@view.style.overflowX.should == :hidden
|
59
|
+
@view.style.overflowY.should == :visible
|
60
|
+
end
|
61
|
+
|
62
|
+
it "falls back to 'visible'" do
|
63
|
+
@view.style.overflow = 'weird stuff'
|
64
|
+
@view.style.overflowX.should == :visible
|
65
|
+
@view.style.overflowY.should == :visible
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe UnderOs::UI::Style do
|
2
|
+
before do
|
3
|
+
@view = UnderOs::UI::View.new
|
4
|
+
@style = @view.style
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should be an instance of UnderOs::UI::Style" do
|
8
|
+
@style.class.should == UnderOs::UI::Style
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should incapsulate the Element's raw uiview object" do
|
12
|
+
@style.view.should === @view._
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should always return the same object" do
|
16
|
+
@view.style.should === @style
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
describe UnderOs::UI::Switch do
|
2
|
+
before do
|
3
|
+
@switch = UnderOs::UI::Switch.new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
it "should spawn new switchs" do
|
8
|
+
@switch.class.should == UnderOs::UI::Switch
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should wrap the UISwitch class" do
|
12
|
+
@switch._.class.should == UISwitch
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should assign correct tag name" do
|
16
|
+
@switch.tagName.should == 'SWITCH'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should accept the 'value' option" do
|
20
|
+
switch = UnderOs::UI::Switch.new(value: 'smth')
|
21
|
+
switch.value.should == 'smth'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should accept the 'checked' option" do
|
25
|
+
switch = UnderOs::UI::Switch.new(checked: true)
|
26
|
+
switch.checked.should == true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#value' do
|
31
|
+
it "should save the value correctly" do
|
32
|
+
@switch.value = 'something'
|
33
|
+
@switch.value.should == 'something'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#checked' do
|
38
|
+
it "should allow to flip the switch on" do
|
39
|
+
@switch.checked = true
|
40
|
+
@switch._.on?.should == true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should allow to flip the switch off" do
|
44
|
+
@switch.checked = false
|
45
|
+
@switch._.on?.should == false
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return the state back correctly" do
|
49
|
+
@switch.checked = true
|
50
|
+
@switch.checked.should == true
|
51
|
+
|
52
|
+
@switch.checked = false
|
53
|
+
@switch.checked.should == false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|