File: test_font_options.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 (84 lines) | stat: -rw-r--r-- 1,875 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
require 'cairo'

class FontOptionsTest < Test::Unit::TestCase
  include Helper

  def setup
    @options = Cairo::FontOptions.new
  end

  sub_test_case "#==" do
    test "not FontOptions" do
      assert do
        !(@options == nil)
      end
    end

    test "same object" do
      assert do
        @options == @options
      end
    end

    test "same content" do
      assert do
        @options == @options.dup
      end
    end
  end

  sub_test_case "#eql? and #hash" do
    test "not FontOptions" do
      object = Object.new
      options = @options
      object.singleton_class.__send__(:define_method, :hash) do
        options.hash
      end

      hash = {
        object => :value,
      }
      assert_nil(hash[@options])
    end

    test "same object" do
      hash = {
        @options => :value,
      }
      assert_equal(:value, hash[@options])
    end

    test "same content" do
      hash = {
        @options => :value,
      }
      assert_equal(:value, hash[@options.dup])
    end
  end

  test "variations" do
    only_cairo_version(1, 15, 12)
    assert_nil(@options.variations)
    @options.variations = "wdth=200"
    assert_equal("wdth=200", @options.variations)
  end

  test "color mode" do
    only_cairo_version(1, 17, 8)
    assert_equal(Cairo::ColorMode::DEFAULT, @options.color_mode)
    @options.color_mode = Cairo::ColorMode::COLOR
    assert_equal(Cairo::ColorMode::COLOR, @options.color_mode)
  end

  test "color palette" do
    only_cairo_version(1, 17, 8)
    assert_equal(Cairo::ColorPalette::DEFAULT, @options.color_palette)
    @options.set_custom_palette_color(1,
                                      1.0,
                                      0.2,
                                      0.0,
                                      0.8)
    @options.color_palette = 1
    assert_equal(1, @options.color_palette)
  end
end