spec/shoes/swt/text_block/painter_spec.rb in shoes-swt-4.0.0.pre4 vs spec/shoes/swt/text_block/painter_spec.rb in shoes-swt-4.0.0.pre5
- old
+ new
@@ -1,15 +1,20 @@
-require 'shoes/swt/spec_helper'
+require 'spec_helper'
describe Shoes::Swt::TextBlock::Painter do
include_context "swt app"
- let(:dsl) { double("dsl", app: shoes_app, gui: gui, hidden?: false) }
- let(:gui) { double("gui", dispose: nil, segments: segment_collection) }
- let(:event) { double("event").as_null_object }
+ let(:parent) { double("parent", absolute_left: 0, absolute_top: 0, height: 100, width: 200) }
+ let(:dsl) { double("dsl", app: shoes_app, gui: gui, parent: parent, hidden?: false) }
+ let(:gui) { double("gui", dispose: nil, segments: segment_collection) }
let(:segment_collection) { double("segment collection", empty?: false) }
+ let(:event) { double("event", gc: graphics_context).as_null_object }
+ let(:graphics_context) { double("graphics context", set_antialias: nil,
+ set_line_cap: nil, set_transform: nil,
+ clipping: nil, set_clipping: nil) }
+
subject { Shoes::Swt::TextBlock::Painter.new(dsl) }
it "doesn't draw if hidden" do
allow(dsl).to receive(:hidden?) { true }
expect(segment_collection).to_not receive(:paint_control)
@@ -26,9 +31,15 @@
it "doesn't draw segment collection is empty" do
allow(segment_collection).to receive(:empty?) { true }
expect(segment_collection).to_not receive(:paint_control)
+ subject.paintControl(event)
+ end
+
+ it "clips to parent" do
+ expect(segment_collection).to receive(:paint_control)
+ expect(graphics_context).to receive(:set_clipping).with(0, 0, 200, 100)
subject.paintControl(event)
end
it "paints" do
expect(segment_collection).to receive(:paint_control)