shoes-swt 4.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +84 -0
- data/Gemfile +24 -0
- data/Guardfile +11 -0
- data/LICENSE +31 -0
- data/README.md +201 -0
- data/lib/shoes/swt.rb +118 -0
- data/lib/shoes/swt/animation.rb +46 -0
- data/lib/shoes/swt/app.rb +314 -0
- data/lib/shoes/swt/arc.rb +71 -0
- data/lib/shoes/swt/background.rb +41 -0
- data/lib/shoes/swt/border.rb +41 -0
- data/lib/shoes/swt/button.rb +18 -0
- data/lib/shoes/swt/check.rb +14 -0
- data/lib/shoes/swt/check_button.rb +19 -0
- data/lib/shoes/swt/color.rb +49 -0
- data/lib/shoes/swt/color_factory.rb +32 -0
- data/lib/shoes/swt/common/child.rb +16 -0
- data/lib/shoes/swt/common/clickable.rb +68 -0
- data/lib/shoes/swt/common/container.rb +28 -0
- data/lib/shoes/swt/common/fill.rb +38 -0
- data/lib/shoes/swt/common/painter.rb +92 -0
- data/lib/shoes/swt/common/painter_updates_position.rb +12 -0
- data/lib/shoes/swt/common/remove.rb +30 -0
- data/lib/shoes/swt/common/resource.rb +29 -0
- data/lib/shoes/swt/common/selection_listener.rb +14 -0
- data/lib/shoes/swt/common/stroke.rb +42 -0
- data/lib/shoes/swt/common/update_position.rb +15 -0
- data/lib/shoes/swt/common/visibility.rb +13 -0
- data/lib/shoes/swt/dialog.rb +90 -0
- data/lib/shoes/swt/disposed_protection.rb +23 -0
- data/lib/shoes/swt/download.rb +24 -0
- data/lib/shoes/swt/font.rb +32 -0
- data/lib/shoes/swt/gradient.rb +92 -0
- data/lib/shoes/swt/image.rb +128 -0
- data/lib/shoes/swt/image_pattern.rb +31 -0
- data/lib/shoes/swt/input_box.rb +73 -0
- data/lib/shoes/swt/key_listener.rb +145 -0
- data/lib/shoes/swt/line.rb +60 -0
- data/lib/shoes/swt/link.rb +31 -0
- data/lib/shoes/swt/link_segment.rb +111 -0
- data/lib/shoes/swt/list_box.rb +48 -0
- data/lib/shoes/swt/mouse_move_listener.rb +67 -0
- data/lib/shoes/swt/oval.rb +52 -0
- data/lib/shoes/swt/progress.rb +35 -0
- data/lib/shoes/swt/radio.rb +29 -0
- data/lib/shoes/swt/radio_group.rb +54 -0
- data/lib/shoes/swt/rect.rb +30 -0
- data/lib/shoes/swt/rect_painter.rb +23 -0
- data/lib/shoes/swt/redrawing_aspect.rb +123 -0
- data/lib/shoes/swt/shape.rb +133 -0
- data/lib/shoes/swt/shoes_layout.rb +43 -0
- data/lib/shoes/swt/slot.rb +39 -0
- data/lib/shoes/swt/sound.rb +119 -0
- data/lib/shoes/swt/star.rb +50 -0
- data/lib/shoes/swt/support/jl1.0.1.jar +0 -0
- data/lib/shoes/swt/support/jogg-0.0.7.jar +0 -0
- data/lib/shoes/swt/support/jorbis-0.0.15.jar +0 -0
- data/lib/shoes/swt/support/log4j-1.2.16.jar +0 -0
- data/lib/shoes/swt/support/mp3spi1.9.5.jar +0 -0
- data/lib/shoes/swt/support/tritonus_share.jar +0 -0
- data/lib/shoes/swt/support/vorbisspi1.0.3.jar +0 -0
- data/lib/shoes/swt/swt_button.rb +56 -0
- data/lib/shoes/swt/text_block.rb +124 -0
- data/lib/shoes/swt/text_block/centered_text_segment.rb +22 -0
- data/lib/shoes/swt/text_block/cursor_painter.rb +53 -0
- data/lib/shoes/swt/text_block/fitter.rb +212 -0
- data/lib/shoes/swt/text_block/painter.rb +47 -0
- data/lib/shoes/swt/text_block/text_font_factory.rb +50 -0
- data/lib/shoes/swt/text_block/text_segment.rb +108 -0
- data/lib/shoes/swt/text_block/text_segment_collection.rb +160 -0
- data/lib/shoes/swt/text_block/text_style_factory.rb +88 -0
- data/lib/shoes/swt/timer.rb +19 -0
- data/lib/shoes/swt/tooling/leak_hunter.rb +35 -0
- data/lib/shoes/swt/version.rb +5 -0
- data/manifests/common.rb +34 -0
- data/manifests/shoes-swt.rb +29 -0
- data/shoes-swt.gemspec +24 -0
- data/spec/code_coverage.rb +14 -0
- data/spec/shoes/animation_spec.rb +65 -0
- data/spec/shoes/app_spec.rb +484 -0
- data/spec/shoes/arc_spec.rb +51 -0
- data/spec/shoes/background_spec.rb +53 -0
- data/spec/shoes/border_spec.rb +47 -0
- data/spec/shoes/builtin_methods_spec.rb +110 -0
- data/spec/shoes/button_spec.rb +44 -0
- data/spec/shoes/check_spec.rb +35 -0
- data/spec/shoes/cli_spec.rb +15 -0
- data/spec/shoes/color_spec.rb +408 -0
- data/spec/shoes/common/inspect_spec.rb +26 -0
- data/spec/shoes/common/remove_spec.rb +38 -0
- data/spec/shoes/common/style_normalizer_spec.rb +28 -0
- data/spec/shoes/common/style_spec.rb +147 -0
- data/spec/shoes/configuration_spec.rb +36 -0
- data/spec/shoes/constants_spec.rb +38 -0
- data/spec/shoes/dialog_spec.rb +163 -0
- data/spec/shoes/dimension_spec.rb +407 -0
- data/spec/shoes/dimensions_spec.rb +837 -0
- data/spec/shoes/download_spec.rb +142 -0
- data/spec/shoes/flow_spec.rb +133 -0
- data/spec/shoes/font_spec.rb +37 -0
- data/spec/shoes/framework_learning_spec.rb +30 -0
- data/spec/shoes/gradient_spec.rb +32 -0
- data/spec/shoes/helpers/fake_element.rb +17 -0
- data/spec/shoes/helpers/inspect_helpers.rb +5 -0
- data/spec/shoes/helpers/sample17_helper.rb +66 -0
- data/spec/shoes/image_spec.rb +49 -0
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +80 -0
- data/spec/shoes/integration_spec.rb +20 -0
- data/spec/shoes/internal_app_spec.rb +141 -0
- data/spec/shoes/keypress_spec.rb +11 -0
- data/spec/shoes/keyrelease_spec.rb +12 -0
- data/spec/shoes/line_spec.rb +49 -0
- data/spec/shoes/link_spec.rb +105 -0
- data/spec/shoes/list_box_spec.rb +74 -0
- data/spec/shoes/logger/ruby_spec.rb +8 -0
- data/spec/shoes/logger_spec.rb +45 -0
- data/spec/shoes/oval_spec.rb +24 -0
- data/spec/shoes/point_spec.rb +71 -0
- data/spec/shoes/progress_spec.rb +54 -0
- data/spec/shoes/radio_spec.rb +32 -0
- data/spec/shoes/rect_spec.rb +39 -0
- data/spec/shoes/renamed_delegate_spec.rb +70 -0
- data/spec/shoes/shape_spec.rb +95 -0
- data/spec/shoes/shared_examples/button.rb +6 -0
- data/spec/shoes/shared_examples/changeable.rb +26 -0
- data/spec/shoes/shared_examples/clickable.rb +5 -0
- data/spec/shoes/shared_examples/common_methods.rb +35 -0
- data/spec/shoes/shared_examples/dimensions.rb +32 -0
- data/spec/shoes/shared_examples/dsl.rb +44 -0
- data/spec/shoes/shared_examples/dsl/animate.rb +29 -0
- data/spec/shoes/shared_examples/dsl/arc.rb +45 -0
- data/spec/shoes/shared_examples/dsl/background.rb +26 -0
- data/spec/shoes/shared_examples/dsl/border.rb +10 -0
- data/spec/shoes/shared_examples/dsl/button.rb +5 -0
- data/spec/shoes/shared_examples/dsl/cap.rb +6 -0
- data/spec/shoes/shared_examples/dsl/check.rb +11 -0
- data/spec/shoes/shared_examples/dsl/edit_box.rb +8 -0
- data/spec/shoes/shared_examples/dsl/edit_line.rb +8 -0
- data/spec/shoes/shared_examples/dsl/editable_element.rb +29 -0
- data/spec/shoes/shared_examples/dsl/fill.rb +27 -0
- data/spec/shoes/shared_examples/dsl/flow.rb +15 -0
- data/spec/shoes/shared_examples/dsl/gradient.rb +62 -0
- data/spec/shoes/shared_examples/dsl/image.rb +21 -0
- data/spec/shoes/shared_examples/dsl/line.rb +9 -0
- data/spec/shoes/shared_examples/dsl/nofill.rb +6 -0
- data/spec/shoes/shared_examples/dsl/nostroke.rb +6 -0
- data/spec/shoes/shared_examples/dsl/oval.rb +88 -0
- data/spec/shoes/shared_examples/dsl/pattern.rb +34 -0
- data/spec/shoes/shared_examples/dsl/progress.rb +7 -0
- data/spec/shoes/shared_examples/dsl/rect.rb +92 -0
- data/spec/shoes/shared_examples/dsl/rgb.rb +26 -0
- data/spec/shoes/shared_examples/dsl/shape.rb +21 -0
- data/spec/shoes/shared_examples/dsl/star.rb +48 -0
- data/spec/shoes/shared_examples/dsl/stroke.rb +30 -0
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +19 -0
- data/spec/shoes/shared_examples/dsl/style.rb +32 -0
- data/spec/shoes/shared_examples/dsl/text_elements.rb +81 -0
- data/spec/shoes/shared_examples/dsl/video.rb +5 -0
- data/spec/shoes/shared_examples/dsl_app_context.rb +8 -0
- data/spec/shoes/shared_examples/hover_leave.rb +11 -0
- data/spec/shoes/shared_examples/parent.rb +6 -0
- data/spec/shoes/shared_examples/scroll.rb +41 -0
- data/spec/shoes/shared_examples/shared_element_method.rb +60 -0
- data/spec/shoes/shared_examples/slot.rb +331 -0
- data/spec/shoes/shared_examples/state.rb +19 -0
- data/spec/shoes/shared_examples/style.rb +82 -0
- data/spec/shoes/slot_spec.rb +130 -0
- data/spec/shoes/sound_spec.rb +15 -0
- data/spec/shoes/span_spec.rb +112 -0
- data/spec/shoes/spec_helper.rb +24 -0
- data/spec/shoes/stack_spec.rb +79 -0
- data/spec/shoes/star_spec.rb +31 -0
- data/spec/shoes/text_block_dimensions_spec.rb +75 -0
- data/spec/shoes/text_block_spec.rb +270 -0
- data/spec/shoes/url_spec.rb +68 -0
- data/spec/shoes/widget_spec.rb +70 -0
- data/spec/shoes_spec.rb +44 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/swt_shoes/animation_spec.rb +86 -0
- data/spec/swt_shoes/app_spec.rb +84 -0
- data/spec/swt_shoes/arc_spec.rb +103 -0
- data/spec/swt_shoes/background_spec.rb +67 -0
- data/spec/swt_shoes/border_spec.rb +52 -0
- data/spec/swt_shoes/button_spec.rb +101 -0
- data/spec/swt_shoes/check_spec.rb +28 -0
- data/spec/swt_shoes/color_factory_spec.rb +49 -0
- data/spec/swt_shoes/color_spec.rb +67 -0
- data/spec/swt_shoes/common/painter_spec.rb +49 -0
- data/spec/swt_shoes/common/remove_spec.rb +53 -0
- data/spec/swt_shoes/configuration_spec.rb +12 -0
- data/spec/swt_shoes/dialog_spec.rb +106 -0
- data/spec/swt_shoes/disposed_protection_spec.rb +49 -0
- data/spec/swt_shoes/flow_spec.rb +36 -0
- data/spec/swt_shoes/font_spec.rb +33 -0
- data/spec/swt_shoes/gradient_spec.rb +31 -0
- data/spec/swt_shoes/image_pattern_spec.rb +35 -0
- data/spec/swt_shoes/image_spec.rb +100 -0
- data/spec/swt_shoes/input_box_spec.rb +116 -0
- data/spec/swt_shoes/integration_spec.rb +27 -0
- data/spec/swt_shoes/key_listener_spec.rb +325 -0
- data/spec/swt_shoes/line_spec.rb +49 -0
- data/spec/swt_shoes/link_segment_spec.rb +120 -0
- data/spec/swt_shoes/link_spec.rb +54 -0
- data/spec/swt_shoes/list_box_spec.rb +56 -0
- data/spec/swt_shoes/minimal.png +0 -0
- data/spec/swt_shoes/mouse_move_listener_spec.rb +123 -0
- data/spec/swt_shoes/oval_spec.rb +51 -0
- data/spec/swt_shoes/progress_spec.rb +44 -0
- data/spec/swt_shoes/radio_group_spec.rb +73 -0
- data/spec/swt_shoes/radio_spec.rb +56 -0
- data/spec/swt_shoes/rect_painter_spec.rb +45 -0
- data/spec/swt_shoes/rect_spec.rb +19 -0
- data/spec/swt_shoes/shape_spec.rb +84 -0
- data/spec/swt_shoes/shared_examples/button.rb +21 -0
- data/spec/swt_shoes/shared_examples/clickable.rb +85 -0
- data/spec/swt_shoes/shared_examples/movable.rb +36 -0
- data/spec/swt_shoes/shared_examples/paintable.rb +7 -0
- data/spec/swt_shoes/shared_examples/painter.rb +83 -0
- data/spec/swt_shoes/shared_examples/pattern.rb +32 -0
- data/spec/swt_shoes/shared_examples/removable.rb +41 -0
- data/spec/swt_shoes/shared_examples/swt_app_context.rb +23 -0
- data/spec/swt_shoes/shared_examples/visibility.rb +15 -0
- data/spec/swt_shoes/shell_control_listener_spec.rb +23 -0
- data/spec/swt_shoes/slot_spec.rb +24 -0
- data/spec/swt_shoes/sound.rb +10 -0
- data/spec/swt_shoes/spec_helper.rb +31 -0
- data/spec/swt_shoes/star_spec.rb +47 -0
- data/spec/swt_shoes/text_block/centered_text_segment_spec.rb +16 -0
- data/spec/swt_shoes/text_block/cursor_painter_spec.rb +120 -0
- data/spec/swt_shoes/text_block/fitter_spec.rb +213 -0
- data/spec/swt_shoes/text_block/painter_spec.rb +212 -0
- data/spec/swt_shoes/text_block/text_font_factory_spec.rb +40 -0
- data/spec/swt_shoes/text_block/text_segment_collection_spec.rb +256 -0
- data/spec/swt_shoes/text_block/text_segment_spec.rb +135 -0
- data/spec/swt_shoes/text_block_spec.rb +199 -0
- metadata +496 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::Line do
|
4
|
+
include_context "swt app"
|
5
|
+
|
6
|
+
let(:container) { double('container', :disposed? => false).as_null_object }
|
7
|
+
let(:dsl) { Shoes::Line.new shoes_app, parent, point_a, point_b }
|
8
|
+
let(:point_a) { Shoes::Point.new(10, 100) }
|
9
|
+
let(:point_b) { Shoes::Point.new(300, 10) }
|
10
|
+
|
11
|
+
subject {
|
12
|
+
Shoes::Swt::Line.new(dsl, swt_app)
|
13
|
+
}
|
14
|
+
|
15
|
+
context "#initialize" do
|
16
|
+
it { is_expected.to be_instance_of(Shoes::Swt::Line) }
|
17
|
+
its(:dsl) { is_expected.to be(dsl) }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "properly disposes" do
|
21
|
+
expect(subject.transform).to receive(:dispose)
|
22
|
+
subject.dispose
|
23
|
+
end
|
24
|
+
|
25
|
+
it_behaves_like "paintable"
|
26
|
+
it_behaves_like "updating visibility"
|
27
|
+
it_behaves_like "clickable backend"
|
28
|
+
|
29
|
+
it {is_expected.to respond_to :remove}
|
30
|
+
|
31
|
+
describe "painter" do
|
32
|
+
include_context "painter context"
|
33
|
+
|
34
|
+
let(:shape) { Shoes::Swt::Line.new(dsl, swt_app) }
|
35
|
+
subject { Shoes::Swt::Line::Painter.new(shape) }
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
allow(dsl).to receive_messages(positioned?: true)
|
39
|
+
end
|
40
|
+
|
41
|
+
it_behaves_like "stroke painter"
|
42
|
+
|
43
|
+
specify "draws line" do
|
44
|
+
# coords as if drawn in box at (0,0)
|
45
|
+
expect(gc).to receive(:draw_line).with(0, 90, 290, 0)
|
46
|
+
subject.paint_control(event)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::LinkSegment do
|
4
|
+
let(:range) { (2..10) }
|
5
|
+
let(:line_width) { 20 }
|
6
|
+
let(:line_height) { 14 }
|
7
|
+
let(:layout) { double('swt layout', width: line_width, line_count: 10) }
|
8
|
+
let(:text_segment) { double('text segment', layout: layout,
|
9
|
+
element_left: 0, element_top: 0) }
|
10
|
+
|
11
|
+
subject { Shoes::Swt::LinkSegment.new(text_segment, range) }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
10.times {|i| stub_line_bounds(i)}
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# ....................
|
19
|
+
context "empty link" do
|
20
|
+
let(:range) { (0...0) }
|
21
|
+
|
22
|
+
it "fails all bounds checks" do
|
23
|
+
stub_start_and_end_locations([0, 0], [10, 0])
|
24
|
+
expect_not_in_bounds(0, 0, 10, line_height)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# xxxxxxxxxx..........
|
29
|
+
it "sets bounds on single line" do
|
30
|
+
stub_start_and_end_locations([0, 0], [10, 0])
|
31
|
+
|
32
|
+
expect_bounded_box(0, 0, 10, line_height)
|
33
|
+
end
|
34
|
+
|
35
|
+
# xxxxxxxxxxxxxxxxxxxx
|
36
|
+
# xxxxx...............
|
37
|
+
it "sets bounds wrapping to second line" do
|
38
|
+
stub_start_and_end_locations([0, 0], [5, line_height])
|
39
|
+
|
40
|
+
expect_bounded_box(0, 0, line_width, line_height)
|
41
|
+
expect_bounded_box(0, line_height, 5, 2*line_height)
|
42
|
+
end
|
43
|
+
|
44
|
+
# .....xxxxxxxxxxxxxxx
|
45
|
+
# xxxxxxxxxxxxxxxxxxxx
|
46
|
+
# xxxxx...............
|
47
|
+
it "sets bounds wrapping over three lines" do
|
48
|
+
stub_start_and_end_locations([5, 0], [5, 2*line_height])
|
49
|
+
|
50
|
+
expect_bounded_box(5, 0, line_width, line_height)
|
51
|
+
expect_bounded_box(0, line_height, line_width, 2*line_height)
|
52
|
+
expect_bounded_box(0, 2*line_height, 5, 3*line_height)
|
53
|
+
end
|
54
|
+
|
55
|
+
# ....................
|
56
|
+
# .....xxxxxxxxxx.....
|
57
|
+
it "sets bounds with single line beginning further down" do
|
58
|
+
stub_start_and_end_locations([5, line_height], [15, line_height])
|
59
|
+
|
60
|
+
expect_bounded_box(5, line_height, 15, 2*line_height)
|
61
|
+
end
|
62
|
+
|
63
|
+
# ....................
|
64
|
+
# ...............xxxxx
|
65
|
+
# xxxxx...............
|
66
|
+
it "sets bounds with two lines beginning further down" do
|
67
|
+
stub_start_and_end_locations([15, line_height], [5, 2*line_height])
|
68
|
+
|
69
|
+
expect_bounded_box(15, line_height, 15, 2*line_height)
|
70
|
+
expect_bounded_box(0, 2*line_height, 5, 3*line_height)
|
71
|
+
end
|
72
|
+
|
73
|
+
# ....................
|
74
|
+
# ...............xxxxx
|
75
|
+
# xxxxxxxxxxxxxxxxxxxx
|
76
|
+
# xxxxx...............
|
77
|
+
it "sets bounds with three lines beginning further down" do
|
78
|
+
stub_start_and_end_locations([15, line_height], [5, 3*line_height])
|
79
|
+
|
80
|
+
expect_bounded_box(15, line_height, 15, 2*line_height)
|
81
|
+
expect_bounded_box(0, 2*line_height, line_width, 3*line_height)
|
82
|
+
expect_bounded_box(0, 3*line_height, 5, 4*line_height)
|
83
|
+
end
|
84
|
+
|
85
|
+
def expect_bounded_box(left, top, right, bottom)
|
86
|
+
expect_in_bounds([left, top], [right, top],
|
87
|
+
[left, bottom], [right,bottom])
|
88
|
+
end
|
89
|
+
|
90
|
+
def expect_in_bounds(*points)
|
91
|
+
points.each do |(x,y)|
|
92
|
+
expect(subject.in_bounds?(x, y)).to be_truthy, "with #{x}, #{y}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def expect_not_in_bounds(*points)
|
97
|
+
points.each do |(x,y)|
|
98
|
+
expect(subject.in_bounds?(x, y)).to be_falsey, "with #{x}, #{y}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def stub_start_and_end_locations(first, last)
|
103
|
+
stub_location(range.first, first[0], first[1])
|
104
|
+
stub_location(range.last, last[0], last[1])
|
105
|
+
end
|
106
|
+
|
107
|
+
def stub_location(at, x, y)
|
108
|
+
allow(text_segment).to receive(:get_location).with(at, anything) { double(x: x, y: y) }
|
109
|
+
end
|
110
|
+
|
111
|
+
def stub_line_bounds(index)
|
112
|
+
allow(layout).to receive(:line_bounds).with(index) {
|
113
|
+
double("line #{index}",
|
114
|
+
x: 0,
|
115
|
+
y: index * line_height,
|
116
|
+
width: line_width,
|
117
|
+
height: line_height)
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::Link do
|
4
|
+
include_context "swt app"
|
5
|
+
|
6
|
+
let(:dsl) { Shoes::Link.new shoes_app, parent, ["linky"] }
|
7
|
+
|
8
|
+
subject { Shoes::Swt::Link.new(dsl, swt_app) }
|
9
|
+
|
10
|
+
its(:dsl) {is_expected.to eq dsl}
|
11
|
+
|
12
|
+
it_behaves_like "clickable backend"
|
13
|
+
|
14
|
+
context "creating link segments" do
|
15
|
+
let(:bounds) { double("bounds", height: 0) }
|
16
|
+
let(:inner_layout) { double("inner layout",
|
17
|
+
get_line_bounds: bounds, line_count: 1,
|
18
|
+
line_bounds: double(x: 0, y: 0, height: 0)) }
|
19
|
+
let(:layout) { double("layout",
|
20
|
+
get_location: double("position", x: 0, y: 0),
|
21
|
+
element_left: 0, element_top: 0,
|
22
|
+
layout: inner_layout) }
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
allow(shoes_app).to receive(:add_listener)
|
26
|
+
allow(shoes_app).to receive(:add_clickable_element)
|
27
|
+
|
28
|
+
allow(swt_app).to receive(:clickable_elements) { [] }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "clears existing" do
|
32
|
+
subject.link_segments << double("segment")
|
33
|
+
subject.create_links_in([])
|
34
|
+
expect(subject.link_segments).to be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it "adds new segments" do
|
38
|
+
subject.create_links_in([
|
39
|
+
[layout, [5..10]],
|
40
|
+
[layout, [0..5]]
|
41
|
+
])
|
42
|
+
expect(subject.link_segments.count).to eql(2)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "clears links" do
|
46
|
+
expect(swt_app).to receive(:remove_listener)
|
47
|
+
|
48
|
+
subject.create_links_in([[layout, 0..10]])
|
49
|
+
subject.remove
|
50
|
+
|
51
|
+
expect(subject.link_segments).to be_empty
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::ListBox do
|
4
|
+
include_context "swt app"
|
5
|
+
|
6
|
+
let(:items) { ["Pie", "Apple", "Sand"] }
|
7
|
+
let(:dsl) { double('dsl', app: shoes_app,
|
8
|
+
items: items, opts: {},
|
9
|
+
element_width: 200, element_height: 20).as_null_object }
|
10
|
+
let(:block) { ->(){} }
|
11
|
+
let(:real) { double('real', text: "", :items= => true,
|
12
|
+
set_size: true, add_selection_listener: true,
|
13
|
+
disposed?: false ) }
|
14
|
+
|
15
|
+
subject { Shoes::Swt::ListBox.new dsl, parent, &block }
|
16
|
+
|
17
|
+
before :each do
|
18
|
+
allow(parent).to receive(:real)
|
19
|
+
allow(::Swt::Widgets::Combo).to receive(:new) { real }
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "updating visibility"
|
23
|
+
|
24
|
+
it "should return nil when nothing is highlighted" do
|
25
|
+
expect(subject.text).to be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should call 'items' when updating values" do
|
29
|
+
expect(real).to receive(:items=).with(["hello"])
|
30
|
+
subject.update_items(["hello"])
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should respond to choose" do
|
34
|
+
expect(subject).to respond_to :choose
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should call text= when choosing" do
|
38
|
+
expect(real).to receive(:text=).with "Bacon"
|
39
|
+
subject.choose "Bacon"
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'sets the items on real upon initialization' do
|
43
|
+
subject
|
44
|
+
expect(real).to have_received(:items=).with(items)
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "when the backend notifies us that the selection has changed" do
|
48
|
+
it "should call the change listeners" do
|
49
|
+
expect(dsl).to receive(:call_change_listeners)
|
50
|
+
expect(real).to receive(:add_selection_listener) do |&blk|
|
51
|
+
blk.call()
|
52
|
+
end
|
53
|
+
subject
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
Binary file
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::MouseMoveListener do
|
4
|
+
let(:app) {double 'SWT App', dsl: dsl_app, shell: shell,
|
5
|
+
clickable_elements: clickable_elements}
|
6
|
+
let(:clickable_elements) {[]}
|
7
|
+
let(:mouse_hover_controls) {[]}
|
8
|
+
let(:mouse_motion) {[]}
|
9
|
+
let(:shell) {double 'Shell', setCursor: nil}
|
10
|
+
let(:dsl_app) {double('DSL App', mouse_hover_controls: mouse_hover_controls,
|
11
|
+
mouse_motion: mouse_motion).as_null_object}
|
12
|
+
let(:x) {10}
|
13
|
+
let(:y) {42}
|
14
|
+
let(:block) {double 'Block', call: nil}
|
15
|
+
let(:mouse_event) {double'mouse event', x: x, y: y}
|
16
|
+
|
17
|
+
subject {Shoes::Swt::MouseMoveListener.new(app)}
|
18
|
+
before :each do
|
19
|
+
subject.mouse_move(mouse_event)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'mouse position' do
|
23
|
+
it 'receives the correct mouse position' do
|
24
|
+
expect(dsl_app).to have_received(:mouse_pos=).with([x, y])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'mouse motion' do
|
29
|
+
let(:mouse_motion) {[block]}
|
30
|
+
|
31
|
+
it 'calls the block with the position' do
|
32
|
+
expect(block).to have_received(:call).with(x, y)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'shape control' do
|
37
|
+
let(:hand_cursor) {Shoes::Swt::Shoes.display.getSystemCursor(::Swt::SWT::CURSOR_HAND)}
|
38
|
+
let(:arrow_cursor) {Shoes::Swt::Shoes.display.getSystemCursor(::Swt::SWT::CURSOR_ARROW)}
|
39
|
+
|
40
|
+
context 'over a clickable element' do
|
41
|
+
let(:clickable_elements) {[double('element', visible?: true, in_bounds?: true)]}
|
42
|
+
it 'should set the curser hand' do
|
43
|
+
expect(shell).to have_received(:setCursor).with(hand_cursor)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'not over a clickable element' do
|
48
|
+
let(:clickable_elements) {[double('element', visible?: true, in_bounds?: false)]}
|
49
|
+
it 'should set the curser hand' do
|
50
|
+
expect(shell).to have_received(:setCursor).with(arrow_cursor)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'hover control' do
|
56
|
+
let(:element) {double 'element', in_bounds?: in_bounds?, hovered?: hovered?,
|
57
|
+
visible?: true, mouse_left: nil, mouse_hovered: nil}
|
58
|
+
let(:mouse_hover_controls) {[element]}
|
59
|
+
|
60
|
+
shared_examples_for 'does not do anything' do
|
61
|
+
it 'calls no hover related methods whatsoever' do
|
62
|
+
expect(element).not_to have_received :mouse_left
|
63
|
+
expect(element).not_to have_received :mouse_hovered
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'in bounds and hovered' do
|
68
|
+
let(:in_bounds?) {true}
|
69
|
+
let(:hovered?) {true}
|
70
|
+
|
71
|
+
it_behaves_like 'does not do anything'
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'out of bounds and not hovered' do
|
75
|
+
let(:in_bounds?) {false}
|
76
|
+
let(:hovered?) {false}
|
77
|
+
|
78
|
+
it_behaves_like 'does not do anything'
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'in bounds and not hovered' do
|
82
|
+
let(:in_bounds?) {true}
|
83
|
+
let(:hovered?) {false}
|
84
|
+
|
85
|
+
it 'calls the hovered method' do
|
86
|
+
expect(element).to have_received :mouse_hovered
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'out of bounds and hovered' do
|
91
|
+
let(:in_bounds?) {false}
|
92
|
+
let(:hovered?) {true}
|
93
|
+
|
94
|
+
it 'calls the mouse_left method' do
|
95
|
+
expect(element).to have_received :mouse_left
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'in bounds, not hovered but hidden' do
|
100
|
+
let(:in_bounds?) {true}
|
101
|
+
let(:hovered?) {false}
|
102
|
+
let(:element) {double 'element', in_bounds?: in_bounds?, hovered?: hovered?,
|
103
|
+
visible?: false, mouse_left: nil, mouse_hovered: nil}
|
104
|
+
|
105
|
+
it_behaves_like 'does not do anything'
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'with 2 elements' do
|
109
|
+
let(:in_bounds?) {false}
|
110
|
+
let(:hovered?) {true}
|
111
|
+
|
112
|
+
let(:element2) {double 'element 2', in_bounds?: true, hovered?: false,
|
113
|
+
visible?: true, mouse_left: nil, mouse_hovered: nil}
|
114
|
+
let(:mouse_hover_controls) {[element, element2]}
|
115
|
+
|
116
|
+
it 'calls leave for element 1 before calling hover for element 2' do
|
117
|
+
expect(element).to receive(:mouse_left).ordered
|
118
|
+
expect(element2).to receive(:mouse_hovered).ordered
|
119
|
+
subject.mouse_move(mouse_event)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::Oval do
|
4
|
+
include_context "swt app"
|
5
|
+
|
6
|
+
let(:left) { 100 }
|
7
|
+
let(:top) { 200 }
|
8
|
+
let(:width) { 300 }
|
9
|
+
let(:height) { 400 }
|
10
|
+
let(:dsl) {::Shoes::Oval.new shoes_app, parent, left, top, width, height}
|
11
|
+
|
12
|
+
subject {
|
13
|
+
Shoes::Swt::Oval.new(dsl, swt_app)
|
14
|
+
}
|
15
|
+
|
16
|
+
it_behaves_like "paintable"
|
17
|
+
it_behaves_like "updating visibility"
|
18
|
+
it_behaves_like 'clickable backend'
|
19
|
+
|
20
|
+
describe "painter" do
|
21
|
+
include_context "painter context"
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
shape.absolute_left = left
|
25
|
+
shape.absolute_top = top
|
26
|
+
end
|
27
|
+
let(:shape) { Shoes::Swt::Oval.new(dsl, swt_app) }
|
28
|
+
subject { Shoes::Swt::Oval::Painter.new(shape) }
|
29
|
+
|
30
|
+
it_behaves_like "fill painter"
|
31
|
+
it_behaves_like "stroke painter"
|
32
|
+
|
33
|
+
it "creates oval clipping area" do
|
34
|
+
double_path = double("path")
|
35
|
+
allow(::Swt::Path).to receive(:new) { double_path }
|
36
|
+
expect(double_path).to receive(:add_arc).with(left, top, width, height, 0, 360)
|
37
|
+
subject.clipping
|
38
|
+
end
|
39
|
+
|
40
|
+
it "fills" do
|
41
|
+
expect(gc).to receive(:fill_oval)
|
42
|
+
subject.paint_control(event)
|
43
|
+
end
|
44
|
+
|
45
|
+
specify "draws oval" do
|
46
|
+
expect(gc).to receive(:draw_oval).with(left+sw/2, top+sw/2, width-sw, height-sw)
|
47
|
+
subject.paint_control(event)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|