Sha256: 9b529790bdbc4a8e6649bac6783e8e029322bb9979ca651dccd9dd3f33413718

Contents?: true

Size: 1.57 KB

Versions: 67

Compression:

Stored size: 1.57 KB

Contents

require 'cairo'
require 'stringio'

class SurfaceTest < Test::Unit::TestCase
  include CairoTestUtils

  def test_new
    output = StringIO.new
    surface = Cairo::PDFSurface.new(output, 10, 10)
    assert_not_equal("%%EOF\n", output.string[-6..-1])
    surface.finish
    assert_equal("%%EOF\n", output.string[-6..-1])
  end

  def test_new_with_block
    output = StringIO.new
    Cairo::PDFSurface.new(output, 10, 10) do |surface|
      assert_not_equal("%%EOF\n", output.string[-6..-1])
    end
    assert_equal("%%EOF\n", output.string[-6..-1])
  end

  def test_new_with_block_and_finish
    assert_nothing_raised do
      Cairo::PDFSurface.new(StringIO.new, 10, 10) do |surface|
        surface.finish
      end
    end
  end

  def test_device_scale
    only_cairo_version(1, 14, 0)
    surface = Cairo::ImageSurface.new(100, 100)

    assert_equal([1.0, 1.0], surface.device_scale)

    surface.set_device_scale(3.0, 4.0)
    assert_equal([3.0, 4.0], surface.device_scale)
  end

  def test_fallback_resolution
    only_cairo_version(1, 7, 2)

    surface = Cairo::ImageSurface.new(100, 100)

    assert_equal([300.0, 300.0], surface.fallback_resolution)

    surface.set_fallback_resolution(95, 95)
    assert_equal([95.0, 95.0], surface.fallback_resolution)
  end

  def test_mime_data
    only_cairo_version(1, 10, 0)

    output = StringIO.new
    surface = Cairo::PDFSurface.new(output, 100, 100)
    surface.set_mime_data(Cairo::MimeType::URI, "http://cairo.rubyforge.org/")
    assert_equal("http://cairo.rubyforge.org/",
                 surface.get_mime_data(Cairo::MimeType::URI))
  end
end

Version data entries

67 entries across 59 versions & 2 rubygems

Version Path
cairo-1.15.13-x64-mingw32 test/test_surface.rb
cairo-1.15.13-x86-mingw32 test/test_surface.rb
cairo-1.15.13 test/test_surface.rb
cairo-1.15.12-x64-mingw32 test/test_surface.rb
cairo-1.15.12-x86-mingw32 test/test_surface.rb
cairo-1.15.12 test/test_surface.rb
cairo-1.15.11-x64-mingw32 test/test_surface.rb
cairo-1.15.11-x86-mingw32 test/test_surface.rb
cairo-1.15.11 test/test_surface.rb
cairo-1.15.10-x86-mingw32 test/test_surface.rb
cairo-1.15.10-x64-mingw32 test/test_surface.rb
cairo-1.15.10 test/test_surface.rb
cairo-1.15.9-x64-mingw32 test/test_surface.rb
cairo-1.15.9 test/test_surface.rb
cairo-1.15.9-x86-mingw32 test/test_surface.rb
cairo-1.15.8-x86-mingw32 test/test_surface.rb
cairo-1.15.8-x64-mingw32 test/test_surface.rb
cairo-1.15.8 test/test_surface.rb
cairo-1.15.7-x64-mingw32 test/test_surface.rb
cairo-1.15.7-x86-mingw32 test/test_surface.rb