diff options
| author | Jay Taoko <jay.taoko@canonical.com> | 2010-06-08 18:55:07 -0400 |
|---|---|---|
| committer | Jay Taoko <jay.taoko@canonical.com> | 2010-06-08 18:55:07 -0400 |
| commit | 9237f708225c92f55d5bd5ed826ab92280a5e9a9 (patch) | |
| tree | fb652636d4646d095ba33242c7a015c302d4d377 /tests | |
| parent | b2ab49db6400a9c5080c1b53de1d9c4d2a355dc9 (diff) | |
Indicators UI testing
[modified] tests/ui/test-automate.vala - fixed automation tests tests/ui/test-indicators.vala - added mouse and keyboard events tests on indicators unity-private/panel/panel-indicator-object-view.vala - added utility function to fix an issue in the test.This is a hack. unity-private/panel/panel-indicator-object-entry-view.vala - added function to return true if the menu is open (bzr r308.2.1)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/test-automate.vala | 2 | ||||
| -rw-r--r-- | tests/ui/test-indicators.vala | 95 | ||||
| -rw-r--r-- | tests/ui/test-ui.vala | 2 |
3 files changed, 86 insertions, 13 deletions
diff --git a/tests/ui/test-automate.vala b/tests/ui/test-automate.vala index 71b5f0cfd..3a1aeebd7 100644 --- a/tests/ui/test-automate.vala +++ b/tests/ui/test-automate.vala @@ -79,7 +79,7 @@ namespace Unity.Tests.UI Logging.init_fatal_handler (); QuicklistController qlcontroller = QuicklistController.get_default (); - ScrollerModel scroller = registry.lookup ("UnityScrollerModel") as ScrollerModel; + ScrollerModel scroller = registry.lookup ("UnityScrollerModel").get(0) as ScrollerModel; gTimer = new GLib.Timer(); int DT = 2500; diff --git a/tests/ui/test-indicators.vala b/tests/ui/test-indicators.vala index 3171ed0d7..31b9b68b9 100644 --- a/tests/ui/test-indicators.vala +++ b/tests/ui/test-indicators.vala @@ -49,7 +49,7 @@ namespace Unity.Tests.UI _label = new Gtk.Label ("Indicator" + index_string); _image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); _menu = new Gtk.Menu (); - //_menu.append (new Gtk.MenuItem.with_label ("lala")); + END_FUNCTION (); } @@ -230,11 +230,12 @@ namespace Unity.Tests.UI entry1.image = image1; indicator_model.indicator_object_1.add_entry (entry1); - Test.add_data_func (DOMAIN + "/Indicators", test_indicators); + Test.add_data_func (DOMAIN + "/IndicatorMouseEvent", test_indicators_mouse_event); + Test.add_data_func (DOMAIN + "/IndicatorKeyboardEvent", test_indicators_keyboard_event); } - private void test_indicators () + private void test_indicators_mouse_event () { ObjectRegistry registry = ObjectRegistry.get_default (); Logging.init_fatal_handler (); @@ -243,19 +244,91 @@ namespace Unity.Tests.UI IndicatorBar indicator_bar = registry.lookup ("IndicatorBar").get (0) as IndicatorBar; assert (indicator_bar != null); + + IndicatorObjectView indicator_object_view0 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_0); + assert (indicator_object_view0 != null); + IndicatorObjectView indicator_object_view1 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_1); + assert (indicator_object_view1 != null); + + indicator_object_view0.remove_first_entry (); + indicator_object_view1.remove_first_entry (); + + indicator_bar.do_queue_redraw (); + + IndicatorObjectEntryView object_entry0 = indicator_object_view0.get_entry_view (entry0); + assert (object_entry0 != null); + IndicatorObjectEntryView object_entry1 = indicator_object_view1.get_entry_view (entry1); + assert (object_entry1 != null); - IndicatorObjectView indicator_object_view = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_0); - assert (indicator_object_view != null); + // Test button press on first indicator + director.button_press (object_entry0, 1, true, 1.0f, 1.0f, false); + assert (object_entry0.is_open () == true); + assert (object_entry1.is_open () == false); + director.do_wait_for_timeout (1000); + + // Test button press on second indicator + director.button_press (object_entry1, 1, true, 1.0f, 1.0f, false); + assert (object_entry0.is_open () == false); + assert (object_entry1.is_open () == true); + director.do_wait_for_timeout (1000); + + // Press to close + director.button_press (object_entry1, 1, true, 1.0f, 1.0f, false); + assert (object_entry0.is_open () == false); + assert (object_entry1.is_open () == false); + + } + // Simulate scrubbing +// stdout.printf ("Begin scrubbing navigation\n"); +// director.do_wait_for_timeout (1000); +// director.button_press (object_entry0, 1, true, 1.0f, 1.0f, false); +// +// director.do_wait_for_timeout (1000); +// director.enter_event (object_entry1, 1, 1); +// +// director.do_wait_for_timeout (1000); +// director.enter_event (object_entry0, 1, 1); +// +// // Press to close +// director.button_press (object_entry0, 1, true, 1.0f, 1.0f, false); +// stdout.printf ("End scrubbing navigation\n"); + + private void test_indicators_keyboard_event () + { + ObjectRegistry registry = ObjectRegistry.get_default (); + Logging.init_fatal_handler (); + + FakeIndicatorsModel indicator_model = IndicatorsModel.get_default () as FakeIndicatorsModel; + + IndicatorBar indicator_bar = registry.lookup ("IndicatorBar").get (0) as IndicatorBar; + assert (indicator_bar != null); + + IndicatorObjectView indicator_object_view0 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_0); + assert (indicator_object_view0 != null); + IndicatorObjectView indicator_object_view1 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_1); + assert (indicator_object_view1 != null); - IndicatorObjectEntryView object_entry = indicator_object_view.get_entry_view (entry0); - assert (object_entry != null); + IndicatorObjectEntryView object_entry0 = indicator_object_view0.get_entry_view (entry0); + assert (object_entry0 != null); + IndicatorObjectEntryView object_entry1 = indicator_object_view1.get_entry_view (entry1); + assert (object_entry1 != null); - stdout.printf("pressing\n"); - director.button_press (object_entry, 1, true, 1.0f, 1.0f, false); + //Simulate key navigation + director.do_wait_for_timeout (1000); + director.button_press (object_entry0, 1, true, 1.0f, 1.0f, false); + assert (object_entry0.is_open () == true); + assert (object_entry1.is_open () == false); + director.do_wait_for_timeout (1000); - director.do_wait_for_timeout (2000); + object_entry0.entry.menu.move_current (Gtk.MenuDirectionType.CHILD); + assert (object_entry0.is_open () == false); + assert (object_entry1.is_open () == true); + director.do_wait_for_timeout (1000); + object_entry1.entry.menu.move_current (Gtk.MenuDirectionType.PARENT); + assert (object_entry0.is_open () == true); + assert (object_entry1.is_open () == false); + director.do_wait_for_timeout (1000); - //dir.button_press (entry0, 1, true, 1.0f, 1.0f, false); } // diff --git a/tests/ui/test-ui.vala b/tests/ui/test-ui.vala index c6962db19..465ca79d5 100644 --- a/tests/ui/test-ui.vala +++ b/tests/ui/test-ui.vala @@ -111,7 +111,7 @@ public class Main //home_button_suite = new HomeButtonSuite (); indicator_test_suite = new IndicatorTestSuite (); - Timeout.add_seconds (5, ()=> { + Timeout.add_seconds (3, ()=> { Test.run (); Gtk.main_quit (); return false; |
