Browse Source

samples: cleanup regression tests

dev
Andy Meneely 10 years ago
parent
commit
dd32e3bfae
  1. 2
      samples/images
  2. 99
      samples/load_images.rb
  3. 73
      spec/data/samples/autoscale_font/_autoscale_font.rb.txt
  4. 24
      spec/data/samples/cairo_access.rb.txt
  5. 0
      spec/data/samples/images/_more_load_images.rb.txt
  6. 0
      spec/data/samples/shapes/_draw_shapes.rb.txt
  7. 8
      spec/samples/samples_regression_spec.rb

2
samples/images

@ -1 +1 @@
Subproject commit c5999924d5fa9102529f0e06248adb84eeef8780 Subproject commit 8f892ecb3b2d6442466a0a1996fdcbc110f31b16

99
samples/load_images.rb

@ -1,99 +0,0 @@
require 'squib'
Squib::Deck.new(width: 825, height: 1125, cards: 1, config: 'load_images_config.yml') do
background color: '#0b7c8e'
rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
png file: 'shiny-purse.png', x: 620, y: 75 # no scaling is done by default
svg file: 'spanner.svg', x: 620, y: 218
# Can be scaled if width and height are set
svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
png file: 'shiny-purse.png', x: 305, y: 50, width: 250, height: 250
# ...but PNGs will warn if it's an upscale, unless you disable them in config.yml
# Can be scaled using just width or height, if one of them is set to :scale
svg file: 'spanner.svg', x: 200, y: 350, width: 35, height: :scale
svg file: 'spanner.svg', x: 200, y: 390, width: :scale, height: 35
png file: 'shiny-purse.png', x: 240, y: 350, width: 35, height: :scale
png file: 'shiny-purse.png', x: 240, y: 390, width: :scale, height: 35
# You can also crop the loaded images, so you can work from a sprite sheet
png file: 'sprites.png', x: 300, y: 350 # entire sprite sheet
png file: 'sprites.png', x: 300, y: 425, # just the robot golem image
crop_x: 0, crop_y: 0, crop_corner_radius: 10,
crop_width: 64, crop_height: 64
png file: 'sprites.png', x: 400, y: 425, # just the drakkar ship image
crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
crop_width: 64, crop_height: 64
png file: 'sprites.png', x: 500, y: 415, # just the drakkar ship image, rotated
crop_x: 64, crop_y: 0, crop_corner_x_radius: 25, crop_corner_y_radius: 25,
crop_width: 64, crop_height: 64, angle: Math::PI / 6
# Cropping also works on SVGs too
svg file: 'spanner.svg', x: 300, y: 500, width: 64, height: 64,
crop_x: 32, crop_y: 32, crop_width: 32, crop_height:32
# We can flip our images too
png file: 'sprites.png', x: 300, y: 535, flip_vertical: true, flip_horizontal: true
svg file: 'spanner.svg', x: 300, y: 615, width: 64, height: 64,
flip_vertical: true, flip_horizontal: true
# We can also limit our rendering to a single object, if the SVG ID is set
svg file: 'spanner.svg', id: '#backdrop', x: 50, y: 350, width: 75, height: 75
# Squib prepends a #-sign if one is not specified
svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
# We can also load SVGs as a string of XML
svg data: File.read('spanner.svg'), x: 50, y: 600, width: 75, height: 75
# The svg data field works nicely with modifying the SVG XML on-the-fly.
# To run this one, do `gem install game_icons` and uncomment the following
#
# require 'game_icons'
# svg data: GameIcons.get('angler-fish').recolor(fg: '#ccc', bg: '#333').string,
# x: 150, y: 600, width: 75, height: 75
#
# More examples at https://github.com/andymeneely/game_icons
# (or `gem install game_icons`) to get & manipulate art from game-icons.net
# Nokogiri (already included in Squib) is also great for XML manipulation.
# WARNING! If you choose to use the SVG ID, the x-y coordinates are still
# relative to the SVG page. See this example in an SVG editor
svg file: 'offset.svg', id: 'thing', x: 0, y: 0, width: 600, height: 600
# Over 15 different blending operators are supported.
# See http://cairographics.org/operators
# Alpha transparency too
png file: 'ball.png', x: 50, y: 700
png file: 'grit.png', x: 70, y: 750, blend: :color_burn, alpha: 0.75
# Images can be rotated around their upper-left corner
png file: 'shiny-purse.png', x: 300, y: 700, angle: 0.0 # default (no rotate)
png file: 'shiny-purse.png', x: 300, y: 800, angle: Math::PI / 4
svg file: 'spanner.svg', x: 300, y: 900, angle: Math::PI / 2 - 0.1
# Images can also be used as masks instead of being directly painted.
# This is particularly useful for switching directly over to black-and-white for printing
# Or, if you want the same image to be used but with different colors/gradients
svg mask: '#00ff00',
file: 'glass-heart.svg',
x: 500, y: 600, width: 200, height: 200
svg mask: '(0,0)(0,500) #ccc@0.0 #333@1.0',
file: 'glass-heart.svg',
x: 500, y: 800, width: 200, height: 200
# Masks are based on the alpha channel, so this is just a magenta square
png mask: :magenta, file: 'shiny-purse.png',
x: 650, y: 950
# Note that this method does nothing, even though it would normally fill up
# the card. force_id: true looks to the id field to be non-empty to render.
# This is useful if you have multiple different icons in one SVG file,
# but sometimes want to use none.
# e.g. id: [:attack, :defend, nil]
svg file: 'spanner.svg', width: :deck, height: :deck,
force_id: true, id: '' # <-- the important part
save prefix: 'load_images_', format: :png
end

73
spec/data/samples/autoscale_font.rb.txt → spec/data/samples/autoscale_font/_autoscale_font.rb.txt

@ -14,16 +14,49 @@ cairo: set_source_color(["white"])
cairo: paint([]) cairo: paint([])
cairo: restore([]) cairo: restore([])
cairo: save([]) cairo: save([])
cairo: rounded_rectangle([0, 0, 300, 100, 0, 0])
cairo: set_source_color(["#0000"])
cairo: fill_preserve([])
cairo: set_source_color(["black"]) cairo: set_source_color(["black"])
cairo: translate([65, 400]) cairo: set_line_width([2.0])
cairo: set_line_join([0])
cairo: set_line_cap([0])
cairo: set_dash([[]])
cairo: stroke([])
cairo: restore([])
cairo: save([])
cairo: rounded_rectangle([0, 0, 300, 100, 0, 0])
cairo: set_source_color(["#0000"])
cairo: fill_preserve([])
cairo: set_source_color(["black"])
cairo: set_line_width([2.0])
cairo: set_line_join([0])
cairo: set_line_cap([0])
cairo: set_dash([[]])
cairo: stroke([])
cairo: restore([])
cairo: save([])
cairo: rounded_rectangle([0, 0, 300, 100, 0, 0])
cairo: set_source_color(["#0000"])
cairo: fill_preserve([])
cairo: set_source_color(["black"])
cairo: set_line_width([2.0])
cairo: set_line_join([0])
cairo: set_line_cap([0])
cairo: set_dash([[]])
cairo: stroke([])
cairo: restore([])
cairo: save([])
cairo: set_source_color(["black"])
cairo: translate([10, 10])
cairo: rotate([0]) cairo: rotate([0])
cairo: move_to([0, 0]) cairo: move_to([0, 0])
pango font: size=([128000]) pango font: size=([32768])
pango: font_description=([MockDouble]) pango: font_description=([MockDouble])
pango: text=(["ShortBig"]) pango: text=(["Short & Big"])
pango: width=([716800]) pango: width=([286720])
pango: wrap=([#<Pango::Layout::WrapMode word-char>]) pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>]) pango: ellipsize=([#<Pango::Layout::EllipsizeMode none>])
pango: alignment=([#<Pango::Layout::Alignment center>]) pango: alignment=([#<Pango::Layout::Alignment center>])
pango: justify=([false]) pango: justify=([false])
cairo: move_to([0, 0]) cairo: move_to([0, 0])
@ -37,15 +70,15 @@ pango: ellipsized?([])
cairo: restore([]) cairo: restore([])
cairo: save([]) cairo: save([])
cairo: set_source_color(["black"]) cairo: set_source_color(["black"])
cairo: translate([65, 400]) cairo: translate([10, 10])
cairo: rotate([0]) cairo: rotate([0])
cairo: move_to([0, 0]) cairo: move_to([0, 0])
pango font: size=([46080]) pango font: size=([18432])
pango: font_description=([MockDouble]) pango: font_description=([MockDouble])
pango: text=(["Medium_Length_Name"]) pango: text=(["Medium Length & Size"])
pango: width=([716800]) pango: width=([286720])
pango: wrap=([#<Pango::Layout::WrapMode word-char>]) pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>]) pango: ellipsize=([#<Pango::Layout::EllipsizeMode none>])
pango: alignment=([#<Pango::Layout::Alignment center>]) pango: alignment=([#<Pango::Layout::Alignment center>])
pango: justify=([false]) pango: justify=([false])
cairo: move_to([0, 0]) cairo: move_to([0, 0])
@ -59,15 +92,15 @@ pango: ellipsized?([])
cairo: restore([]) cairo: restore([])
cairo: save([]) cairo: save([])
cairo: set_source_color(["black"]) cairo: set_source_color(["black"])
cairo: translate([65, 400]) cairo: translate([10, 10])
cairo: rotate([0]) cairo: rotate([0])
cairo: move_to([0, 0]) cairo: move_to([0, 0])
pango font: size=([36864]) pango font: size=([12288])
pango: font_description=([MockDouble]) pango: font_description=([MockDouble])
pango: text=(["Super_Duper_Long_Name"]) pango: text=(["Super duper long string here, therefore a smaller font."])
pango: width=([716800]) pango: width=([286720])
pango: wrap=([#<Pango::Layout::WrapMode word-char>]) pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>]) pango: ellipsize=([#<Pango::Layout::EllipsizeMode none>])
pango: alignment=([#<Pango::Layout::Alignment center>]) pango: alignment=([#<Pango::Layout::Alignment center>])
pango: justify=([false]) pango: justify=([false])
cairo: move_to([0, 0]) cairo: move_to([0, 0])
@ -79,6 +112,10 @@ cairo: set_line_width([2.0])
cairo: stroke([]) cairo: stroke([])
pango: ellipsized?([]) pango: ellipsized?([])
cairo: restore([]) cairo: restore([])
surface: write_to_png(["_output/autoscale_00.png"]) cairo: set_source([MockDouble, 0, 0])
surface: write_to_png(["_output/autoscale_01.png"]) cairo: paint([])
surface: write_to_png(["_output/autoscale_02.png"]) cairo: set_source([MockDouble, 100, 0])
cairo: paint([])
cairo: set_source([MockDouble, 200, 0])
cairo: paint([])
surface: write_to_png(["./card_00.png"])

24
spec/data/samples/cairo_access.rb.txt

@ -23,5 +23,29 @@ cairo: circle([50, 50, 50])
cairo: set_source_color([:red]) cairo: set_source_color([:red])
cairo: fill([]) cairo: fill([])
cairo: restore([]) cairo: restore([])
cairo: translate([500, 500])
cairo: translate([500, 500])
cairo: save([])
cairo: rounded_rectangle([0, 0, 50, 50, 0, 0])
cairo: set_source_color(["red"])
cairo: fill_preserve([])
cairo: set_source_color(["black"])
cairo: set_line_width([2.0])
cairo: set_line_join([0])
cairo: set_line_cap([0])
cairo: set_dash([[]])
cairo: stroke([])
cairo: restore([])
cairo: save([])
cairo: rounded_rectangle([0, 0, 50, 50, 0, 0])
cairo: set_source_color(["red"])
cairo: fill_preserve([])
cairo: set_source_color(["black"])
cairo: set_line_width([2.0])
cairo: set_line_join([0])
cairo: set_line_cap([0])
cairo: set_dash([[]])
cairo: stroke([])
cairo: restore([])
surface: write_to_png(["_output/cairo_access_00.png"]) surface: write_to_png(["_output/cairo_access_00.png"])
surface: write_to_png(["_output/cairo_access_01.png"]) surface: write_to_png(["_output/cairo_access_01.png"])

0
spec/data/samples/load_images.rb.txt → spec/data/samples/images/_more_load_images.rb.txt

0
spec/data/samples/draw_shapes.rb.txt → spec/data/samples/shapes/_draw_shapes.rb.txt

8
spec/samples/samples_regression_spec.rb

@ -38,19 +38,19 @@ describe 'Squib samples' do
# These are samples that don't really need a regression log # These are samples that don't really need a regression log
# colors.rb # colors.rb
# unicode.rb # unicode.rb
%w( autoscale_font.rb %w( autoscale_font/_autoscale_font.rb
basic.rb basic.rb
cairo_access.rb cairo_access.rb
csv_import.rb csv_import.rb
config_text_markup.rb config_text_markup.rb
custom_config.rb custom_config.rb
draw_shapes.rb shapes/_draw_shapes.rb
embed_text.rb embed_text.rb
excel.rb excel.rb
gradients.rb gradients.rb
hand.rb hand.rb
hello_world.rb hello_world.rb
load_images.rb images/_more_load_images.rb
portrait-landscape.rb portrait-landscape.rb
ranges.rb ranges.rb
saves.rb saves.rb
@ -63,7 +63,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

Loading…
Cancel
Save