Sha256: 50b7c8100d3ab247393e65f316d9ea6a0b968ad5be99356350257eebbe867942

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require 'shoes/swt/spec_helper'

describe Shoes::Swt::RectPainter do
  include_context "painter context"

  let(:corners) { 0 }
  let(:app) { double('app', :real => container, :add_paint_listener => true, :dsl => dsl) }
  let(:container) { double('container', :disposed? => false) }
  let(:dsl) { double("dsl object", hidden: false, rotate: 0,
                     element_left: left, element_top: top,
                     element_width: width, element_height: height,
                     curve: corners).as_null_object }
  let(:left) { 55 }
  let(:top) { 77 }
  let(:width) { 222 }
  let(:height) { 111 }
  let(:shape) { Shoes::Swt::Rect.new dsl, app}
  subject { Shoes::Swt::RectPainter.new shape }

  it_behaves_like "fill painter"
  it_behaves_like "stroke painter"

  describe "square corners" do
    let(:corners) { 0 }

    it "fills rect" do
      expect(gc).to receive(:fill_round_rectangle).with(left, top, width, height, corners*2, corners*2)
      subject.paint_control(event)
    end

    it "draws rect" do
      expect(gc).to receive(:draw_round_rectangle).with(left+sw/2, top+sw/2, width-sw, height-sw, corners*2, corners*2)
      subject.paint_control(event)
    end
  end

  describe "round corners" do
    let(:corners) { 13 }

    it "draws rect with rounded corners" do
      expect(gc).to receive(:draw_round_rectangle).with(left+sw/2, top+sw/2, width-sw, height-sw, corners*2, corners*2)
      subject.paint_control(event)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre4 spec/shoes/swt/rect_painter_spec.rb
shoes-swt-4.0.0.pre3 spec/shoes/swt/rect_painter_spec.rb