summaryrefslogtreecommitdiff
path: root/tests
diff options
authorNeil Jagdish Patel <neil.patel@canonical.com>2010-06-09 12:32:56 +0100
committerNeil Jagdish Patel <neil.patel@canonical.com>2010-06-09 12:32:56 +0100
commit90043614c6e44ac60fbfb27b6f86a3fbdc9878bb (patch)
tree6471093e78718b0471d1343335dcd40de56d1222 /tests
parente955c2c10eb7be7e2b0b0f96ca15224e86418d42 (diff)
- Complete support for loading placefiles, with correct-file tests
added: tests/unit/test-places-place.vala modified: .bzrignore tests/unit/Makefile.am tests/unit/data/place0.place tests/unit/data/place1.place tests/unit/test-places-place-file-model.vala tests/unit/test-unit.vala unity-private/places/places-place-entry.vala unity-private/places/places-place.vala (bzr r312.2.5)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/Makefile.am2
-rw-r--r--tests/unit/data/place0.place2
-rw-r--r--tests/unit/data/place1.place18
-rw-r--r--tests/unit/test-places-place-file-model.vala4
-rw-r--r--tests/unit/test-places-place.vala119
-rw-r--r--tests/unit/test-unit.vala6
6 files changed, 137 insertions, 14 deletions
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 7396a842c..7b4f77958 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -40,6 +40,7 @@ test_unit_VALAFLAGS = \
--pkg clutk-0.3 \
--pkg launcher-0.3 \
--pkg libwnck-1.0 \
+ --pkg posix \
--pkg test-const \
--pkg unique-1.0 \
--pkg unity \
@@ -52,6 +53,7 @@ test_unit_SOURCES = \
test-panel-indicator-object-entry-view.vala \
test-panel-indicator-object-view.vala \
test-places-place-file-model.vala \
+ test-places-place.vala \
test-places.vala \
test-place.vala \
test-unit.vala
diff --git a/tests/unit/data/place0.place b/tests/unit/data/place0.place
index e780a0419..269749689 100644
--- a/tests/unit/data/place0.place
+++ b/tests/unit/data/place0.place
@@ -1,3 +1,3 @@
[Place]
DBusName=org.ayatana.Unity.Place0
-DBusPath=org.ayatana.Unity.Place0
+DBusPath=/org/ayatana/Unity/Place0
diff --git a/tests/unit/data/place1.place b/tests/unit/data/place1.place
index 0e4c17eb4..05b85a6b1 100644
--- a/tests/unit/data/place1.place
+++ b/tests/unit/data/place1.place
@@ -3,25 +3,25 @@ DBusName=org.ayatana.Unity.Place1
DBusPath=/org/ayatana/Unity/Place1
[Entry:One]
-DBusObjectPath=/org/ayatana/Unity/Entry1
+DBusObjectPath=/org/ayatana/Unity/Place1/Entry1
Icon=gtk-apply
Name=One
Description=One Description
-ShowGlobal=True
-ShowEntry=False
+ShowGlobal=true
+ShowEntry=false
[Entry:Two]
-DBusObjectPath=/org/ayatana/Unity/Entry2
+DBusObjectPath=/org/ayatana/Unity/Place1/Entry2
Icon=gtk-close
Name=Two
Description=Two Description
-ShowGlobal=False
-ShowEntry=True
+ShowGlobal=false
+ShowEntry=true
[Entry:Three]
-DBusObjectPath=/org/ayatana/Unity/Entry3
+DBusObjectPath=/org/ayatana/Unity/Place1/Entry3
Icon=gtk-cancel
Name=Three
Description=Three Description
-ShowGlobal=False
-ShowEntry=False
+ShowGlobal=false
+ShowEntry=false
diff --git a/tests/unit/test-places-place-file-model.vala b/tests/unit/test-places-place-file-model.vala
index 6cc0c11ae..67c855eb5 100644
--- a/tests/unit/test-places-place-file-model.vala
+++ b/tests/unit/test-places-place-file-model.vala
@@ -22,11 +22,11 @@ using Unity.Places;
namespace Unity.Tests.Unit
{
- public class PlacesPlaceFileModel : Object
+ public class PlacesPlaceFileModelSuite : Object
{
public const string DOMAIN = "/Unit/Places/PlaceFileModel";
- public PlacesPlaceFileModel ()
+ public PlacesPlaceFileModelSuite ()
{
Logging.init_fatal_handler ();
diff --git a/tests/unit/test-places-place.vala b/tests/unit/test-places-place.vala
new file mode 100644
index 000000000..9b696616c
--- /dev/null
+++ b/tests/unit/test-places-place.vala
@@ -0,0 +1,119 @@
+/*
+ * 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 Neil Jagdish Patel <neil.patel@canonical.com>
+ *
+ */
+using Unity;
+using Unity.Testing;
+using Unity.Places;
+using GLib.Test;
+
+namespace Unity.Tests.Unit
+{
+ public class PlacesPlaceSuite : Object
+ {
+ public const string DOMAIN = "/Unit/Places/Place";
+
+ public PlacesPlaceSuite ()
+ {
+ Logging.init_fatal_handler ();
+
+ Test.add_data_func (DOMAIN + "/Allocation", test_allocation);
+ Test.add_data_func (DOMAIN + "/SimpleKeyfile", test_simple_placefile);
+ Test.add_data_func (DOMAIN + "/AdvancedKeyFile", test_advanced_placefile);
+ }
+
+ private void test_allocation ()
+ {
+ var place = new Places.Place ("__name__", "__path__");
+ assert (place is Places.Place);
+ assert (place.dbus_name == "__name__");
+ assert (place.dbus_path == "__path__");
+ }
+
+ private void test_simple_placefile ()
+ {
+ var file = new KeyFile ();
+ try {
+ file.load_from_file (TESTDIR + "/data/place0.place",
+ KeyFileFlags.NONE);
+ } catch (Error e) {
+ error ("Unable to load test place: %s", e.message);
+ }
+
+ var place = Places.Place.new_from_keyfile (file);
+ assert (place is Places.Place);
+
+ /* Test Place group was loaded properly */
+ assert (place.dbus_name == "org.ayatana.Unity.Place0");
+ assert (place.dbus_path == "/org/ayatana/Unity/Place0");
+
+ /* Test entries were loaded properly */
+ assert (place.n_entries == 0);
+ }
+
+ private void test_advanced_placefile ()
+ {
+ var file = new KeyFile ();
+ try {
+ file.load_from_file (TESTDIR + "/data/place1.place",
+ KeyFileFlags.NONE);
+ } catch (Error error) {
+ warning ("Unable to load test place: %s", error.message);
+ }
+
+ var place = Places.Place.new_from_keyfile (file);
+ assert (place is Places.Place);
+
+ /* Test Place group was loaded properly */
+ assert (place.dbus_name == "org.ayatana.Unity.Place1");
+ assert (place.dbus_path == "/org/ayatana/Unity/Place1");
+
+ /* Test entries were loaded properly */
+ assert (place.n_entries == 3);
+
+ /* Test individual entry's properties were loaded correctly */
+ PlaceEntry? e;
+
+ e = place.get_nth_entry (0);
+ assert (e is PlaceEntry);
+ assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry1");
+ assert (e.name == "One");
+ assert (e.icon == "gtk-apply");
+ assert (e.description == "One Description");
+ assert (e.show_global == true);
+ assert (e.show_entry == false);
+
+ e = place.get_nth_entry (1);
+ assert (e is PlaceEntry);
+ assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry2");
+ assert (e.name == "Two");
+ assert (e.icon == "gtk-close");
+ assert (e.description == "Two Description");
+ assert (e.show_global == false);
+ assert (e.show_entry == true);
+
+ e = place.get_nth_entry (2);
+ assert (e is PlaceEntry);
+ assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry3");
+ assert (e.name == "Three");
+ assert (e.icon == "gtk-cancel");
+ assert (e.description == "Three Description");
+ assert (e.show_global == false);
+ assert (e.show_entry == false);
+ }
+ }
+}
diff --git a/tests/unit/test-unit.vala b/tests/unit/test-unit.vala
index 3cb7c8dd1..b74819f60 100644
--- a/tests/unit/test-unit.vala
+++ b/tests/unit/test-unit.vala
@@ -29,7 +29,8 @@ public class Main
PanelIndicatorObjectEntryViewSuite panel_object_entry_view_suite;
PanelIndicatorObjectViewSuite panel_object_view_suite;
- PlacesPlaceFileModel place_file_model;
+ PlacesPlaceFileModelSuite place_file_model;
+ PlacesPlaceSuite places_place;
PlacesSuite places;
PlaceSuite place;
@@ -43,7 +44,8 @@ public class Main
/* Panel tests */
panel_object_entry_view_suite = new PanelIndicatorObjectEntryViewSuite ();
panel_object_view_suite = new PanelIndicatorObjectViewSuite ();
- place_file_model = new PlacesPlaceFileModel ();
+ place_file_model = new PlacesPlaceFileModelSuite ();
+ places_place = new PlacesPlaceSuite ();
/* Places tests */
places = new PlacesSuite ();