shoes-swt 4.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +84 -0
- data/Gemfile +24 -0
- data/Guardfile +11 -0
- data/LICENSE +31 -0
- data/README.md +201 -0
- data/lib/shoes/swt.rb +118 -0
- data/lib/shoes/swt/animation.rb +46 -0
- data/lib/shoes/swt/app.rb +314 -0
- data/lib/shoes/swt/arc.rb +71 -0
- data/lib/shoes/swt/background.rb +41 -0
- data/lib/shoes/swt/border.rb +41 -0
- data/lib/shoes/swt/button.rb +18 -0
- data/lib/shoes/swt/check.rb +14 -0
- data/lib/shoes/swt/check_button.rb +19 -0
- data/lib/shoes/swt/color.rb +49 -0
- data/lib/shoes/swt/color_factory.rb +32 -0
- data/lib/shoes/swt/common/child.rb +16 -0
- data/lib/shoes/swt/common/clickable.rb +68 -0
- data/lib/shoes/swt/common/container.rb +28 -0
- data/lib/shoes/swt/common/fill.rb +38 -0
- data/lib/shoes/swt/common/painter.rb +92 -0
- data/lib/shoes/swt/common/painter_updates_position.rb +12 -0
- data/lib/shoes/swt/common/remove.rb +30 -0
- data/lib/shoes/swt/common/resource.rb +29 -0
- data/lib/shoes/swt/common/selection_listener.rb +14 -0
- data/lib/shoes/swt/common/stroke.rb +42 -0
- data/lib/shoes/swt/common/update_position.rb +15 -0
- data/lib/shoes/swt/common/visibility.rb +13 -0
- data/lib/shoes/swt/dialog.rb +90 -0
- data/lib/shoes/swt/disposed_protection.rb +23 -0
- data/lib/shoes/swt/download.rb +24 -0
- data/lib/shoes/swt/font.rb +32 -0
- data/lib/shoes/swt/gradient.rb +92 -0
- data/lib/shoes/swt/image.rb +128 -0
- data/lib/shoes/swt/image_pattern.rb +31 -0
- data/lib/shoes/swt/input_box.rb +73 -0
- data/lib/shoes/swt/key_listener.rb +145 -0
- data/lib/shoes/swt/line.rb +60 -0
- data/lib/shoes/swt/link.rb +31 -0
- data/lib/shoes/swt/link_segment.rb +111 -0
- data/lib/shoes/swt/list_box.rb +48 -0
- data/lib/shoes/swt/mouse_move_listener.rb +67 -0
- data/lib/shoes/swt/oval.rb +52 -0
- data/lib/shoes/swt/progress.rb +35 -0
- data/lib/shoes/swt/radio.rb +29 -0
- data/lib/shoes/swt/radio_group.rb +54 -0
- data/lib/shoes/swt/rect.rb +30 -0
- data/lib/shoes/swt/rect_painter.rb +23 -0
- data/lib/shoes/swt/redrawing_aspect.rb +123 -0
- data/lib/shoes/swt/shape.rb +133 -0
- data/lib/shoes/swt/shoes_layout.rb +43 -0
- data/lib/shoes/swt/slot.rb +39 -0
- data/lib/shoes/swt/sound.rb +119 -0
- data/lib/shoes/swt/star.rb +50 -0
- data/lib/shoes/swt/support/jl1.0.1.jar +0 -0
- data/lib/shoes/swt/support/jogg-0.0.7.jar +0 -0
- data/lib/shoes/swt/support/jorbis-0.0.15.jar +0 -0
- data/lib/shoes/swt/support/log4j-1.2.16.jar +0 -0
- data/lib/shoes/swt/support/mp3spi1.9.5.jar +0 -0
- data/lib/shoes/swt/support/tritonus_share.jar +0 -0
- data/lib/shoes/swt/support/vorbisspi1.0.3.jar +0 -0
- data/lib/shoes/swt/swt_button.rb +56 -0
- data/lib/shoes/swt/text_block.rb +124 -0
- data/lib/shoes/swt/text_block/centered_text_segment.rb +22 -0
- data/lib/shoes/swt/text_block/cursor_painter.rb +53 -0
- data/lib/shoes/swt/text_block/fitter.rb +212 -0
- data/lib/shoes/swt/text_block/painter.rb +47 -0
- data/lib/shoes/swt/text_block/text_font_factory.rb +50 -0
- data/lib/shoes/swt/text_block/text_segment.rb +108 -0
- data/lib/shoes/swt/text_block/text_segment_collection.rb +160 -0
- data/lib/shoes/swt/text_block/text_style_factory.rb +88 -0
- data/lib/shoes/swt/timer.rb +19 -0
- data/lib/shoes/swt/tooling/leak_hunter.rb +35 -0
- data/lib/shoes/swt/version.rb +5 -0
- data/manifests/common.rb +34 -0
- data/manifests/shoes-swt.rb +29 -0
- data/shoes-swt.gemspec +24 -0
- data/spec/code_coverage.rb +14 -0
- data/spec/shoes/animation_spec.rb +65 -0
- data/spec/shoes/app_spec.rb +484 -0
- data/spec/shoes/arc_spec.rb +51 -0
- data/spec/shoes/background_spec.rb +53 -0
- data/spec/shoes/border_spec.rb +47 -0
- data/spec/shoes/builtin_methods_spec.rb +110 -0
- data/spec/shoes/button_spec.rb +44 -0
- data/spec/shoes/check_spec.rb +35 -0
- data/spec/shoes/cli_spec.rb +15 -0
- data/spec/shoes/color_spec.rb +408 -0
- data/spec/shoes/common/inspect_spec.rb +26 -0
- data/spec/shoes/common/remove_spec.rb +38 -0
- data/spec/shoes/common/style_normalizer_spec.rb +28 -0
- data/spec/shoes/common/style_spec.rb +147 -0
- data/spec/shoes/configuration_spec.rb +36 -0
- data/spec/shoes/constants_spec.rb +38 -0
- data/spec/shoes/dialog_spec.rb +163 -0
- data/spec/shoes/dimension_spec.rb +407 -0
- data/spec/shoes/dimensions_spec.rb +837 -0
- data/spec/shoes/download_spec.rb +142 -0
- data/spec/shoes/flow_spec.rb +133 -0
- data/spec/shoes/font_spec.rb +37 -0
- data/spec/shoes/framework_learning_spec.rb +30 -0
- data/spec/shoes/gradient_spec.rb +32 -0
- data/spec/shoes/helpers/fake_element.rb +17 -0
- data/spec/shoes/helpers/inspect_helpers.rb +5 -0
- data/spec/shoes/helpers/sample17_helper.rb +66 -0
- data/spec/shoes/image_spec.rb +49 -0
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +80 -0
- data/spec/shoes/integration_spec.rb +20 -0
- data/spec/shoes/internal_app_spec.rb +141 -0
- data/spec/shoes/keypress_spec.rb +11 -0
- data/spec/shoes/keyrelease_spec.rb +12 -0
- data/spec/shoes/line_spec.rb +49 -0
- data/spec/shoes/link_spec.rb +105 -0
- data/spec/shoes/list_box_spec.rb +74 -0
- data/spec/shoes/logger/ruby_spec.rb +8 -0
- data/spec/shoes/logger_spec.rb +45 -0
- data/spec/shoes/oval_spec.rb +24 -0
- data/spec/shoes/point_spec.rb +71 -0
- data/spec/shoes/progress_spec.rb +54 -0
- data/spec/shoes/radio_spec.rb +32 -0
- data/spec/shoes/rect_spec.rb +39 -0
- data/spec/shoes/renamed_delegate_spec.rb +70 -0
- data/spec/shoes/shape_spec.rb +95 -0
- data/spec/shoes/shared_examples/button.rb +6 -0
- data/spec/shoes/shared_examples/changeable.rb +26 -0
- data/spec/shoes/shared_examples/clickable.rb +5 -0
- data/spec/shoes/shared_examples/common_methods.rb +35 -0
- data/spec/shoes/shared_examples/dimensions.rb +32 -0
- data/spec/shoes/shared_examples/dsl.rb +44 -0
- data/spec/shoes/shared_examples/dsl/animate.rb +29 -0
- data/spec/shoes/shared_examples/dsl/arc.rb +45 -0
- data/spec/shoes/shared_examples/dsl/background.rb +26 -0
- data/spec/shoes/shared_examples/dsl/border.rb +10 -0
- data/spec/shoes/shared_examples/dsl/button.rb +5 -0
- data/spec/shoes/shared_examples/dsl/cap.rb +6 -0
- data/spec/shoes/shared_examples/dsl/check.rb +11 -0
- data/spec/shoes/shared_examples/dsl/edit_box.rb +8 -0
- data/spec/shoes/shared_examples/dsl/edit_line.rb +8 -0
- data/spec/shoes/shared_examples/dsl/editable_element.rb +29 -0
- data/spec/shoes/shared_examples/dsl/fill.rb +27 -0
- data/spec/shoes/shared_examples/dsl/flow.rb +15 -0
- data/spec/shoes/shared_examples/dsl/gradient.rb +62 -0
- data/spec/shoes/shared_examples/dsl/image.rb +21 -0
- data/spec/shoes/shared_examples/dsl/line.rb +9 -0
- data/spec/shoes/shared_examples/dsl/nofill.rb +6 -0
- data/spec/shoes/shared_examples/dsl/nostroke.rb +6 -0
- data/spec/shoes/shared_examples/dsl/oval.rb +88 -0
- data/spec/shoes/shared_examples/dsl/pattern.rb +34 -0
- data/spec/shoes/shared_examples/dsl/progress.rb +7 -0
- data/spec/shoes/shared_examples/dsl/rect.rb +92 -0
- data/spec/shoes/shared_examples/dsl/rgb.rb +26 -0
- data/spec/shoes/shared_examples/dsl/shape.rb +21 -0
- data/spec/shoes/shared_examples/dsl/star.rb +48 -0
- data/spec/shoes/shared_examples/dsl/stroke.rb +30 -0
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +19 -0
- data/spec/shoes/shared_examples/dsl/style.rb +32 -0
- data/spec/shoes/shared_examples/dsl/text_elements.rb +81 -0
- data/spec/shoes/shared_examples/dsl/video.rb +5 -0
- data/spec/shoes/shared_examples/dsl_app_context.rb +8 -0
- data/spec/shoes/shared_examples/hover_leave.rb +11 -0
- data/spec/shoes/shared_examples/parent.rb +6 -0
- data/spec/shoes/shared_examples/scroll.rb +41 -0
- data/spec/shoes/shared_examples/shared_element_method.rb +60 -0
- data/spec/shoes/shared_examples/slot.rb +331 -0
- data/spec/shoes/shared_examples/state.rb +19 -0
- data/spec/shoes/shared_examples/style.rb +82 -0
- data/spec/shoes/slot_spec.rb +130 -0
- data/spec/shoes/sound_spec.rb +15 -0
- data/spec/shoes/span_spec.rb +112 -0
- data/spec/shoes/spec_helper.rb +24 -0
- data/spec/shoes/stack_spec.rb +79 -0
- data/spec/shoes/star_spec.rb +31 -0
- data/spec/shoes/text_block_dimensions_spec.rb +75 -0
- data/spec/shoes/text_block_spec.rb +270 -0
- data/spec/shoes/url_spec.rb +68 -0
- data/spec/shoes/widget_spec.rb +70 -0
- data/spec/shoes_spec.rb +44 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/swt_shoes/animation_spec.rb +86 -0
- data/spec/swt_shoes/app_spec.rb +84 -0
- data/spec/swt_shoes/arc_spec.rb +103 -0
- data/spec/swt_shoes/background_spec.rb +67 -0
- data/spec/swt_shoes/border_spec.rb +52 -0
- data/spec/swt_shoes/button_spec.rb +101 -0
- data/spec/swt_shoes/check_spec.rb +28 -0
- data/spec/swt_shoes/color_factory_spec.rb +49 -0
- data/spec/swt_shoes/color_spec.rb +67 -0
- data/spec/swt_shoes/common/painter_spec.rb +49 -0
- data/spec/swt_shoes/common/remove_spec.rb +53 -0
- data/spec/swt_shoes/configuration_spec.rb +12 -0
- data/spec/swt_shoes/dialog_spec.rb +106 -0
- data/spec/swt_shoes/disposed_protection_spec.rb +49 -0
- data/spec/swt_shoes/flow_spec.rb +36 -0
- data/spec/swt_shoes/font_spec.rb +33 -0
- data/spec/swt_shoes/gradient_spec.rb +31 -0
- data/spec/swt_shoes/image_pattern_spec.rb +35 -0
- data/spec/swt_shoes/image_spec.rb +100 -0
- data/spec/swt_shoes/input_box_spec.rb +116 -0
- data/spec/swt_shoes/integration_spec.rb +27 -0
- data/spec/swt_shoes/key_listener_spec.rb +325 -0
- data/spec/swt_shoes/line_spec.rb +49 -0
- data/spec/swt_shoes/link_segment_spec.rb +120 -0
- data/spec/swt_shoes/link_spec.rb +54 -0
- data/spec/swt_shoes/list_box_spec.rb +56 -0
- data/spec/swt_shoes/minimal.png +0 -0
- data/spec/swt_shoes/mouse_move_listener_spec.rb +123 -0
- data/spec/swt_shoes/oval_spec.rb +51 -0
- data/spec/swt_shoes/progress_spec.rb +44 -0
- data/spec/swt_shoes/radio_group_spec.rb +73 -0
- data/spec/swt_shoes/radio_spec.rb +56 -0
- data/spec/swt_shoes/rect_painter_spec.rb +45 -0
- data/spec/swt_shoes/rect_spec.rb +19 -0
- data/spec/swt_shoes/shape_spec.rb +84 -0
- data/spec/swt_shoes/shared_examples/button.rb +21 -0
- data/spec/swt_shoes/shared_examples/clickable.rb +85 -0
- data/spec/swt_shoes/shared_examples/movable.rb +36 -0
- data/spec/swt_shoes/shared_examples/paintable.rb +7 -0
- data/spec/swt_shoes/shared_examples/painter.rb +83 -0
- data/spec/swt_shoes/shared_examples/pattern.rb +32 -0
- data/spec/swt_shoes/shared_examples/removable.rb +41 -0
- data/spec/swt_shoes/shared_examples/swt_app_context.rb +23 -0
- data/spec/swt_shoes/shared_examples/visibility.rb +15 -0
- data/spec/swt_shoes/shell_control_listener_spec.rb +23 -0
- data/spec/swt_shoes/slot_spec.rb +24 -0
- data/spec/swt_shoes/sound.rb +10 -0
- data/spec/swt_shoes/spec_helper.rb +31 -0
- data/spec/swt_shoes/star_spec.rb +47 -0
- data/spec/swt_shoes/text_block/centered_text_segment_spec.rb +16 -0
- data/spec/swt_shoes/text_block/cursor_painter_spec.rb +120 -0
- data/spec/swt_shoes/text_block/fitter_spec.rb +213 -0
- data/spec/swt_shoes/text_block/painter_spec.rb +212 -0
- data/spec/swt_shoes/text_block/text_font_factory_spec.rb +40 -0
- data/spec/swt_shoes/text_block/text_segment_collection_spec.rb +256 -0
- data/spec/swt_shoes/text_block/text_segment_spec.rb +135 -0
- data/spec/swt_shoes/text_block_spec.rb +199 -0
- metadata +496 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::ListBox do
|
4
|
+
include_context "dsl app"
|
5
|
+
let(:input_opts) { { items: items, left: left, top: top, width: width,
|
6
|
+
height: height } }
|
7
|
+
|
8
|
+
let(:items) {["Wine", "Vodka", "Water"]}
|
9
|
+
|
10
|
+
let(:left) { 10 }
|
11
|
+
let(:top) { 20 }
|
12
|
+
let(:width) { 100 }
|
13
|
+
let(:height) { 200 }
|
14
|
+
|
15
|
+
subject(:list_box) { Shoes::ListBox.new(app, parent, input_opts, input_block) }
|
16
|
+
|
17
|
+
it_behaves_like "an element that can respond to change"
|
18
|
+
it_behaves_like "object with style" do
|
19
|
+
let(:subject_without_style) { Shoes::ListBox.new(app, parent) }
|
20
|
+
let(:subject_with_style) { Shoes::ListBox.new(app, parent, arg_styles) }
|
21
|
+
end
|
22
|
+
it_behaves_like "object with state"
|
23
|
+
it_behaves_like "object with dimensions"
|
24
|
+
|
25
|
+
describe "relative dimensions from parent" do
|
26
|
+
subject { Shoes::ListBox.new(app, parent, relative_opts, input_block) }
|
27
|
+
it_behaves_like "object with relative dimensions"
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "negative dimensions" do
|
31
|
+
subject { Shoes::ListBox.new(app, parent, negative_opts, input_block) }
|
32
|
+
it_behaves_like "object with negative dimensions"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "contains the correct items" do
|
36
|
+
expect(subject.items).to eq(["Wine", "Vodka", "Water"])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "changes the items" do
|
40
|
+
list_box.items = ["Pie", "Apple", "Pig"]
|
41
|
+
expect(list_box.items).to eq(["Pie", "Apple", "Pig"])
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'Choosing' do
|
45
|
+
it "allows us to choose an option" do
|
46
|
+
expect(list_box).to respond_to(:choose)
|
47
|
+
end
|
48
|
+
|
49
|
+
def expect_gui_choose_with(string)
|
50
|
+
expect_any_instance_of(Shoes.configuration.backend::ListBox).
|
51
|
+
to receive(:choose).with string
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should call @gui.choose when we choose something" do
|
55
|
+
expect_gui_choose_with "Wine"
|
56
|
+
list_box.choose "Wine"
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should call @gui.choose when the choose option is passed' do
|
60
|
+
expect_gui_choose_with 'Wine'
|
61
|
+
Shoes::ListBox.new app, parent, input_opts.merge(choose: 'Wine')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should delegate #text to the backend" do
|
66
|
+
expect_any_instance_of(Shoes.configuration.backend::ListBox).
|
67
|
+
to receive(:text).and_return("Sneakers & Sandals")
|
68
|
+
expect(list_box.text).to eq("Sneakers & Sandals")
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'has the initialized text elements' do
|
72
|
+
expect(subject.items).to eq items
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Logger do
|
4
|
+
let(:awesome_logger) { Class.new }
|
5
|
+
after { Shoes::Logger.unregister(:awesome_logger) }
|
6
|
+
|
7
|
+
describe ".register" do
|
8
|
+
it "allows new loggers to be registered" do
|
9
|
+
Shoes::Logger.register(:awesome_logger, awesome_logger)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".get" do
|
14
|
+
before { Shoes::Logger.register(:awesome_logger, awesome_logger) }
|
15
|
+
|
16
|
+
it "retrieves a registered logger" do
|
17
|
+
expect(Shoes::Logger.get(:awesome_logger)).to equal(awesome_logger)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "default logger" do
|
22
|
+
let(:logger) { Shoes.logger }
|
23
|
+
|
24
|
+
it "is a ruby logger" do
|
25
|
+
expect(logger).to be_an_instance_of(Shoes::Logger::Ruby)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Shoes::Logger::Ruby do
|
31
|
+
let(:logdevice) { StringIO.new }
|
32
|
+
subject(:logger) { Shoes::Logger::Ruby.new logdevice }
|
33
|
+
|
34
|
+
it "logs messages with format 'LEVEL: Message'" do
|
35
|
+
logger.info "Message"
|
36
|
+
expect(logdevice.string).to eq("INFO: Message\n")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "defaults to STDERR" do
|
40
|
+
allow(STDERR).to receive(:write)
|
41
|
+
logger = Shoes::Logger::Ruby.new
|
42
|
+
logger.error "Message"
|
43
|
+
expect(STDERR).to have_received(:write)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Oval do
|
4
|
+
include_context "dsl app"
|
5
|
+
|
6
|
+
let(:left) { 20 }
|
7
|
+
let(:top) { 30 }
|
8
|
+
let(:width) { 100 }
|
9
|
+
let(:height) { 200 }
|
10
|
+
|
11
|
+
describe "basic" do
|
12
|
+
subject { Shoes::Oval.new(app, parent, left, top, width, height) }
|
13
|
+
it_behaves_like "object with style" do
|
14
|
+
let(:subject_without_style) { Shoes::Oval.new(app, parent, left, top, width, height) }
|
15
|
+
let(:subject_with_style) { Shoes::Oval.new(app, parent, left, top, width, height, arg_styles) }
|
16
|
+
end
|
17
|
+
it_behaves_like "object with dimensions"
|
18
|
+
it_behaves_like "movable object"
|
19
|
+
it_behaves_like "left, top as center"
|
20
|
+
it_behaves_like "object with parent"
|
21
|
+
|
22
|
+
#it_styles_with :art_styles, :center, :dimensions, :radius
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Point do
|
4
|
+
subject { Shoes::Point.new(40, 50) }
|
5
|
+
let(:other_point) { Shoes::Point.new(10, 60) }
|
6
|
+
|
7
|
+
its(:x) { should eq(40) }
|
8
|
+
its(:y) { should eq(50) }
|
9
|
+
|
10
|
+
it "#left works on either point" do
|
11
|
+
expect(subject.left(other_point)).to eq(10)
|
12
|
+
expect(other_point.left(subject)).to eq(10)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "#top works on either point" do
|
16
|
+
expect(subject.top(other_point)).to eq(50)
|
17
|
+
expect(other_point.top(subject)).to eq(50)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "equality" do
|
21
|
+
it "requires x and y to be equal" do
|
22
|
+
expect(subject).to eq(Shoes::Point.new 40, 50)
|
23
|
+
expect(subject).not_to eq(Shoes::Point.new 41, 50)
|
24
|
+
expect(subject).not_to eq(Shoes::Point.new 40, 51)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "works with other (x,y) objects" do
|
28
|
+
expect(subject).to eq(Struct.new(:x, :y).new(40, 50))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#to" do
|
33
|
+
it "positive" do
|
34
|
+
expect(subject.to(24, 166)).to eq(Shoes::Point.new(64, 216))
|
35
|
+
end
|
36
|
+
|
37
|
+
it "negative" do
|
38
|
+
expect(subject.to(-24, -166)).to eq(Shoes::Point.new(16, -116))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "calculates width of rectangle created with other point" do
|
43
|
+
expect(subject.width(other_point)).to eq(30)
|
44
|
+
expect(other_point.width(subject)).to eq(30)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "calculates height of rectangle created with other point" do
|
48
|
+
expect(subject.height(other_point)).to eq(10)
|
49
|
+
expect(other_point.height(subject)).to eq(10)
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "converting to string" do
|
53
|
+
include InspectHelpers
|
54
|
+
|
55
|
+
it "looks like (x,y)" do
|
56
|
+
expect(subject.to_s).to eq("(40,50)")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "inspects like (Shoes::Point:0x01234567 (x,y))" do
|
60
|
+
expect(subject.inspect).to match(/[(]Shoes::Point:#{shoes_object_id_pattern} [(]40,50[)][)]/)
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "with nil values" do
|
64
|
+
subject { Shoes::Point.new(nil, nil) }
|
65
|
+
|
66
|
+
it "looks like (nil,nil)" do
|
67
|
+
expect(subject.to_s).to eq("(_,_)")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Progress do
|
4
|
+
include_context "dsl app"
|
5
|
+
let(:input_opts) { { left: left, top: top, width: width, height: height } }
|
6
|
+
|
7
|
+
let(:left) { 10 }
|
8
|
+
let(:top) { 20 }
|
9
|
+
let(:width) { 100 }
|
10
|
+
let(:height) { 200 }
|
11
|
+
|
12
|
+
subject(:progress) { Shoes::Progress.new(app, parent, input_opts, input_block) }
|
13
|
+
|
14
|
+
it { is_expected.to respond_to :fraction }
|
15
|
+
it { is_expected.to respond_to :fraction= }
|
16
|
+
|
17
|
+
it_behaves_like "object with dimensions"
|
18
|
+
|
19
|
+
it_behaves_like "object with style" do
|
20
|
+
let(:subject_without_style) { Shoes::Progress.new(app, parent) }
|
21
|
+
let(:subject_with_style) { Shoes::Progress.new(app, parent, arg_styles) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "initialize" do
|
25
|
+
let(:input_opts) { { fraction: 50 } }
|
26
|
+
|
27
|
+
it "sets fraction" do
|
28
|
+
expect_any_instance_of(Shoes.configuration.backend::Progress).to receive(:fraction=).with(50)
|
29
|
+
expect(progress).not_to be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "setting fraction" do
|
34
|
+
it "sets on gui" do
|
35
|
+
expect(progress.gui).to receive(:fraction=).with(0.5)
|
36
|
+
progress.fraction = 0.5
|
37
|
+
end
|
38
|
+
|
39
|
+
it "sets on self" do
|
40
|
+
progress.fraction = 0.5
|
41
|
+
expect(progress.fraction).to eq(0.5)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "relative dimensions from parent" do
|
46
|
+
subject { Shoes::Progress.new(app, parent, relative_opts, input_block) }
|
47
|
+
it_behaves_like "object with relative dimensions"
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "negative dimensions" do
|
51
|
+
subject { Shoes::Progress.new(app, parent, negative_opts, input_block) }
|
52
|
+
it_behaves_like "object with negative dimensions"
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Radio do
|
4
|
+
include_context "dsl app"
|
5
|
+
|
6
|
+
subject(:radio) { Shoes::Radio.new(app, parent, group, input_opts, input_block) }
|
7
|
+
let(:group) { :a_group }
|
8
|
+
|
9
|
+
it_behaves_like "checkable"
|
10
|
+
it_behaves_like "object with state"
|
11
|
+
|
12
|
+
it_behaves_like "object with style" do
|
13
|
+
let(:subject_without_style) { Shoes::Radio.new(app, parent, group) }
|
14
|
+
let(:subject_with_style) { Shoes::Radio.new(app, parent, group, arg_styles) }
|
15
|
+
end
|
16
|
+
|
17
|
+
# only one radio in a group can be checked
|
18
|
+
|
19
|
+
describe "#initialize" do
|
20
|
+
it "sets accessors" do
|
21
|
+
expect(radio.parent).to eq(parent)
|
22
|
+
expect(radio.group).to eq(group)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#group=" do
|
27
|
+
it "changes the group" do
|
28
|
+
radio.group = "New Group"
|
29
|
+
expect(radio.group).to eq("New Group")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for "basic rect" do
|
4
|
+
it "retains app" do
|
5
|
+
expect(rect.app).to eq(app)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "creates gui object" do
|
9
|
+
expect(rect.gui).not_to be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Shoes::Rect do
|
14
|
+
include_context "dsl app"
|
15
|
+
|
16
|
+
let(:parent) { app }
|
17
|
+
let(:left) { 44 }
|
18
|
+
let(:top) { 66 }
|
19
|
+
let(:width) { 111 }
|
20
|
+
let(:height) { 333 }
|
21
|
+
subject(:rect) { Shoes::Rect.new(app, parent, left, top, width, height) }
|
22
|
+
|
23
|
+
describe '#style' do
|
24
|
+
it 'restyles handed in fill colors (even the weird ones)' do
|
25
|
+
subject.style fill: 'fff'
|
26
|
+
expect(subject.style[:fill]).to eq Shoes::Color.new 255, 255, 255
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it_behaves_like "basic rect"
|
31
|
+
it_behaves_like "object with style" do
|
32
|
+
let(:subject_without_style) { Shoes::Rect.new(app, parent, left, top, width, height) }
|
33
|
+
let(:subject_with_style) { Shoes::Rect.new(app, parent, left, top, width, height, arg_styles) }
|
34
|
+
end
|
35
|
+
it_behaves_like "object with dimensions"
|
36
|
+
it_behaves_like "movable object"
|
37
|
+
it_behaves_like "left, top as center"
|
38
|
+
it_behaves_like 'object with parent'
|
39
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RenamedDelegate do
|
4
|
+
|
5
|
+
class ToDelegate
|
6
|
+
def method_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def abcd
|
10
|
+
end
|
11
|
+
|
12
|
+
def key
|
13
|
+
end
|
14
|
+
|
15
|
+
def bla_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_something
|
19
|
+
end
|
20
|
+
|
21
|
+
def key_something
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class TestClass
|
26
|
+
extend RenamedDelegate
|
27
|
+
|
28
|
+
attr_reader :delegate
|
29
|
+
|
30
|
+
def initialize(delegate)
|
31
|
+
@delegate = delegate
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
TestClass.renamed_delegate_to :delegate,
|
36
|
+
ToDelegate.public_instance_methods(false),
|
37
|
+
{'key' => 'shoes', 'something' => 'awesome'}
|
38
|
+
|
39
|
+
let(:delegate) {double('delegate').as_null_object}
|
40
|
+
subject {TestClass.new delegate}
|
41
|
+
|
42
|
+
def test_renaming(new_name, old_name)
|
43
|
+
subject.public_send new_name
|
44
|
+
expect(delegate).to have_received old_name
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'delegates method_shoes to method_key' do
|
48
|
+
test_renaming :method_shoes, :method_key
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'delegates shoes to key' do
|
52
|
+
test_renaming :shoes, :key
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'delegates bla_shoes to bla_key' do
|
56
|
+
test_renaming :bla_shoes, :bla_key
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'delegates method_awesome to method_something' do
|
60
|
+
test_renaming :method_awesome, :method_something
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'also applies multiple renamings' do
|
64
|
+
test_renaming :shoes_awesome, :key_something
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'does not define a method for methods without renamings' do
|
68
|
+
expect(subject).not_to respond_to :abcd
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Shape do
|
4
|
+
include_context "dsl app"
|
5
|
+
|
6
|
+
let(:style) { Hash.new }
|
7
|
+
let(:draw) { Proc.new { } }
|
8
|
+
|
9
|
+
subject { Shoes::Shape.new app, parent, style, draw }
|
10
|
+
|
11
|
+
it_behaves_like "object with style" do
|
12
|
+
let(:subject_without_style) { Shoes::Shape.new(app, parent) }
|
13
|
+
let(:subject_with_style) { Shoes::Shape.new(app, parent, arg_styles) }
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like "movable object"
|
17
|
+
|
18
|
+
describe "octagon" do
|
19
|
+
let(:draw) {
|
20
|
+
Proc.new {
|
21
|
+
xs = [200, 300, 370, 370, 300, 200, 130, 130]
|
22
|
+
ys = [100, 100, 170, 270, 340, 340, 270, 170]
|
23
|
+
move_to xs.first, ys.first
|
24
|
+
xs.zip(ys).each do |x, y|
|
25
|
+
line_to(x, y)
|
26
|
+
end
|
27
|
+
line_to xs.first, ys.first
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
its(:left) { should be_nil }
|
32
|
+
its(:top) { should be_nil }
|
33
|
+
its(:left_bound) { should eq(130) }
|
34
|
+
its(:top_bound) { should eq(100) }
|
35
|
+
its(:right_bound) { should eq(370) }
|
36
|
+
its(:bottom_bound) { should eq(340) }
|
37
|
+
its(:width) { should eq(app.width) }
|
38
|
+
its(:height) { should eq app.height }
|
39
|
+
|
40
|
+
it_behaves_like "movable object"
|
41
|
+
|
42
|
+
describe "when created with left and top values" do
|
43
|
+
let(:style) { {left: 10, top: 100} }
|
44
|
+
|
45
|
+
its(:left) { should eq(10) }
|
46
|
+
its(:top) { should eq(100) }
|
47
|
+
its(:left_bound) { should eq(130) }
|
48
|
+
its(:top_bound) { should eq(100) }
|
49
|
+
its(:right_bound) { should eq(370) }
|
50
|
+
its(:bottom_bound) { should eq(340) }
|
51
|
+
its(:width) { should eq(app.width) }
|
52
|
+
its(:height) { should eq app.height }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "curve" do
|
57
|
+
let(:draw) {
|
58
|
+
Proc.new {
|
59
|
+
move_to 10, 10
|
60
|
+
curve_to 20, 30, 100, 200, 50, 50
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
its(:left_bound) { should eq(10) }
|
65
|
+
its(:top_bound) { should eq(10) }
|
66
|
+
its(:right_bound) { should eq(100) }
|
67
|
+
its(:bottom_bound) { should eq(200) }
|
68
|
+
its(:width) { should eq(app.width) }
|
69
|
+
its(:height) { should eq app.height }
|
70
|
+
|
71
|
+
it_behaves_like "movable object"
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "arc" do
|
75
|
+
let(:draw) {
|
76
|
+
Proc.new {
|
77
|
+
arc 10, 10, 100, 100, Shoes::PI, Shoes::TWO_PI
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
it_behaves_like "movable object"
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "accesses app" do
|
85
|
+
let(:draw) {
|
86
|
+
Proc.new {
|
87
|
+
background Shoes::COLORS[:red]
|
88
|
+
stroke Shoes::COLORS[:blue]
|
89
|
+
rect 10, 10, 100, 100
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
it_behaves_like "movable object"
|
94
|
+
end
|
95
|
+
end
|