spec/shoes/swt/common/painter_spec.rb in shoes-swt-4.0.0.pre4 vs spec/shoes/swt/common/painter_spec.rb in shoes-swt-4.0.0.pre5

- old
+ new

@@ -1,14 +1,18 @@ -require 'shoes/swt/spec_helper' +require 'spec_helper' describe Shoes::Swt::Common::Painter do let(:object) {double 'object', dsl: dsl, transform: transform, - apply_fill: nil, apply_stroke: nil} - let(:dsl) {double 'dsl', visible?: true, positioned?: true, style: Hash.new} + apply_fill: nil, apply_stroke: nil} + let(:parent) {double 'parent', absolute_left: 0, absolute_top: 0, + width: 200, height: 100, fixed_height?: true} + let(:dsl) {double 'dsl', parent: parent, + visible?: true, positioned?: true, style: {}} let(:event) {double 'paint event', gc: graphics_context} let(:graphics_context) { double 'graphics_context', dispose: nil, + clipping: nil, set_clipping: nil, set_antialias: nil, set_line_cap: nil, set_transform: nil, setTransform: nil } let(:transform) { double 'transform', disposed?: false } subject {Shoes::Swt::Common::Painter.new object} @@ -29,9 +33,15 @@ end it 'does not paint the object if it is not positioned' do allow(dsl).to receive_messages positioned?: false expect(subject).not_to receive(:paint_object) + subject.paint_control event + end + + it 'clips to parent region' do + allow(dsl).to receive(:needs_rotate?) { false } + expect(graphics_context).to receive(:set_clipping).with(0, 0, 200, 100) subject.paint_control event end it 'rotates' do allow(dsl).to receive(:needs_rotate?) { true }