shoes-swt 4.0.0.pre6 → 4.0.0.pre7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -1
- data/lib/shoes/swt.rb +8 -0
- data/lib/shoes/swt/app.rb +5 -7
- data/lib/shoes/swt/arc.rb +3 -28
- data/lib/shoes/swt/arc_painter.rb +34 -0
- data/lib/shoes/swt/arrow.rb +35 -0
- data/lib/shoes/swt/arrow_painter.rb +59 -0
- data/lib/shoes/swt/background.rb +1 -0
- data/lib/shoes/swt/border.rb +1 -0
- data/lib/shoes/swt/check_button.rb +17 -17
- data/lib/shoes/swt/click_listener.rb +6 -6
- data/lib/shoes/swt/common/painter.rb +4 -2
- data/lib/shoes/swt/common/translate.rb +15 -0
- data/lib/shoes/swt/{generate-backend.rb → generate_backend.rb} +1 -3
- data/lib/shoes/swt/gradient.rb +3 -4
- data/lib/shoes/swt/key_listener.rb +9 -7
- data/lib/shoes/swt/line.rb +5 -13
- data/lib/shoes/swt/line_painter.rb +16 -0
- data/lib/shoes/swt/link.rb +4 -0
- data/lib/shoes/swt/link_segment.rb +1 -1
- data/lib/shoes/swt/oval.rb +2 -21
- data/lib/shoes/swt/oval_painter.rb +27 -0
- data/lib/shoes/swt/packager.rb +1 -1
- data/lib/shoes/swt/radio_group.rb +1 -1
- data/lib/shoes/swt/rect.rb +1 -0
- data/lib/shoes/swt/rect_painter.rb +27 -9
- data/lib/shoes/swt/redrawing_aspect.rb +30 -17
- data/lib/shoes/swt/shape.rb +13 -18
- data/lib/shoes/swt/shape_painter.rb +13 -0
- data/lib/shoes/swt/shoes_layout.rb +1 -1
- data/lib/shoes/swt/slot.rb +12 -1
- data/lib/shoes/swt/sound.rb +21 -23
- data/lib/shoes/swt/star.rb +2 -46
- data/lib/shoes/swt/star_painter.rb +51 -0
- data/lib/shoes/swt/text_block.rb +4 -3
- data/lib/shoes/swt/text_block/fitter.rb +3 -4
- data/lib/shoes/swt/text_block/text_font_factory.rb +1 -1
- data/lib/shoes/swt/text_block/text_segment.rb +8 -3
- data/lib/shoes/swt/text_block/text_segment_collection.rb +1 -1
- data/lib/shoes/swt/text_block/text_style_factory.rb +1 -3
- data/lib/shoes/swt/timer.rb +1 -3
- data/lib/shoes/swt/version.rb +3 -1
- data/shoes-swt.gemspec +1 -1
- data/spec/shoes/cli_spec.rb +2 -2
- data/spec/shoes/swt/animation_spec.rb +4 -3
- data/spec/shoes/swt/app_spec.rb +17 -17
- data/spec/shoes/swt/arc_painter_spec.rb +80 -0
- data/spec/shoes/swt/arc_spec.rb +7 -68
- data/spec/shoes/swt/arrow_painter_spec.rb +37 -0
- data/spec/shoes/swt/arrow_spec.rb +27 -0
- data/spec/shoes/swt/background_spec.rb +13 -11
- data/spec/shoes/swt/border_spec.rb +8 -5
- data/spec/shoes/swt/button_spec.rb +4 -4
- data/spec/shoes/swt/check_spec.rb +19 -8
- data/spec/shoes/swt/click_listener_spec.rb +1 -1
- data/spec/shoes/swt/common/painter_spec.rb +29 -14
- data/spec/shoes/swt/common/remove_spec.rb +2 -2
- data/spec/shoes/swt/dialog_spec.rb +1 -1
- data/spec/shoes/swt/flow_spec.rb +5 -3
- data/spec/shoes/swt/font_spec.rb +1 -1
- data/spec/shoes/swt/gradient_spec.rb +6 -3
- data/spec/shoes/swt/image_spec.rb +9 -9
- data/spec/shoes/swt/input_box_spec.rb +20 -15
- data/spec/shoes/swt/integration_spec.rb +1 -1
- data/spec/shoes/swt/key_listener_spec.rb +34 -33
- data/spec/shoes/swt/line_painter_spec.rb +26 -0
- data/spec/shoes/swt/line_spec.rb +2 -25
- data/spec/shoes/swt/link_segment_spec.rb +20 -18
- data/spec/shoes/swt/link_spec.rb +11 -8
- data/spec/shoes/swt/list_box_spec.rb +15 -11
- data/spec/shoes/swt/mouse_move_listener_spec.rb +55 -39
- data/spec/shoes/swt/oval_painter_spec.rb +40 -0
- data/spec/shoes/swt/oval_spec.rb +3 -34
- data/spec/shoes/swt/progress_spec.rb +2 -2
- data/spec/shoes/swt/radio_group_spec.rb +1 -1
- data/spec/shoes/swt/radio_spec.rb +7 -4
- data/spec/shoes/swt/rect_painter_spec.rb +13 -8
- data/spec/shoes/swt/rect_spec.rb +2 -4
- data/spec/shoes/swt/shape_painter_spec.rb +27 -0
- data/spec/shoes/swt/shape_spec.rb +7 -24
- data/spec/shoes/swt/shared_examples/clickable.rb +2 -2
- data/spec/shoes/swt/shared_examples/swt_app_context.rb +21 -12
- data/spec/shoes/swt/shell_control_listener_spec.rb +9 -9
- data/spec/shoes/swt/shoes_layout_spec.rb +18 -13
- data/spec/shoes/swt/slot_spec.rb +15 -4
- data/spec/shoes/swt/spec_helper.rb +1 -1
- data/spec/shoes/swt/star_painter_spec.rb +36 -0
- data/spec/shoes/swt/star_spec.rb +0 -25
- data/spec/shoes/swt/text_block/centered_text_segment_spec.rb +2 -2
- data/spec/shoes/swt/text_block/cursor_painter_spec.rb +17 -13
- data/spec/shoes/swt/text_block/fitter_spec.rb +25 -18
- data/spec/shoes/swt/text_block/painter_spec.rb +7 -4
- data/spec/shoes/swt/text_block/text_font_factory_spec.rb +3 -3
- data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +22 -15
- data/spec/shoes/swt/text_block/text_segment_spec.rb +15 -12
- data/spec/shoes/swt/text_block_spec.rb +12 -10
- data/spec/spec_helper.rb +3 -1
- metadata +30 -8
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::StarPainter do
|
4
|
+
include_context "swt app"
|
5
|
+
include_context "painter context"
|
6
|
+
|
7
|
+
let(:left) { 55 }
|
8
|
+
let(:top) { 77 }
|
9
|
+
let(:points) { 7 }
|
10
|
+
let(:outer) { 100 }
|
11
|
+
let(:inner) { 20 }
|
12
|
+
let(:corners) { 0 }
|
13
|
+
|
14
|
+
let(:dsl) do
|
15
|
+
double("dsl object", hidden: false, points: points, outer: outer,
|
16
|
+
inner: inner, element_width: outer * 2.0,
|
17
|
+
element_height: outer * 2.0, element_left: left,
|
18
|
+
element_top: top).as_null_object
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:shape) { Shoes::Swt::Star.new dsl, swt_app }
|
22
|
+
subject { Shoes::Swt::StarPainter.new shape }
|
23
|
+
|
24
|
+
it_behaves_like "fill painter"
|
25
|
+
it_behaves_like "stroke painter"
|
26
|
+
|
27
|
+
it "fills star" do
|
28
|
+
expect(gc).to receive(:fillPolygon)
|
29
|
+
subject.paint_control(event)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "draws star" do
|
33
|
+
expect(gc).to receive(:drawPolygon)
|
34
|
+
subject.paint_control(event)
|
35
|
+
end
|
36
|
+
end
|
data/spec/shoes/swt/star_spec.rb
CHANGED
@@ -19,29 +19,4 @@ describe Shoes::Swt::Star do
|
|
19
19
|
it_behaves_like "paintable"
|
20
20
|
it_behaves_like "updating visibility"
|
21
21
|
it_behaves_like 'clickable backend'
|
22
|
-
|
23
|
-
describe "painter" do
|
24
|
-
include_context "painter context"
|
25
|
-
|
26
|
-
let(:corners) { 0 }
|
27
|
-
let(:dsl) { double("dsl object", hidden: false, points: points, outer: outer,
|
28
|
-
inner: inner, element_width: outer * 2.0,
|
29
|
-
element_height: outer * 2.0, element_left: left,
|
30
|
-
element_top: top).as_null_object }
|
31
|
-
let(:shape) { Shoes::Swt::Star.new dsl, swt_app }
|
32
|
-
subject { Shoes::Swt::Star::Painter.new shape }
|
33
|
-
|
34
|
-
it_behaves_like "fill painter"
|
35
|
-
it_behaves_like "stroke painter"
|
36
|
-
|
37
|
-
it "fills star" do
|
38
|
-
expect(gc).to receive(:fillPolygon)
|
39
|
-
subject.paint_control(event)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "draws star" do
|
43
|
-
expect(gc).to receive(:drawPolygon)
|
44
|
-
subject.paint_control(event)
|
45
|
-
end
|
46
|
-
end
|
47
22
|
end
|
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shoes::Swt::TextBlock::CenteredTextSegment do
|
4
4
|
let(:width) { 200 }
|
5
|
-
let(:dsl) { double("dsl", text: "boo", font: "", size: 16, style:{}) }
|
5
|
+
let(:dsl) { double("dsl", text: "boo", font: "", size: 16, style: {}) }
|
6
6
|
|
7
|
-
subject { Shoes::Swt::TextBlock::CenteredTextSegment.new(dsl, width)}
|
7
|
+
subject { Shoes::Swt::TextBlock::CenteredTextSegment.new(dsl, width) }
|
8
8
|
|
9
9
|
it "takes all the width it can get" do
|
10
10
|
expect(subject.width).to eq(width)
|
@@ -4,13 +4,13 @@ describe Shoes::Swt::TextBlock::CursorPainter do
|
|
4
4
|
include_context "swt app"
|
5
5
|
|
6
6
|
let(:dsl) { double("dsl", app: shoes_app, textcursor: textcursor, textcursor?: true) }
|
7
|
-
let(:textcursor) { double("textcursor", left:0, top: 0, height: 10) }
|
8
|
-
let(:segment_collection) { double('segment collection',
|
9
|
-
cursor_height: 12,
|
10
|
-
relative_text_position: 0)}
|
7
|
+
let(:textcursor) { double("textcursor", left: 0, top: 0, height: 10) }
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
let(:segment_collection) do
|
10
|
+
double('segment collection', cursor_height: 12, relative_text_position: 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { Shoes::Swt::TextBlock::CursorPainter.new(dsl, segment_collection) }
|
14
14
|
|
15
15
|
describe "missing cursor" do
|
16
16
|
before(:each) do
|
@@ -21,7 +21,7 @@ describe Shoes::Swt::TextBlock::CursorPainter do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "shouldn't do anything without text cursor" do
|
24
|
-
allow(dsl).to receive(:textcursor?) { nil}
|
24
|
+
allow(dsl).to receive(:textcursor?) { nil }
|
25
25
|
subject.draw
|
26
26
|
expect(dsl).to_not have_received(:textcursor=)
|
27
27
|
end
|
@@ -37,9 +37,11 @@ describe Shoes::Swt::TextBlock::CursorPainter do
|
|
37
37
|
let(:left) { 10 }
|
38
38
|
let(:top) { 20 }
|
39
39
|
let(:position) { double(x: 5, y: 5) }
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
|
41
|
+
let(:first_segment) do
|
42
|
+
double("first segment", text: "first", get_location: position, height: 10,
|
43
|
+
element_left: left, element_top: top)
|
44
|
+
end
|
43
45
|
|
44
46
|
before(:each) do
|
45
47
|
allow(textcursor).to receive(:move)
|
@@ -47,9 +49,11 @@ describe Shoes::Swt::TextBlock::CursorPainter do
|
|
47
49
|
end
|
48
50
|
|
49
51
|
context "with two segments" do
|
50
|
-
let(:second_segment)
|
51
|
-
|
52
|
-
|
52
|
+
let(:second_segment) do
|
53
|
+
double("second segment", text: "second", get_location: position,
|
54
|
+
element_left: left, element_top: top + 100)
|
55
|
+
end
|
56
|
+
|
53
57
|
before(:each) do
|
54
58
|
allow(dsl).to receive(:text).and_return(first_segment.text + second_segment.text)
|
55
59
|
end
|
@@ -1,18 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::TextBlock::Fitter do
|
4
|
-
let(:dsl)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
let(:dsl) do
|
5
|
+
double('dsl', parent: parent_dsl, text: "Text goes here",
|
6
|
+
desired_width: 85, centered?: false,
|
7
|
+
absolute_left: 25, absolute_top: 75,
|
8
|
+
element_left: 26, element_top: 76,
|
9
|
+
margin_left: 1, margin_top: 1)
|
10
|
+
end
|
9
11
|
|
10
|
-
let(:parent_dsl)
|
11
|
-
|
12
|
-
|
12
|
+
let(:parent_dsl) do
|
13
|
+
double('parent_dsl', parent: grandparent_dsl,
|
14
|
+
absolute_top: 0, absolute_left: 0, absolute_right: 100,
|
15
|
+
width: parent_width, height: 200)
|
16
|
+
end
|
13
17
|
|
14
|
-
let(:grandparent_dsl)
|
15
|
-
|
18
|
+
let(:grandparent_dsl) do
|
19
|
+
double('grandparent_dsl', parent: app, width: grandparent_width)
|
20
|
+
end
|
16
21
|
|
17
22
|
let(:app) { double('app', width: app_width) }
|
18
23
|
|
@@ -60,14 +65,14 @@ describe Shoes::Swt::TextBlock::Fitter do
|
|
60
65
|
end
|
61
66
|
|
62
67
|
it "bumps out until it fits" do
|
63
|
-
when_positioned_at(x:1010, y: 5, next_line_start: 5)
|
68
|
+
when_positioned_at(x: 1010, y: 5, next_line_start: 5)
|
64
69
|
allow(dsl).to receive(:desired_width).with(app_width) { 990 }
|
65
70
|
|
66
71
|
expect(subject.available_space).to eq([990, :unbounded])
|
67
72
|
end
|
68
73
|
|
69
74
|
it "just gives up if it still won't fit" do
|
70
|
-
when_positioned_at(x:1010, y: 5, next_line_start: 5)
|
75
|
+
when_positioned_at(x: 1010, y: 5, next_line_start: 5)
|
71
76
|
expect(subject.available_space).to eq([0, 0])
|
72
77
|
end
|
73
78
|
end
|
@@ -76,14 +81,14 @@ describe Shoes::Swt::TextBlock::Fitter do
|
|
76
81
|
describe "finding what didn't fit" do
|
77
82
|
it "splits when one line past requested height" do
|
78
83
|
segment = double('segment', line_offsets: [0, 5, 10], text: "Text Split")
|
79
|
-
allow(segment).to receive(:get_line_bounds) { double('line_bounds', height: 25)}
|
84
|
+
allow(segment).to receive(:get_line_bounds) { double('line_bounds', height: 25) }
|
80
85
|
|
81
86
|
expect(subject.split_text(segment, 24)).to eq(["Text ", "Split"])
|
82
87
|
end
|
83
88
|
|
84
89
|
it "should be able to split text when too small" do
|
85
90
|
segment = double('segment', line_offsets: [0, 10], text: "Text Split")
|
86
|
-
allow(segment).to receive(:get_line_bounds).with(0) { double('line_bounds', height: 21)}
|
91
|
+
allow(segment).to receive(:get_line_bounds).with(0) { double('line_bounds', height: 21) }
|
87
92
|
allow(segment).to receive(:get_line_bounds).with(1) { raise "Boom" }
|
88
93
|
|
89
94
|
expect(subject.split_text(segment, 33)).to eq(["Text Split", ""])
|
@@ -91,10 +96,12 @@ describe Shoes::Swt::TextBlock::Fitter do
|
|
91
96
|
end
|
92
97
|
|
93
98
|
describe "fit it in" do
|
94
|
-
let(:bounds) { double('bounds', width: 100, height: 50)}
|
95
|
-
|
96
|
-
|
97
|
-
|
99
|
+
let(:bounds) { double('bounds', width: 100, height: 50) }
|
100
|
+
|
101
|
+
let(:segment) do
|
102
|
+
double('segment', text: "something something", :text= => nil,
|
103
|
+
line_count: 1, line_offsets: [], bounds: bounds)
|
104
|
+
end
|
98
105
|
|
99
106
|
before(:each) do
|
100
107
|
layout = double('swt_layout', :spacing => 4, :spacing= => nil)
|
@@ -8,10 +8,13 @@ describe Shoes::Swt::TextBlock::Painter do
|
|
8
8
|
let(:gui) { double("gui", dispose: nil, segments: segment_collection) }
|
9
9
|
let(:segment_collection) { double("segment collection", empty?: false) }
|
10
10
|
|
11
|
-
let(:event)
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
let(:event) { double("event", gc: graphics_context).as_null_object }
|
12
|
+
|
13
|
+
let(:graphics_context) do
|
14
|
+
double("graphics context", set_antialias: nil, set_line_cap: nil,
|
15
|
+
set_transform: nil, clipping: nil,
|
16
|
+
set_clipping: nil)
|
17
|
+
end
|
15
18
|
|
16
19
|
subject { Shoes::Swt::TextBlock::Painter.new(dsl) }
|
17
20
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::TextFontFactory do
|
4
|
-
let(:font_details)
|
4
|
+
let(:font_details) do
|
5
5
|
{
|
6
6
|
name: "Helvetica",
|
7
7
|
size: 16,
|
8
8
|
styles: [::Swt::SWT::BOLD]
|
9
9
|
}
|
10
|
-
|
10
|
+
end
|
11
11
|
|
12
|
-
subject { Shoes::Swt::TextFontFactory.new
|
12
|
+
subject { Shoes::Swt::TextFontFactory.new }
|
13
13
|
|
14
14
|
it "creates a font" do
|
15
15
|
font = subject.create_font(font_details)
|
@@ -5,11 +5,14 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
5
5
|
|
6
6
|
let(:first_segment) { create_segment("first", "first") }
|
7
7
|
let(:second_segment) { create_segment("second", "rest") }
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
let(:dsl) do
|
10
|
+
double("dsl", font: "", size: 16, style: {},
|
11
|
+
text_styles: {(0..-1) => ["whatever"]})
|
12
|
+
end
|
10
13
|
|
11
14
|
let(:gc) { double("gc") }
|
12
|
-
let(:default_text_styles)
|
15
|
+
let(:default_text_styles) do
|
13
16
|
{
|
14
17
|
fg: :fg,
|
15
18
|
bg: :bg,
|
@@ -21,12 +24,14 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
21
24
|
styles: [::Swt::SWT::NORMAL]
|
22
25
|
}
|
23
26
|
}
|
24
|
-
|
27
|
+
end
|
25
28
|
|
26
29
|
describe "with one segment" do
|
27
|
-
subject
|
28
|
-
|
29
|
-
|
30
|
+
subject do
|
31
|
+
Shoes::Swt::TextBlock::TextSegmentCollection.new(dsl,
|
32
|
+
[first_segment],
|
33
|
+
default_text_styles)
|
34
|
+
end
|
30
35
|
|
31
36
|
before do
|
32
37
|
allow(dsl).to receive(:text) { first_segment.text }
|
@@ -42,7 +47,7 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
42
47
|
end
|
43
48
|
|
44
49
|
it "applies segment styling" do
|
45
|
-
styles = [[0..1, [double("segment", style:{stroke: :blue})]]]
|
50
|
+
styles = [[0..1, [double("segment", style: {stroke: :blue})]]]
|
46
51
|
subject.style_segment_ranges(styles)
|
47
52
|
|
48
53
|
expected_style = style_with(stroke: :blue, fg: :blue)
|
@@ -129,9 +134,11 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
129
134
|
end
|
130
135
|
|
131
136
|
describe "with two segments" do
|
132
|
-
subject
|
133
|
-
|
134
|
-
|
137
|
+
subject do
|
138
|
+
Shoes::Swt::TextBlock::TextSegmentCollection.new(dsl,
|
139
|
+
[first_segment, second_segment],
|
140
|
+
default_text_styles)
|
141
|
+
end
|
135
142
|
|
136
143
|
before do
|
137
144
|
allow(dsl).to receive(:text) { first_segment.text + second_segment.text }
|
@@ -154,11 +161,11 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
154
161
|
it "spans both segments" do
|
155
162
|
result = subject.segment_ranges(2..7)
|
156
163
|
expect(result).to eql([[first_segment, 2..5],
|
157
|
-
[second_segment,
|
164
|
+
[second_segment, 0..2]])
|
158
165
|
end
|
159
166
|
|
160
167
|
it "applies segment styling in first segment" do
|
161
|
-
styles = [[0..2, [double("segment", style:{stroke: :blue})]]]
|
168
|
+
styles = [[0..2, [double("segment", style: {stroke: :blue})]]]
|
162
169
|
subject.style_segment_ranges(styles)
|
163
170
|
|
164
171
|
expected_style = style_with(stroke: :blue, fg: :blue)
|
@@ -167,7 +174,7 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
167
174
|
end
|
168
175
|
|
169
176
|
it "applies segment styling in second segment" do
|
170
|
-
styles = [[5..7, [double("segment", style:{stroke: :blue})]]]
|
177
|
+
styles = [[5..7, [double("segment", style: {stroke: :blue})]]]
|
171
178
|
subject.style_segment_ranges(styles)
|
172
179
|
|
173
180
|
expected_style = style_with(stroke: :blue, fg: :blue)
|
@@ -176,7 +183,7 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
176
183
|
end
|
177
184
|
|
178
185
|
it "applies segment styling in both segments" do
|
179
|
-
styles = [[2..7, [double("segment", style:{stroke: :blue})]]]
|
186
|
+
styles = [[2..7, [double("segment", style: {stroke: :blue})]]]
|
180
187
|
subject.style_segment_ranges(styles)
|
181
188
|
|
182
189
|
expected_style = style_with(stroke: :blue, fg: :blue)
|
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::TextBlock::TextSegment do
|
4
|
-
let(:layout)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
let(:layout) do
|
5
|
+
double("layout", text: "the text",
|
6
|
+
:alignment= => nil, :justify= => nil, :spacing= => nil,
|
7
|
+
:text= => nil, :width= => nil,
|
8
|
+
disposed?: false, dispose: nil,
|
9
|
+
set_style: nil, bounds: bounds)
|
10
|
+
end
|
11
|
+
|
9
12
|
let(:bounds) { Java::OrgEclipseSwtGraphics::Rectangle.new(0, 0, 0, 0) }
|
10
13
|
let(:element_left) { 0 }
|
11
14
|
let(:element_top) { 0 }
|
@@ -19,7 +22,7 @@ describe Shoes::Swt::TextBlock::TextSegment do
|
|
19
22
|
let(:font) { double("font") }
|
20
23
|
let(:style) { double("style") }
|
21
24
|
|
22
|
-
let(:style_hash)
|
25
|
+
let(:style_hash) do
|
23
26
|
{
|
24
27
|
bg: double("bg"),
|
25
28
|
fg: double("fg"),
|
@@ -29,9 +32,9 @@ describe Shoes::Swt::TextBlock::TextSegment do
|
|
29
32
|
styles: nil
|
30
33
|
}
|
31
34
|
}
|
32
|
-
|
35
|
+
end
|
33
36
|
|
34
|
-
let(:dsl) { double("dsl", font: "", size: 16, style:{}) }
|
37
|
+
let(:dsl) { double("dsl", font: "", size: 16, style: {}) }
|
35
38
|
|
36
39
|
before(:each) do
|
37
40
|
allow(::Swt::TextLayout).to receive(:new) { layout }
|
@@ -61,9 +64,9 @@ describe Shoes::Swt::TextBlock::TextSegment do
|
|
61
64
|
context "setting style" do
|
62
65
|
it "on full range" do
|
63
66
|
subject.set_style(style_hash)
|
64
|
-
expect(layout).to have_received(:set_style)
|
65
|
-
|
66
|
-
|
67
|
+
expect(layout).to have_received(:set_style)
|
68
|
+
.with(style, 0, layout.text.length - 1)
|
69
|
+
.at_least(1).times
|
67
70
|
end
|
68
71
|
|
69
72
|
it "with a range" do
|
@@ -94,7 +97,7 @@ describe Shoes::Swt::TextBlock::TextSegment do
|
|
94
97
|
end
|
95
98
|
|
96
99
|
it "checks boundaries" do
|
97
|
-
expect(subject.in_bounds?(1,1)).to be_truthy
|
100
|
+
expect(subject.in_bounds?(1, 1)).to be_truthy
|
98
101
|
end
|
99
102
|
|
100
103
|
describe "offsets left" do
|
@@ -6,10 +6,12 @@ describe Shoes::Swt::TextBlock do
|
|
6
6
|
let(:height) { 100 }
|
7
7
|
let(:width) { 200 }
|
8
8
|
let(:margin) { 10 }
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
|
10
|
+
let(:dsl) do
|
11
|
+
double("dsl", app: shoes_app, text: "text", margin_left: 0, margin_right: 0,
|
12
|
+
margin_top: 0, margin_bottom: 0, pass_coordinates?: nil)
|
13
|
+
.as_null_object
|
14
|
+
end
|
13
15
|
|
14
16
|
subject { Shoes::Swt::TextBlock.new(dsl, swt_app) }
|
15
17
|
|
@@ -17,18 +19,18 @@ describe Shoes::Swt::TextBlock do
|
|
17
19
|
it_behaves_like "updating visibility"
|
18
20
|
it_behaves_like "clickable backend"
|
19
21
|
|
20
|
-
# reported nil, caused trouble in
|
22
|
+
# reported nil, caused trouble in simple_downloader.rb
|
21
23
|
it 'initially responds with empty segments' do
|
22
24
|
expect(subject.segments).to be_empty
|
23
25
|
end
|
24
26
|
|
25
27
|
describe "bounds checking" do
|
26
28
|
it "delegates to segment" do
|
27
|
-
segment = double
|
29
|
+
segment = double
|
28
30
|
subject.segments = [segment]
|
29
31
|
expect(segment).to receive(:in_bounds?)
|
30
32
|
|
31
|
-
subject.in_bounds?(1,1)
|
33
|
+
subject.in_bounds?(1, 1)
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -44,7 +46,7 @@ describe Shoes::Swt::TextBlock do
|
|
44
46
|
let(:segment) { create_segment }
|
45
47
|
let(:second_segment) { create_segment }
|
46
48
|
|
47
|
-
let(:current_position) { Shoes::Slot::
|
49
|
+
let(:current_position) { Shoes::Slot::Position.new(0, 0) }
|
48
50
|
|
49
51
|
before(:each) do
|
50
52
|
allow(::Shoes::Swt::TextBlock::Fitter).to receive(:new) { fitter }
|
@@ -178,7 +180,7 @@ describe Shoes::Swt::TextBlock do
|
|
178
180
|
end
|
179
181
|
|
180
182
|
context "links" do
|
181
|
-
let(:link)
|
183
|
+
let(:link) { Shoes::Link.new(shoes_app, ["link"]) }
|
182
184
|
|
183
185
|
before(:each) do
|
184
186
|
allow(dsl).to receive(:links) { [link] }
|
@@ -196,7 +198,7 @@ describe Shoes::Swt::TextBlock do
|
|
196
198
|
end
|
197
199
|
|
198
200
|
def create_segment(name = "segment", width = layout_width,
|
199
|
-
|
201
|
+
height = layout_height, last_line_height = line_height)
|
200
202
|
bounds = double("bounds", width: width, height: height)
|
201
203
|
double(name, disposed?: false, style_from: nil,
|
202
204
|
width: width, height: height,
|