root/lang/ruby/ruwin/test/ruwin/list_box/test_multiple.rb @ 28824

Revision 28824, 2.3 kB (checked in by isaisstillalive, 4 years ago)
  • テストモジュールのrequireパスを修正。
Line 
1require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "helper"))
2require "ruwin"
3require "ruwin/list_box"
4require File.expand_path(File.join(File.dirname(__FILE__), "..", "testm_list_box"))
5
6class TestRuwinListBoxMultiple < Test::Unit::TestCase
7  include TestModuleListBox
8  include Ruwin::Const::ListBox
9  TARGET_CLASS = Ruwin::ListBox::Multiple
10 
11  def test_style
12    assert_equal LBS_MULTIPLESEL, (@control.style&(LBS_MULTIPLESEL|LBS_EXTENDEDSEL))
13  end
14 
15  def test_get_position_no_position
16    assert_equal 0, @control.position
17  end
18 
19  def test_change_selection_multiple
20    @control.push "text1"
21    @control.push "text2"
22    @control.change_selection 0, true
23    @control.change_selection 1, true
24    assert_equal true, @control.selected?(0)
25    assert_equal true, @control.selected?(1)
26  end
27 
28  def test_selection_count_multiple
29    @control.push "text1"
30    @control.push "text2"
31    @control.push "text3"
32    @control.select 0
33    @control.select 1
34    assert_equal 2, @control.selection_count
35  end
36 
37  def test_selection_indexes_multiple
38    @control.push "text1"
39    @control.push "text2"
40    @control.push "text3"
41    @control.select 0
42    @control.select 1
43    assert_equal [0, 1], @control.selection_indexes
44  end
45 
46  def test_selections_multiple
47    @control.push "text1"
48    @control.push "text2"
49    @control.push "text3"
50    @control.select 1
51    @control.select 2
52   
53    enum = @control.selections
54    assert_kind_of Enumerable::Enumerator, enum
55   
56    actual = []
57    enum.each{|v| actual << v }
58    assert_equal ["text2", "text3"], actual
59  end
60 
61  def test_selections_with_block_multiple
62    @control.push "text1"
63    @control.push "text2"
64    @control.push "text3"
65    @control.select 1
66    @control.select 2
67   
68    actual = []
69    @control.selections{|v| actual << v }
70    assert_equal ["text2", "text3"], actual
71  end
72end
73
74class TestRuwinListBoxExtend < Test::Unit::TestCase
75  include Ruwin::Const::ListBox
76  TARGET_CLASS = Ruwin::ListBox::Extend
77 
78  def setup
79    @window = Ruwin::Window.new
80    @control = self.class::TARGET_CLASS.new @window
81  end
82 
83  def test_style
84    assert_equal LBS_EXTENDEDSEL, (@control.style&(LBS_MULTIPLESEL|LBS_EXTENDEDSEL))
85  end
86end
Note: See TracBrowser for help on using the browser.