[cairo-commit] rcairo/test test_scaled_font.rb, 1.1, 1.2 test_text_cluster.rb, NONE, 1.1

Kouhei Sutou commit at pdx.freedesktop.org
Sat Aug 16 01:16:42 PDT 2008


Committed by: kou

Update of /cvs/cairo/rcairo/test
In directory kemper:/tmp/cvs-serv8545/test

Modified Files:
	test_scaled_font.rb 
Added Files:
	test_text_cluster.rb 
Log Message:
        * test/test_text_cluster.rb: add tests for Cairo::TextCluster.

        * test/test_scaled_font.rb (ScaledFontTest#test_text_to_glyphs):
        add a test for Cairo::ScaledFont#text_to_glyphs.

        * src/rb_cairo.h, src/rb_cairo.c, src/cairo.def,
        src/rb_cairo_text_cluster.c: add Cairo::TextCluster.

        * src/rb_cairo_scaled_font.c: support
        Cairo::ScaledFont#text_to_glyphs.

        * src/rb_cairo_private.[ch] (rb_cairo__glyphs_to_ruby_object),
        (rb_cairo__text_clusters_to_ruby_object): add.


Index: test_scaled_font.rb
===================================================================
RCS file: /cvs/cairo/rcairo/test/test_scaled_font.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_scaled_font.rb	14 Aug 2008 12:37:51 -0000	1.1
+++ test_scaled_font.rb	16 Aug 2008 08:16:40 -0000	1.2
@@ -1,4 +1,5 @@
 require 'cairo'
+require 'stringio'
 
 class ScaledFontTest < Test::Unit::TestCase
   include CairoTestUtils
@@ -14,4 +15,20 @@
                                    10.0, 0.0, 0.0),
                  scaled_font.scale_matrix)
   end
+
+  def test_text_to_glyphs
+    only_cairo_version(1, 7, 2)
+
+    surface = Cairo::PDFSurface.new(StringIO.new, 10, 10)
+    context = Cairo::Context.new(surface)
+    scaled_font = Cairo::ScaledFont.new(context.font_face,
+                                        Cairo::Matrix.identity,
+                                        Cairo::Matrix.identity,
+                                        Cairo::FontOptions.new)
+    expected_glyphs = []
+    expected_clusters = []
+    expected_backward = false
+    assert_equal([expected_glyphs, expected_clusters, expected_backward],
+                 scaled_font.text_to_glyphs(0, 0, "text"))
+  end
 end

--- NEW FILE: test_text_cluster.rb ---
require 'cairo'

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

  def test_new
    only_cairo_version(1, 7, 2)

    cluster = Cairo::TextCluster.new(2, 3)
    assert_equal([2, 3], [cluster.num_bytes, cluster.num_glyphs])
    assert_equal("#<Cairo::TextCluster: num_bytes=2, num_glyphs=3>",
                 cluster.to_s)
  end

  def test_accessor
    only_cairo_version(1, 7, 2)

    cluster = Cairo::TextCluster.new(5, 7)
    assert_equal([5, 7], [cluster.num_bytes, cluster.num_glyphs])
    cluster.num_bytes = 1
    cluster.num_glyphs = 2
    assert_equal([1, 2], [cluster.num_bytes, cluster.num_glyphs])
  end

  def test_to_s
    only_cairo_version(1, 7, 2)

    cluster = Cairo::TextCluster.new(9, 1)
    assert_equal("#<Cairo::TextCluster: num_bytes=9, num_glyphs=1>",
                 cluster.to_s)
  end
end



More information about the cairo-commit mailing list