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
data/manifests/common.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake/file_list'
|
2
|
+
|
3
|
+
module ShoesManifestReport
|
4
|
+
def report
|
5
|
+
puts "Manifest of #{gem_name} gem"
|
6
|
+
puts
|
7
|
+
puts "files"
|
8
|
+
puts "-----"
|
9
|
+
puts files.sort.join("\n")
|
10
|
+
puts
|
11
|
+
puts "test_files"
|
12
|
+
puts "----------"
|
13
|
+
puts test_files.sort.join("\n")
|
14
|
+
puts
|
15
|
+
puts "#{files.length} files, #{test_files.length} test_files"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class ShoesCommonManifest
|
20
|
+
def self.files
|
21
|
+
Rake::FileList[%w(
|
22
|
+
CHANGELOG
|
23
|
+
Gemfile
|
24
|
+
Guardfile
|
25
|
+
LICENSE
|
26
|
+
README.md
|
27
|
+
manifests/common.rb
|
28
|
+
)]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.test_files
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'common'
|
2
|
+
|
3
|
+
class ShoesSwtManifest
|
4
|
+
extend ShoesManifestReport
|
5
|
+
|
6
|
+
def self.gem_name
|
7
|
+
'shoes-swt'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.files
|
11
|
+
@files = ShoesCommonManifest.files
|
12
|
+
.include(%w[
|
13
|
+
lib/shoes/swt.rb
|
14
|
+
lib/shoes/swt/**/*
|
15
|
+
manifests/shoes-swt.rb
|
16
|
+
shoes-swt.gemspec
|
17
|
+
])
|
18
|
+
.include(test_files)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.test_files
|
22
|
+
@test_files = Rake::FileList['spec/**/*']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
if $0 == __FILE__
|
28
|
+
puts ShoesSwtManifest.report
|
29
|
+
end
|
data/shoes-swt.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require_relative 'lib/shoes/swt/version'
|
3
|
+
require_relative 'manifests/shoes-swt'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "shoes-swt"
|
7
|
+
s.version = Shoes::Swt::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Team Shoes"]
|
10
|
+
s.email = ["shoes@librelist.com"]
|
11
|
+
s.homepage = "https://github.com/shoes/shoes4"
|
12
|
+
s.summary = %q{A JRuby and Swt backend for Shoes, the best little GUI toolkit for Ruby.}
|
13
|
+
s.description = %q{A JRuby and Swt backend for Shoes, the best little GUI toolkit for Ruby. Shoes makes building for Mac, Windows, and Linux super simple.}
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = ShoesSwtManifest.files
|
17
|
+
s.test_files = ShoesSwtManifest.test_files
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency "swt", "~>4.4"
|
21
|
+
s.add_dependency "after_do", "~>0.3"
|
22
|
+
s.add_dependency "shoes-dsl", Shoes::Swt::VERSION
|
23
|
+
s.add_dependency "furoshiki", "~>0.2.0" # For packaging
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
# using coveralls to publish test coverage statistics
|
3
|
+
require 'coveralls'
|
4
|
+
require "codeclimate-test-reporter"
|
5
|
+
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
Coveralls::SimpleCov::Formatter,
|
8
|
+
SimpleCov::Formatter::HTMLFormatter
|
9
|
+
]
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '/spec/'
|
12
|
+
end
|
13
|
+
|
14
|
+
CodeClimate::TestReporter.start
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for Shoes::Animation do
|
4
|
+
it "should start" do
|
5
|
+
subject.start
|
6
|
+
expect(subject).not_to be_stopped
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should stop" do
|
10
|
+
subject.stop
|
11
|
+
expect(subject).to be_stopped
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should toggle on" do
|
15
|
+
subject.stop
|
16
|
+
subject.toggle
|
17
|
+
expect(subject).not_to be_stopped
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should toggle off" do
|
21
|
+
subject.start
|
22
|
+
subject.toggle
|
23
|
+
expect(subject).to be_stopped
|
24
|
+
end
|
25
|
+
|
26
|
+
it "increments frame" do
|
27
|
+
frame = subject.current_frame
|
28
|
+
subject.increment_frame
|
29
|
+
expect(subject.current_frame).to eq(frame + 1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe Shoes::Animation do
|
34
|
+
let(:app) { double('app') }
|
35
|
+
let(:app_gui) { double('app gui') }
|
36
|
+
let(:opts) { {} }
|
37
|
+
let(:block) { double('block') }
|
38
|
+
subject { Shoes::Animation.new( app, opts, block ) }
|
39
|
+
|
40
|
+
before :each do
|
41
|
+
expect(app).to receive(:gui) { app_gui }
|
42
|
+
end
|
43
|
+
|
44
|
+
it_behaves_like Shoes::Animation
|
45
|
+
|
46
|
+
it "sets default framerate" do
|
47
|
+
expect(subject.framerate).to eq(10)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "sets current frame to 0" do
|
51
|
+
expect(subject.current_frame).to eq(0)
|
52
|
+
end
|
53
|
+
|
54
|
+
it { is_expected.not_to be_stopped }
|
55
|
+
|
56
|
+
describe "with framerate" do
|
57
|
+
let(:opts) { {:framerate => 36, :app => app} }
|
58
|
+
|
59
|
+
it "sets framerate" do
|
60
|
+
expect(subject.framerate).to eq(36)
|
61
|
+
end
|
62
|
+
|
63
|
+
it_behaves_like Shoes::Animation
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,484 @@
|
|
1
|
+
require 'shoes/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::App do
|
4
|
+
let(:input_blk) { Proc.new {} }
|
5
|
+
let(:opts) { Hash.new }
|
6
|
+
subject(:app) { Shoes::App.new(opts, &input_blk) }
|
7
|
+
|
8
|
+
after do
|
9
|
+
Shoes.unregister_all
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like "DSL container"
|
13
|
+
it { is_expected.to respond_to :clipboard }
|
14
|
+
it { is_expected.to respond_to :clipboard= }
|
15
|
+
it { is_expected.to respond_to :owner }
|
16
|
+
|
17
|
+
# For Shoes 3 compatibility
|
18
|
+
it "exposes self as #app" do
|
19
|
+
expect(app.app).to eq(app)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "initialize" do
|
23
|
+
let(:input_blk) { Proc.new {} }
|
24
|
+
|
25
|
+
it "initializes style hash", :qt do
|
26
|
+
style = Shoes::App.new.style
|
27
|
+
expect(style.class).to eq(Hash)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "console" do
|
31
|
+
end
|
32
|
+
|
33
|
+
context "defaults" do
|
34
|
+
let(:opts) { Hash.new }
|
35
|
+
let(:defaults) { Shoes::InternalApp::DEFAULT_OPTIONS }
|
36
|
+
|
37
|
+
it "sets width", :qt do
|
38
|
+
expect(subject.width).to eq defaults[:width]
|
39
|
+
end
|
40
|
+
|
41
|
+
it "sets height", :qt do
|
42
|
+
expect(subject.height).to eq defaults[:height]
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'has an absolute_left of 0' do
|
46
|
+
expect(subject.absolute_left).to eq 0
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'has an absolute_top of 0' do
|
50
|
+
expect(subject.absolute_top).to eq 0
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "inspect" do
|
54
|
+
include InspectHelpers
|
55
|
+
|
56
|
+
it "shows title in #to_s" do
|
57
|
+
expect(subject.to_s).to eq("(Shoes::App \"#{defaults.fetch :title}\")")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "shows title in #inspect" do
|
61
|
+
expect(subject.inspect).to match("(Shoes::App:#{shoes_object_id_pattern} \"#{defaults.fetch :title}\")")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "from opts" do
|
67
|
+
let(:opts) { {:width => 150, :height => 2, :title => "Shoes::App Spec", :resizable => false} }
|
68
|
+
|
69
|
+
it "sets width", :qt do
|
70
|
+
expect(subject.width).to eq opts[:width]
|
71
|
+
end
|
72
|
+
|
73
|
+
it "sets height", :qt do
|
74
|
+
expect(subject.height).to eq opts[:height]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "passes opts to InternalApp" do
|
78
|
+
expect(Shoes::InternalApp).to receive(:new).with(kind_of(Shoes::App), opts).and_call_original
|
79
|
+
subject
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'initializes a flow with the right parameters' do
|
83
|
+
expect(Shoes::Flow).to receive(:new).with(anything, anything,
|
84
|
+
{width: opts[:width],
|
85
|
+
height: opts[:height]}).
|
86
|
+
and_call_original
|
87
|
+
subject
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when registering" do
|
92
|
+
before :each do
|
93
|
+
Shoes.unregister_all
|
94
|
+
end
|
95
|
+
|
96
|
+
it "registers" do
|
97
|
+
old_apps_length = Shoes.apps.length
|
98
|
+
subject
|
99
|
+
expect(Shoes.apps.length).to eq(old_apps_length + 1)
|
100
|
+
expect(Shoes.apps).to include(subject)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "style with defaults" do
|
106
|
+
let(:default_styles) { Shoes::Common::Style::DEFAULT_STYLES }
|
107
|
+
|
108
|
+
it "sets app defaults" do
|
109
|
+
expect(app.style).to eq(default_styles)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "merges new styles with existing styles" do
|
113
|
+
subject.style strokewidth: 4
|
114
|
+
expect(subject.style).to eq(default_styles.merge(strokewidth: 4))
|
115
|
+
end
|
116
|
+
|
117
|
+
default_styles = Shoes::Common::Style::DEFAULT_STYLES
|
118
|
+
|
119
|
+
default_styles.each do |key, value|
|
120
|
+
describe "#{key}" do
|
121
|
+
it "defaults to #{value}" do
|
122
|
+
expect(subject.style[key]).to eq(value)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "passes default to objects" do
|
126
|
+
expect(subject.line(0, 100, 100, 0).style[key]).to eq(value)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
describe "default styles" do
|
134
|
+
it "are independent among Shoes::App instances" do
|
135
|
+
app1 = Shoes::App.new
|
136
|
+
app2 = Shoes::App.new
|
137
|
+
|
138
|
+
app1.strokewidth 10
|
139
|
+
expect(app1.line(0, 100, 100, 0).style[:strokewidth]).to eq(10)
|
140
|
+
|
141
|
+
# .. but does not affect app2
|
142
|
+
expect(app2.line(0, 100, 100, 0).style[:strokewidth]).not_to eq(10)
|
143
|
+
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "app-level style setter" do
|
149
|
+
let(:goldenrod) { Shoes::COLORS[:goldenrod] }
|
150
|
+
|
151
|
+
pattern_styles = Shoes::DSL::PATTERN_APP_STYLES
|
152
|
+
other_styles = Shoes::DSL::OTHER_APP_STYLES
|
153
|
+
|
154
|
+
pattern_styles.each do |style|
|
155
|
+
it "sets #{style} for objects" do
|
156
|
+
subject.public_send(style, goldenrod)
|
157
|
+
expect(subject.line(0, 100, 100, 0).style[style]).to eq(goldenrod)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
other_styles.each do |style|
|
162
|
+
it "sets #{style} for objects" do
|
163
|
+
subject.public_send(style, 'val')
|
164
|
+
expect(subject.line(0, 100, 100, 0).style[style]).to eq('val')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "connecting with gui" do
|
171
|
+
let(:gui) { app.instance_variable_get(:@__app__).gui }
|
172
|
+
|
173
|
+
describe "clipboard" do
|
174
|
+
it "gets clipboard" do
|
175
|
+
expect(gui).to receive(:clipboard)
|
176
|
+
subject.clipboard
|
177
|
+
end
|
178
|
+
|
179
|
+
it "sets clipboard" do
|
180
|
+
expect(gui).to receive(:clipboard=).with("test")
|
181
|
+
subject.clipboard = "test"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "quitting" do
|
186
|
+
it "#quit tells the GUI to quit" do
|
187
|
+
expect(gui).to receive :quit
|
188
|
+
subject.quit
|
189
|
+
end
|
190
|
+
|
191
|
+
it '#close tells the GUI to quit' do
|
192
|
+
expect(gui).to receive :quit
|
193
|
+
subject.close
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "#started?" do
|
199
|
+
it "checks the window has been displayed or not" do
|
200
|
+
subject.started?
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe 'Execution context' do
|
205
|
+
it 'starts with self as the execution context' do
|
206
|
+
my_self = nil
|
207
|
+
app = Shoes.app do my_self = self end
|
208
|
+
expect(my_self).to eq app
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe '#append' do
|
213
|
+
let(:input_blk) {Proc.new do append do para 'Hi' end end}
|
214
|
+
|
215
|
+
it 'understands append' do
|
216
|
+
expect(subject).to respond_to :append
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should receive a call to what is called in the append block' do
|
220
|
+
expect_any_instance_of(Shoes::App).to receive :para
|
221
|
+
subject
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe '#resize' do
|
226
|
+
it 'understands resize' do
|
227
|
+
expect(subject).to respond_to :resize
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe 'fullscreen' do
|
232
|
+
context 'defaults' do
|
233
|
+
it 'is not fullscreen' do
|
234
|
+
expect(app).not_to be_fullscreen
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'can enter fullscreen' do
|
238
|
+
app.fullscreen = true
|
239
|
+
expect(app).to be_fullscreen
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe 'going into fullscreen and back out again' do
|
244
|
+
let(:defaults) { Shoes::InternalApp::DEFAULT_OPTIONS }
|
245
|
+
|
246
|
+
before :each do
|
247
|
+
app.fullscreen = true
|
248
|
+
app.fullscreen = false
|
249
|
+
end
|
250
|
+
|
251
|
+
# Failing on Mac fullscreen doesnt seem to work see #397
|
252
|
+
it 'is not in fullscreen', :fails_on_osx do
|
253
|
+
expect(app).not_to be_fullscreen
|
254
|
+
end
|
255
|
+
|
256
|
+
# Failing on Mac fullscreen doesnt seem to work see #397
|
257
|
+
it 'has its origina', :fails_on_osx do
|
258
|
+
expect(app.width).to eq(defaults[:width])
|
259
|
+
end
|
260
|
+
|
261
|
+
# Failing on Mac fullscreen doesnt seem to work see #397
|
262
|
+
it 'has its original height', :fails_on_osx do
|
263
|
+
expect(app.height).to eq(defaults[:height])
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe '#clear' do
|
269
|
+
let(:input_blk) do
|
270
|
+
Proc.new do
|
271
|
+
para 'Hello'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
let(:internal_app) {subject.instance_variable_get(:@__app__)}
|
275
|
+
|
276
|
+
it 'has initial contents' do
|
277
|
+
expect(subject.contents).to_not be_empty
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'removes everything (regression)' do
|
281
|
+
subject.clear
|
282
|
+
expect(subject.contents).to be_empty
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe "#gutter" do
|
287
|
+
context "when app has a scrollbar" do
|
288
|
+
let(:input_opts) { {width: 100, height: 100} }
|
289
|
+
let(:input_block) { Proc.new { para "Round peg, square hole" * 200 } }
|
290
|
+
|
291
|
+
it "has gutter of 16" do
|
292
|
+
expect(app.gutter).to be_within(1).of(16)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "when app has no scrollbar" do
|
297
|
+
let(:input_block) { Proc.new { para "Round peg, square hole" } }
|
298
|
+
|
299
|
+
it "has gutter of 16" do
|
300
|
+
expect(app.gutter).to be_within(1).of(16)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
describe "#parent" do
|
306
|
+
context "for a top-level element (not explicitly in a slot)" do
|
307
|
+
it "returns the top_slot" do
|
308
|
+
my_parent = nil
|
309
|
+
app = Shoes.app do
|
310
|
+
flow do
|
311
|
+
my_parent = parent
|
312
|
+
end
|
313
|
+
end
|
314
|
+
expect(my_parent).to eq app.instance_variable_get(:@__app__).top_slot
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
context "for an element within a slot" do
|
319
|
+
it "returns the enclosing slot" do
|
320
|
+
my_parent = nil
|
321
|
+
my_stack = nil
|
322
|
+
app = Shoes.app do
|
323
|
+
my_stack = stack do
|
324
|
+
flow do
|
325
|
+
my_parent = parent
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
expect(my_parent).to eq my_stack
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
end
|
335
|
+
|
336
|
+
describe "additional context" do
|
337
|
+
it "fails on unknown method" do
|
338
|
+
expect { subject.asdf }.to raise_error(NoMethodError)
|
339
|
+
end
|
340
|
+
|
341
|
+
it "calls through to context if available" do
|
342
|
+
context = double("context", asdf: nil)
|
343
|
+
expect(context).to receive(:asdf)
|
344
|
+
|
345
|
+
subject.eval_with_additional_context(context) do
|
346
|
+
asdf
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
it "clears context when finished" do
|
351
|
+
context = double("context")
|
352
|
+
|
353
|
+
captured_context = nil
|
354
|
+
subject.eval_with_additional_context(context) do
|
355
|
+
captured_context = @__additional_context__
|
356
|
+
end
|
357
|
+
|
358
|
+
expect(captured_context).to eq(context)
|
359
|
+
expect(subject.instance_variable_get(:@__additional_context__)).to be_nil
|
360
|
+
end
|
361
|
+
|
362
|
+
it "still clears context when failure in eval" do
|
363
|
+
context = double("context")
|
364
|
+
|
365
|
+
expect do
|
366
|
+
subject.eval_with_additional_context(context) { raise "O_o" }
|
367
|
+
end.to raise_error(RuntimeError)
|
368
|
+
|
369
|
+
expect(subject.instance_variable_get(:@__additional_context__)).to be_nil
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
describe 'subscribing to DSL methods' do
|
374
|
+
|
375
|
+
class TestSubscribeClass
|
376
|
+
attr_reader :app
|
377
|
+
def initialize(app)
|
378
|
+
@app = app
|
379
|
+
end
|
380
|
+
Shoes::App.subscribe_to_dsl_methods(self)
|
381
|
+
end
|
382
|
+
|
383
|
+
let(:subscribed_instance) {TestSubscribeClass.new subject}
|
384
|
+
|
385
|
+
AUTO_SUBSCRIBED_CLASSES = [Shoes::App, Shoes::URL, Shoes::Widget]
|
386
|
+
SUBSCRIBED_CLASSES = AUTO_SUBSCRIBED_CLASSES + [TestSubscribeClass]
|
387
|
+
|
388
|
+
describe '.subscribe_to_dsl_methods' do
|
389
|
+
it 'has its instances respond to the dsl methods of the app' do
|
390
|
+
expect(subscribed_instance).to respond_to :para, :image
|
391
|
+
end
|
392
|
+
|
393
|
+
it 'delegates does methods to the passed in app' do
|
394
|
+
expect(subject).to receive(:para)
|
395
|
+
subscribed_instance.para
|
396
|
+
end
|
397
|
+
|
398
|
+
SUBSCRIBED_CLASSES.each do |klazz|
|
399
|
+
it "#{klazz} responds to a regular DSL method" do
|
400
|
+
expect(klazz).to be_public_method_defined(:para)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
describe '.new_dsl_method (for widget method notifications etc.)' do
|
406
|
+
|
407
|
+
before :each do
|
408
|
+
Shoes::App.new_dsl_method :widget_method do
|
409
|
+
# noop
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
SUBSCRIBED_CLASSES.each do |klazz|
|
414
|
+
it "#{klazz} now responds to this method" do
|
415
|
+
expect(klazz).to be_public_method_defined(:widget_method)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
describe 'DELEGATE_METHODS' do
|
421
|
+
subject {Shoes::App::DELEGATE_METHODS}
|
422
|
+
|
423
|
+
describe 'does not include general ruby object methods' do
|
424
|
+
it {is_expected.not_to include :new, :initialize}
|
425
|
+
end
|
426
|
+
|
427
|
+
describe 'it has access to Shoes app and DSL methods' do
|
428
|
+
it {is_expected.to include :para, :rect, :stack, :flow, :image, :location}
|
429
|
+
end
|
430
|
+
|
431
|
+
describe 'it does not have access to private methods' do
|
432
|
+
it {is_expected.not_to include :pop_style, :style_normalizer, :create}
|
433
|
+
end
|
434
|
+
|
435
|
+
describe 'there are blacklisted methods that wreck havoc' do
|
436
|
+
it {is_expected.not_to include :parent, :app}
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
describe "App registry" do
|
444
|
+
subject { Shoes.apps }
|
445
|
+
|
446
|
+
before :each do
|
447
|
+
Shoes.unregister_all
|
448
|
+
end
|
449
|
+
|
450
|
+
it "only exposes a copy" do
|
451
|
+
subject << double("app")
|
452
|
+
expect(Shoes.apps.length).to eq(0)
|
453
|
+
end
|
454
|
+
|
455
|
+
context "with no apps" do
|
456
|
+
it { is_expected.to be_empty }
|
457
|
+
end
|
458
|
+
|
459
|
+
context "with one app" do
|
460
|
+
let(:app) { double('app') }
|
461
|
+
before :each do
|
462
|
+
Shoes.register(app)
|
463
|
+
end
|
464
|
+
|
465
|
+
its(:length) { should eq(1) }
|
466
|
+
it "marks first app as main app" do
|
467
|
+
expect(Shoes.main_app).to be(app)
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
context "with two apps" do
|
472
|
+
let(:app_1) { double("app 1") }
|
473
|
+
let(:app_2) { double("app 2") }
|
474
|
+
|
475
|
+
before :each do
|
476
|
+
[app_1, app_2].each { |a| Shoes.register(a) }
|
477
|
+
end
|
478
|
+
|
479
|
+
its(:length) { should eq(2) }
|
480
|
+
it "marks first app as main app" do
|
481
|
+
expect(Shoes.main_app).to be(app_1)
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|