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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +1 -1
  3. data/lib/shoes/swt.rb +8 -0
  4. data/lib/shoes/swt/app.rb +5 -7
  5. data/lib/shoes/swt/arc.rb +3 -28
  6. data/lib/shoes/swt/arc_painter.rb +34 -0
  7. data/lib/shoes/swt/arrow.rb +35 -0
  8. data/lib/shoes/swt/arrow_painter.rb +59 -0
  9. data/lib/shoes/swt/background.rb +1 -0
  10. data/lib/shoes/swt/border.rb +1 -0
  11. data/lib/shoes/swt/check_button.rb +17 -17
  12. data/lib/shoes/swt/click_listener.rb +6 -6
  13. data/lib/shoes/swt/common/painter.rb +4 -2
  14. data/lib/shoes/swt/common/translate.rb +15 -0
  15. data/lib/shoes/swt/{generate-backend.rb → generate_backend.rb} +1 -3
  16. data/lib/shoes/swt/gradient.rb +3 -4
  17. data/lib/shoes/swt/key_listener.rb +9 -7
  18. data/lib/shoes/swt/line.rb +5 -13
  19. data/lib/shoes/swt/line_painter.rb +16 -0
  20. data/lib/shoes/swt/link.rb +4 -0
  21. data/lib/shoes/swt/link_segment.rb +1 -1
  22. data/lib/shoes/swt/oval.rb +2 -21
  23. data/lib/shoes/swt/oval_painter.rb +27 -0
  24. data/lib/shoes/swt/packager.rb +1 -1
  25. data/lib/shoes/swt/radio_group.rb +1 -1
  26. data/lib/shoes/swt/rect.rb +1 -0
  27. data/lib/shoes/swt/rect_painter.rb +27 -9
  28. data/lib/shoes/swt/redrawing_aspect.rb +30 -17
  29. data/lib/shoes/swt/shape.rb +13 -18
  30. data/lib/shoes/swt/shape_painter.rb +13 -0
  31. data/lib/shoes/swt/shoes_layout.rb +1 -1
  32. data/lib/shoes/swt/slot.rb +12 -1
  33. data/lib/shoes/swt/sound.rb +21 -23
  34. data/lib/shoes/swt/star.rb +2 -46
  35. data/lib/shoes/swt/star_painter.rb +51 -0
  36. data/lib/shoes/swt/text_block.rb +4 -3
  37. data/lib/shoes/swt/text_block/fitter.rb +3 -4
  38. data/lib/shoes/swt/text_block/text_font_factory.rb +1 -1
  39. data/lib/shoes/swt/text_block/text_segment.rb +8 -3
  40. data/lib/shoes/swt/text_block/text_segment_collection.rb +1 -1
  41. data/lib/shoes/swt/text_block/text_style_factory.rb +1 -3
  42. data/lib/shoes/swt/timer.rb +1 -3
  43. data/lib/shoes/swt/version.rb +3 -1
  44. data/shoes-swt.gemspec +1 -1
  45. data/spec/shoes/cli_spec.rb +2 -2
  46. data/spec/shoes/swt/animation_spec.rb +4 -3
  47. data/spec/shoes/swt/app_spec.rb +17 -17
  48. data/spec/shoes/swt/arc_painter_spec.rb +80 -0
  49. data/spec/shoes/swt/arc_spec.rb +7 -68
  50. data/spec/shoes/swt/arrow_painter_spec.rb +37 -0
  51. data/spec/shoes/swt/arrow_spec.rb +27 -0
  52. data/spec/shoes/swt/background_spec.rb +13 -11
  53. data/spec/shoes/swt/border_spec.rb +8 -5
  54. data/spec/shoes/swt/button_spec.rb +4 -4
  55. data/spec/shoes/swt/check_spec.rb +19 -8
  56. data/spec/shoes/swt/click_listener_spec.rb +1 -1
  57. data/spec/shoes/swt/common/painter_spec.rb +29 -14
  58. data/spec/shoes/swt/common/remove_spec.rb +2 -2
  59. data/spec/shoes/swt/dialog_spec.rb +1 -1
  60. data/spec/shoes/swt/flow_spec.rb +5 -3
  61. data/spec/shoes/swt/font_spec.rb +1 -1
  62. data/spec/shoes/swt/gradient_spec.rb +6 -3
  63. data/spec/shoes/swt/image_spec.rb +9 -9
  64. data/spec/shoes/swt/input_box_spec.rb +20 -15
  65. data/spec/shoes/swt/integration_spec.rb +1 -1
  66. data/spec/shoes/swt/key_listener_spec.rb +34 -33
  67. data/spec/shoes/swt/line_painter_spec.rb +26 -0
  68. data/spec/shoes/swt/line_spec.rb +2 -25
  69. data/spec/shoes/swt/link_segment_spec.rb +20 -18
  70. data/spec/shoes/swt/link_spec.rb +11 -8
  71. data/spec/shoes/swt/list_box_spec.rb +15 -11
  72. data/spec/shoes/swt/mouse_move_listener_spec.rb +55 -39
  73. data/spec/shoes/swt/oval_painter_spec.rb +40 -0
  74. data/spec/shoes/swt/oval_spec.rb +3 -34
  75. data/spec/shoes/swt/progress_spec.rb +2 -2
  76. data/spec/shoes/swt/radio_group_spec.rb +1 -1
  77. data/spec/shoes/swt/radio_spec.rb +7 -4
  78. data/spec/shoes/swt/rect_painter_spec.rb +13 -8
  79. data/spec/shoes/swt/rect_spec.rb +2 -4
  80. data/spec/shoes/swt/shape_painter_spec.rb +27 -0
  81. data/spec/shoes/swt/shape_spec.rb +7 -24
  82. data/spec/shoes/swt/shared_examples/clickable.rb +2 -2
  83. data/spec/shoes/swt/shared_examples/swt_app_context.rb +21 -12
  84. data/spec/shoes/swt/shell_control_listener_spec.rb +9 -9
  85. data/spec/shoes/swt/shoes_layout_spec.rb +18 -13
  86. data/spec/shoes/swt/slot_spec.rb +15 -4
  87. data/spec/shoes/swt/spec_helper.rb +1 -1
  88. data/spec/shoes/swt/star_painter_spec.rb +36 -0
  89. data/spec/shoes/swt/star_spec.rb +0 -25
  90. data/spec/shoes/swt/text_block/centered_text_segment_spec.rb +2 -2
  91. data/spec/shoes/swt/text_block/cursor_painter_spec.rb +17 -13
  92. data/spec/shoes/swt/text_block/fitter_spec.rb +25 -18
  93. data/spec/shoes/swt/text_block/painter_spec.rb +7 -4
  94. data/spec/shoes/swt/text_block/text_font_factory_spec.rb +3 -3
  95. data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +22 -15
  96. data/spec/shoes/swt/text_block/text_segment_spec.rb +15 -12
  97. data/spec/shoes/swt/text_block_spec.rb +12 -10
  98. data/spec/spec_helper.rb +3 -1
  99. metadata +30 -8
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shoes::Swt::OvalPainter do
4
+ include_context "swt app"
5
+ include_context "painter context"
6
+
7
+ subject { Shoes::Swt::OvalPainter.new(shape) }
8
+
9
+ let(:left) { 100 }
10
+ let(:top) { 200 }
11
+ let(:width) { 300 }
12
+ let(:height) { 400 }
13
+ let(:dsl) { ::Shoes::Oval.new shoes_app, parent, left, top, width, height }
14
+ let(:shape) { Shoes::Swt::Oval.new(dsl, swt_app) }
15
+
16
+ before :each do
17
+ shape.absolute_left = left
18
+ shape.absolute_top = top
19
+ end
20
+
21
+ it_behaves_like "fill painter"
22
+ it_behaves_like "stroke painter"
23
+
24
+ it "creates oval clipping area" do
25
+ double_path = double("path")
26
+ allow(::Swt::Path).to receive(:new) { double_path }
27
+ expect(double_path).to receive(:add_arc).with(left, top, width, height, 0, 360)
28
+ subject.clipping
29
+ end
30
+
31
+ it "fills" do
32
+ expect(gc).to receive(:fill_oval)
33
+ subject.paint_control(event)
34
+ end
35
+
36
+ specify "draws oval" do
37
+ expect(gc).to receive(:draw_oval).with(left + sw / 2, top + sw / 2, width - sw, height - sw)
38
+ subject.paint_control(event)
39
+ end
40
+ end
@@ -7,44 +7,13 @@ describe Shoes::Swt::Oval do
7
7
  let(:top) { 200 }
8
8
  let(:width) { 300 }
9
9
  let(:height) { 400 }
10
- let(:dsl) {::Shoes::Oval.new shoes_app, parent, left, top, width, height}
10
+ let(:dsl) { ::Shoes::Oval.new shoes_app, parent, left, top, width, height }
11
11
 
12
- subject {
12
+ subject do
13
13
  Shoes::Swt::Oval.new(dsl, swt_app)
14
- }
14
+ end
15
15
 
16
16
  it_behaves_like "paintable"
17
17
  it_behaves_like "updating visibility"
18
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
19
  end
@@ -6,7 +6,7 @@ describe Shoes::Swt::Progress do
6
6
  let(:text) { "TEXT" }
7
7
  let(:dsl) { double('dsl', app: shoes_app).as_null_object }
8
8
  let(:real) { double('real', disposed?: real_disposed).as_null_object }
9
- let(:real_disposed) {false}
9
+ let(:real_disposed) { false }
10
10
 
11
11
  subject { Shoes::Swt::Progress.new dsl, swt_app }
12
12
 
@@ -33,7 +33,7 @@ describe Shoes::Swt::Progress do
33
33
  end
34
34
 
35
35
  context "with disposed real element" do
36
- let(:real_disposed) {true}
36
+ let(:real_disposed) { true }
37
37
 
38
38
  it "shouldn't set selection" do
39
39
  expect(real).not_to receive(:selection=)
@@ -21,7 +21,7 @@ describe Shoes::Swt::RadioGroup do
21
21
 
22
22
  describe 'after adding a button' do
23
23
  before :each do
24
- subject.add radio
24
+ subject.add radio
25
25
  end
26
26
 
27
27
  it "only one button is added" do
@@ -4,10 +4,13 @@ describe Shoes::Swt::Radio do
4
4
  include_context "swt app"
5
5
 
6
6
  let(:text) { "TEXT" }
7
- let(:dsl) { double('dsl', :app => shoes_app,
8
- :width= => true, :width => 100,
9
- :height= => true, :height => 200,
10
- :group => nil, :blk => block).as_null_object }
7
+
8
+ let(:dsl) do
9
+ double('dsl', :app => shoes_app, :width= => true, :width => 100,
10
+ :height= => true, :height => 200, :group => nil,
11
+ :blk => block).as_null_object
12
+ end
13
+
11
14
  let(:block) { proc {} }
12
15
  let(:real) { double('real').as_null_object }
13
16
 
@@ -6,15 +6,20 @@ describe Shoes::Swt::RectPainter do
6
6
  let(:corners) { 0 }
7
7
  let(:app) { double('app', real: container, add_paint_listener: true, dsl: dsl) }
8
8
  let(:container) { double('container', disposed?: false) }
9
- let(:dsl) { double("dsl object", hidden: false, rotate: 0,
10
- element_left: left, element_top: top,
11
- element_width: width, element_height: height,
12
- curve: corners).as_null_object }
9
+
10
+ let(:dsl) do
11
+ double("dsl object", hidden: false, rotate: 0,
12
+ translate_left: 0, translate_top: 0,
13
+ element_left: left, element_top: top,
14
+ element_width: width, element_height: height,
15
+ curve: corners, style: {}, strokewidth: 1).as_null_object
16
+ end
17
+
13
18
  let(:left) { 55 }
14
19
  let(:top) { 77 }
15
20
  let(:width) { 222 }
16
21
  let(:height) { 111 }
17
- let(:shape) { Shoes::Swt::Rect.new dsl, app}
22
+ let(:shape) { Shoes::Swt::Rect.new dsl, app }
18
23
  subject { Shoes::Swt::RectPainter.new shape }
19
24
 
20
25
  it_behaves_like "fill painter"
@@ -24,12 +29,12 @@ describe Shoes::Swt::RectPainter do
24
29
  let(:corners) { 0 }
25
30
 
26
31
  it "fills rect" do
27
- expect(gc).to receive(:fill_round_rectangle).with(left, top, width, height, corners*2, corners*2)
32
+ expect(gc).to receive(:fill_round_rectangle).with(left, top, width, height, corners * 2, corners * 2)
28
33
  subject.paint_control(event)
29
34
  end
30
35
 
31
36
  it "draws rect" do
32
- expect(gc).to receive(:draw_round_rectangle).with(left+sw/2, top+sw/2, width-sw, height-sw, corners*2, corners*2)
37
+ expect(gc).to receive(:draw_round_rectangle).with(left + sw / 2, top + sw / 2, width - sw, height - sw, corners * 2, corners * 2)
33
38
  subject.paint_control(event)
34
39
  end
35
40
  end
@@ -38,7 +43,7 @@ describe Shoes::Swt::RectPainter do
38
43
  let(:corners) { 13 }
39
44
 
40
45
  it "draws rect with rounded corners" do
41
- expect(gc).to receive(:draw_round_rectangle).with(left+sw/2, top+sw/2, width-sw, height-sw, corners*2, corners*2)
46
+ expect(gc).to receive(:draw_round_rectangle).with(left + sw / 2, top + sw / 2, width - sw, height - sw, corners * 2, corners * 2)
42
47
  subject.paint_control(event)
43
48
  end
44
49
  end
@@ -7,11 +7,9 @@ describe Shoes::Swt::Rect do
7
7
  let(:top) { 77 }
8
8
  let(:width) { 222 }
9
9
  let(:height) { 111 }
10
- let(:dsl) {::Shoes::Rect.new shoes_app, parent, left, top, width, height}
10
+ let(:dsl) { ::Shoes::Rect.new shoes_app, parent, left, top, width, height }
11
11
 
12
- subject {
13
- Shoes::Swt::Rect.new dsl, swt_app
14
- }
12
+ subject { Shoes::Swt::Rect.new dsl, swt_app }
15
13
 
16
14
  it_behaves_like "paintable"
17
15
  it_behaves_like "updating visibility"
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shoes::Swt::ShapePainter do
4
+ include_context "swt app"
5
+ include_context "painter context"
6
+
7
+ let(:dsl) do
8
+ double("Shoes::Shape", hidden: false, needs_rotate?: false, style: {}).as_null_object
9
+ end
10
+
11
+ let(:shape) { Shoes::Swt::Shape.new(dsl, swt_app) }
12
+ subject { Shoes::Swt::ShapePainter.new(shape) }
13
+
14
+ it_behaves_like "stroke painter"
15
+ it_behaves_like "fill painter"
16
+ it_behaves_like "movable painter"
17
+
18
+ it "fills path" do
19
+ expect(gc).to receive(:fill_path)
20
+ subject.paint_control(event)
21
+ end
22
+
23
+ it "draws path" do
24
+ expect(gc).to receive(:draw_path)
25
+ subject.paint_control(event)
26
+ end
27
+ end
@@ -3,8 +3,12 @@ require 'spec_helper'
3
3
  describe Shoes::Swt::Shape do
4
4
  include_context "swt app"
5
5
 
6
- let(:dsl) { instance_double("Shoes::Shape", hidden: false,
7
- needs_rotate?: false,style: {}).as_null_object }
6
+ let(:dsl) do
7
+ double("Shoes::Shape", hidden: false, needs_rotate?: false,
8
+ translate_left: 0, translate_top: 0,
9
+ style: {}).as_null_object
10
+ end
11
+
8
12
  subject { Shoes::Swt::Shape.new dsl, swt_app }
9
13
 
10
14
  shared_examples_for "Swt::Shape" do
@@ -48,7 +52,7 @@ describe Shoes::Swt::Shape do
48
52
 
49
53
  it "delegates #arc_to" do
50
54
  expect(element).to receive(:add_arc).with(25, 45, 50, 20, 0.0, -90.0)
51
- subject.arc_to 50, 55, 50, 20, 0, Shoes::PI/2
55
+ subject.arc_to 50, 55, 50, 20, 0, Shoes::PI / 2
52
56
  end
53
57
  end
54
58
 
@@ -66,25 +70,4 @@ describe Shoes::Swt::Shape do
66
70
  subject.update_position
67
71
  end
68
72
  end
69
-
70
- describe "painter" do
71
- include_context "painter context"
72
-
73
- let(:shape) { Shoes::Swt::Shape.new(dsl, swt_app) }
74
- subject { Shoes::Swt::Shape::Painter.new(shape) }
75
-
76
- it_behaves_like "stroke painter"
77
- it_behaves_like "fill painter"
78
- it_behaves_like "movable painter"
79
-
80
- it "fills path" do
81
- expect(gc).to receive(:fill_path)
82
- subject.paint_control(event)
83
- end
84
-
85
- it "draws path" do
86
- expect(gc).to receive(:draw_path)
87
- subject.paint_control(event)
88
- end
89
- end
90
73
  end
@@ -1,12 +1,12 @@
1
1
  shared_examples 'clickable backend' do
2
2
  describe 'interaction with the swt app object' do
3
3
  it 'adds a listener for the MouseDown event when click is called' do
4
- subject.click Proc.new {}
4
+ subject.click proc {}
5
5
  expect(click_listener).to have_received(:add_click_listener).at_least(1)
6
6
  end
7
7
 
8
8
  it 'adds a listener for the MouseUp event when release is called' do
9
- subject.release Proc.new {}
9
+ subject.release proc {}
10
10
  expect(click_listener).to have_received(:add_release_listener).at_least(1)
11
11
  end
12
12
  end
@@ -3,14 +3,17 @@
3
3
  # - swt_app: use for instantiating a Shoes::Swt object
4
4
  # - shoes_app: use for instantiating a Shoes DSL object
5
5
  shared_context "swt app" do
6
- let(:swt_app_real) { double('swt app real', disposed?: false,
7
- set_visible: true) }
6
+ let(:swt_app_real) do
7
+ double('swt app real', disposed?: false, set_visible: true)
8
+ end
8
9
 
9
10
  let(:clickable_element) { double("clickable_element", delete: nil) }
10
- let(:click_listener) { double("click listener",
11
- add_click_listener: nil,
12
- add_release_listener: nil,
13
- remove_listeners_for: nil) }
11
+
12
+ let(:click_listener) do
13
+ double("click listener", add_click_listener: nil, add_release_listener: nil,
14
+ remove_listeners_for: nil)
15
+ end
16
+
14
17
  let(:swt_app) do
15
18
  swt_double = double('swt app', real: swt_app_real, disposed?: false,
16
19
  add_paint_listener: true, remove_paint_listener: true,
@@ -23,10 +26,16 @@ shared_context "swt app" do
23
26
  end
24
27
 
25
28
  let(:shoes_app) { double('shoes app', gui: swt_app, rotate: 0, style: {}, element_styles: {}) }
26
- let(:parent) { double('parent', app: swt_app, add_child: true, real: true,
27
- absolute_left: 0, absolute_top: 0,
28
- width: 200, height: 100, fixed_height?: true) }
29
- let(:parent_dsl) {double("parent dsl", add_child: true, contents: [],
30
- gui: parent, x_dimension: double.as_null_object,
31
- y_dimension: double.as_null_object)}
29
+
30
+ let(:parent) do
31
+ double('parent', app: swt_app, add_child: true, real: true,
32
+ absolute_left: 0, absolute_top: 0,
33
+ width: 200, height: 100, fixed_height?: true)
34
+ end
35
+
36
+ let(:parent_dsl) do
37
+ double("parent dsl", add_child: true, contents: [], gui: parent,
38
+ x_dimension: double.as_null_object,
39
+ y_dimension: double.as_null_object)
40
+ end
32
41
  end
@@ -1,21 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Shoes::Swt::ShellControlListener do
4
- let(:app) {double 'SWT App', dsl: dsl_app, shell: shell, real: real}
5
- let(:shell) {double('Shell').as_null_object}
6
- let(:resize_callbacks) {[]}
7
- let(:dsl_app) {double('DSL App', resize_callbacks: resize_callbacks).as_null_object}
8
- let(:block) {double 'Block', call: nil}
9
- let(:resize_event) {double 'resize_event', widget: shell}
10
- let(:real) {double('Swt Real').as_null_object}
4
+ let(:app) { double 'SWT App', dsl: dsl_app, shell: shell, real: real }
5
+ let(:shell) { double('Shell').as_null_object }
6
+ let(:resize_callbacks) { [] }
7
+ let(:dsl_app) { double('DSL App', resize_callbacks: resize_callbacks).as_null_object }
8
+ let(:block) { double 'Block', call: nil }
9
+ let(:resize_event) { double 'resize_event', widget: shell }
10
+ let(:real) { double('Swt Real').as_null_object }
11
11
 
12
- subject {Shoes::Swt::ShellControlListener.new(app)}
12
+ subject { Shoes::Swt::ShellControlListener.new(app) }
13
13
  before :each do
14
14
  subject.controlResized(resize_event)
15
15
  end
16
16
 
17
17
  describe 'resize' do
18
- let(:resize_callbacks) {[block]}
18
+ let(:resize_callbacks) { [block] }
19
19
  it 'calls the resize block' do
20
20
  expect(block).to have_received(:call)
21
21
  end
@@ -7,22 +7,27 @@ describe Shoes::Swt::ShoesLayout do
7
7
  result
8
8
  end
9
9
 
10
- let(:gui_app) { double('gui_app', dsl: dsl, real: real, shell: shell) }
11
- let(:real) { double('real', set_size: nil,
12
- location: location, :location= => nil) }
13
- let(:size) { double('size', height: 0, width: 0) }
14
- let(:location) { double('location', :y= => nil) }
15
- let(:dsl) { double('dsl', top_slot: top_slot,
16
- height: 100, width: 100) }
17
- let(:top_slot) { double('top_slot', contents_alignment: 0,
18
- :width= => nil, :height= => nil) }
19
- let(:shell) { double('shell', vertical_bar: vertical_bar) }
20
- let(:vertical_bar) { double('vertical_bar', :increment= => nil,
21
- :visible= => nil, :maximum= => nil,
22
- :thumb= => nil, thumb: 0) }
10
+ let(:gui_app) { double('gui_app', dsl: dsl, real: real, shell: shell) }
11
+ let(:size) { double('size', height: 0, width: 0) }
12
+ let(:location) { double('location', :y= => nil) }
13
+ let(:dsl) { double('dsl', top_slot: top_slot, height: 100, width: 100) }
14
+ let(:shell) { double('shell', vertical_bar: vertical_bar) }
23
15
 
24
16
  let(:scroll_height) { dsl.height * 2 }
25
17
 
18
+ let(:real) do
19
+ double('real', set_size: nil, location: location, :location= => nil)
20
+ end
21
+
22
+ let(:top_slot) do
23
+ double('top_slot', contents_alignment: 0, :width= => nil, :height= => nil)
24
+ end
25
+
26
+ let(:vertical_bar) do
27
+ double('vertical_bar', :increment= => nil, :visible= => nil,
28
+ :maximum= => nil, :thumb= => nil, thumb: 0)
29
+ end
30
+
26
31
  before do
27
32
  allow(real).to receive(:compute_trim) do |_, _, width, height|
28
33
  double('size', width: width, height: height)
@@ -2,11 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe Shoes::Swt::Slot do
4
4
  include_context "swt app"
5
- let(:dsl) {instance_double Shoes::Slot, hidden?: true,
6
- visible?: false, contents: [content] }
7
- let(:content) {double 'content', show: true, hide: true}
8
5
 
9
- subject {Shoes::Swt::Slot.new dsl, swt_app}
6
+ let(:dsl) do
7
+ instance_double Shoes::Slot, hidden?: true, visible?: false,
8
+ contents: [content]
9
+ end
10
+
11
+ let(:content) { double 'content', show: true, hide: true }
12
+
13
+ subject { Shoes::Swt::Slot.new dsl, swt_app }
10
14
 
11
15
  describe '#update_visibility' do
12
16
  it 'does not set visibility on the parent #904' do
@@ -27,4 +31,11 @@ describe Shoes::Swt::Slot do
27
31
  expect(content).to have_received(:hide).once
28
32
  end
29
33
  end
34
+
35
+ describe '#remove' do
36
+ it 'cleans up click listeners' do
37
+ expect(swt_app.click_listener).to receive(:remove_listeners_for).with(dsl)
38
+ subject.remove
39
+ end
40
+ end
30
41
  end
@@ -29,7 +29,7 @@ end
29
29
  # as we do not create real apps most of the time there are no redraws and we
30
30
  # we don't really want that during test execution either way as it adds stuff to
31
31
  # methods that might break
32
- def with_redraws(&blk)
32
+ def with_redraws
33
33
  allow(Shoes::Swt::RedrawingAspect).to receive(:new).and_call_original
34
34
  aspect = Shoes::Swt::RedrawingAspect.new swt_app, double
35
35
  begin