test-unit-runner-fox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ === 0.0.1 / 2008-06-18
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday (as a gem)!
@@ -0,0 +1,6 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/test/unit/runner/fox.rb
6
+ lib/test/unit/ui/fox/testrunner.rb
@@ -0,0 +1,25 @@
1
+ = Test::Unit::Runner::FOX
2
+
3
+ * http://rubyforge.org/projects/test-unit/
4
+
5
+ == DESCRIPTION:
6
+
7
+ Test::Unit::Runner::FOX - A Test::Unit UI built on FXRuby.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * This provides "--runner=fox" option to use FOX UI.
12
+
13
+ == INSTALL:
14
+
15
+ * sudo gem install test-unit-runner-fox
16
+
17
+ == USAGE:
18
+
19
+ require 'test/unit/runner/fox'
20
+
21
+ == LICENSE:
22
+
23
+ (The Ruby License)
24
+
25
+ This software is distributed under the same terms as ruby.
@@ -0,0 +1,25 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ gem 'test-unit'
5
+ require 'hoe'
6
+ require './lib/test/unit/runner/fox'
7
+
8
+ Test::Unit.run = true
9
+
10
+ version = Test::Unit::Runner::FOX::VERSION
11
+ ENV["VERSION"] = version
12
+ Hoe.new('test-unit-runner-fox', version) do |p|
13
+ p.developer('Kouhei Sutou', 'kou@cozmixng.org')
14
+ p.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
15
+
16
+ p.rubyforge_name = "test-unit"
17
+ end
18
+
19
+ task :tag do
20
+ message = "Released Test::Unit::Runner::FOX #{version}!"
21
+ base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/extensions/test-unit-runner-fox/"
22
+ sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
23
+ end
24
+
25
+ # vim: syntax=Ruby
@@ -0,0 +1,16 @@
1
+ require 'test/unit'
2
+
3
+ module Test
4
+ module Unit
5
+ AutoRunner.register_runner(:fox) do |auto_runner|
6
+ require 'test/unit/ui/fox/testrunner'
7
+ Test::Unit::UI::FOX::TestRunner
8
+ end
9
+
10
+ module Runner
11
+ module FOX
12
+ VERSION = "0.0.1"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,269 @@
1
+ #--
2
+ #
3
+ # Author:: Nathaniel Talbott.
4
+ # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
5
+ # License:: Ruby license.
6
+
7
+ begin
8
+ require 'fox16'
9
+ rescue LoadError
10
+ require 'rubygems'
11
+ require 'fox16'
12
+ end
13
+
14
+ require 'test/unit/ui/testrunner'
15
+ require 'test/unit/ui/testrunnermediator'
16
+
17
+ module Test
18
+ module Unit
19
+ module UI
20
+ module FOX
21
+
22
+ # Runs a Test::Unit::TestSuite in a FOX UI. Obviously,
23
+ # this one requires you to have FOX
24
+ # (http://www.fox-toolkit.org/fox.html) and the Ruby
25
+ # FOX extension (http://fxruby.sourceforge.net/)
26
+ # installed.
27
+ class TestRunner < UI::TestRunner
28
+ include Fox
29
+
30
+ RED_STYLE = Fox::FXRGBA(0xFF,0,0,0xFF) #0xFF000000
31
+ GREEN_STYLE = Fox::FXRGBA(0,0xFF,0,0xFF) #0x00FF0000
32
+
33
+ # Creates a new TestRunner for running the passed
34
+ # suite.
35
+ def initialize(suite, options={})
36
+ super
37
+ @result = nil
38
+ @red = false
39
+ end
40
+
41
+ # Begins the test run.
42
+ def start
43
+ setup_ui
44
+ setup_mediator
45
+ attach_to_mediator
46
+ start_ui
47
+ @result
48
+ end
49
+
50
+ def setup_mediator
51
+ @mediator = TestRunnerMediator.new(@suite)
52
+ suite_name = @suite.to_s
53
+ if ( @suite.kind_of?(Module) )
54
+ suite_name = @suite.name
55
+ end
56
+ @suite_name_entry.text = suite_name
57
+ end
58
+
59
+ def attach_to_mediator
60
+ @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui))
61
+ @mediator.add_listener(TestResult::FAULT, &method(:add_fault))
62
+ @mediator.add_listener(TestResult::CHANGED, &method(:result_changed))
63
+ @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
64
+ @mediator.add_listener(TestCase::STARTED, &method(:test_started))
65
+ @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
66
+ end
67
+
68
+ def start_ui
69
+ @application.create
70
+ @window.show(PLACEMENT_SCREEN)
71
+ @application.addTimeout(1) do
72
+ @mediator.run_suite
73
+ end
74
+ @application.run
75
+ end
76
+
77
+ def stop
78
+ @application.exit(0)
79
+ end
80
+
81
+ def reset_ui(count)
82
+ @test_progress_bar.barColor = GREEN_STYLE
83
+ @test_progress_bar.total = count
84
+ @test_progress_bar.progress = 0
85
+ @red = false
86
+
87
+ @test_count_label.text = "0"
88
+ @assertion_count_label.text = "0"
89
+ @failure_count_label.text = "0"
90
+ @error_count_label.text = "0"
91
+
92
+ @fault_list.clearItems
93
+ end
94
+
95
+ def add_fault(fault)
96
+ if ( ! @red )
97
+ @test_progress_bar.barColor = RED_STYLE
98
+ @red = true
99
+ end
100
+ item = FaultListItem.new(fault)
101
+ @fault_list.appendItem(item)
102
+ end
103
+
104
+ def show_fault(fault)
105
+ raw_show_fault(fault.long_display)
106
+ end
107
+
108
+ def raw_show_fault(string)
109
+ @detail_text.setText(string)
110
+ end
111
+
112
+ def clear_fault
113
+ raw_show_fault("")
114
+ end
115
+
116
+ def result_changed(result)
117
+ @test_progress_bar.progress = result.run_count
118
+
119
+ @test_count_label.text = result.run_count.to_s
120
+ @assertion_count_label.text = result.assertion_count.to_s
121
+ @failure_count_label.text = result.failure_count.to_s
122
+ @error_count_label.text = result.error_count.to_s
123
+
124
+ # repaint now!
125
+ @info_panel.repaint
126
+ @application.flush
127
+ end
128
+
129
+ def started(result)
130
+ @result = result
131
+ output_status("Started...")
132
+ end
133
+
134
+ def test_started(test_name)
135
+ output_status("Running #{test_name}...")
136
+ end
137
+
138
+ def finished(elapsed_time)
139
+ output_status("Finished in #{elapsed_time} seconds")
140
+ end
141
+
142
+ def output_status(string)
143
+ @status_entry.text = string
144
+ @status_entry.repaint
145
+ end
146
+
147
+ def setup_ui
148
+ @application = create_application
149
+ create_tooltip(@application)
150
+
151
+ @window = create_window(@application)
152
+
153
+ @status_entry = create_entry(@window)
154
+
155
+ main_panel = create_main_panel(@window)
156
+
157
+ suite_panel = create_suite_panel(main_panel)
158
+ create_label(suite_panel, "Suite:")
159
+ @suite_name_entry = create_entry(suite_panel)
160
+ create_button(suite_panel, "&Run\tRun the current suite", proc { @mediator.run_suite })
161
+
162
+ @test_progress_bar = create_progress_bar(main_panel)
163
+
164
+ @info_panel = create_info_panel(main_panel)
165
+ create_label(@info_panel, "Tests:")
166
+ @test_count_label = create_label(@info_panel, "0")
167
+ create_label(@info_panel, "Assertions:")
168
+ @assertion_count_label = create_label(@info_panel, "0")
169
+ create_label(@info_panel, "Failures:")
170
+ @failure_count_label = create_label(@info_panel, "0")
171
+ create_label(@info_panel, "Errors:")
172
+ @error_count_label = create_label(@info_panel, "0")
173
+
174
+ list_panel = create_list_panel(main_panel)
175
+ @fault_list = create_fault_list(list_panel)
176
+
177
+ detail_panel = create_detail_panel(main_panel)
178
+ @detail_text = create_text(detail_panel)
179
+ end
180
+
181
+ def create_application
182
+ app = FXApp.new("TestRunner", "Test::Unit")
183
+ app.init([])
184
+ app
185
+ end
186
+
187
+ def create_window(app)
188
+ FXMainWindow.new(app, "Test::Unit TestRunner", nil, nil, DECOR_ALL, 0, 0, 450)
189
+ end
190
+
191
+ def create_tooltip(app)
192
+ FXToolTip.new(app)
193
+ end
194
+
195
+ def create_main_panel(parent)
196
+ panel = FXVerticalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y)
197
+ panel.vSpacing = 10
198
+ panel
199
+ end
200
+
201
+ def create_suite_panel(parent)
202
+ FXHorizontalFrame.new(parent, LAYOUT_SIDE_LEFT | LAYOUT_FILL_X)
203
+ end
204
+
205
+ def create_button(parent, text, action)
206
+ FXButton.new(parent, text).connect(SEL_COMMAND, &action)
207
+ end
208
+
209
+ def create_progress_bar(parent)
210
+ FXProgressBar.new(parent, nil, 0, PROGRESSBAR_NORMAL | LAYOUT_FILL_X)
211
+ end
212
+
213
+ def create_info_panel(parent)
214
+ FXMatrix.new(parent, 1, MATRIX_BY_ROWS | LAYOUT_FILL_X)
215
+ end
216
+
217
+ def create_label(parent, text)
218
+ FXLabel.new(parent, text, nil, JUSTIFY_CENTER_X | LAYOUT_FILL_COLUMN)
219
+ end
220
+
221
+ def create_list_panel(parent)
222
+ FXHorizontalFrame.new(parent, LAYOUT_FILL_X | FRAME_SUNKEN | FRAME_THICK)
223
+ end
224
+
225
+ def create_fault_list(parent)
226
+ list = FXList.new(parent,
227
+ :opts => LIST_SINGLESELECT | LAYOUT_FILL_X,
228
+ :width => 150)
229
+ list.connect(SEL_COMMAND) do |sender, sel, ptr|
230
+ item = sender.getItem(sender.currentItem)
231
+ if item.selected?
232
+ show_fault(item.fault)
233
+ else
234
+ clear_fault
235
+ end
236
+ end
237
+ list
238
+ end
239
+
240
+ def create_detail_panel(parent)
241
+ FXHorizontalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK)
242
+ end
243
+
244
+ def create_text(parent)
245
+ FXText.new(parent, nil, 0, TEXT_READONLY | LAYOUT_FILL_X | LAYOUT_FILL_Y)
246
+ end
247
+
248
+ def create_entry(parent)
249
+ entry = FXTextField.new(parent, 30, nil, 0, TEXTFIELD_NORMAL | LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X)
250
+ entry.disable
251
+ entry
252
+ end
253
+ end
254
+
255
+ class FaultListItem < Fox::FXListItem
256
+ attr_reader(:fault)
257
+ def initialize(fault)
258
+ super(fault.short_display)
259
+ @fault = fault
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
266
+
267
+ if __FILE__ == $0
268
+ Test::Unit::UI::FOX::TestRunner.start_command_line_test
269
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test-unit-runner-fox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kouhei Sutou
8
+ - Ryan Davis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-06-18 00:00:00 +09:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: hoe
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.6.0
24
+ version:
25
+ description: Test::Unit::Runner::FOX - A Test::Unit UI built on FXRuby.
26
+ email:
27
+ - kou@cozmixng.org
28
+ - ryand-ruby@zenspider.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files:
34
+ - History.txt
35
+ - Manifest.txt
36
+ - README.txt
37
+ files:
38
+ - History.txt
39
+ - Manifest.txt
40
+ - README.txt
41
+ - Rakefile
42
+ - lib/test/unit/runner/fox.rb
43
+ - lib/test/unit/ui/fox/testrunner.rb
44
+ has_rdoc: true
45
+ homepage: http://rubyforge.org/projects/test-unit/
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --main
49
+ - README.txt
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project: test-unit
67
+ rubygems_version: 1.1.1
68
+ signing_key:
69
+ specification_version: 2
70
+ summary: Test::Unit::Runner::FOX - A Test::Unit UI built on FXRuby.
71
+ test_files: []
72
+