zerenity 1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -0
- data/README +63 -0
- data/examples/example_calendar.rb +6 -0
- data/examples/example_colorselection.rb +5 -0
- data/examples/example_entry.rb +16 -0
- data/examples/example_error.rb +3 -0
- data/examples/example_fileselection.rb +26 -0
- data/examples/example_info.rb +3 -0
- data/examples/example_list.rb +10 -0
- data/examples/example_progress.rb +40 -0
- data/examples/example_question.rb +4 -0
- data/examples/example_textinfo.rb +11 -0
- data/examples/example_warning.rb +3 -0
- data/lib/zerenity.rb +14 -0
- data/lib/zerenity/base.rb +50 -0
- data/lib/zerenity/calendar.rb +26 -0
- data/lib/zerenity/colorselection.rb +30 -0
- data/lib/zerenity/entry.rb +36 -0
- data/lib/zerenity/error.rb +17 -0
- data/lib/zerenity/fileselection.rb +68 -0
- data/lib/zerenity/info.rb +18 -0
- data/lib/zerenity/list.rb +110 -0
- data/lib/zerenity/messagedialog.rb +34 -0
- data/lib/zerenity/progress.rb +136 -0
- data/lib/zerenity/progress.rb~ +136 -0
- data/lib/zerenity/question.rb +26 -0
- data/lib/zerenity/scale.rb +41 -0
- data/lib/zerenity/textinfo.rb +49 -0
- data/lib/zerenity/warning.rb +18 -0
- data/test/all.rb +2 -0
- data/test/tc_base.rb +35 -0
- data/test/tc_calendar.rb +28 -0
- data/test/tc_entry.rb +49 -0
- data/test/tc_fileselection.rb +37 -0
- data/test/tc_info.rb +16 -0
- data/test/tc_list.rb +138 -0
- data/test/tc_messagedialog.rb +16 -0
- data/test/tc_progress.rb +76 -0
- data/test/tc_question.rb +23 -0
- data/test/tc_scale.rb +33 -0
- data/test/tc_textinfo.rb +33 -0
- data/test/tc_warning.rb +16 -0
- data/test/ts_zerenity.rb +33 -0
- metadata +97 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require('zerenity/base')
|
2
|
+
|
3
|
+
module Zerenity
|
4
|
+
# Displays a sliding scale. Returns the value selected or nil if
|
5
|
+
# cancel is pressed.
|
6
|
+
#
|
7
|
+
# ====Options
|
8
|
+
# [:min] The minimum value of the sliding scale. Defaults to 0.
|
9
|
+
# [:max] The maximum value of the sliding scale. Defaults to 100.
|
10
|
+
# [:step] The size of the value increment of the sliding scale for keyboard shortcuts. Defaults to 1.
|
11
|
+
# [:initial] The initial value of the sliding scale. Defaults to 0.
|
12
|
+
# ====Example Usage
|
13
|
+
# value = Zerenity::Scale(:text=>"Please select a value", :min => 1, :max => 250, :step => 3)
|
14
|
+
def self.Scale(options={})
|
15
|
+
Scale.run(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
class Scale < Zerenity::Base # :nodoc:
|
19
|
+
def self.check(options)
|
20
|
+
super(options)
|
21
|
+
options[:initial] ||= 0.0
|
22
|
+
options[:min] ||= 0.0
|
23
|
+
options[:max] ||= 100.0
|
24
|
+
options[:step] ||= 1.0
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.build(dialog,options)
|
28
|
+
super(dialog,options)
|
29
|
+
label = Gtk::Label.new(options[:text])
|
30
|
+
hscale = Gtk::HScale.new(options[:min],options[:max],options[:step])
|
31
|
+
hscale.value = options[:initial].to_f
|
32
|
+
dialog.vbox.add(label)
|
33
|
+
dialog.vbox.add(hscale)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.retrieve_selection(dialog,options)
|
37
|
+
super(dialog,options)
|
38
|
+
dialog.vbox.children[1].value.to_i
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require('zerenity/base')
|
2
|
+
|
3
|
+
module Zerenity
|
4
|
+
# Displays text in a multiline text info box.
|
5
|
+
#
|
6
|
+
# ====Options
|
7
|
+
# [:editable] If set to true the text info box is editable.
|
8
|
+
# [:scrollable] If the size of the text does not fit in the
|
9
|
+
# height and width constraints, the text info box will become
|
10
|
+
# scrollable
|
11
|
+
# [:height,:width] The height and width of the text box, in pixels.
|
12
|
+
# Note this is not the height and weidth of the full window.
|
13
|
+
# [:text] The text to be displayed in the text info box.
|
14
|
+
#
|
15
|
+
# ====Example Usage
|
16
|
+
# Zerenity::TextIfno(:text=>File.new($0).read)
|
17
|
+
def self.TextInfo(options={})
|
18
|
+
TextInfo.run(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
class TextInfo < Base # :nodoc:
|
22
|
+
def self.check(options)
|
23
|
+
super(options)
|
24
|
+
options[:editable] ||= false
|
25
|
+
options[:scrollable] ||= false
|
26
|
+
options[:height] ||= -1
|
27
|
+
options[:width] ||= -1
|
28
|
+
options[:text] ||= ""
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build(dialog,options)
|
32
|
+
super(dialog,options)
|
33
|
+
textView = Gtk::TextView.new
|
34
|
+
textView.set_size_request(options[:width].to_i,options[:height].to_i)
|
35
|
+
textView.buffer.text = options[:text].to_s
|
36
|
+
textView.editable = options[:editable]
|
37
|
+
scrolledWindow = Gtk::ScrolledWindow.new
|
38
|
+
scrolledWindow.hscrollbar_policy = options[:scrollable] ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER
|
39
|
+
scrolledWindow.vscrollbar_policy = options[:scrollable] ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER
|
40
|
+
scrolledWindow.add(textView)
|
41
|
+
dialog.vbox.add(scrolledWindow)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.retrieve_selection(dialog,options)
|
45
|
+
super(dialog,options)
|
46
|
+
return dialog.vbox.children[0].children[0].buffer.text
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'zerenity/messagedialog'
|
2
|
+
|
3
|
+
module Zerenity
|
4
|
+
# Displays a warning dialog on the screen.
|
5
|
+
#
|
6
|
+
# ====Example Usage
|
7
|
+
# Zerenity::Warning(:text=>"This operation can cause data corruption if interrupted")
|
8
|
+
def self.Warning(options={})
|
9
|
+
Warning.run(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Warning < MessageDialog # :nodoc:
|
13
|
+
def self.check(options)
|
14
|
+
super(options)
|
15
|
+
options[:type] = Gtk::MessageDialog::WARNING
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/all.rb
ADDED
data/test/tc_base.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('zerenity/base')
|
3
|
+
|
4
|
+
class TC_Base < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Gtk.init
|
7
|
+
@options={}
|
8
|
+
@dialog=Gtk::Dialog.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_check_normal
|
12
|
+
Zerenity::Base.check(@options)
|
13
|
+
assert(@options[:activatesDefault])
|
14
|
+
assert_equal("",@options[:title])
|
15
|
+
assert_equal("",@options[:text])
|
16
|
+
@options[:activatesDefault] = false
|
17
|
+
Zerenity::Base.check(@options)
|
18
|
+
assert(!@options[:activatesDefault])
|
19
|
+
@options[:activatesDefault] = "Randome object"
|
20
|
+
Zerenity::Base.check(@options)
|
21
|
+
assert(@options[:activatesDefault])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_normal_build
|
25
|
+
Zerenity::Base.build(@dialog,@options)
|
26
|
+
assert(@options[:ok_button].use_stock?)
|
27
|
+
assert(@options[:cancel_button].use_stock?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_button_options
|
31
|
+
Zerenity::Base.build(@dialog,@options.merge!(:ok_button => "Foo", :cancel_button => "Bar"))
|
32
|
+
assert_equal "Foo", @options[:ok_button].label
|
33
|
+
assert_equal("Bar", @options[:cancel_button].label)
|
34
|
+
end
|
35
|
+
end
|
data/test/tc_calendar.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('gtk2')
|
3
|
+
require('zerenity/calendar')
|
4
|
+
|
5
|
+
class TC_Calender < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Gtk.init
|
8
|
+
@options={:text=>"Select a date"}
|
9
|
+
@dialog=Gtk::Dialog.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_build_normal
|
13
|
+
Zerenity::Calendar.build(@dialog,@options)
|
14
|
+
assert_equal(Gtk::Label,@dialog.vbox.children[0].class)
|
15
|
+
assert_equal("Select a date",@dialog.vbox.children[0].text)
|
16
|
+
assert_equal(Gtk::Calendar,@dialog.vbox.children[1].class)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_retrieve_selection_normal
|
20
|
+
Zerenity::Calendar.build(@dialog,@options)
|
21
|
+
@dialog.vbox.children[1].select_month(1,1979)
|
22
|
+
@dialog.vbox.children[1].select_day(5)
|
23
|
+
time = Zerenity::Calendar.retrieve_selection(@dialog,@options)
|
24
|
+
assert_equal(5,time.day)
|
25
|
+
assert_equal(1,time.month)
|
26
|
+
assert_equal(1979,time.year)
|
27
|
+
end
|
28
|
+
end
|
data/test/tc_entry.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require('zerenity/entry')
|
2
|
+
|
3
|
+
class TC_Entry < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Gtk.init
|
6
|
+
@options = {:title=>"Enter your name",:text=>"Enter your name"}
|
7
|
+
@dialog = Gtk::Dialog.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_build_normal
|
11
|
+
Zerenity::Entry.build(@dialog,@options)
|
12
|
+
assert_equal(true,@dialog.vbox.children[1].visibility?)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_build_adds_default_string
|
16
|
+
Zerenity::Entry.build(@dialog,@options.merge(:string => "hi"))
|
17
|
+
assert_equal("hi", @dialog.vbox.children[1].text)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_build_password
|
21
|
+
@options[:password] = true
|
22
|
+
Zerenity::Entry.build(@dialog,@options)
|
23
|
+
assert_equal(false,@dialog.vbox.children[1].visibility?)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_build_activates_default
|
27
|
+
@options[:activatesDefault] = false
|
28
|
+
Zerenity::Entry.build(@dialog,@options)
|
29
|
+
assert(!@dialog.vbox.children[1].activates_default?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_check_normal
|
33
|
+
Zerenity::Entry.check(@options)
|
34
|
+
assert(!@options[:password])
|
35
|
+
assert(@options[:activatesDefault])
|
36
|
+
@options[:password] = true
|
37
|
+
Zerenity::Entry.check(@options)
|
38
|
+
assert(@options[:password])
|
39
|
+
@options[:activatesDefault] = false
|
40
|
+
Zerenity::Entry.check(@options)
|
41
|
+
assert(!@options[:activatesDefault])
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_retrieve_selection_normal
|
45
|
+
Zerenity::Entry.build(@dialog,@options)
|
46
|
+
@dialog.vbox.children[1].text = "Farrel"
|
47
|
+
assert_equal("Farrel",Zerenity::Entry.retrieve_selection(@dialog,@options))
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('gtk2')
|
3
|
+
require('zerenity/fileselection')
|
4
|
+
|
5
|
+
class TC_FileSelection < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Gtk.init
|
8
|
+
@options={}
|
9
|
+
@dialog=Gtk::Dialog.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_normal
|
13
|
+
Zerenity::FileSelection.check(@options)
|
14
|
+
assert_equal(Gtk::FileChooser::ACTION_OPEN,@options[:action])
|
15
|
+
assert_equal("",@options[:title])
|
16
|
+
assert_equal(false,@options[:multiple])
|
17
|
+
assert_nil(@options[:filename])
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_check_save
|
21
|
+
@options[:action] = :save
|
22
|
+
Zerenity::FileSelection.check(@options)
|
23
|
+
assert_equal(Gtk::FileChooser::ACTION_SAVE,@options[:action])
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_check_select_folder
|
27
|
+
@options[:action] = :select_folder
|
28
|
+
Zerenity::FileSelection.check(@options)
|
29
|
+
assert_equal(Gtk::FileChooser::ACTION_SELECT_FOLDER,@options[:action])
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_check_create_folder
|
33
|
+
@options[:action] = :create_folder
|
34
|
+
Zerenity::FileSelection.check(@options)
|
35
|
+
assert_equal(Gtk::FileChooser::ACTION_CREATE_FOLDER,@options[:action])
|
36
|
+
end
|
37
|
+
end
|
data/test/tc_info.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('gtk2')
|
3
|
+
require('zerenity/info')
|
4
|
+
|
5
|
+
class TC_Info < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Gtk.init
|
8
|
+
@options={}
|
9
|
+
@dialog=Gtk::Dialog.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_normal
|
13
|
+
Zerenity::Info.check(@options)
|
14
|
+
assert_equal(Gtk::MessageDialog::INFO,@options[:type])
|
15
|
+
end
|
16
|
+
end
|
data/test/tc_list.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('gtk2')
|
3
|
+
require('zerenity/list')
|
4
|
+
|
5
|
+
class TC_List < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Gtk.init
|
8
|
+
@options = {:columns=>["Snack","Energy(KJ)"],:data=>[["Beer","300"],["Chips","500"],["Chocolate","750"]]}
|
9
|
+
@dialog = Gtk::Dialog.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_normal
|
13
|
+
assert_nothing_raised{Zerenity::List.check(@options)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_check_no_options
|
17
|
+
assert_raise(ArgumentError,""){Zerenity::List.check}
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_check_no_data
|
21
|
+
@options[:data] = nil
|
22
|
+
assert_raise(ArgumentError,"Column data not set but no error raised"){Zerenity::List.check(@options)}
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_check_no_columns
|
26
|
+
@options[:columns] = nil
|
27
|
+
assert_raise(ArgumentError,"Column headers not set but no error raised"){Zerenity::List.check(@options)}
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_check_different_columns_data_length
|
31
|
+
@options[:columns] << "Fat"
|
32
|
+
assert_raise(ArgumentError,"Columns length greater than data but no error raised"){Zerenity::List.check(@options)}
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_check_different_data_length
|
36
|
+
@options[:data][1] << "100"
|
37
|
+
assert_raise(ArgumentError,"Data lengths differ but no error was raised"){Zerenity::List.check(@options)}
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_check_both_radiolist_checklist
|
41
|
+
@options[:checklist] = true
|
42
|
+
@options[:radiolist] = true
|
43
|
+
assert_raise(ArgumentError,"Radio and checkist options set but no error was raised"){Zerenity::List.check(@options)}
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_build_normal
|
47
|
+
Zerenity::List.build(@dialog,@options)
|
48
|
+
treeView = @dialog.vbox.children[0]
|
49
|
+
assert_equal(Gtk::ListStore,treeView.model.class,"TreeView model class is not ListStore")
|
50
|
+
assert_equal(2,treeView.model.n_columns)
|
51
|
+
assert_equal(String,treeView.model.get_column_type(0))
|
52
|
+
assert_equal(String,treeView.model.get_column_type(1))
|
53
|
+
row = treeView.model.iter_first
|
54
|
+
@options[:data].each do |datarow|
|
55
|
+
datarow.each_with_index do |value,index|
|
56
|
+
assert_equal(value,row[index])
|
57
|
+
end
|
58
|
+
row.next!
|
59
|
+
end
|
60
|
+
assert_equal(@options[:columns].size,treeView.columns.size)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_retrieve_selection_normal
|
64
|
+
Zerenity::List.build(@dialog,@options)
|
65
|
+
treeView = @dialog.vbox.children[0]
|
66
|
+
treeView.selection.select_iter(treeView.model.iter_first)
|
67
|
+
selection = Zerenity::List.retrieve_selection(@dialog,@options)
|
68
|
+
assert_equal(@options[:data][0][0],selection[0])
|
69
|
+
assert_equal(@options[:data][0][1],selection[1])
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_build_radio
|
73
|
+
@options[:columns] = Array("Selected").concat(@options[:columns])
|
74
|
+
@options[:data][0] = Array(true).concat(@options[:data][0])
|
75
|
+
@options[:data][1] = Array(false).concat(@options[:data][1])
|
76
|
+
@options[:data][2] = Array(false).concat(@options[:data][2])
|
77
|
+
@options[:radiolist] = true
|
78
|
+
Zerenity::List.build(@dialog,@options)
|
79
|
+
treeView = @dialog.vbox.children[0]
|
80
|
+
assert_equal(3,treeView.model.n_columns)
|
81
|
+
assert_equal(TrueClass,treeView.model.get_column_type(0))
|
82
|
+
assert_equal(String,treeView.model.get_column_type(1))
|
83
|
+
assert_equal(String,treeView.model.get_column_type(2))
|
84
|
+
row = treeView.model.iter_first
|
85
|
+
@options[:data].each do |datarow|
|
86
|
+
datarow.each_with_index do |value,index|
|
87
|
+
assert_equal(value,row[index])
|
88
|
+
end
|
89
|
+
row.next!
|
90
|
+
end
|
91
|
+
assert_equal(@options[:columns].size,treeView.columns.size)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_retrieve_selection_radio
|
95
|
+
@options[:columns] = Array("Selected").concat(@options[:columns])
|
96
|
+
@options[:data][0] = Array(true).concat(@options[:data][0])
|
97
|
+
@options[:data][1] = Array(false).concat(@options[:data][1])
|
98
|
+
@options[:data][2] = Array(false).concat(@options[:data][2])
|
99
|
+
@options[:radiolist] = true
|
100
|
+
Zerenity::List.build(@dialog,@options)
|
101
|
+
selected = Zerenity::List.retrieve_selection(@dialog,@options)
|
102
|
+
assert_equal(@options[:data][0][1..2],selected)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_build_checklist
|
106
|
+
@options[:columns] = Array("Selected").concat(@options[:columns])
|
107
|
+
@options[:data][0] = Array(true).concat(@options[:data][0])
|
108
|
+
@options[:data][1] = Array(true).concat(@options[:data][1])
|
109
|
+
@options[:data][2] = Array(false).concat(@options[:data][2])
|
110
|
+
@options[:checklist] = true
|
111
|
+
Zerenity::List.build(@dialog,@options)
|
112
|
+
treeView = @dialog.vbox.children[0]
|
113
|
+
assert_equal(3,treeView.model.n_columns)
|
114
|
+
assert_equal(TrueClass,treeView.model.get_column_type(0))
|
115
|
+
assert_equal(String,treeView.model.get_column_type(1))
|
116
|
+
assert_equal(String,treeView.model.get_column_type(2))
|
117
|
+
row = treeView.model.iter_first
|
118
|
+
@options[:data].each do |datarow|
|
119
|
+
datarow.each_with_index do |value,index|
|
120
|
+
assert_equal(value,row[index])
|
121
|
+
end
|
122
|
+
row.next!
|
123
|
+
end
|
124
|
+
assert_equal(@options[:columns].size,treeView.columns.size)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_retrieve_selection_cheklist
|
128
|
+
@options[:columns] = Array("Selected").concat(@options[:columns])
|
129
|
+
@options[:data][0] = Array(true).concat(@options[:data][0])
|
130
|
+
@options[:data][1] = Array(true).concat(@options[:data][1])
|
131
|
+
@options[:data][2] = Array(false).concat(@options[:data][2])
|
132
|
+
@options[:checklist] = true
|
133
|
+
Zerenity::List.build(@dialog,@options)
|
134
|
+
selected = Zerenity::List.retrieve_selection(@dialog,@options)
|
135
|
+
assert_equal(@options[:data][0][1..2],selected[0])
|
136
|
+
assert_equal(@options[:data][1][1..2],selected[1])
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('gtk2')
|
3
|
+
require('zerenity/messagedialog')
|
4
|
+
|
5
|
+
class TC_MessageDialog < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Gtk.init
|
8
|
+
@options={}
|
9
|
+
@dialog = Gtk::Dialog.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_build_normal
|
13
|
+
Zerenity::MessageDialog.build(@dialog,@options)
|
14
|
+
assert_nil(@options[:cancel_button])
|
15
|
+
end
|
16
|
+
end
|
data/test/tc_progress.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require('test/unit')
|
2
|
+
require('zerenity/progress')
|
3
|
+
|
4
|
+
class TC_Progress < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Gtk.init
|
7
|
+
@options = {:title=>"Operation in progress",:text=>"Building index..."}
|
8
|
+
@dialog = Gtk::Dialog.new
|
9
|
+
@hButtonBox = Gtk::HButtonBox.new
|
10
|
+
@hButtonBox.add(Gtk::Button.new)
|
11
|
+
@hButtonBox.add(Gtk::Button.new)
|
12
|
+
@progressProxy = Zerenity::ProgressProxy.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_build_normal
|
16
|
+
Zerenity::Progress.build(@dialog,@options,@progressProxy)
|
17
|
+
assert_equal(Gtk::ProgressBar,@dialog.vbox.children[1].class)
|
18
|
+
assert_equal(@options[:text],@dialog.vbox.children[0].text)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_check_normal
|
22
|
+
Zerenity::Progress.check(@options)
|
23
|
+
assert(!@options[:autoClose])
|
24
|
+
assert(!@options[:cancellable])
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_check_options
|
28
|
+
@options[:autoClose]=true
|
29
|
+
@options[:cancellable]=true
|
30
|
+
Zerenity::Progress.check(@options)
|
31
|
+
assert(@options[:autoClose])
|
32
|
+
assert(@options[:cancellable])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class TC_ProgressProxy < Test::Unit::TestCase
|
37
|
+
def setup
|
38
|
+
Gtk.init
|
39
|
+
@progressBar = Gtk::ProgressBar.new
|
40
|
+
@progress= Zerenity::ProgressProxy.new
|
41
|
+
@progress.progressBar = @progressBar
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_update
|
45
|
+
@progress.update(0.10,"10%")
|
46
|
+
assert_equal(0.10,@progressBar.fraction)
|
47
|
+
assert_equal("10%",@progressBar.text)
|
48
|
+
@progress.update(0.15)
|
49
|
+
assert_equal(0.15,@progressBar.fraction)
|
50
|
+
assert_raise(ArgumentError){@progress.update}
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_pulse
|
54
|
+
@progress.pulse
|
55
|
+
assert(@progressBar.pulse)
|
56
|
+
assert_nil(@progressBar.text)
|
57
|
+
@progress.pulse("Compiling")
|
58
|
+
assert(@progressBar.pulse)
|
59
|
+
assert_equal("Compiling",@progressBar.text)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_text
|
63
|
+
@progress.text="Compiling"
|
64
|
+
assert_equal("Compiling",@progressBar.text)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_percentage
|
68
|
+
@progress.percentage=0.5
|
69
|
+
assert_equal(0.5,@progressBar.fraction)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_cancelled
|
73
|
+
@progress.cancel!
|
74
|
+
assert_equal(true,@progress.cancelled?)
|
75
|
+
end
|
76
|
+
end
|