summaryrefslogtreecommitdiff
path: root/tests
diff options
authorJay Taoko <jay.taoko@canonical.com>2010-06-07 00:57:01 -0400
committerJay Taoko <jay.taoko@canonical.com>2010-06-07 00:57:01 -0400
commitf3db0e725b9d2f46df4f20e42e1e1712781472ab (patch)
tree82a8fa55bd3fdc6e53577c1f7c09f29958f27896 /tests
parenta46bd64dcfb3d3871be226c573316bd869105ca8 (diff)
Work in progress:
Implementing get_entries in FakeIndicators UI testing of indicators [modified] tests/ui/Makefile.am tests/ui/Makefile.am [added] tests/ui/test-indicators.vala - implementing UI testing (bzr r308.1.2)
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/Makefile.am1
-rw-r--r--tests/ui/test-indicators.vala215
-rw-r--r--tests/ui/test-ui.vala2
3 files changed, 218 insertions, 0 deletions
diff --git a/tests/ui/Makefile.am b/tests/ui/Makefile.am
index 27218ae1f..fc178e042 100644
--- a/tests/ui/Makefile.am
+++ b/tests/ui/Makefile.am
@@ -49,6 +49,7 @@ test_ui_VALAFLAGS = \
test_ui_SOURCES = \
test-automate.vala \
test-home-button.vala \
+ test-indicators.vala \
test-quicklist.vala \
test-ui.vala
diff --git a/tests/ui/test-indicators.vala b/tests/ui/test-indicators.vala
new file mode 100644
index 000000000..4c4ea46d8
--- /dev/null
+++ b/tests/ui/test-indicators.vala
@@ -0,0 +1,215 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ * Copyright (C) 2010 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by Jay Taoko <jay.taoko@canonical.com>
+ *
+ */
+
+using Unity;
+using Unity.Testing;
+using Unity.Panel;
+using Unity.Panel.Indicators;
+
+namespace Unity.Tests.UI
+{
+ public class FakeIndicatorObject: Indicator.Object
+ {
+ public Gee.ArrayList<Indicator.ObjectEntry> indicator_entry_array;
+ public Gtk.Label _label = null;
+ public Gtk.Image _image = null;
+ public Gtk.Menu _menu = null;
+ public int index {get; set construct;}
+
+ public FakeIndicatorObject (int i)
+ {
+ Object(index:i);
+ }
+
+ construct
+ {
+ START_FUNCTION ();
+ string index_string = "%d".printf(index);
+ indicator_entry_array = new Gee.ArrayList< unowned Indicator.ObjectEntry> ();
+
+ _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 ();
+ }
+
+ public void add_entry(Indicator.ObjectEntry entry)
+ {
+ int pos = indicator_entry_array.index_of (entry);
+ if (pos != -1)
+ return;
+
+ indicator_entry_array.add (entry);
+ entry_added (entry);
+ }
+
+ public void remove_entry(Indicator.ObjectEntry entry)
+ {
+ int pos = indicator_entry_array.index_of (entry);
+ if (pos != -1)
+ {
+ indicator_entry_array.remove_at (pos);
+ entry_removed (entry);
+ }
+ }
+
+ public override unowned Gtk.Label get_label ()
+ {
+ return this._label;
+ }
+
+ public override unowned Gtk.Image get_image ()
+ {
+ return this._image;
+ }
+
+ public override unowned Gtk.Menu get_menu ()
+ {
+ return this._menu;
+ }
+
+/* public override unowned GLib.List get_entries ()
+ {
+
+ }*/
+ }
+
+ public class FakeIndicatorsModel : IndicatorsModel
+ {
+ //public static Gee.HashMap<string, int> indicator_order = null;
+ public Gee.HashMap<Indicator.Object, string> indicator_map;
+ public Gee.ArrayList<Indicator.Object> indicator_list;
+
+ private Indicator.ObjectEntry entry;
+ private Gtk.Menu menu;
+ private Gtk.Label label;
+ private Gtk.Image image;
+ private Gtk.MenuItem item;
+
+ public FakeIndicatorsModel ()
+ {
+ START_FUNCTION ();
+
+ indicator_map = new Gee.HashMap<Indicator.Object, string> ();
+ //indicator_order = new Gee.HashMap<string, int> ();
+ indicator_list = new Gee.ArrayList<Indicator.Object> ();
+
+ load_fake_indicators ();
+
+ END_FUNCTION ();
+ }
+
+ private void load_fake_indicators ()
+ {
+ entry = new Indicator.ObjectEntry ();
+ menu = new Gtk.Menu ();
+ item = new Gtk.MenuItem.with_label ("lala");
+ //menu.append (item);
+ entry.menu = menu;
+
+ label = new Gtk.Label ("Label");
+ entry.label = label;
+
+ image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU);
+ entry.image = image;
+
+ FakeIndicatorObject o;
+
+ o = new FakeIndicatorObject (0);
+
+ if (o is Indicator.Object)
+ {
+ o.add_entry (entry);
+ this.indicator_map[o] = "fakeindicator0";
+ indicator_list.add (o);
+ }
+
+ /*o = new FakeIndicatorObject (1);
+ this.indicator_map[o] = "fakeindicator1";
+ indicator_list.add (o);*/
+ }
+
+ public override Gee.ArrayList<Indicator.Object> get_indicators ()
+ {
+ stdout.printf ("Returning indicator list\n");
+ return indicator_list;
+ }
+
+ public override string get_indicator_name (Indicator.Object o)
+ {
+ return indicator_map[o];
+ }
+ }
+
+
+ public class IndicatorTestSuite : Object
+ {
+ private const string DOMAIN = "/UI/Indicators";
+
+ Unity.Testing.Window? window;
+ Clutter.Stage? stage;
+ Unity.Testing.Director director;
+
+ public IndicatorTestSuite ()
+ {
+ Logging.init_fatal_handler ();
+
+ FakeIndicatorsModel fake_indicator_model = new FakeIndicatorsModel ();
+ IndicatorsModel.set_default (fake_indicator_model);
+
+ /* Testup the test window */
+ window = new Unity.Testing.Window (true, 1024, 600);
+ window.init_test_mode ();
+ stage = window.stage;
+ window.title = "Indicators testing";
+ window.show_all ();
+
+ director = new Unity.Testing.Director (stage);
+
+
+ Test.add_data_func (DOMAIN + "/Indicators", test_indicators);
+ }
+
+
+ private void test_indicators ()
+ {
+ //director.button_press (home_button, 1, true, 1.0f, 1.0f, false);
+
+ //Logging.init_fatal_handler ();
+
+ //assert (g_flag == true);
+ }
+
+ //
+ // mostly a dummy shell-implementation to satisfy the interface
+ //
+ public bool menus_swallow_events { get { return true; } }
+
+ public ShellMode
+ get_mode ()
+ {
+ return ShellMode.UNDERLAY;
+ }
+
+
+ }
+}
+
diff --git a/tests/ui/test-ui.vala b/tests/ui/test-ui.vala
index afdd74d7f..a3c5cfe66 100644
--- a/tests/ui/test-ui.vala
+++ b/tests/ui/test-ui.vala
@@ -91,6 +91,7 @@ public class Main
QuicklistSuite quicklist_suite;
HomeButtonSuite home_button_suite;
//AutomationBasicTestSuite basic_test_suite;
+ IndicatorTestSuite indicator_test_suite;
Environment.set_variable ("UNITY_DISABLE_TRAY", "1", true);
@@ -108,6 +109,7 @@ public class Main
//basic_test_suite = new AutomationBasicTestSuite ();
quicklist_suite = new QuicklistSuite ();
home_button_suite = new HomeButtonSuite ();
+ indicator_test_suite = new IndicatorTestSuite ();
Timeout.add_seconds (3, ()=> {
Test.run ();