Class: Test::Unit::UI::FOX::TestRunner
- Inherits:
-
UI::TestRunner
- Object
- UI::TestRunner
- Test::Unit::UI::FOX::TestRunner
- Includes:
- Fox
- Defined in:
- lib/test/unit/ui/fox/testrunner.rb
Overview
Runs a Test::Unit::TestSuite in a FOX UI. Obviously, this one requires you to have FOX (www.fox-toolkit.org/fox.html) and the Ruby FOX extension (fxruby.sourceforge.net/) installed.
Constant Summary collapse
- RED_STYLE =
0xFF000000
Fox::FXRGBA(0xFF,0,0,0xFF)
- GREEN_STYLE =
0x00FF0000
Fox::FXRGBA(0,0xFF,0,0xFF)
Instance Method Summary collapse
- #add_fault(fault) ⇒ Object
- #attach_to_mediator ⇒ Object
- #clear_fault ⇒ Object
- #create_application ⇒ Object
- #create_button(parent, text, action) ⇒ Object
- #create_detail_panel(parent) ⇒ Object
- #create_entry(parent) ⇒ Object
- #create_fault_list(parent) ⇒ Object
- #create_info_panel(parent) ⇒ Object
- #create_label(parent, text) ⇒ Object
- #create_list_panel(parent) ⇒ Object
- #create_main_panel(parent) ⇒ Object
- #create_progress_bar(parent) ⇒ Object
- #create_suite_panel(parent) ⇒ Object
- #create_text(parent) ⇒ Object
- #create_tooltip(app) ⇒ Object
- #create_window(app) ⇒ Object
- #finished(elapsed_time) ⇒ Object
-
#initialize(suite, options = {}) ⇒ TestRunner
constructor
Creates a new TestRunner for running the passed suite.
- #output_status(string) ⇒ Object
- #raw_show_fault(string) ⇒ Object
- #reset_ui(count) ⇒ Object
- #result_changed(result) ⇒ Object
- #setup_mediator ⇒ Object
- #setup_ui ⇒ Object
- #show_fault(fault) ⇒ Object
-
#start ⇒ Object
Begins the test run.
- #start_ui ⇒ Object
- #started(result) ⇒ Object
- #stop ⇒ Object
- #test_started(test_name) ⇒ Object
Constructor Details
#initialize(suite, options = {}) ⇒ TestRunner
Creates a new TestRunner for running the passed suite.
35 36 37 38 39 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 35 def initialize(suite, ={}) super @result = nil @red = false end |
Instance Method Details
#add_fault(fault) ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 95 def add_fault(fault) if ( ! @red ) @test_progress_bar. = RED_STYLE @red = true end item = FaultListItem.new(fault) @fault_list.appendItem(item) end |
#attach_to_mediator ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 59 def attach_to_mediator @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui)) @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @mediator.add_listener(TestResult::CHANGED, &method(:result_changed)) @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) @mediator.add_listener(TestCase::STARTED, &method(:test_started)) @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) end |
#clear_fault ⇒ Object
112 113 114 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 112 def clear_fault raw_show_fault("") end |
#create_application ⇒ Object
181 182 183 184 185 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 181 def create_application app = FXApp.new("TestRunner", "Test::Unit") app.init([]) app end |
#create_button(parent, text, action) ⇒ Object
205 206 207 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 205 def (parent, text, action) FXButton.new(parent, text).connect(SEL_COMMAND, &action) end |
#create_detail_panel(parent) ⇒ Object
240 241 242 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 240 def create_detail_panel(parent) FXHorizontalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK) end |
#create_entry(parent) ⇒ Object
248 249 250 251 252 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 248 def create_entry(parent) entry = FXTextField.new(parent, 30, nil, 0, TEXTFIELD_NORMAL | LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X) entry.disable entry end |
#create_fault_list(parent) ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 225 def create_fault_list(parent) list = FXList.new(parent, :opts => LIST_SINGLESELECT | LAYOUT_FILL_X, :width => 150) list.connect(SEL_COMMAND) do |sender, sel, ptr| item = sender.getItem(sender.currentItem) if item.selected? show_fault(item.fault) else clear_fault end end list end |
#create_info_panel(parent) ⇒ Object
213 214 215 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 213 def create_info_panel(parent) FXMatrix.new(parent, 1, MATRIX_BY_ROWS | LAYOUT_FILL_X) end |
#create_label(parent, text) ⇒ Object
217 218 219 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 217 def create_label(parent, text) FXLabel.new(parent, text, nil, JUSTIFY_CENTER_X | LAYOUT_FILL_COLUMN) end |
#create_list_panel(parent) ⇒ Object
221 222 223 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 221 def create_list_panel(parent) FXHorizontalFrame.new(parent, LAYOUT_FILL_X | FRAME_SUNKEN | FRAME_THICK) end |
#create_main_panel(parent) ⇒ Object
195 196 197 198 199 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 195 def create_main_panel(parent) panel = FXVerticalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y) panel.vSpacing = 10 panel end |
#create_progress_bar(parent) ⇒ Object
209 210 211 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 209 def (parent) FXProgressBar.new(parent, nil, 0, PROGRESSBAR_NORMAL | LAYOUT_FILL_X) end |
#create_suite_panel(parent) ⇒ Object
201 202 203 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 201 def create_suite_panel(parent) FXHorizontalFrame.new(parent, LAYOUT_SIDE_LEFT | LAYOUT_FILL_X) end |
#create_text(parent) ⇒ Object
244 245 246 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 244 def create_text(parent) FXText.new(parent, nil, 0, TEXT_READONLY | LAYOUT_FILL_X | LAYOUT_FILL_Y) end |
#create_tooltip(app) ⇒ Object
191 192 193 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 191 def create_tooltip(app) FXToolTip.new(app) end |
#create_window(app) ⇒ Object
187 188 189 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 187 def create_window(app) FXMainWindow.new(app, "Test::Unit TestRunner", nil, nil, DECOR_ALL, 0, 0, 450) end |
#finished(elapsed_time) ⇒ Object
138 139 140 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 138 def finished(elapsed_time) output_status("Finished in #{elapsed_time} seconds") end |
#output_status(string) ⇒ Object
142 143 144 145 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 142 def output_status(string) @status_entry.text = string @status_entry.repaint end |
#raw_show_fault(string) ⇒ Object
108 109 110 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 108 def raw_show_fault(string) @detail_text.setText(string) end |
#reset_ui(count) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 81 def reset_ui(count) @test_progress_bar. = GREEN_STYLE @test_progress_bar.total = count @test_progress_bar.progress = 0 @red = false @test_count_label.text = "0" @assertion_count_label.text = "0" @failure_count_label.text = "0" @error_count_label.text = "0" @fault_list.clearItems end |
#result_changed(result) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 116 def result_changed(result) @test_progress_bar.progress = result.run_count @test_count_label.text = result.run_count.to_s @assertion_count_label.text = result.assertion_count.to_s @failure_count_label.text = result.failure_count.to_s @error_count_label.text = result.error_count.to_s # repaint now! @info_panel.repaint @application.flush end |
#setup_mediator ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 50 def setup_mediator @mediator = TestRunnerMediator.new(@suite) suite_name = @suite.to_s if ( @suite.kind_of?(Module) ) suite_name = @suite.name end @suite_name_entry.text = suite_name end |
#setup_ui ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 147 def setup_ui @application = create_application create_tooltip(@application) @window = create_window(@application) @status_entry = create_entry(@window) main_panel = create_main_panel(@window) suite_panel = create_suite_panel(main_panel) create_label(suite_panel, "Suite:") @suite_name_entry = create_entry(suite_panel) (suite_panel, "&Run\tRun the current suite", proc { @mediator.run_suite }) @test_progress_bar = (main_panel) @info_panel = create_info_panel(main_panel) create_label(@info_panel, "Tests:") @test_count_label = create_label(@info_panel, "0") create_label(@info_panel, "Assertions:") @assertion_count_label = create_label(@info_panel, "0") create_label(@info_panel, "Failures:") @failure_count_label = create_label(@info_panel, "0") create_label(@info_panel, "Errors:") @error_count_label = create_label(@info_panel, "0") list_panel = create_list_panel(main_panel) @fault_list = create_fault_list(list_panel) detail_panel = create_detail_panel(main_panel) @detail_text = create_text(detail_panel) end |
#show_fault(fault) ⇒ Object
104 105 106 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 104 def show_fault(fault) raw_show_fault(fault.long_display) end |
#start ⇒ Object
Begins the test run.
42 43 44 45 46 47 48 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 42 def start setup_ui setup_mediator attach_to_mediator start_ui @result end |
#start_ui ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 68 def start_ui @application.create @window.show(PLACEMENT_SCREEN) @application.addTimeout(1) do @mediator.run_suite end @application.run end |
#started(result) ⇒ Object
129 130 131 132 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 129 def started(result) @result = result output_status("Started...") end |
#stop ⇒ Object
77 78 79 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 77 def stop @application.exit(0) end |
#test_started(test_name) ⇒ Object
134 135 136 |
# File 'lib/test/unit/ui/fox/testrunner.rb', line 134 def test_started(test_name) output_status("Running #{test_name}...") end |