Browse Source

Fixing up regression tests for release

dev
Andy Meneely 11 years ago
parent
commit
0185f2dfcf
  1. 25
      spec/data/samples/config_text_markup.rb.txt
  2. 9
      spec/data/samples/embed_text.rb.txt
  3. 3
      spec/graphics/graphics_text_spec.rb
  4. 2
      spec/samples/samples_regression_spec.rb
  5. 13
      spec/spec_helper.rb

25
spec/data/samples/config_text_markup.rb.txt

@ -1,4 +1,8 @@
cairo: antialias=(["subpixel"]) cairo: antialias=(["gray"])
cairo: save([])
cairo: set_source_color([:white])
cairo: paint([])
cairo: restore([])
cairo: save([]) cairo: save([])
cairo: set_source_color([:black]) cairo: set_source_color([:black])
cairo: translate([10, 10]) cairo: translate([10, 10])
@ -23,6 +27,25 @@ cairo: set_source_color([:cyan])
cairo: set_line_width([2.0]) cairo: set_line_width([2.0])
cairo: stroke([]) cairo: stroke([])
cairo: restore([]) cairo: restore([])
cairo: save([])
cairo: set_source_color([:black])
cairo: translate([320, 10])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["Notice also the antialiasing method."])
pango: width=([307200])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
pango: justify=([false])
pango: spacing=([0])
cairo: update_pango_layout([MockDouble])
cairo: move_to([0, 0])
cairo: update_pango_layout([MockDouble])
cairo: show_pango_layout([MockDouble])
cairo: restore([])
surface: write_to_png(["_output/config_text_00.png"]) surface: write_to_png(["_output/config_text_00.png"])
cairo: antialias=(["subpixel"]) cairo: antialias=(["subpixel"])
cairo: save([]) cairo: save([])

9
spec/data/samples/embed_text.rb.txt

@ -286,13 +286,10 @@ cairo: restore([])
surface: write_to_png(["_output/embed_multi_00.png"]) surface: write_to_png(["_output/embed_multi_00.png"])
surface: write_to_png(["_output/embed_multi_01.png"]) surface: write_to_png(["_output/embed_multi_01.png"])
surface: write_to_png(["_output/embed_multi_02.png"]) surface: write_to_png(["_output/embed_multi_02.png"])
surface: write_to_png(["_output/embed_multisheet_00.png"])
cairo: set_source([MockDouble, 0, 0]) cairo: set_source([MockDouble, 0, 0])
cairo: paint([]) cairo: paint([])
surface: write_to_png(["_output/embed_multisheet_01.png"]) cairo: set_source([MockDouble, 100, 0])
cairo: set_source([MockDouble, 0, 0])
cairo: paint([]) cairo: paint([])
surface: write_to_png(["_output/embed_multisheet_02.png"]) cairo: set_source([MockDouble, 200, 0])
cairo: set_source([MockDouble, 0, 0])
cairo: paint([]) cairo: paint([])
surface: write_to_png(["_output/embed_multisheet_03.png"]) surface: write_to_png(["_output/embed_multisheet_00.png"])

3
spec/graphics/graphics_text_spec.rb

@ -8,6 +8,7 @@ describe Squib::Card, '#text' do
let(:context) { double(Cairo::Context) } let(:context) { double(Cairo::Context) }
let(:layout) { double(Pango::Layout) } let(:layout) { double(Pango::Layout) }
let(:font_desc) { double(Pango::FontDescription) } let(:font_desc) { double(Pango::FontDescription) }
let(:pango_cxt) { double(Pango::Context) }
before(:each) do before(:each) do
allow(Cairo::Context).to receive(:new).and_return(context) allow(Cairo::Context).to receive(:new).and_return(context)
@ -15,6 +16,7 @@ describe Squib::Card, '#text' do
allow(deck).to receive(:count_format).and_return('%02d') allow(deck).to receive(:count_format).and_return('%02d')
allow(deck).to receive(:prefix).and_return('card_') allow(deck).to receive(:prefix).and_return('card_')
allow(deck).to receive(:antialias).and_return('best') allow(deck).to receive(:antialias).and_return('best')
allow(layout).to receive(:context).and_return(pango_cxt)
end end
it 'make all the expected calls on a smoke test' do it 'make all the expected calls on a smoke test' do
@ -34,6 +36,7 @@ describe Squib::Card, '#text' do
expect(layout ).to receive(:height=).with(25 * Pango::SCALE).once expect(layout ).to receive(:height=).with(25 * Pango::SCALE).once
expect(layout ).to receive(:ellipsize=).with(Pango::Layout::ELLIPSIZE_NONE).once expect(layout ).to receive(:ellipsize=).with(Pango::Layout::ELLIPSIZE_NONE).once
expect(layout ).to receive(:alignment=).with(Pango::Layout::ALIGN_LEFT).once expect(layout ).to receive(:alignment=).with(Pango::Layout::ALIGN_LEFT).once
expect(pango_cxt).to receive(:font_options=).once
expect(layout ).to receive(:justify=).with(false).once expect(layout ).to receive(:justify=).with(false).once
expect(layout ).to receive(:spacing=).with(1.0 * Pango::SCALE).once expect(layout ).to receive(:spacing=).with(1.0 * Pango::SCALE).once
expect(context).to receive(:update_pango_layout).once expect(context).to receive(:update_pango_layout).once

2
spec/samples/samples_regression_spec.rb

@ -71,7 +71,7 @@ describe "Squib samples" do
log = StringIO.new log = StringIO.new
mock_cairo(log) mock_cairo(log)
load sample load sample
overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log # overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log
test_file_str = File.open(sample_regression_file(sample), 'r:UTF-8').read test_file_str = File.open(sample_regression_file(sample), 'r:UTF-8').read
expect(log.string).to eq(test_file_str) expect(log.string).to eq(test_file_str)
end end

13
spec/spec_helper.rb

@ -55,12 +55,13 @@ end
# Build a mock cairo instance that allows basically any method # Build a mock cairo instance that allows basically any method
# and logs that call to the string buffer # and logs that call to the string buffer
def mock_cairo(strio) def mock_cairo(strio)
cxt = double(Cairo::Context) cxt = double(Cairo::Context)
surface = double(Cairo::ImageSurface) surface = double(Cairo::ImageSurface)
pango = double(Pango::Layout) pango = double(Pango::Layout)
font = double(Pango::FontDescription) font = double(Pango::FontDescription)
iter = double('pango_iter') iter = double('pango_iter')
pango_cxt = double('pango_cxt')
allow(Squib.logger).to receive(:warn) {} allow(Squib.logger).to receive(:warn) {}
allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new) allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new)
allow(Cairo::ImageSurface).to receive(:new).and_return(surface) allow(Cairo::ImageSurface).to receive(:new).and_return(surface)
@ -77,6 +78,8 @@ def mock_cairo(strio)
allow(pango).to receive(:iter).and_return(iter) allow(pango).to receive(:iter).and_return(iter)
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT) allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
allow(pango).to receive(:text).and_return("foo") allow(pango).to receive(:text).and_return("foo")
allow(pango).to receive(:context).and_return(pango_cxt)
allow(pango_cxt).to receive(:font_options=)
allow(iter).to receive(:next_char!).and_return(false) allow(iter).to receive(:next_char!).and_return(false)
allow(iter).to receive(:char_extents).and_return(Pango::Rectangle.new(5,5,5,5)) allow(iter).to receive(:char_extents).and_return(Pango::Rectangle.new(5,5,5,5))
allow(iter).to receive(:index).and_return(1000) allow(iter).to receive(:index).and_return(1000)

Loading…
Cancel
Save