shoes-swt 4.0.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,44 @@
|
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoes::Swt::Progress do
|
|
4
|
+
include_context "swt app"
|
|
5
|
+
|
|
6
|
+
let(:text) { "TEXT" }
|
|
7
|
+
let(:dsl) { double('dsl', app: shoes_app).as_null_object }
|
|
8
|
+
let(:real) { double('real', disposed?: false, :disposed? => false).as_null_object }
|
|
9
|
+
|
|
10
|
+
subject { Shoes::Swt::Progress.new dsl, parent }
|
|
11
|
+
|
|
12
|
+
before :each do
|
|
13
|
+
allow(parent).to receive(:real)
|
|
14
|
+
allow(::Swt::Widgets::ProgressBar).to receive(:new) { real }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it_behaves_like "movable element"
|
|
18
|
+
it_behaves_like "updating visibility"
|
|
19
|
+
|
|
20
|
+
it "should have a method called fraction=" do
|
|
21
|
+
expect(subject).to respond_to :fraction=
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should multiply the value by 100 when calling real.selection" do
|
|
25
|
+
expect(real).to receive(:selection=).and_return(55)
|
|
26
|
+
subject.fraction = 0.55
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should round up correctly" do
|
|
30
|
+
expect(real).to receive(:selection=).and_return(100)
|
|
31
|
+
subject.fraction = 0.999
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with disposed real element" do
|
|
35
|
+
before :each do
|
|
36
|
+
allow(real).to receive(:disposed?) { true }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "shouldn't set selection" do
|
|
40
|
+
expect(real).not_to receive(:selection=)
|
|
41
|
+
subject.fraction = 0.55
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoes::Swt::RadioGroup do
|
|
4
|
+
let(:name) { "Group Name" }
|
|
5
|
+
let(:real) { double('real', add_selection_listener: true, remove_selection_listener: true).as_null_object }
|
|
6
|
+
let(:radio) { double('radio', real: real) }
|
|
7
|
+
|
|
8
|
+
subject { Shoes::Swt::RadioGroup.new name }
|
|
9
|
+
|
|
10
|
+
describe "#initialize" do
|
|
11
|
+
it "sets name" do
|
|
12
|
+
expect(subject.name).to eq("Group Name")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#add" do
|
|
17
|
+
it "monitors selection" do
|
|
18
|
+
expect(real).to receive(:add_selection_listener)
|
|
19
|
+
subject.add(radio)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'after adding a button' do
|
|
23
|
+
before :each do
|
|
24
|
+
subject.add radio
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "only one button is added" do
|
|
28
|
+
expect(subject.length).to eq(1)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "the correct button is added" do
|
|
32
|
+
expect(subject.include?(radio)).to eq(true)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "#remove" do
|
|
38
|
+
before :each do
|
|
39
|
+
subject.add(radio)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "stops monitoring selection" do
|
|
43
|
+
expect(real).to receive(:remove_selection_listener)
|
|
44
|
+
subject.remove(radio)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "removes one button" do
|
|
48
|
+
subject.remove(radio)
|
|
49
|
+
expect(subject.length).to eq(0)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "#select_only_one_radio_in_group" do
|
|
54
|
+
let(:real_selected) { double('real').as_null_object }
|
|
55
|
+
let(:radio_selected) { double('radio', real: real_selected) }
|
|
56
|
+
before :each do
|
|
57
|
+
subject.add(radio)
|
|
58
|
+
subject.add(radio_selected)
|
|
59
|
+
end
|
|
60
|
+
after :each do
|
|
61
|
+
subject.select_only_one_radio_in_group(radio_selected)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "turns on the selected radio" do
|
|
65
|
+
expect(real_selected).to receive(:set_selection).with(true)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "turns off the non-selected radios" do
|
|
69
|
+
expect(real).to receive(:set_selection).with(false)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoes::Swt::Radio do
|
|
4
|
+
include_context "swt app"
|
|
5
|
+
|
|
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 }
|
|
11
|
+
let(:block) { proc {} }
|
|
12
|
+
let(:real) { double('real').as_null_object }
|
|
13
|
+
|
|
14
|
+
subject { Shoes::Swt::Radio.new dsl, parent }
|
|
15
|
+
|
|
16
|
+
before :each do
|
|
17
|
+
allow(::Swt::Widgets::Button).to receive(:new) { real }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_behaves_like "buttons"
|
|
21
|
+
it_behaves_like "movable element"
|
|
22
|
+
it_behaves_like "selectable"
|
|
23
|
+
it_behaves_like "updating visibility"
|
|
24
|
+
|
|
25
|
+
describe "#initialize" do
|
|
26
|
+
it "sets group to default" do
|
|
27
|
+
expect(subject.group).to eq(Shoes::Swt::RadioGroup::DEFAULT_RADIO_GROUP)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "#group=" do
|
|
32
|
+
let(:group_name) { "New Group Name" }
|
|
33
|
+
let(:radio_group) { double("radio_group").as_null_object }
|
|
34
|
+
let(:group_lookup) { double('group_lookup', :[] => radio_group).as_null_object }
|
|
35
|
+
before :each do
|
|
36
|
+
allow(Shoes::Swt::RadioGroup).to receive(:group_lookup) { group_lookup }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "changes the group" do
|
|
40
|
+
subject.group = group_name
|
|
41
|
+
expect(subject.group).to eq(group_name)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "adds to the new radio group" do
|
|
45
|
+
expect(group_lookup).to receive(:[]).with group_name
|
|
46
|
+
expect(radio_group).to receive(:add).with subject
|
|
47
|
+
subject.group = group_name
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "removes from the old radio group" do
|
|
51
|
+
expect(group_lookup).to receive(:[]).with Shoes::Swt::RadioGroup::DEFAULT_RADIO_GROUP
|
|
52
|
+
expect(radio_group).to receive(:remove).with subject
|
|
53
|
+
subject.group = group_name
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoes::Swt::RectPainter do
|
|
4
|
+
include_context "painter context"
|
|
5
|
+
|
|
6
|
+
let(:corners) { 0 }
|
|
7
|
+
let(:app) { double('app', :real => container, :add_paint_listener => true, :dsl => dsl) }
|
|
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 }
|
|
13
|
+
let(:left) { 55 }
|
|
14
|
+
let(:top) { 77 }
|
|
15
|
+
let(:width) { 222 }
|
|
16
|
+
let(:height) { 111 }
|
|
17
|
+
let(:shape) { Shoes::Swt::Rect.new dsl, app}
|
|
18
|
+
subject { Shoes::Swt::RectPainter.new shape }
|
|
19
|
+
|
|
20
|
+
it_behaves_like "fill painter"
|
|
21
|
+
it_behaves_like "stroke painter"
|
|
22
|
+
|
|
23
|
+
describe "square corners" do
|
|
24
|
+
let(:corners) { 0 }
|
|
25
|
+
|
|
26
|
+
it "fills rect" do
|
|
27
|
+
expect(gc).to receive(:fill_round_rectangle).with(left, top, width, height, corners*2, corners*2)
|
|
28
|
+
subject.paint_control(event)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
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)
|
|
33
|
+
subject.paint_control(event)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "round corners" do
|
|
38
|
+
let(:corners) { 13 }
|
|
39
|
+
|
|
40
|
+
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)
|
|
42
|
+
subject.paint_control(event)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoes::Swt::Rect do
|
|
4
|
+
include_context "swt app"
|
|
5
|
+
|
|
6
|
+
let(:left) { 55 }
|
|
7
|
+
let(:top) { 77 }
|
|
8
|
+
let(:width) { 222 }
|
|
9
|
+
let(:height) { 111 }
|
|
10
|
+
let(:dsl) {::Shoes::Rect.new shoes_app, parent, left, top, width, height}
|
|
11
|
+
|
|
12
|
+
subject {
|
|
13
|
+
Shoes::Swt::Rect.new dsl, swt_app
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it_behaves_like "paintable"
|
|
17
|
+
it_behaves_like "updating visibility"
|
|
18
|
+
it_behaves_like 'clickable backend'
|
|
19
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'swt_shoes/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoes::Swt::Shape do
|
|
4
|
+
include_context "swt app"
|
|
5
|
+
|
|
6
|
+
let(:dsl) { instance_double("Shoes::Shape", hidden: false, style: {}).as_null_object }
|
|
7
|
+
subject { Shoes::Swt::Shape.new dsl, swt_app }
|
|
8
|
+
|
|
9
|
+
shared_examples_for "Swt::Shape" do
|
|
10
|
+
let(:ancestors) { subject.class.ancestors.map(&:name) }
|
|
11
|
+
|
|
12
|
+
it "uses Shoes::Swt" do
|
|
13
|
+
expect(ancestors).to include('Shoes::Swt::Shape')
|
|
14
|
+
subject
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
its(:dsl) { is_expected.to be(dsl) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_behaves_like "Swt::Shape"
|
|
21
|
+
it_behaves_like "paintable"
|
|
22
|
+
it_behaves_like "removable"
|
|
23
|
+
|
|
24
|
+
it "properly disposes" do
|
|
25
|
+
expect(subject.transform).to receive(:dispose)
|
|
26
|
+
expect(subject.element).to receive(:dispose)
|
|
27
|
+
subject.dispose
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "Swt element" do
|
|
31
|
+
let(:element) { double("element") }
|
|
32
|
+
|
|
33
|
+
before :each do
|
|
34
|
+
allow(::Swt::Path).to receive(:new) { element }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "delegates #move_to" do
|
|
38
|
+
expect(element).to receive(:move_to).with(20, 30)
|
|
39
|
+
subject.move_to 20, 30
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "delegates #line_to" do
|
|
43
|
+
expect(element).to receive(:line_to).with(20, 30)
|
|
44
|
+
subject.line_to 20, 30
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "moving" do
|
|
49
|
+
let(:transform) { double("transform") }
|
|
50
|
+
|
|
51
|
+
before :each do
|
|
52
|
+
allow(::Swt::Transform).to receive(:new) { transform }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "translates position to dsl's element_left and element_top" do
|
|
56
|
+
allow(dsl).to receive(:element_left) { 20 }
|
|
57
|
+
allow(dsl).to receive(:element_top) { 30 }
|
|
58
|
+
expect(transform).to receive(:translate).with(20, 30)
|
|
59
|
+
subject.update_position
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "painter" do
|
|
65
|
+
include_context "painter context"
|
|
66
|
+
|
|
67
|
+
let(:shape) { Shoes::Swt::Shape.new(dsl, swt_app) }
|
|
68
|
+
subject { Shoes::Swt::Shape::Painter.new(shape) }
|
|
69
|
+
|
|
70
|
+
it_behaves_like "stroke painter"
|
|
71
|
+
it_behaves_like "fill painter"
|
|
72
|
+
it_behaves_like "movable painter"
|
|
73
|
+
|
|
74
|
+
it "fills path" do
|
|
75
|
+
expect(gc).to receive(:fill_path)
|
|
76
|
+
subject.paint_control(event)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "draws path" do
|
|
80
|
+
expect(gc).to receive(:draw_path)
|
|
81
|
+
subject.paint_control(event)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
shared_examples "buttons" do
|
|
2
|
+
|
|
3
|
+
it "calls set_focus when focus is called" do
|
|
4
|
+
expect(real).to receive(:set_focus)
|
|
5
|
+
subject.focus
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Check and Radio
|
|
11
|
+
shared_examples "selectable" do
|
|
12
|
+
it "calls get_selection when checked? is called" do
|
|
13
|
+
expect(real).to receive(:get_selection)
|
|
14
|
+
subject.checked?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "calls set_selection when checked= is called" do
|
|
18
|
+
expect(real).to receive(:set_selection).with(true)
|
|
19
|
+
subject.checked = true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
shared_examples 'clickable backend' do
|
|
2
|
+
|
|
3
|
+
before :each do
|
|
4
|
+
allow(swt_app).to receive :add_clickable_element
|
|
5
|
+
allow(swt_app).to receive :remove_listener
|
|
6
|
+
allow(swt_app).to receive(:clickable_elements).and_return(clickable_elements)
|
|
7
|
+
allow(dsl).to receive(:in_bounds?) { true }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:block) {clickable_block}
|
|
11
|
+
let(:clickable_elements) { double("clickable_elements", delete: nil) }
|
|
12
|
+
|
|
13
|
+
let(:clickable_block) {double 'clickable_block'}
|
|
14
|
+
let(:clickable_subject) do
|
|
15
|
+
subject.clickable clickable_block
|
|
16
|
+
subject
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
let(:mouse_event) {double 'mouse_event', button: 1, x: 2, y:3}
|
|
20
|
+
|
|
21
|
+
it {is_expected.to respond_to :clickable}
|
|
22
|
+
|
|
23
|
+
it 'its click_handler should not be nil' do
|
|
24
|
+
expect(clickable_subject.click_listener).not_to be_nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# This let will be used for expectations on click parameters
|
|
28
|
+
let(:click_block_parameters) { [dsl] }
|
|
29
|
+
|
|
30
|
+
# This is the alternate form of click parameters we can expect
|
|
31
|
+
# set click_block_parameters to this for examples with coordinate clicks
|
|
32
|
+
let(:click_block_coordinates) { [1, 2, 3] }
|
|
33
|
+
|
|
34
|
+
it 'calls the block when a click event comes in bounds' do
|
|
35
|
+
allow(dsl).to receive(:hidden?) { false }
|
|
36
|
+
expect(clickable_block).to receive(:call).with(*click_block_parameters)
|
|
37
|
+
clickable_subject.click_listener.handleEvent mouse_event
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "doesn't call the block if the object is hidden" do
|
|
41
|
+
allow(dsl).to receive(:hidden?) { true }
|
|
42
|
+
expect(clickable_block).to_not receive(:call)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe 'interaction with the swt app object' do
|
|
46
|
+
|
|
47
|
+
def expect_added_listener_for(event)
|
|
48
|
+
click_listener = subject.click_listener
|
|
49
|
+
expect(swt_app).to have_received(:add_listener).with(event,
|
|
50
|
+
click_listener)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'receives the add_clickable_element message' do
|
|
54
|
+
expect(swt_app).to receive(:add_clickable_element)
|
|
55
|
+
clickable_subject
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'adds a listener for the MouseDown event' do
|
|
59
|
+
clickable_subject
|
|
60
|
+
expect_added_listener_for ::Swt::SWT::MouseDown
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'adds the correct listener' do
|
|
64
|
+
clickable_subject
|
|
65
|
+
expect_added_listener_for ::Swt::SWT::MouseDown
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'adds a listener for the MouseDown event when click is called' do
|
|
69
|
+
subject.click Proc.new {}
|
|
70
|
+
expect_added_listener_for ::Swt::SWT::MouseDown
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'adds a listener for the MouseUp event when release is called' do
|
|
74
|
+
subject.release Proc.new {}
|
|
75
|
+
expect_added_listener_for ::Swt::SWT::MouseUp
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'only hands the dsl object to the app' do
|
|
80
|
+
subject.click Proc.new {}
|
|
81
|
+
# at least is used for link - because it already triggers it in intialize
|
|
82
|
+
expect(swt_app).to have_received(:add_clickable_element).with(subject.dsl).
|
|
83
|
+
at_least(1).times
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
shared_examples "movable element" do |left, top|
|
|
2
|
+
|
|
3
|
+
before :each do
|
|
4
|
+
allow(dsl).to receive_messages element_left: left, element_top: top
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
context "with disposed real element" do
|
|
8
|
+
before :each do
|
|
9
|
+
allow(real).to receive(:disposed?) { true }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "doesn't delegate to real" do
|
|
13
|
+
expect(real).not_to receive(:set_location)
|
|
14
|
+
subject.update_position
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "with undisposed real element" do
|
|
19
|
+
before :each do
|
|
20
|
+
allow(real).to receive(:disposed?) { false }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "delegates to real" do
|
|
24
|
+
expect(real).to receive(:set_location).with(left, top)
|
|
25
|
+
subject.update_position
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
shared_examples_for "movable shape" do |x, y|
|
|
31
|
+
it "redraws container" do
|
|
32
|
+
expect(container).to receive(:redraw).at_least(2).times
|
|
33
|
+
allow(dsl).to receive_messages element_left: x, element_top: y
|
|
34
|
+
subject.update_position
|
|
35
|
+
end
|
|
36
|
+
end
|