blob: 278a4cf940d129cc3d9a9ee56739985cee34a4d3 (
plain)
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
|
# -*- coding: utf-8 -*-
require 'test/unit'
$cairo = true
require File.expand_path(File.dirname(__FILE__) + '/../helper')
# require File.expand_path(File.dirname(__FILE__) + '/../utils')
miquire :mui, 'textselector'
$debug = true # !> instance variable @textselect_start not initialized
# seterrorlevel(:notice)
$logfile = nil
$daemon = false
class MockPainter
include Gdk::TextSelector
def on_modify
end
end
class TC_TextSelector < Test::Unit::TestCase
S1 = 'this is <b>a <a>test</a></b> text'.freeze
S2 = 'escape > text'
S3 = 'にほんごもじれつ'
def setup
end
def test_select
mp = MockPainter.new
assert_equal('th<span background="#000000" foreground="#ffffff">is is </span><b><span background="#000000" foreground="#ffffff">a </span><a><span background="#000000" foreground="#ffffff">te</span>st</a></b> text',
mp.textselector_press(2).textselector_release(12).textselector_markup(S1))
assert_equal('th<span background="#000000" foreground="#ffffff">is i</span>s <b>a <a>test</a></b> text',
mp.textselector_press(2).textselector_release(6).textselector_markup(S1))
assert_equal('th<span background="#000000" foreground="#ffffff">is is <b>a <a>test</a></b> tex</span>t',
mp.textselector_press(2).textselector_release(18).textselector_markup(S1))
assert_equal('esca<span background="#000000" foreground="#ffffff">pe > t</span>ext',
mp.textselector_press(4).textselector_release(9).textselector_markup(S2))
assert_equal('にほ<span background="#000000" foreground="#ffffff">んごも</span>じれつ',
mp.textselector_press(2).textselector_release(5).textselector_markup(S3))
end
end
# >> Loaded suite -
# >> Started
# >> .
# >> Finished in 0.002221 seconds.
# >>
# >> 1 tests, 5 assertions, 0 failures, 0 errors
|