diff options
Diffstat (limited to 'lib/test/unit/ui/gtk/testrunner.rb')
-rw-r--r-- | lib/test/unit/ui/gtk/testrunner.rb | 86 |
1 files changed, 42 insertions, 44 deletions
diff --git a/lib/test/unit/ui/gtk/testrunner.rb b/lib/test/unit/ui/gtk/testrunner.rb index 2e962ca184..8bd7f0e2fc 100644 --- a/lib/test/unit/ui/gtk/testrunner.rb +++ b/lib/test/unit/ui/gtk/testrunner.rb @@ -1,5 +1,3 @@ -# :nodoc: -# # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. @@ -11,7 +9,7 @@ require 'test/unit/ui/testrunnerutilities' module Test module Unit module UI - module GTK # :nodoc: + module GTK # Runs a Test::Unit::TestSuite in a Gtk UI. Obviously, # this one requires you to have Gtk @@ -49,7 +47,7 @@ module Test end private - def setup_mediator # :nodoc: + def setup_mediator @mediator = TestRunnerMediator.new(@suite) suite_name = @suite.to_s if ( @suite.kind_of?(Module) ) @@ -58,7 +56,7 @@ module Test suite_name_entry.set_text(suite_name) end - def attach_to_mediator # :nodoc: + def attach_to_mediator run_button.signal_connect("clicked", nil, &method(:run_test)) @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui)) @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @@ -73,7 +71,7 @@ module Test @runner.raise(@restart_signal) end - def start_ui # :nodoc: + def start_ui @viewer.run running = false begin @@ -93,11 +91,11 @@ module Test end end - def stop(*) # :nodoc: + def stop(*) Gtk.main_quit end - def reset_ui(count) # :nodoc: + def reset_ui(count) test_progress_bar.set_style(green_style) test_progress_bar.configure(0, 0, count) @red = false @@ -110,7 +108,7 @@ module Test fault_list.remove_items(fault_list.children) end - def add_fault(fault) # :nodoc: + def add_fault(fault) if ( ! @red ) test_progress_bar.set_style(red_style) @red = true @@ -120,27 +118,27 @@ module Test fault_list.append_items([item]) end - def show_fault(fault) # :nodoc: + def show_fault(fault) raw_show_fault(fault.long_display) end - def raw_show_fault(string) # :nodoc: + def raw_show_fault(string) fault_detail_label.set_text(string) outer_detail_sub_panel.queue_resize end - def clear_fault # :nodoc: + def clear_fault raw_show_fault("") end - def result_changed(result) # :nodoc: + def result_changed(result) run_count_label.set_text(result.run_count.to_s) assertion_count_label.set_text(result.assertion_count.to_s) failure_count_label.set_text(result.failure_count.to_s) error_count_label.set_text(result.error_count.to_s) end - def started(result) # :nodoc: + def started(result) @result = result output_status("Started...") end @@ -157,11 +155,11 @@ module Test output_status("Finished in #{elapsed_time} seconds") end - def output_status(string) # :nodoc: + def output_status(string) status_entry.set_text(string) end - def setup_ui # :nodoc: + def setup_ui main_window.signal_connect("destroy", nil, &method(:stop)) main_window.show_all fault_list.signal_connect("select-child", nil) { @@ -174,7 +172,7 @@ module Test @red = false end - def main_window # :nodoc: + def main_window lazy_initialize(:main_window) { @main_window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL) @main_window.set_title("Test::Unit TestRunner") @@ -185,7 +183,7 @@ module Test } end - def main_panel # :nodoc: + def main_panel lazy_initialize(:main_panel) { @main_panel = Gtk::VBox.new(false, 0) @main_panel.pack_start(suite_panel, false, false, 0) @@ -197,7 +195,7 @@ module Test } end - def suite_panel # :nodoc: + def suite_panel lazy_initialize(:suite_panel) { @suite_panel = Gtk::HBox.new(false, 10) @suite_panel.border_width(10) @@ -207,20 +205,20 @@ module Test } end - def suite_name_entry # :nodoc: + def suite_name_entry lazy_initialize(:suite_name_entry) { @suite_name_entry = Gtk::Entry.new @suite_name_entry.set_editable(false) } end - def run_button # :nodoc: + def run_button lazy_initialize(:run_button) { @run_button = Gtk::Button.new("Run") } end - def progress_panel # :nodoc: + def progress_panel lazy_initialize(:progress_panel) { @progress_panel = Gtk::HBox.new(false, 10) @progress_panel.border_width(10) @@ -228,7 +226,7 @@ module Test } end - def test_progress_bar # :nodoc: + def test_progress_bar lazy_initialize(:test_progress_bar) { @test_progress_bar = EnhancedProgressBar.new @test_progress_bar.set_usize(@test_progress_bar.allocation.width, @@ -237,21 +235,21 @@ module Test } end - def green_style # :nodoc: + def green_style lazy_initialize(:green_style) { @green_style = Gtk::Style.new @green_style.set_bg(Gtk::STATE_PRELIGHT, 0x0000, 0xFFFF, 0x0000) } end - def red_style # :nodoc: + def red_style lazy_initialize(:red_style) { @red_style = Gtk::Style.new @red_style.set_bg(Gtk::STATE_PRELIGHT, 0xFFFF, 0x0000, 0x0000) } end - def info_panel # :nodoc: + def info_panel lazy_initialize(:info_panel) { @info_panel = Gtk::HBox.new(false, 0) @info_panel.border_width(10) @@ -266,35 +264,35 @@ module Test } end - def run_count_label # :nodoc: + def run_count_label lazy_initialize(:run_count_label) { @run_count_label = Gtk::Label.new("0") @run_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end - def assertion_count_label # :nodoc: + def assertion_count_label lazy_initialize(:assertion_count_label) { @assertion_count_label = Gtk::Label.new("0") @assertion_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end - def failure_count_label # :nodoc: + def failure_count_label lazy_initialize(:failure_count_label) { @failure_count_label = Gtk::Label.new("0") @failure_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end - def error_count_label # :nodoc: + def error_count_label lazy_initialize(:error_count_label) { @error_count_label = Gtk::Label.new("0") @error_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end - def list_panel # :nodoc: + def list_panel lazy_initialize(:list_panel) { @list_panel = Gtk::HBox.new @list_panel.border_width(10) @@ -302,7 +300,7 @@ module Test } end - def list_scrolled_window # :nodoc: + def list_scrolled_window lazy_initialize(:list_scrolled_window) { @list_scrolled_window = Gtk::ScrolledWindow.new @list_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @@ -311,13 +309,13 @@ module Test } end - def fault_list # :nodoc: + def fault_list lazy_initialize(:fault_list) { @fault_list = Gtk::List.new } end - def detail_panel # :nodoc: + def detail_panel lazy_initialize(:detail_panel) { @detail_panel = Gtk::HBox.new @detail_panel.border_width(10) @@ -325,7 +323,7 @@ module Test } end - def detail_scrolled_window # :nodoc: + def detail_scrolled_window lazy_initialize(:detail_scrolled_window) { @detail_scrolled_window = Gtk::ScrolledWindow.new @detail_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @@ -334,21 +332,21 @@ module Test } end - def outer_detail_sub_panel # :nodoc: + def outer_detail_sub_panel lazy_initialize(:outer_detail_sub_panel) { @outer_detail_sub_panel = Gtk::VBox.new @outer_detail_sub_panel.pack_start(inner_detail_sub_panel, false, false, 0) } end - def inner_detail_sub_panel # :nodoc: + def inner_detail_sub_panel lazy_initialize(:inner_detail_sub_panel) { @inner_detail_sub_panel = Gtk::HBox.new @inner_detail_sub_panel.pack_start(fault_detail_label, false, false, 0) } end - def fault_detail_label # :nodoc: + def fault_detail_label lazy_initialize(:fault_detail_label) { @fault_detail_label = EnhancedLabel.new("") style = Gtk::Style.new @@ -362,7 +360,7 @@ module Test } end - def status_panel # :nodoc: + def status_panel lazy_initialize(:status_panel) { @status_panel = Gtk::HBox.new @status_panel.border_width(10) @@ -370,14 +368,14 @@ module Test } end - def status_entry # :nodoc: + def status_entry lazy_initialize(:status_entry) { @status_entry = Gtk::Entry.new @status_entry.set_editable(false) } end - def lazy_initialize(symbol) # :nodoc: + def lazy_initialize(symbol) if (!instance_eval("defined?(@#{symbol.to_s})")) yield end @@ -385,7 +383,7 @@ module Test end end - class EnhancedProgressBar < Gtk::ProgressBar # :nodoc: all + class EnhancedProgressBar < Gtk::ProgressBar all def set_style(style) super hide @@ -393,13 +391,13 @@ module Test end end - class EnhancedLabel < Gtk::Label # :nodoc: all + class EnhancedLabel < Gtk::Label all def set_text(text) super(text.gsub(/\n\t/, "\n" + (" " * 4))) end end - class FaultListItem < Gtk::ListItem # :nodoc: all + class FaultListItem < Gtk::ListItem all attr_reader(:fault) def initialize(fault) super(fault.short_display) |