shoes-swt 4.0.0.pre4 → 4.0.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +4 -0
- data/lib/shoes/swt/app.rb +11 -2
- data/lib/shoes/swt/button.rb +2 -4
- data/lib/shoes/swt/check_button.rb +2 -4
- data/lib/shoes/swt/color_factory.rb +1 -2
- data/lib/shoes/swt/common/painter.rb +8 -6
- data/lib/shoes/swt/common/resource.rb +14 -0
- data/lib/shoes/swt/download.rb +1 -1
- data/lib/shoes/swt/generate-backend.rb +1 -1
- data/lib/shoes/swt/gradient.rb +3 -2
- data/lib/shoes/swt/image.rb +3 -4
- data/lib/shoes/swt/input_box.rb +10 -11
- data/lib/shoes/swt/key_listener.rb +11 -5
- data/lib/shoes/swt/link.rb +2 -0
- data/lib/shoes/swt/list_box.rb +4 -9
- data/lib/shoes/swt/packager.rb +1 -0
- data/lib/shoes/swt/progress.rb +4 -5
- data/lib/shoes/swt/radio.rb +3 -3
- data/lib/shoes/swt/redrawing_aspect.rb +4 -13
- data/lib/shoes/swt/slot.rb +4 -1
- data/lib/shoes/swt/sound.rb +1 -1
- data/lib/shoes/swt/swt_button.rb +4 -4
- data/lib/shoes/swt/text_block/painter.rb +4 -1
- data/lib/shoes/swt/text_block/text_segment_collection.rb +14 -3
- data/lib/shoes/swt/text_block/text_style_factory.rb +1 -0
- data/lib/shoes/swt/text_block.rb +5 -1
- data/lib/shoes/swt/version.rb +1 -1
- data/lib/shoes/swt.rb +3 -3
- data/shoes-swt.gemspec +1 -1
- data/spec/shoes/swt/animation_spec.rb +6 -7
- data/spec/shoes/swt/app_spec.rb +56 -14
- data/spec/shoes/swt/arc_spec.rb +5 -5
- data/spec/shoes/swt/background_spec.rb +5 -5
- data/spec/shoes/swt/border_spec.rb +3 -3
- data/spec/shoes/swt/button_spec.rb +3 -7
- data/spec/shoes/swt/check_spec.rb +1 -1
- data/spec/shoes/swt/click_listener_spec.rb +2 -2
- data/spec/shoes/swt/color_factory_spec.rb +1 -1
- data/spec/shoes/swt/color_spec.rb +1 -1
- data/spec/shoes/swt/common/painter_spec.rb +13 -3
- data/spec/shoes/swt/common/remove_spec.rb +1 -1
- data/spec/shoes/swt/configuration_spec.rb +1 -2
- data/spec/shoes/swt/dialog_spec.rb +1 -4
- data/spec/shoes/swt/flow_spec.rb +4 -4
- data/spec/shoes/swt/font_spec.rb +1 -3
- data/spec/shoes/swt/gradient_spec.rb +1 -1
- data/spec/shoes/swt/image_pattern_spec.rb +1 -1
- data/spec/shoes/swt/image_spec.rb +3 -4
- data/spec/shoes/swt/input_box_spec.rb +6 -8
- data/spec/shoes/swt/integration_spec.rb +1 -1
- data/spec/shoes/swt/key_listener_spec.rb +44 -17
- data/spec/shoes/swt/line_spec.rb +2 -2
- data/spec/shoes/swt/link_segment_spec.rb +2 -3
- data/spec/shoes/swt/link_spec.rb +1 -1
- data/spec/shoes/swt/list_box_spec.rb +8 -9
- data/spec/shoes/swt/mouse_move_listener_spec.rb +6 -6
- data/spec/shoes/swt/oval_spec.rb +1 -1
- data/spec/shoes/swt/progress_spec.rb +3 -3
- data/spec/shoes/swt/radio_group_spec.rb +1 -2
- data/spec/shoes/swt/radio_spec.rb +4 -4
- data/spec/shoes/swt/rect_painter_spec.rb +6 -6
- data/spec/shoes/swt/rect_spec.rb +1 -1
- data/spec/shoes/swt/shape_spec.rb +2 -3
- data/spec/shoes/swt/shared_examples/button.rb +0 -2
- data/spec/shoes/swt/shared_examples/movable.rb +0 -1
- data/spec/shoes/swt/shared_examples/painter.rb +2 -3
- data/spec/shoes/swt/shared_examples/swt_app_context.rb +11 -9
- data/spec/shoes/swt/shell_control_listener_spec.rb +2 -2
- data/spec/shoes/swt/shoes_layout_spec.rb +6 -7
- data/spec/shoes/swt/slot_spec.rb +10 -4
- data/spec/shoes/swt/spec_helper.rb +11 -0
- data/spec/shoes/swt/star_spec.rb +4 -4
- data/spec/shoes/swt/text_block/centered_text_segment_spec.rb +1 -1
- data/spec/shoes/swt/text_block/cursor_painter_spec.rb +7 -7
- data/spec/shoes/swt/text_block/fitter_spec.rb +8 -9
- data/spec/shoes/swt/text_block/painter_spec.rb +15 -4
- data/spec/shoes/swt/text_block/text_font_factory_spec.rb +4 -4
- data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +17 -18
- data/spec/shoes/swt/text_block/text_segment_spec.rb +5 -5
- data/spec/shoes/swt/text_block_spec.rb +13 -11
- data/spec/spec_helper.rb +2 -1
- metadata +14 -14
- data/lib/shoes/swt/common/child.rb +0 -16
data/spec/shoes/swt/app_spec.rb
CHANGED
@@ -1,22 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::App do
|
4
|
-
let(:opts) { {:
|
4
|
+
let(:opts) { {background: Shoes::COLORS[:salmon], resizable: true} }
|
5
5
|
let(:app) { double('app') }
|
6
|
-
let(:dsl) { double('dsl', :
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
|
12
|
-
let(:opts_unresizable) { {:
|
13
|
-
:
|
14
|
-
let(:app_unresizable) { double('app', :
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
6
|
+
let(:dsl) { double('dsl', app: app,
|
7
|
+
opts: opts,
|
8
|
+
width: width,
|
9
|
+
height: 0,
|
10
|
+
app_title: 'double') }
|
11
|
+
|
12
|
+
let(:opts_unresizable) { { background: Shoes::COLORS[:salmon],
|
13
|
+
resizable: false } }
|
14
|
+
let(:app_unresizable) { double('app', opts: opts_unresizable,
|
15
|
+
width: 0,
|
16
|
+
height: 0,
|
17
|
+
app_title: 'double') }
|
18
|
+
let(:opts_always_on_top) { {background: Shoes::COLORS[:salmon],
|
19
|
+
always_on_top: true} }
|
20
|
+
let(:app_always_on_top) { double('app', opts: opts_always_on_top,
|
21
|
+
width: 0,
|
22
|
+
height: 0,
|
23
|
+
app_title: 'double') }
|
24
|
+
let(:plain_app) { double('app', opts: {},
|
25
|
+
width: 2,
|
26
|
+
height: 2,
|
27
|
+
app_title: 'double') }
|
18
28
|
let(:width) {0}
|
19
29
|
|
30
|
+
let(:swt_salmon) { Shoes::Swt::Color.new(Shoes::COLORS[:salmon]).real }
|
31
|
+
|
20
32
|
subject { Shoes::Swt::App.new(dsl) }
|
21
33
|
|
22
34
|
it { is_expected.to respond_to :clipboard }
|
@@ -76,6 +88,11 @@ describe Shoes::Swt::App do
|
|
76
88
|
not_resizable = Shoes::Swt::App.new app_unresizable
|
77
89
|
expect(not_resizable.send(:main_window_style)).to eq(BASE_BITMASK)
|
78
90
|
end
|
91
|
+
|
92
|
+
it "should return a bitmask that represents always being on top" do
|
93
|
+
always_on_top = Shoes::Swt::App.new app_always_on_top
|
94
|
+
expect(always_on_top.send(:main_window_style)).to eq(BASE_BITMASK | Swt::SWT::ON_TOP)
|
95
|
+
end
|
79
96
|
end
|
80
97
|
|
81
98
|
context "when attempting to copy text" do
|
@@ -123,4 +140,29 @@ describe Shoes::Swt::App do
|
|
123
140
|
end
|
124
141
|
end
|
125
142
|
|
143
|
+
describe 'App Background color' do
|
144
|
+
it 'has the given background when specified' do
|
145
|
+
not_resizable = Shoes::Swt::App.new app_unresizable
|
146
|
+
background = not_resizable.shell.background
|
147
|
+
expect(background).to eq swt_salmon
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
it 'has the default system background when unspecified' do
|
152
|
+
default_background = ::Swt.display.getSystemColor(::Swt::SWT::COLOR_WIDGET_BACKGROUND)
|
153
|
+
app = Shoes::Swt::App.new(Shoes::InternalApp.new(Shoes::App.new, {}))
|
154
|
+
background = app.shell.background
|
155
|
+
expect(background).to eq default_background
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'setup_system_colors' do
|
159
|
+
default_background = ::Swt.display.getSystemColor(::Swt::SWT::COLOR_WIDGET_BACKGROUND)
|
160
|
+
expect(::Shoes::DSL).to receive(:define_shoes_color)
|
161
|
+
.with(:system_background,
|
162
|
+
default_background.red,
|
163
|
+
default_background.green,
|
164
|
+
default_background.blue)
|
165
|
+
subject.class.setup_system_colors
|
166
|
+
end
|
167
|
+
end
|
126
168
|
end
|
data/spec/shoes/swt/arc_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Arc do
|
4
4
|
include_context "swt app"
|
@@ -10,10 +10,10 @@ describe Shoes::Swt::Arc do
|
|
10
10
|
let(:angle1) { Shoes::PI }
|
11
11
|
let(:angle2) { Shoes::HALF_PI }
|
12
12
|
let(:dsl) { double("dsl object", app: shoes_app, element_width: width,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
element_height: height, element_left: left,
|
14
|
+
element_top: top, angle1: angle1, angle2: angle2,
|
15
|
+
wedge?: false, pass_coordinates?: nil,
|
16
|
+
hidden: false).as_null_object }
|
17
17
|
let(:fill_color) { Shoes::Color.new(40, 50, 60, 70) }
|
18
18
|
let(:stroke_color) { Shoes::Color.new(80, 90, 100, 110) }
|
19
19
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Background do
|
4
4
|
include_context "swt app"
|
@@ -10,10 +10,10 @@ describe Shoes::Swt::Background do
|
|
10
10
|
let(:corners) { 0 }
|
11
11
|
let(:fill) { Shoes::COLORS[:salmon] }
|
12
12
|
let(:dsl) { double("dsl object", app: shoes_app,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
element_left: left, element_top: top,
|
14
|
+
element_width: width, element_height: height,
|
15
|
+
strokewidth: 1, curve: corners, fill: fill,
|
16
|
+
hidden: false).as_null_object}
|
17
17
|
|
18
18
|
subject {
|
19
19
|
Shoes::Swt::Background.new dsl, swt_app
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Border do
|
4
4
|
include_context "swt app"
|
@@ -9,8 +9,8 @@ describe Shoes::Swt::Border do
|
|
9
9
|
let(:height) { 111 }
|
10
10
|
let(:corners) { 0 }
|
11
11
|
let(:dsl) { double("dsl object", element_width: width, element_height: height,
|
12
|
-
|
13
|
-
|
12
|
+
element_left: left, element_top: top, parent: parent,
|
13
|
+
strokewidth: 1, curve: corners,hidden: false).as_null_object }
|
14
14
|
|
15
15
|
subject { Shoes::Swt::Border.new dsl, swt_app }
|
16
16
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Button do
|
4
4
|
include_context "swt app"
|
@@ -8,11 +8,9 @@ describe Shoes::Swt::Button do
|
|
8
8
|
let(:block) { proc {} }
|
9
9
|
let(:real) { double('real', disposed?: false).as_null_object }
|
10
10
|
|
11
|
-
subject { Shoes::Swt::Button.new dsl,
|
11
|
+
subject { Shoes::Swt::Button.new dsl, swt_app }
|
12
12
|
|
13
13
|
before :each do
|
14
|
-
allow(parent).to receive(:real)
|
15
|
-
allow(parent).to receive(:dsl){double(contents: [])}
|
16
14
|
allow(dsl).to receive(:width=)
|
17
15
|
allow(dsl).to receive(:height=)
|
18
16
|
allow(::Swt::Widgets::Button).to receive(:new) { real }
|
@@ -36,8 +34,6 @@ describe Shoes::Swt::Button do
|
|
36
34
|
let(:real) {double('button real', size: size, pack: true).as_null_object}
|
37
35
|
|
38
36
|
before :each do
|
39
|
-
allow(parent).to receive(:real)
|
40
|
-
allow(parent).to receive(:dsl){double(contents: [])}
|
41
37
|
allow(::Swt::Widgets::Button).to receive(:new) { real }
|
42
38
|
end
|
43
39
|
|
@@ -50,7 +46,7 @@ describe Shoes::Swt::Button do
|
|
50
46
|
dsl = dsl_for_dimensions input_width, input_height
|
51
47
|
expect(dsl).to receive(:element_width=).with(expected_width) unless input_width
|
52
48
|
expect(dsl).to receive(:element_height=).with(expected_height) unless input_height
|
53
|
-
Shoes::Swt::Button.new dsl,
|
49
|
+
Shoes::Swt::Button.new dsl, swt_app
|
54
50
|
end
|
55
51
|
|
56
52
|
it 'uses only real when width and height are not specified' do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::ClickListener do
|
4
4
|
include_context 'swt app'
|
@@ -100,7 +100,7 @@ describe Shoes::Swt::ClickListener do
|
|
100
100
|
|
101
101
|
it "takes the last element to respond" do
|
102
102
|
other_dsl = double("other dsl", in_bounds?: true,
|
103
|
-
|
103
|
+
hidden?: false, pass_coordinates?: false)
|
104
104
|
other_block = double("other block", call: nil)
|
105
105
|
|
106
106
|
subject.send(add_method, other_dsl, other_block)
|
@@ -1,12 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Common::Painter do
|
4
4
|
let(:object) {double 'object', dsl: dsl, transform: transform,
|
5
|
-
|
6
|
-
let(:
|
5
|
+
apply_fill: nil, apply_stroke: nil}
|
6
|
+
let(:parent) {double 'parent', absolute_left: 0, absolute_top: 0,
|
7
|
+
width: 200, height: 100, fixed_height?: true}
|
8
|
+
let(:dsl) {double 'dsl', parent: parent,
|
9
|
+
visible?: true, positioned?: true, style: {}}
|
7
10
|
let(:event) {double 'paint event', gc: graphics_context}
|
8
11
|
let(:graphics_context) { double 'graphics_context',
|
9
12
|
dispose: nil,
|
13
|
+
clipping: nil, set_clipping: nil,
|
10
14
|
set_antialias: nil, set_line_cap: nil,
|
11
15
|
set_transform: nil, setTransform: nil }
|
12
16
|
let(:transform) { double 'transform', disposed?: false }
|
@@ -34,6 +38,12 @@ describe Shoes::Swt::Common::Painter do
|
|
34
38
|
subject.paint_control event
|
35
39
|
end
|
36
40
|
|
41
|
+
it 'clips to parent region' do
|
42
|
+
allow(dsl).to receive(:needs_rotate?) { false }
|
43
|
+
expect(graphics_context).to receive(:set_clipping).with(0, 0, 200, 100)
|
44
|
+
subject.paint_control event
|
45
|
+
end
|
46
|
+
|
37
47
|
it 'rotates' do
|
38
48
|
allow(dsl).to receive(:needs_rotate?) { true }
|
39
49
|
allow(dsl).to receive(:rotate) { 10 }
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
main_object = self
|
4
4
|
|
5
5
|
describe Shoes::Swt::Dialog do
|
6
|
-
|
7
6
|
def double_message_box
|
8
7
|
create_double_message_box double(:mb, open: true, :message= => true)
|
9
8
|
end
|
@@ -77,7 +76,6 @@ describe Shoes::Swt::Dialog do
|
|
77
76
|
|
78
77
|
describe 'on the main object' do
|
79
78
|
describe '#alert' do
|
80
|
-
|
81
79
|
it 'returns nil' do
|
82
80
|
double_message_box
|
83
81
|
expect(main_object.alert('Something')).to be_nil
|
@@ -96,5 +94,4 @@ describe Shoes::Swt::Dialog do
|
|
96
94
|
end
|
97
95
|
end
|
98
96
|
end
|
99
|
-
|
100
97
|
end
|
data/spec/shoes/swt/flow_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Flow do
|
4
4
|
include_context "swt app"
|
5
5
|
|
6
6
|
let(:dsl) { double('dsl', app: shoes_app,
|
7
|
-
|
7
|
+
pass_coordinates?: true).as_null_object }
|
8
8
|
let(:real) { double('real', disposed?: false) }
|
9
|
-
let(:parent_real) { double('parent_real', :
|
9
|
+
let(:parent_real) { double('parent_real', get_layout: "ok") }
|
10
10
|
|
11
11
|
subject { Shoes::Swt::Flow.new(dsl, parent) }
|
12
12
|
|
@@ -24,7 +24,7 @@ describe Shoes::Swt::Flow do
|
|
24
24
|
describe "#initialize" do
|
25
25
|
before do
|
26
26
|
allow(parent).to receive(:real) { parent_real }
|
27
|
-
allow(parent_real).to receive(:get_layout){double(top_slot: true)}
|
27
|
+
allow(parent_real).to receive(:get_layout) {double(top_slot: true)}
|
28
28
|
end
|
29
29
|
|
30
30
|
it "sets readers" do
|
data/spec/shoes/swt/font_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Image do
|
4
4
|
include_context "swt app"
|
@@ -18,7 +18,7 @@ describe Shoes::Swt::Image do
|
|
18
18
|
|
19
19
|
subject {
|
20
20
|
allow(dsl).to receive(:file_path) { image }
|
21
|
-
Shoes::Swt::Image.new(dsl,
|
21
|
+
Shoes::Swt::Image.new(dsl, swt_app)
|
22
22
|
}
|
23
23
|
|
24
24
|
it_behaves_like "paintable"
|
@@ -42,7 +42,7 @@ describe Shoes::Swt::Image do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "painting raw images" do
|
45
|
-
let(:image) { File.read(image_path, :
|
45
|
+
let(:image) { File.read(image_path, mode: "rb") }
|
46
46
|
|
47
47
|
specify "loads image from raw data" do
|
48
48
|
subject.real.image_data.width = 3
|
@@ -52,7 +52,6 @@ describe Shoes::Swt::Image do
|
|
52
52
|
|
53
53
|
# note the image used is 3x1 pixel big
|
54
54
|
describe 'dimensions' do
|
55
|
-
|
56
55
|
it 'has the given width' do
|
57
56
|
expect(subject.width).to eq(IMAGE_WIDTH)
|
58
57
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::InputBox do
|
4
4
|
include_context "swt app"
|
@@ -8,12 +8,12 @@ describe Shoes::Swt::InputBox do
|
|
8
8
|
secret?: secret,
|
9
9
|
call_change_listeners: true).as_null_object }
|
10
10
|
let(:real) { double('real', disposed?: false, text: text,
|
11
|
-
|
11
|
+
add_modify_listener: true).as_null_object }
|
12
12
|
let(:styles) {::Swt::SWT::SINGLE | ::Swt::SWT::BORDER}
|
13
13
|
let(:secret) {false}
|
14
14
|
let(:text) {'Some text...'}
|
15
15
|
|
16
|
-
subject { Shoes::Swt::InputBox.new dsl,
|
16
|
+
subject { Shoes::Swt::InputBox.new dsl, swt_app, styles }
|
17
17
|
|
18
18
|
before :each do
|
19
19
|
allow(::Swt::Widgets::Text).to receive(:new) { real }
|
@@ -33,7 +33,6 @@ describe Shoes::Swt::InputBox do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'change listeners' do
|
36
|
-
|
37
36
|
it "should set up a listener that delegates change events" do
|
38
37
|
expect(dsl).to receive(:call_change_listeners)
|
39
38
|
expect(real).to receive(:add_modify_listener) do |&blk|
|
@@ -74,7 +73,6 @@ describe Shoes::Swt::InputBox do
|
|
74
73
|
expect(dsl).to_not have_received :call_change_listeners
|
75
74
|
end
|
76
75
|
end
|
77
|
-
|
78
76
|
end
|
79
77
|
end
|
80
78
|
end
|
@@ -92,13 +90,13 @@ describe Shoes::Swt::InputBox do
|
|
92
90
|
end
|
93
91
|
|
94
92
|
describe Shoes::Swt::EditLine do
|
95
|
-
subject {Shoes::Swt::EditLine.new dsl,
|
93
|
+
subject {Shoes::Swt::EditLine.new dsl, swt_app}
|
96
94
|
describe ":secret option" do
|
97
95
|
context "when NOT set" do
|
98
96
|
it "does NOT set PASSWORD style" do
|
99
97
|
options = Shoes::Swt::EditLine::DEFAULT_STYLES
|
100
98
|
allow(dsl).to receive(:secret?) { false }
|
101
|
-
expect(::Swt::Widgets::Text).to receive(:new).with(
|
99
|
+
expect(::Swt::Widgets::Text).to receive(:new).with(swt_app.real, options)
|
102
100
|
subject
|
103
101
|
end
|
104
102
|
end
|
@@ -107,7 +105,7 @@ describe Shoes::Swt::InputBox do
|
|
107
105
|
it "sets PASSWORD style" do
|
108
106
|
options = Shoes::Swt::EditLine::DEFAULT_STYLES | ::Swt::SWT::PASSWORD
|
109
107
|
allow(dsl).to receive(:secret?) { true }
|
110
|
-
expect(::Swt::Widgets::Text).to receive(:new).with(
|
108
|
+
expect(::Swt::Widgets::Text).to receive(:new).with(swt_app.real, options)
|
111
109
|
subject
|
112
110
|
end
|
113
111
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require '
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Shoes::Swt::Keypress do
|
5
5
|
let(:app) { double('app', add_key_listener: nil, remove_key_listener: nil) }
|
6
6
|
let(:dsl) { double('dsl') }
|
7
|
-
let(:block) { proc{ |key| key} }
|
7
|
+
let(:block) { proc { |key| key} }
|
8
8
|
let(:key_listener) {Shoes::Swt::Keypress.new(dsl, app, &block)}
|
9
9
|
|
10
10
|
describe '.get_swt_constant' do
|
@@ -14,7 +14,6 @@ describe Shoes::Swt::Keypress do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "subclasses" do
|
17
|
-
|
18
17
|
describe "Subclass Keypress" do
|
19
18
|
it "adds key listener on creation" do
|
20
19
|
expect(app).to receive(:add_key_listener)
|
@@ -38,14 +37,15 @@ describe Shoes::Swt::Keypress do
|
|
38
37
|
CTRL = ::Swt::SWT::CTRL
|
39
38
|
ALT = ::Swt::SWT::ALT
|
40
39
|
SHIFT = ::Swt::SWT::SHIFT
|
40
|
+
COMMAND = ::Swt::SWT::COMMAND
|
41
41
|
|
42
42
|
subject {key_listener}
|
43
43
|
|
44
44
|
def test_character_press(character, state_modifier = 0, result_char = character)
|
45
45
|
expect(block).to receive(:call).with(result_char)
|
46
46
|
event = double character: character.ord,
|
47
|
-
|
48
|
-
|
47
|
+
stateMask: 0 | state_modifier,
|
48
|
+
keyCode: character.downcase.ord
|
49
49
|
subject.handle_key_event(event)
|
50
50
|
end
|
51
51
|
|
@@ -55,6 +55,11 @@ describe Shoes::Swt::Keypress do
|
|
55
55
|
test_character_press(character, state_modifier, result)
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_command_character_press(character, state_mask_modifier = 0)
|
59
|
+
state_modifier = COMMAND | state_mask_modifier
|
60
|
+
result = ('super_' + character).to_sym
|
61
|
+
test_character_press(character, state_modifier, result)
|
62
|
+
end
|
58
63
|
|
59
64
|
describe 'works with simple keys such as' do
|
60
65
|
it '"a"' do
|
@@ -154,6 +159,20 @@ describe Shoes::Swt::Keypress do
|
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
162
|
+
describe 'works with command key pressed such as' do
|
163
|
+
it ':super_a' do
|
164
|
+
test_command_character_press 'a'
|
165
|
+
end
|
166
|
+
|
167
|
+
it ':super_z' do
|
168
|
+
test_command_character_press 'z'
|
169
|
+
end
|
170
|
+
|
171
|
+
it ':super_/' do
|
172
|
+
test_command_character_press '/'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
157
176
|
describe 'only modifier keys yield nothing' do
|
158
177
|
def test_receive_nothing_with_modifier(modifier, last_key_press = modifier)
|
159
178
|
expect(block).not_to receive :call
|
@@ -173,10 +192,18 @@ describe Shoes::Swt::Keypress do
|
|
173
192
|
test_receive_nothing_with_modifier CTRL
|
174
193
|
end
|
175
194
|
|
195
|
+
it 'command' do
|
196
|
+
test_receive_nothing_with_modifier COMMAND
|
197
|
+
end
|
198
|
+
|
176
199
|
it 'shift + ctrl' do
|
177
200
|
test_receive_nothing_with_modifier SHIFT | CTRL, SHIFT
|
178
201
|
end
|
179
202
|
|
203
|
+
it 'shift + command' do
|
204
|
+
test_receive_nothing_with_modifier SHIFT | COMMAND, SHIFT
|
205
|
+
end
|
206
|
+
|
180
207
|
it 'ctrl + alt' do
|
181
208
|
test_receive_nothing_with_modifier CTRL | ALT, CTRL
|
182
209
|
end
|
@@ -184,17 +211,20 @@ describe Shoes::Swt::Keypress do
|
|
184
211
|
it 'shift + ctrl + alt' do
|
185
212
|
test_receive_nothing_with_modifier CTRL | SHIFT | ALT, ALT
|
186
213
|
end
|
214
|
+
|
215
|
+
it 'shift + ctrl + command + alt' do
|
216
|
+
test_receive_nothing_with_modifier CTRL | SHIFT | ALT | COMMAND, ALT
|
217
|
+
end
|
187
218
|
end
|
188
219
|
|
189
220
|
describe 'special keys' do
|
190
|
-
|
191
221
|
ARROW_LEFT = ::Swt::SWT::ARROW_LEFT
|
192
222
|
|
193
223
|
def special_key_test(code, expected, modifier = 0)
|
194
224
|
expect(block).to receive(:call).with(expected)
|
195
225
|
event = double stateMask: modifier,
|
196
|
-
|
197
|
-
|
226
|
+
keyCode: code,
|
227
|
+
character: 0
|
198
228
|
subject.handle_key_event(event)
|
199
229
|
end
|
200
230
|
|
@@ -253,19 +283,17 @@ describe Shoes::Swt::Keypress do
|
|
253
283
|
end
|
254
284
|
|
255
285
|
describe '#ignore_event?' do
|
256
|
-
|
257
286
|
let(:character) {'a'}
|
258
287
|
let(:event) {double 'key event',
|
259
288
|
widget: widget,
|
260
289
|
stateMask: 0,
|
261
290
|
keyCode: keyCode,
|
262
291
|
character: character.ord }
|
263
|
-
let(:shell){Java::OrgEclipseSwtWidgets::Shell.new}
|
292
|
+
let(:shell) {Java::OrgEclipseSwtWidgets::Shell.new}
|
264
293
|
let(:style) {0}
|
265
294
|
let(:keyCode) {character.downcase.ord}
|
266
295
|
|
267
|
-
|
268
|
-
subject{key_listener.ignore_event? event}
|
296
|
+
subject {key_listener.ignore_event? event}
|
269
297
|
|
270
298
|
shared_examples_for 'ignores space and enter' do
|
271
299
|
describe 'with a space' do
|
@@ -282,12 +310,12 @@ describe Shoes::Swt::Keypress do
|
|
282
310
|
shared_examples_for 'accepts normal characters' do
|
283
311
|
describe 'with a normal character' do
|
284
312
|
let(:character) {'a'}
|
285
|
-
it{is_expected.to be_falsey}
|
313
|
+
it {is_expected.to be_falsey}
|
286
314
|
end
|
287
315
|
end
|
288
316
|
|
289
317
|
context 'on a Shell' do
|
290
|
-
let(:widget){shell}
|
318
|
+
let(:widget) {shell}
|
291
319
|
it {is_expected.to be_falsey}
|
292
320
|
|
293
321
|
describe 'even with enter' do
|
@@ -297,7 +325,7 @@ describe Shoes::Swt::Keypress do
|
|
297
325
|
end
|
298
326
|
|
299
327
|
context 'on a Text' do
|
300
|
-
let(:widget){Java::OrgEclipseSwtWidgets::Text.new(shell, style)}
|
328
|
+
let(:widget) {Java::OrgEclipseSwtWidgets::Text.new(shell, style)}
|
301
329
|
it {is_expected.to be_truthy}
|
302
330
|
end
|
303
331
|
|
@@ -315,11 +343,10 @@ describe Shoes::Swt::Keypress do
|
|
315
343
|
|
316
344
|
describe 'with up' do
|
317
345
|
let(:keyCode) {::Swt::SWT::ARROW_UP}
|
318
|
-
it{is_expected.to be_truthy}
|
346
|
+
it {is_expected.to be_truthy}
|
319
347
|
end
|
320
348
|
|
321
349
|
it_behaves_like 'accepts normal characters'
|
322
350
|
end
|
323
351
|
end
|
324
|
-
|
325
352
|
end
|
data/spec/shoes/swt/line_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Line do
|
4
4
|
include_context "swt app"
|
5
5
|
|
6
|
-
let(:container) { double('container',
|
6
|
+
let(:container) { double('container', disposed?: false).as_null_object }
|
7
7
|
let(:dsl) { Shoes::Line.new shoes_app, parent, point_a, point_b }
|
8
8
|
let(:point_a) { Shoes::Point.new(10, 100) }
|
9
9
|
let(:point_b) { Shoes::Point.new(300, 10) }
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::LinkSegment do
|
4
4
|
let(:range) { (2..10) }
|
@@ -6,7 +6,7 @@ describe Shoes::Swt::LinkSegment do
|
|
6
6
|
let(:line_height) { 14 }
|
7
7
|
let(:layout) { double('swt layout', width: line_width, line_count: 10) }
|
8
8
|
let(:text_segment) { double('text segment', layout: layout,
|
9
|
-
|
9
|
+
element_left: 0, element_top: 0) }
|
10
10
|
|
11
11
|
subject { Shoes::Swt::LinkSegment.new(text_segment, range) }
|
12
12
|
|
@@ -14,7 +14,6 @@ describe Shoes::Swt::LinkSegment do
|
|
14
14
|
10.times {|i| stub_line_bounds(i)}
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
# ....................
|
19
18
|
context "empty link" do
|
20
19
|
let(:range) { (0...0) }
|