File: test_tee_surface.rb

package info (click to toggle)
ruby-cairo 1.17.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,532 kB
  • sloc: ruby: 11,997; ansic: 10,183; sh: 48; makefile: 4
file content (34 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class TeeSurfaceTest < Test::Unit::TestCase
  include Helper

  def setup
    only_surface("Tee")
    only_surface("Script")
  end

  def test_new
    output1 = StringIO.new
    device1 = Cairo::ScriptDevice.new(output1)
    Cairo::ScriptSurface.create(device1, 100, 200) do |surface1|
      output2 = StringIO.new
      device2 = Cairo::ScriptDevice.new(output2)
      Cairo::ScriptSurface.create(device2, 100, 200) do |surface2|
        Cairo::TeeSurface.create(surface1) do |surface|
          surface << surface2
          Cairo::Context.create(surface) do |context|
            context.move_to(15, 30)
            context.line_to(80, 100)
            context.stroke
          end
          assert_equal(<<-SCRIPT, output1.string)
%!CairoScript
<< /content //COLOR_ALPHA /width 100 /height 200 >> surface context
n 15 30 m 80 100 l
stroke+
          SCRIPT
          assert_equal(output1.string, output2.string)
        end
      end
    end
  end
end