Merge lp:~unity-team/unity/enable-vala-tests into lp:unity
- enable-vala-tests
- Merge into trunk
Proposed by
Neil J. Patel
on 2010-11-29
| Status: | Rejected |
|---|---|
| Rejected by: | Mikkel Kamstrup Erlandsen on 2010-12-15 |
| Proposed branch: | lp:~unity-team/unity/enable-vala-tests |
| Merge into: | lp:unity |
| Diff against target: |
2726 lines (+533/-2012) 24 files modified
src/unityshell.cpp (+1/-1) tests/CMakeLists.txt (+37/-8) tests/vala/numpty.cpp (+1/-0) tests/vala/test-appinfo-manager.vala (+146/-0) tests/vala/test-io.vala (+86/-0) tests/vala/test-place-browser.vala (+129/-0) tests/vala/test-unit.vala (+7/-31) tests/vala/test-utils.vala (+126/-0) vala_tests/ui/Makefile.am (+0/-73) vala_tests/ui/data/Makefile.am (+0/-1) vala_tests/ui/test-automate.vala (+0/-131) vala_tests/ui/test-const.vapi (+0/-25) vala_tests/ui/test-home-button.vala (+0/-188) vala_tests/ui/test-indicators.vala (+0/-321) vala_tests/ui/test-quicklist.vala (+0/-85) vala_tests/ui/test-ui.vala (+0/-129) vala_tests/unit/Makefile.am (+0/-85) vala_tests/unit/test-dbusmenu-quicklists.vala (+0/-188) vala_tests/unit/test-launcher.vala (+0/-223) vala_tests/unit/test-panel-indicator-object-entry-view.vala (+0/-97) vala_tests/unit/test-panel-indicator-object-view.vala (+0/-154) vala_tests/unit/test-places-place-file-model.vala (+0/-43) vala_tests/unit/test-places-place.vala (+0/-161) vala_tests/unit/test-places.vala (+0/-68) |
| To merge this branch: | bzr merge lp:~unity-team/unity/enable-vala-tests |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Gord Allott | 2010-11-29 | Pending | |
|
Review via email:
|
|||
Commit Message
Description of the Change
- Removes all the tests that no longer apply
- Re-enables building of vala tests for libunity
- Adds test-vala to the make check target
- Stubs for test-appinfo-
- I left test-pixbuf-cache because I'm still thinking what to do with it
you should be able to `make check` and see all the tests fly by and (hopefully) pass.
N.B. unity.[h|cpp] => unityshell.[h|cpp] because it clashes with the unity.h that libunity produces and, in any case, this now matches the plugin name.
To post a comment you must log in.
| Gord Allott (gordallott) wrote : | # |
I merged this branch into lp:~kamstrup/unity/gio-vapi-break-fixes. So we can close this merge proposal.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === renamed file 'src/unity.cpp' => 'src/unityshell.cpp' |
| 2 | --- src/unity.cpp 2010-11-26 08:12:02 +0000 |
| 3 | +++ src/unityshell.cpp 2010-11-29 11:57:46 +0000 |
| 4 | @@ -31,7 +31,7 @@ |
| 5 | #include "LauncherController.h" |
| 6 | #include "PluginAdapter.h" |
| 7 | #include "StartupNotifyService.h" |
| 8 | -#include "unity.h" |
| 9 | +#include "unityshell.h" |
| 10 | |
| 11 | #include <dbus/dbus.h> |
| 12 | #include <dbus/dbus-glib.h> |
| 13 | |
| 14 | === renamed file 'src/unity.h' => 'src/unityshell.h' |
| 15 | === modified file 'tests/CMakeLists.txt' |
| 16 | --- tests/CMakeLists.txt 2010-11-25 16:23:26 +0000 |
| 17 | +++ tests/CMakeLists.txt 2010-11-29 11:57:46 +0000 |
| 18 | @@ -8,7 +8,7 @@ |
| 19 | # Unit tests |
| 20 | # |
| 21 | find_package (PkgConfig) |
| 22 | -set (TEST_DEPS "${UNITY_PLUGIN_DEPS};indicator") |
| 23 | +set (TEST_DEPS "${UNITY_PLUGIN_DEPS};indicator;gee-1.0") |
| 24 | pkg_check_modules (TEST_UNIT_DEPS REQUIRED ${TEST_DEPS} indicator) |
| 25 | |
| 26 | set (CFLAGS |
| 27 | @@ -17,16 +17,17 @@ |
| 28 | "-DGETTEXT_PACKAGE=\"unity\"" |
| 29 | "-DINDICATORDIR=\"${CMAKE_BINARY_DIR}/tests\"" |
| 30 | "-DINDICATORICONDIR=\"${CMAKE_BINARY_DIR}/tests\"" |
| 31 | + "-I${CMAKE_BINARY_DIR}/libuntiy" |
| 32 | ) |
| 33 | add_definitions (${CFLAGS}) |
| 34 | |
| 35 | -set (LIBS ${TEST_UNIT_DEPS_LIBRARIES}) |
| 36 | +set (LIBS ${TEST_UNIT_DEPS_LIBRARIES} -lunity) |
| 37 | link_libraries (${LIBS}) |
| 38 | |
| 39 | -set (LIB_PATHS ${TEST_UNIT_DEPS_LIBRARY_DIRS}) |
| 40 | +set (LIB_PATHS ${TEST_UNIT_DEPS_LIBRARY_DIRS} ${CMAKE_BINARY_DIR}/libunity) |
| 41 | link_directories (${LIB_PATHS}) |
| 42 | |
| 43 | -include_directories (. .. ../services ../src ${CMAKE_BINARY_DIR}) |
| 44 | +include_directories (. .. ${CMAKE_BINARY_DIR}/libunity ../services ${CMAKE_BINARY_DIR}) |
| 45 | |
| 46 | # We can't have convenience libs so we need to rebuild with what we need |
| 47 | # Please keep actual test files alphabetically at top and then files |
| 48 | @@ -81,11 +82,39 @@ |
| 49 | ) |
| 50 | |
| 51 | # |
| 52 | +# Vala tests |
| 53 | +# |
| 54 | +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala) |
| 55 | +include(ValaPrecompile) |
| 56 | +include(ValaVersion) |
| 57 | + |
| 58 | +find_package (Vala) |
| 59 | + |
| 60 | +vala_precompile (VALA_C vala/test-unit.vala |
| 61 | + vala/test-place-browser.vala |
| 62 | + vala/test-place.vala |
| 63 | + vala/test-utils.vala |
| 64 | + PACKAGES gtk+-2.0 |
| 65 | + gio-2.0 |
| 66 | + glib-2.0 |
| 67 | + gobject-2.0 |
| 68 | + gee-1.0 |
| 69 | + dbus-glib-1 |
| 70 | + gee-1.0 |
| 71 | + OPTIONS --thread |
| 72 | + CUSTOM_VAPIS ${CMAKE_SOURCE_DIR}/vapi/dee-1.0.vapi |
| 73 | + vala/test-const.vapi |
| 74 | + ${CMAKE_BINARY_DIR}/libunity/unity.vapi |
| 75 | +) |
| 76 | + |
| 77 | +add_executable(test-vala ${VALA_C} vala/numpty.cpp) |
| 78 | + |
| 79 | +# |
| 80 | # check target |
| 81 | # |
| 82 | set (TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/tests) |
| 83 | -set (TEST_RESULT_XML ${TEST_RESULT_DIR}/test-unit-results.xml) |
| 84 | -set (TEST_RESULT_HTML ${TEST_RESULT_DIR}/test-unit-results.html) |
| 85 | -set (TEST_UNIT_COMMAND gtester --verbose -k --g-fatal-warnings -o=${TEST_RESULT_XML} ./test-unit) |
| 86 | -add_custom_target (check COMMAND ${TEST_UNIT_COMMAND} DEPENDS test-unit) |
| 87 | +set (TEST_RESULT_XML ${TEST_RESULT_DIR}/test-results.xml) |
| 88 | +set (TEST_RESULT_HTML ${TEST_RESULT_DIR}/test-results.html) |
| 89 | +set (TEST_COMMAND gtester --verbose -k --g-fatal-warnings -o=${TEST_RESULT_XML} ./test-unit ./test-vala) |
| 90 | +add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-vala) |
| 91 | add_custom_target (check-report COMMAND ${TEST_UNIT_COMMAND} && gtester-report ${TEST_RESULT_XML} > ${TEST_RESULT_HTML}) |
| 92 | |
| 93 | === renamed directory 'vala_tests' => 'tests/vala' |
| 94 | === renamed directory 'vala_tests/unit/data' => 'tests/vala/data' |
| 95 | === added file 'tests/vala/numpty.cpp' |
| 96 | --- tests/vala/numpty.cpp 1970-01-01 00:00:00 +0000 |
| 97 | +++ tests/vala/numpty.cpp 2010-11-29 11:57:46 +0000 |
| 98 | @@ -0,0 +1,1 @@ |
| 99 | + |
| 100 | |
| 101 | === added file 'tests/vala/test-appinfo-manager.vala' |
| 102 | --- tests/vala/test-appinfo-manager.vala 1970-01-01 00:00:00 +0000 |
| 103 | +++ tests/vala/test-appinfo-manager.vala 2010-11-29 11:57:46 +0000 |
| 104 | @@ -0,0 +1,146 @@ |
| 105 | +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 106 | +/* |
| 107 | + * Copyright (C) 2010 Canonical Ltd |
| 108 | + * |
| 109 | + * This program is free software: you can redistribute it and/or modify |
| 110 | + * it under the terms of the GNU General Public License version 3 as |
| 111 | + * published by the Free Software Foundation. |
| 112 | + * |
| 113 | + * This program is distributed in the hope that it will be useful, |
| 114 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 115 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 116 | + * GNU General Public License for more details. |
| 117 | + * |
| 118 | + * You should have received a copy of the GNU General Public License |
| 119 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 120 | + * |
| 121 | + * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> |
| 122 | + * |
| 123 | + */ |
| 124 | +using Unity; |
| 125 | +using Unity.Testing; |
| 126 | + |
| 127 | +namespace Unity.Tests.Unit |
| 128 | +{ |
| 129 | + public class AppInfoManagerSuite |
| 130 | + { |
| 131 | + |
| 132 | + public AppInfoManagerSuite () |
| 133 | + { |
| 134 | + Test.add_data_func ("/Unit/AppInfoManager/Allocation", |
| 135 | + AppInfoManagerSuite.test_allocation); |
| 136 | + Test.add_data_func ("/Unit/AppInfoManager/ClearEmpty", |
| 137 | + AppInfoManagerSuite.test_clear_empty); |
| 138 | + Test.add_data_func ("/Unit/AppInfoManager/SyncLookupMissing", |
| 139 | + AppInfoManagerSuite.test_sync_lookup_missing); |
| 140 | + Test.add_data_func ("/Unit/AppInfoManager/AsyncLookupMissing", |
| 141 | + AppInfoManagerSuite.test_async_lookup_missing); |
| 142 | + Test.add_data_func ("/Unit/AppInfoManager/SyncLookupOk", |
| 143 | + AppInfoManagerSuite.test_sync_lookup_ok); |
| 144 | + Test.add_data_func ("/Unit/AppInfoManager/AsyncLookupOk", |
| 145 | + AppInfoManagerSuite.test_async_lookup_ok); |
| 146 | + } |
| 147 | + |
| 148 | + /* Test that we can even get a valid ref to the manager */ |
| 149 | + internal static void test_allocation() |
| 150 | + { |
| 151 | + var manager = AppInfoManager.get_instance(); |
| 152 | + assert (manager is AppInfoManager); |
| 153 | + } |
| 154 | + |
| 155 | + /* Test that we can clear an empty manager */ |
| 156 | + internal static void test_clear_empty() |
| 157 | + { |
| 158 | + var manager = AppInfoManager.get_instance(); |
| 159 | + manager.clear (); |
| 160 | + manager.clear (); |
| 161 | + } |
| 162 | + |
| 163 | + /* Test that we can clear an empty manager */ |
| 164 | + internal static void test_sync_lookup_missing() |
| 165 | + { |
| 166 | + var manager = AppInfoManager.get_instance(); |
| 167 | + assert (manager.lookup ("_foobar.desktop") == null); |
| 168 | + } |
| 169 | + |
| 170 | + internal static void test_async_lookup_missing() |
| 171 | + { |
| 172 | + MainLoop mainloop = new MainLoop(); |
| 173 | + do_test_async_lookup_missing.begin(mainloop); |
| 174 | + mainloop.run (); |
| 175 | + } |
| 176 | + |
| 177 | + internal static async void do_test_async_lookup_missing (MainLoop mainloop) |
| 178 | + { |
| 179 | + var manager = AppInfoManager.get_instance(); |
| 180 | + |
| 181 | + try { |
| 182 | + AppInfo? appinfo = yield manager.lookup_async ("_foobar.desktop"); |
| 183 | + assert (appinfo == null); |
| 184 | + } catch (Error e) { |
| 185 | + error ("Error reading desktop file: %s", e.message); |
| 186 | + } |
| 187 | + |
| 188 | + mainloop.quit (); |
| 189 | + } |
| 190 | + |
| 191 | + /* Test that we can lookup something which is indeed there */ |
| 192 | + internal static void test_sync_lookup_ok() |
| 193 | + { |
| 194 | + string old_datadir = Environment.get_user_data_dir (); |
| 195 | + var manager = AppInfoManager.get_instance(); |
| 196 | + |
| 197 | + Environment.set_variable ("XDG_DATA_HOME", Config.TESTUNITDIR+"/data", true); |
| 198 | + debug ("XDG %s", Config.TESTUNITDIR+"/data"); |
| 199 | + |
| 200 | + var info = manager.lookup ("ubuntu-about.desktop"); |
| 201 | + assert (info != null); |
| 202 | + assert (info is AppInfo); |
| 203 | + assert ("About Ubuntu" == info.get_name ()); |
| 204 | + |
| 205 | + Gee.List<string> categories = manager.get_categories ("ubuntu-about.desktop"); |
| 206 | + assert (categories != null); |
| 207 | + assert (categories[0] == "GNOME"); |
| 208 | + assert (categories[1] == "Application"); |
| 209 | + assert (categories[2] == "Core"); |
| 210 | + |
| 211 | + /* Reset the environment like a good citizen */ |
| 212 | + Environment.set_variable ("XDG_DATA_HOME", old_datadir, true); |
| 213 | + } |
| 214 | + |
| 215 | + internal static void test_async_lookup_ok() |
| 216 | + { |
| 217 | + MainLoop mainloop = new MainLoop(); |
| 218 | + do_test_async_lookup_ok.begin(mainloop); |
| 219 | + mainloop.run (); |
| 220 | + } |
| 221 | + |
| 222 | + internal static async void do_test_async_lookup_ok (MainLoop mainloop) |
| 223 | + { |
| 224 | + string old_datadir = Environment.get_user_data_dir (); |
| 225 | + var manager = AppInfoManager.get_instance(); |
| 226 | + |
| 227 | + Environment.set_variable ("XDG_DATA_HOME", Config.TESTUNITDIR+"/data", true); |
| 228 | + |
| 229 | + try{ |
| 230 | + var info = yield manager.lookup_async ("ubuntu-about.desktop"); |
| 231 | + assert (info is AppInfo); |
| 232 | + assert ("About Ubuntu" == info.get_name ()); |
| 233 | + } catch (Error e) { |
| 234 | + error ("Error reading desktop file: %s", e.message); |
| 235 | + } |
| 236 | + |
| 237 | + Gee.List<string> categories = manager.get_categories ("ubuntu-about.desktop"); |
| 238 | + assert (categories != null); |
| 239 | + assert (categories[0] == "GNOME"); |
| 240 | + assert (categories[1] == "Application"); |
| 241 | + assert (categories[2] == "Core"); |
| 242 | + |
| 243 | + /* Reset the environment like a good citizen */ |
| 244 | + Environment.set_variable ("XDG_DATA_HOME", old_datadir, true); |
| 245 | + |
| 246 | + mainloop.quit (); |
| 247 | + } |
| 248 | + |
| 249 | + } |
| 250 | +} |
| 251 | |
| 252 | === renamed file 'vala_tests/unit/test-const.vapi' => 'tests/vala/test-const.vapi' |
| 253 | === added file 'tests/vala/test-io.vala' |
| 254 | --- tests/vala/test-io.vala 1970-01-01 00:00:00 +0000 |
| 255 | +++ tests/vala/test-io.vala 2010-11-29 11:57:46 +0000 |
| 256 | @@ -0,0 +1,86 @@ |
| 257 | +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 258 | +/* |
| 259 | + * Copyright (C) 2010 Canonical Ltd |
| 260 | + * |
| 261 | + * This program is free software: you can redistribute it and/or modify |
| 262 | + * it under the terms of the GNU General Public License version 3 as |
| 263 | + * published by the Free Software Foundation. |
| 264 | + * |
| 265 | + * This program is distributed in the hope that it will be useful, |
| 266 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 267 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 268 | + * GNU General Public License for more details. |
| 269 | + * |
| 270 | + * You should have received a copy of the GNU General Public License |
| 271 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 272 | + * |
| 273 | + * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> |
| 274 | + * |
| 275 | + */ |
| 276 | +using Unity; |
| 277 | +using Unity.Place; |
| 278 | +using Unity.Testing; |
| 279 | + |
| 280 | +namespace Unity.Tests.Unit |
| 281 | +{ |
| 282 | + public class IOSuite |
| 283 | + { |
| 284 | + /* Copy of the data found in data/test_desktop_file.deskop */ |
| 285 | + static string TEST_DATA = """[Desktop Entry] |
| 286 | +Name=Test Application |
| 287 | +Comment=This is a test application desktop file |
| 288 | +Exec=xclock |
| 289 | +Terminal=false |
| 290 | +Type=Application |
| 291 | +StartupNotify=false |
| 292 | +Icon=test_desktop_icon.png |
| 293 | +"""; |
| 294 | + |
| 295 | + public IOSuite () |
| 296 | + { |
| 297 | + Test.add_data_func ("/Unit/IO/AsyncDektopFile", |
| 298 | + IOSuite.test_async_find_and_load); |
| 299 | + } |
| 300 | + |
| 301 | + internal static void test_async_find_and_load() |
| 302 | + { |
| 303 | + MainLoop mainloop = new MainLoop(); |
| 304 | + do_test_async_find_and_load.begin(mainloop); |
| 305 | + mainloop.run (); |
| 306 | + } |
| 307 | + |
| 308 | + internal static async void do_test_async_find_and_load (MainLoop mainloop) |
| 309 | + { |
| 310 | + string[] dirs = new string[1]; |
| 311 | + dirs[0] = Path.build_filename (Config.TESTUNITDIR, "data", null |
| 312 | + ); |
| 313 | + try |
| 314 | + { |
| 315 | + var input = yield IO.open_from_dirs ("test_desktop_file.desktop", |
| 316 | + dirs); |
| 317 | + assert (input is FileInputStream); |
| 318 | + |
| 319 | + /* Read in small chunks to test reading across buffer pages */ |
| 320 | + uchar[] buf = new uchar[16]; |
| 321 | + void* data; |
| 322 | + size_t data_size; |
| 323 | + yield IO.read_stream_async (input, buf, 16, Priority.DEFAULT, null, |
| 324 | + out data, out data_size); |
| 325 | + |
| 326 | + /* The test file is 177 bytes long */ |
| 327 | + assert (data_size == 177); |
| 328 | + |
| 329 | + /* null terminate the data so we can use it string comparison */ |
| 330 | + string sdata = ((string)data).ndup(data_size); |
| 331 | + assert (sdata == TEST_DATA); |
| 332 | + } |
| 333 | + catch (Error e) |
| 334 | + { |
| 335 | + error ("Failed read test file: %s", e.message); |
| 336 | + } |
| 337 | + |
| 338 | + mainloop.quit (); |
| 339 | + } |
| 340 | + |
| 341 | + } |
| 342 | +} |
| 343 | |
| 344 | === added file 'tests/vala/test-place-browser.vala' |
| 345 | --- tests/vala/test-place-browser.vala 1970-01-01 00:00:00 +0000 |
| 346 | +++ tests/vala/test-place-browser.vala 2010-11-29 11:57:46 +0000 |
| 347 | @@ -0,0 +1,129 @@ |
| 348 | +/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 349 | +/* |
| 350 | + * Copyright (C) 2010 Canonical Ltd |
| 351 | + * |
| 352 | + * This program is free software: you can redistribute it and/or modify |
| 353 | + * it under the terms of the GNU General Public License version 3 as |
| 354 | + * published by the Free Software Foundation. |
| 355 | + * |
| 356 | + * This program is distributed in the hope that it will be useful, |
| 357 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 358 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 359 | + * GNU General Public License for more details. |
| 360 | + * |
| 361 | + * You should have received a copy of the GNU General Public License |
| 362 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 363 | + * |
| 364 | + * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> |
| 365 | + * |
| 366 | + */ |
| 367 | +using Unity; |
| 368 | +using Unity.Place; |
| 369 | +using Unity.Testing; |
| 370 | +using Gee; |
| 371 | + |
| 372 | +namespace Unity.Tests.Unit |
| 373 | +{ |
| 374 | + public class PlaceBrowserSuite |
| 375 | + { |
| 376 | + public PlaceBrowserSuite () |
| 377 | + { |
| 378 | + Test.add_data_func ("/Unit/Place/Stack", |
| 379 | + PlaceBrowserSuite.test_stack); |
| 380 | + Test.add_data_func ("/Unit/Place/Browser", |
| 381 | + PlaceBrowserSuite.test_browser); |
| 382 | + } |
| 383 | + |
| 384 | + internal static void test_stack() |
| 385 | + { |
| 386 | + /* Test the empty stack */ |
| 387 | + var stack = new Stack<string> (); |
| 388 | + assert (stack.is_empty ()); |
| 389 | + assert (stack.size () == 0); |
| 390 | + assert (stack.pop () == null); |
| 391 | + |
| 392 | + /* Test with one element */ |
| 393 | + stack.push ("foo"); |
| 394 | + assert (!stack.is_empty ()); |
| 395 | + assert (stack.size () == 1); |
| 396 | + assert ("foo" == stack.pop ()); |
| 397 | + assert (stack.is_empty ()); |
| 398 | + assert (stack.size () == 0); |
| 399 | + assert (stack.pop () == null); |
| 400 | + |
| 401 | + /* Test with two elements */ |
| 402 | + stack.push ("bar"); |
| 403 | + assert (!stack.is_empty ()); |
| 404 | + assert (stack.size () == 1); |
| 405 | + stack.push ("baz"); |
| 406 | + assert (!stack.is_empty ()); |
| 407 | + assert (stack.size () == 2); |
| 408 | + assert ("baz" == stack.pop ()); |
| 409 | + assert (!stack.is_empty ()); |
| 410 | + assert (stack.size () == 1); |
| 411 | + assert ("bar" == stack.pop ()); |
| 412 | + assert (stack.is_empty ()); |
| 413 | + assert (stack.size () == 0); |
| 414 | + assert (stack.pop () == null); |
| 415 | + } |
| 416 | + |
| 417 | + internal static void test_browser () |
| 418 | + { |
| 419 | + Gee.List<string> playback = new ArrayList<string> (); |
| 420 | + Browser<string> browser = new Browser<string> ("/org/example/browser/1"); |
| 421 | + |
| 422 | + assert (browser.dbus_path == "/org/example/browser/1"); |
| 423 | + |
| 424 | + browser.back.connect ( (b, state, comment) => { |
| 425 | + playback.add ((string)state); |
| 426 | + }); |
| 427 | + |
| 428 | + browser.forward.connect ( (b, state, comment) => { |
| 429 | + playback.add ((string)state); |
| 430 | + }); |
| 431 | + |
| 432 | + browser.record_state ("First", "Comment1"); |
| 433 | + browser.record_state ("Second", "Comment2"); |
| 434 | + browser.record_state ("Third", "Comment3"); |
| 435 | + browser.record_state ("Fourth", "Comment4"); |
| 436 | + |
| 437 | + browser.go_back (); |
| 438 | + assert (playback[playback.size - 1] == "Third"); |
| 439 | + |
| 440 | + browser.go_back (); |
| 441 | + assert (playback[playback.size - 1] == "Second"); |
| 442 | + |
| 443 | + browser.record_state ("Fifth", "Comment5"); |
| 444 | + browser.record_state ("Sixth", "Comment6"); |
| 445 | + browser.record_state ("Seven", "Comment7"); |
| 446 | + |
| 447 | + browser.go_back (); |
| 448 | + assert (playback[playback.size - 1] == "Sixth"); |
| 449 | + |
| 450 | + browser.go_back (); |
| 451 | + assert (playback[playback.size - 1] == "Fifth"); |
| 452 | + |
| 453 | + browser.go_back (); |
| 454 | + assert (playback[playback.size - 1] == "Second"); |
| 455 | + |
| 456 | + browser.go_back (); |
| 457 | + var last_size = playback.size; |
| 458 | + assert (playback[playback.size - 1] == "First"); |
| 459 | + assert (playback.size == last_size); |
| 460 | + |
| 461 | + browser.go_back (); // no-op |
| 462 | + assert (playback[playback.size - 1] == "First"); |
| 463 | + assert (playback.size == last_size); |
| 464 | + |
| 465 | + browser.go_forward (); |
| 466 | + assert (playback[playback.size - 1] == "Second"); |
| 467 | + |
| 468 | + browser.go_forward (); |
| 469 | + assert (playback[playback.size - 1] == "Fifth"); |
| 470 | + |
| 471 | + browser.go_forward (); |
| 472 | + assert (playback[playback.size - 1] == "Sixth"); |
| 473 | + } |
| 474 | + |
| 475 | + } |
| 476 | +} |
| 477 | |
| 478 | === renamed file 'vala_tests/unit/test-place.vala' => 'tests/vala/test-place.vala' |
| 479 | === renamed file 'vala_tests/unit/test-unit.vala' => 'tests/vala/test-unit.vala' |
| 480 | --- vala_tests/unit/test-unit.vala 2010-08-02 07:33:41 +0000 |
| 481 | +++ tests/vala/test-unit.vala 2010-11-29 11:57:46 +0000 |
| 482 | @@ -24,47 +24,23 @@ |
| 483 | { |
| 484 | public static int main (string[] args) |
| 485 | { |
| 486 | - UnityPixbufCacheSuite unity_pixbuf_cache; |
| 487 | - |
| 488 | - LauncherSuite launcher; |
| 489 | - QuicklistSuite quicklists; |
| 490 | - |
| 491 | - PanelIndicatorObjectEntryViewSuite panel_object_entry_view_suite; |
| 492 | - PanelIndicatorObjectViewSuite panel_object_view_suite; |
| 493 | - |
| 494 | - PlacesPlaceFileModelSuite place_file_model; |
| 495 | - PlacesPlaceSuite places_place; |
| 496 | - PlacesSuite places; |
| 497 | PlaceSuite place; |
| 498 | PlaceBrowserSuite place_browser; |
| 499 | - IOSuite io; |
| 500 | - AppInfoManagerSuite appinfo_manager; |
| 501 | + //IOSuite io; |
| 502 | + //AppInfoManagerSuite appinfo_manager; |
| 503 | |
| 504 | Gtk.init (ref args); |
| 505 | - Ctk.init (ref args); |
| 506 | Test.init (ref args); |
| 507 | |
| 508 | - /* Libunity tests */ |
| 509 | - unity_pixbuf_cache = new UnityPixbufCacheSuite (); |
| 510 | - |
| 511 | - /* Launcher tests */ |
| 512 | - launcher = new LauncherSuite (); |
| 513 | - quicklists = new QuicklistSuite (); |
| 514 | - |
| 515 | - /* Panel tests */ |
| 516 | - panel_object_entry_view_suite = new PanelIndicatorObjectEntryViewSuite (); |
| 517 | - panel_object_view_suite = new PanelIndicatorObjectViewSuite (); |
| 518 | - place_file_model = new PlacesPlaceFileModelSuite (); |
| 519 | - places_place = new PlacesPlaceSuite (); |
| 520 | - |
| 521 | /* Places tests */ |
| 522 | - places = new PlacesSuite (); |
| 523 | place = new PlaceSuite (); |
| 524 | place_browser = new PlaceBrowserSuite (); |
| 525 | |
| 526 | - /* IO utility tests */ |
| 527 | - io = new IOSuite (); |
| 528 | - appinfo_manager = new AppInfoManagerSuite (); |
| 529 | + /* FIXME: IO utility tests */ |
| 530 | + //io = new IOSuite (); |
| 531 | + |
| 532 | + /* FIXME: This needs to be re-enabled in mikkels branch |
| 533 | + appinfo_manager = new AppInfoManagerSuite ();*/ |
| 534 | |
| 535 | Test.run (); |
| 536 | |
| 537 | |
| 538 | === renamed file 'vala_tests/unit/test-unity-pixbuf-cache.vala' => 'tests/vala/test-unity-pixbuf-cache.vala' |
| 539 | === added file 'tests/vala/test-utils.vala' |
| 540 | --- tests/vala/test-utils.vala 1970-01-01 00:00:00 +0000 |
| 541 | +++ tests/vala/test-utils.vala 2010-11-29 11:57:46 +0000 |
| 542 | @@ -0,0 +1,126 @@ |
| 543 | +/* |
| 544 | + * Copyright (C) 2010 Canonical Ltd |
| 545 | + * |
| 546 | + * This program is free software: you can redistribute it and/or modify |
| 547 | + * it under the terms of the GNU General Public License version 3 as |
| 548 | + * published by the Free Software Foundation. |
| 549 | + * |
| 550 | + * This program is distributed in the hope that it will be useful, |
| 551 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 552 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 553 | + * GNU General Public License for more details. |
| 554 | + * |
| 555 | + * You should have received a copy of the GNU General Public License |
| 556 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 557 | + * |
| 558 | + * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 559 | + * |
| 560 | + */ |
| 561 | + |
| 562 | +namespace G |
| 563 | +{ |
| 564 | + namespace Test |
| 565 | + { |
| 566 | + public class Log |
| 567 | + { |
| 568 | + public delegate bool LogFatalFunc (string? log_domain, |
| 569 | + LogLevelFlags flags, |
| 570 | + string? message); |
| 571 | + |
| 572 | + public extern static void set_fatal_handler (LogFatalFunc func); |
| 573 | + } |
| 574 | + } |
| 575 | +} |
| 576 | + |
| 577 | +namespace Unity.Testing |
| 578 | +{ |
| 579 | + public class Logging |
| 580 | + { |
| 581 | + public Logging () |
| 582 | + { |
| 583 | + Log.set_default_handler (log_handler); |
| 584 | + } |
| 585 | + |
| 586 | + public static bool fatal_handler (string? log_domain, |
| 587 | + LogLevelFlags flags, |
| 588 | + string? message) |
| 589 | + { |
| 590 | + if (log_domain == null) |
| 591 | + return true; |
| 592 | + |
| 593 | + if ("liblauncher" in log_domain) |
| 594 | + return false; |
| 595 | + |
| 596 | + if ("bamfdaemon" in log_domain) |
| 597 | + return false; |
| 598 | + |
| 599 | + if ("Gtk" in log_domain) |
| 600 | + return false; |
| 601 | + |
| 602 | + if ("ndicator" in log_domain) |
| 603 | + return false; |
| 604 | + |
| 605 | + if (message == null) |
| 606 | + return true; |
| 607 | + |
| 608 | + if ("widget class `GtkImage' has no property named `x-ayatana-indicator-dynamic'" in message) |
| 609 | + return false; |
| 610 | + |
| 611 | + if ("is currently inside an allocation cycle" in message) |
| 612 | + return false; |
| 613 | + |
| 614 | + if ("Bamf r" in message) |
| 615 | + return false; |
| 616 | + |
| 617 | + return true; |
| 618 | + } |
| 619 | + |
| 620 | + /** |
| 621 | + * init_fatal_handler: |
| 622 | + * Makes sure that known warnings don't make our testing fail |
| 623 | + **/ |
| 624 | + public static void init_fatal_handler () |
| 625 | + { |
| 626 | + G.Test.Log.set_fatal_handler (fatal_handler); |
| 627 | + } |
| 628 | + |
| 629 | + private void log_handler (string? log_domain, |
| 630 | + LogLevelFlags flags, |
| 631 | + string message) |
| 632 | + { |
| 633 | + string level; |
| 634 | + |
| 635 | + if (log_domain == "Clutter" && (flags & LogLevelFlags.LEVEL_WARNING)!=0) |
| 636 | + { |
| 637 | + if ("is currently inside an allocation cycle" in message) |
| 638 | + return; |
| 639 | + } |
| 640 | + |
| 641 | + if (log_domain == "Gtk" && (flags & LogLevelFlags.LEVEL_WARNING) != 0) |
| 642 | + { |
| 643 | + if ("has no property named `x-ayatana-indicator-dynamic'" in message) |
| 644 | + return; |
| 645 | + } |
| 646 | + |
| 647 | + if ((flags & LogLevelFlags.LEVEL_ERROR) != 0) |
| 648 | + level = "FATAL"; |
| 649 | + else if ((flags & LogLevelFlags.LEVEL_CRITICAL) != 0) |
| 650 | + level = "CRITICAL"; |
| 651 | + else if ((flags & LogLevelFlags.LEVEL_WARNING) != 0) |
| 652 | + level = "WARNING"; |
| 653 | + else if ((flags & LogLevelFlags.LEVEL_MESSAGE) != 0) |
| 654 | + level = "MESSAGE"; |
| 655 | + else if ((flags & LogLevelFlags.LEVEL_INFO) != 0) |
| 656 | + level = "INFO"; |
| 657 | + else if ((flags & LogLevelFlags.LEVEL_DEBUG) != 0) |
| 658 | + level = "DEBUG"; |
| 659 | + else |
| 660 | + level = @"$flags"; |
| 661 | + |
| 662 | + print ("%s-%s: %s\n\n", |
| 663 | + log_domain == null ? "Unity" : log_domain, |
| 664 | + level, |
| 665 | + message); |
| 666 | + } |
| 667 | + } |
| 668 | +} |
| 669 | |
| 670 | === removed directory 'vala_tests/ui' |
| 671 | === removed file 'vala_tests/ui/Makefile.am' |
| 672 | --- vala_tests/ui/Makefile.am 2010-07-12 08:50:07 +0000 |
| 673 | +++ vala_tests/ui/Makefile.am 1970-01-01 00:00:00 +0000 |
| 674 | @@ -1,73 +0,0 @@ |
| 675 | -SUBDIRS = data |
| 676 | - |
| 677 | -noinst_PROGRAMS = test-ui |
| 678 | - |
| 679 | -TESTDIR = $(top_srcdir)/tests/ui |
| 680 | - |
| 681 | -test_ui_CPPFLAGS = \ |
| 682 | - -I$(top_srcdir) \ |
| 683 | - -I$(top_srcdir)/unity \ |
| 684 | - -I$(top_srcdir)/unity-private \ |
| 685 | - -I$(top_srcdir)/src \ |
| 686 | - -DTESTDIR=\"$(TESTDIR)\" \ |
| 687 | - $(BASE_CFLAGS) |
| 688 | - |
| 689 | -test_ui_LDADD = \ |
| 690 | - $(top_builddir)/unity/libunity.la \ |
| 691 | - $(top_builddir)/unity-private/libunity-private.la \ |
| 692 | - $(BASE_LIBS) \ |
| 693 | - $(MAINTAINER_LIBS) |
| 694 | - |
| 695 | -test_ui_VALAFLAGS = \ |
| 696 | - --vapidir=$(top_srcdir)/unity \ |
| 697 | - --vapidir=$(top_srcdir)/unity-private \ |
| 698 | - --vapidir=$(top_srcdir)/src \ |
| 699 | - --vapidir=$(top_srcdir)/vapi/ \ |
| 700 | - --vapidir=$(top_srcdir)/tests/ui \ |
| 701 | - --pkg Bamf-0.2 \ |
| 702 | - --pkg clutter-1.0 \ |
| 703 | - --pkg clutter-gtk-0.10 \ |
| 704 | - --pkg dbus-glib-1 \ |
| 705 | - --pkg Dbusmenu-Glib-0.2 \ |
| 706 | - --pkg dee-1.0 \ |
| 707 | - --pkg gtk+-2.0 \ |
| 708 | - --pkg gdk-2.0 \ |
| 709 | - --pkg gee-1.0 \ |
| 710 | - --pkg x11 \ |
| 711 | - --pkg gtk+-2.0 \ |
| 712 | - --pkg gee-1.0 \ |
| 713 | - --pkg indicator \ |
| 714 | - --pkg clutk-0.3 \ |
| 715 | - --pkg launcher-0.3 \ |
| 716 | - --pkg test-const \ |
| 717 | - --pkg unique-1.0 \ |
| 718 | - --pkg unity \ |
| 719 | - --pkg unity-const \ |
| 720 | - --pkg unity-private \ |
| 721 | - $(MAINTAINER_VALAFLAGS) |
| 722 | - |
| 723 | -test_ui_SOURCES = \ |
| 724 | - test-automate.vala \ |
| 725 | - test-home-button.vala \ |
| 726 | - test-indicators.vala \ |
| 727 | - test-quicklist.vala \ |
| 728 | - test-ui.vala |
| 729 | - |
| 730 | -# GTester stuff |
| 731 | -XML_REPORT = test-ui-results.xml |
| 732 | -HTML_REPORT = test-ui-results.html |
| 733 | - |
| 734 | -unit-tester: test-ui |
| 735 | - @gtester -o=$(XML_REPORT) ./test-ui |
| 736 | - |
| 737 | -check-report: |
| 738 | - @gtester -o=$(XML_REPORT) -k ./test-ui \ |
| 739 | - && (gtester-report $(XML_REPORT) \ |
| 740 | - | sed 's/GTester UI Test Report</>GTester UI Test Report (normal)</' \ |
| 741 | - > $(HTML_REPORT)) \ |
| 742 | - && xdg-open $(HTML_REPORT) |
| 743 | - |
| 744 | -check-local: unit-tester |
| 745 | - |
| 746 | -EXTRA_DIST = test-const.vapi |
| 747 | -CLEANFILES = *.stamp $(XML_REPORT) $(HTML_REPORT) *.c |
| 748 | |
| 749 | === removed directory 'vala_tests/ui/data' |
| 750 | === removed file 'vala_tests/ui/data/Makefile.am' |
| 751 | --- vala_tests/ui/data/Makefile.am 2010-04-14 14:00:26 +0000 |
| 752 | +++ vala_tests/ui/data/Makefile.am 1970-01-01 00:00:00 +0000 |
| 753 | @@ -1,1 +0,0 @@ |
| 754 | -EXTRA_DIST = *.png |
| 755 | |
| 756 | === removed file 'vala_tests/ui/data/quicklist_controller_show_label.png' |
| 757 | Binary files vala_tests/ui/data/quicklist_controller_show_label.png 2010-06-03 13:14:06 +0000 and vala_tests/ui/data/quicklist_controller_show_label.png 1970-01-01 00:00:00 +0000 differ |
| 758 | === removed file 'vala_tests/ui/data/quicklist_shown_on_hover.png' |
| 759 | Binary files vala_tests/ui/data/quicklist_shown_on_hover.png 2010-04-14 14:00:56 +0000 and vala_tests/ui/data/quicklist_shown_on_hover.png 1970-01-01 00:00:00 +0000 differ |
| 760 | === removed file 'vala_tests/ui/test-automate.vala' |
| 761 | --- vala_tests/ui/test-automate.vala 2010-07-08 12:08:51 +0000 |
| 762 | +++ vala_tests/ui/test-automate.vala 1970-01-01 00:00:00 +0000 |
| 763 | @@ -1,131 +0,0 @@ |
| 764 | -/* |
| 765 | - * Copyright (C) 2010 Canonical Ltd |
| 766 | - * |
| 767 | - * This program is free software: you can redistribute it and/or modify |
| 768 | - * it under the terms of the GNU General Public License version 3 as |
| 769 | - * published by the Free Software Foundation. |
| 770 | - * |
| 771 | - * This program is distributed in the hope that it will be useful, |
| 772 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 773 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 774 | - * GNU General Public License for more details. |
| 775 | - * |
| 776 | - * You should have received a copy of the GNU General Public License |
| 777 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 778 | - * |
| 779 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 780 | - * |
| 781 | - */ |
| 782 | - |
| 783 | -using Unity; |
| 784 | -using Unity.Testing; |
| 785 | -using Unity.Launcher; |
| 786 | - |
| 787 | -GLib.Timer gTimer; |
| 788 | -static void |
| 789 | -on_animation_started (Clutter.Animation? anim) |
| 790 | -{ |
| 791 | - //stdout.printf("Animation Started\n"); |
| 792 | - gTimer.start (); |
| 793 | -} |
| 794 | - |
| 795 | -static void |
| 796 | -on_animation_completed (Clutter.Animation? anim) |
| 797 | -{ |
| 798 | - //stdout.printf("Animation Completed\n"); |
| 799 | - gTimer.stop (); |
| 800 | -} |
| 801 | - |
| 802 | -namespace Unity.Tests.UI |
| 803 | -{ |
| 804 | - public class AutomationBasicTestSuite : Object |
| 805 | - { |
| 806 | - private const string DOMAIN = "/UI/Quicklist"; |
| 807 | - |
| 808 | - Unity.Testing.Window? window; |
| 809 | - Clutter.Stage? stage; |
| 810 | - |
| 811 | - public AutomationBasicTestSuite () |
| 812 | - { |
| 813 | - Logging.init_fatal_handler (); |
| 814 | - |
| 815 | - /* Testup the test window */ |
| 816 | - window = new Unity.Testing.Window (true, 1024, 600); |
| 817 | - window.init_test_mode (); |
| 818 | - stage = window.stage; |
| 819 | - window.title = "Automation Tests"; |
| 820 | - window.show_all (); |
| 821 | - |
| 822 | - Test.add_data_func (DOMAIN + "/Automation", |
| 823 | - test_automation); |
| 824 | - |
| 825 | - |
| 826 | - /* Keep this one last, it's a dummy to clean up the state as Vala cant |
| 827 | - * deal with the standard TestSuite stuff properly |
| 828 | - */ |
| 829 | - Test.add_data_func (DOMAIN +"/Teardown", test_teardown); |
| 830 | - } |
| 831 | - |
| 832 | - private void test_teardown () |
| 833 | - { |
| 834 | - //window.destroy (); |
| 835 | - stage = null; |
| 836 | - } |
| 837 | - |
| 838 | - private void test_automation () |
| 839 | - { |
| 840 | -/* |
| 841 | - ObjectRegistry registry = ObjectRegistry.get_default (); |
| 842 | - |
| 843 | - Logging.init_fatal_handler (); |
| 844 | - |
| 845 | - QuicklistController qlcontroller = QuicklistController.get_default (); |
| 846 | - ScrollerModel scroller = registry.lookup ("UnityScrollerModel").get(0) as ScrollerModel; |
| 847 | - |
| 848 | - gTimer = new GLib.Timer(); |
| 849 | - int DT = 2500; |
| 850 | - stdout.printf("\n"); |
| 851 | - |
| 852 | - foreach (ScrollerChild launcher in scroller) |
| 853 | - { |
| 854 | - //launcher = scroller[i] as ScrollerChild; |
| 855 | - var dir = new Director (launcher.get_stage() as Clutter.Stage); |
| 856 | - |
| 857 | - qlcontroller.show_label ("Ubuntu Software Centre", launcher); |
| 858 | - |
| 859 | - Clutter.Animation? anim; |
| 860 | - launcher.opacity = 255; |
| 861 | - |
| 862 | - |
| 863 | - gTimer.start (); |
| 864 | - anim = launcher.animate (Clutter.AnimationMode.EASE_IN_SINE, 2500, "opacity", 0); |
| 865 | - //anim.started.connect (on_animation_started); |
| 866 | - anim.completed.connect (on_animation_completed); |
| 867 | - dir.do_wait_for_animation (launcher); |
| 868 | - |
| 869 | - float dt = (float)gTimer.elapsed (); |
| 870 | - float dt0 = (float)DT/1000.0f; |
| 871 | - stdout.printf("Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", dt0, dt, |
| 872 | - (dt - dt0)*100.0f/dt0); |
| 873 | - |
| 874 | - gTimer.start (); |
| 875 | - anim = launcher.animate (Clutter.AnimationMode.EASE_IN_SINE, 2500, "opacity", 255); |
| 876 | - //anim.started.connect (on_animation_started); |
| 877 | - anim.completed.connect (on_animation_completed); |
| 878 | - dir.do_wait_for_animation (launcher); |
| 879 | - |
| 880 | - dt = (float)gTimer.elapsed (); |
| 881 | - dt0 = (float)DT/1000.0f; |
| 882 | - stdout.printf("Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", dt0, dt, |
| 883 | - (dt - dt0)*100.0f/dt0); |
| 884 | - |
| 885 | - |
| 886 | - //dir.do_wait_for_timeout (5000); |
| 887 | - } |
| 888 | - |
| 889 | - //debug ("After Animation"); |
| 890 | - qlcontroller.close_menu (); |
| 891 | -*/ |
| 892 | - } |
| 893 | - } |
| 894 | -} |
| 895 | |
| 896 | === removed file 'vala_tests/ui/test-const.vapi' |
| 897 | --- vala_tests/ui/test-const.vapi 2010-04-07 16:16:07 +0000 |
| 898 | +++ vala_tests/ui/test-const.vapi 1970-01-01 00:00:00 +0000 |
| 899 | @@ -1,25 +0,0 @@ |
| 900 | -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 901 | -/* |
| 902 | - * Copyright (C) 2009 Canonical Ltd |
| 903 | - * |
| 904 | - * This program is free software: you can redistribute it and/or modify |
| 905 | - * idst under the terms of the GNU General Public License version 3 as |
| 906 | - * published by the Free Software Foundation. |
| 907 | - * |
| 908 | - * This program is distributed in the hope that it will be useful, |
| 909 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 910 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 911 | - * GNU General Public License for more details. |
| 912 | - * |
| 913 | - * You should have received a copy of the GNU General Public License |
| 914 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 915 | - * |
| 916 | - * Authored by Gordon Allott <gord.allott@canonical.com> |
| 917 | - * |
| 918 | - */ |
| 919 | - |
| 920 | -namespace Unity.Tests { |
| 921 | - [CCode (cname = "TESTDIR")] |
| 922 | - public static const string TESTDIR; |
| 923 | - |
| 924 | -} |
| 925 | |
| 926 | === removed file 'vala_tests/ui/test-home-button.vala' |
| 927 | --- vala_tests/ui/test-home-button.vala 2010-08-26 13:00:32 +0000 |
| 928 | +++ vala_tests/ui/test-home-button.vala 1970-01-01 00:00:00 +0000 |
| 929 | @@ -1,188 +0,0 @@ |
| 930 | -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 931 | -/* |
| 932 | - * Copyright (C) 2010 Canonical Ltd |
| 933 | - * |
| 934 | - * This program is free software: you can redistribute it and/or modify |
| 935 | - * it under the terms of the GNU General Public License version 3 as |
| 936 | - * published by the Free Software Foundation. |
| 937 | - * |
| 938 | - * This program is distributed in the hope that it will be useful, |
| 939 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 940 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 941 | - * GNU General Public License for more details. |
| 942 | - * |
| 943 | - * You should have received a copy of the GNU General Public License |
| 944 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 945 | - * |
| 946 | - * Authored by Mirco Müller <mirco.mueller@canonical.com> |
| 947 | - * |
| 948 | - */ |
| 949 | - |
| 950 | -using Unity; |
| 951 | -using Unity.Testing; |
| 952 | -using Unity.Panel; |
| 953 | - |
| 954 | -bool g_flag = false; |
| 955 | - |
| 956 | -namespace Unity.Tests.UI |
| 957 | -{ |
| 958 | - public class HomeButtonSuite : Object, Shell |
| 959 | - { |
| 960 | - private const string DOMAIN = "/UI/HomeButton"; |
| 961 | - |
| 962 | - Unity.Testing.Window? window; |
| 963 | - Clutter.Stage? stage; |
| 964 | - Unity.Testing.Director director; |
| 965 | - Unity.Panel.HomeButton home_button; |
| 966 | - public bool super_key_active {get; set;} |
| 967 | - public bool is_starting {get; set;} |
| 968 | - |
| 969 | - public HomeButtonSuite () |
| 970 | - { |
| 971 | - Logging.init_fatal_handler (); |
| 972 | - |
| 973 | - /* Testup the test window */ |
| 974 | - window = new Unity.Testing.Window (true, 1024, 600); |
| 975 | - window.init_test_mode (); |
| 976 | - stage = window.stage; |
| 977 | - window.title = "HomeButton Test"; |
| 978 | - window.show_all (); |
| 979 | - |
| 980 | - home_button = new Unity.Panel.HomeButton (this); |
| 981 | - director = new Unity.Testing.Director (stage); |
| 982 | - |
| 983 | - Test.add_data_func (DOMAIN + "/HomeButton", test_click_home_button); |
| 984 | - } |
| 985 | - |
| 986 | - |
| 987 | - private void test_click_home_button () |
| 988 | - { |
| 989 | - director.button_press (home_button, 1, true, 1.0f, 1.0f, false); |
| 990 | - |
| 991 | - Logging.init_fatal_handler (); |
| 992 | - |
| 993 | - assert (g_flag == true); |
| 994 | - } |
| 995 | - |
| 996 | - // |
| 997 | - // mostly a dummy shell-implementation to satisfy the interface |
| 998 | - // |
| 999 | - public bool menus_swallow_events { get { return true; } } |
| 1000 | - |
| 1001 | - public void get_window_details (uint32 xid, out bool a, out bool b) |
| 1002 | - { |
| 1003 | - |
| 1004 | - } |
| 1005 | - |
| 1006 | - public void do_window_action (uint32 xid, WindowAction action) |
| 1007 | - { |
| 1008 | - |
| 1009 | - } |
| 1010 | - |
| 1011 | - public ShellMode |
| 1012 | - get_mode () |
| 1013 | - { |
| 1014 | - return ShellMode.MINIMIZED; |
| 1015 | - } |
| 1016 | - |
| 1017 | - public Clutter.Stage |
| 1018 | - get_stage () |
| 1019 | - { |
| 1020 | - return this.stage; |
| 1021 | - } |
| 1022 | - |
| 1023 | - public void |
| 1024 | - show_unity () |
| 1025 | - { |
| 1026 | - g_flag = true; |
| 1027 | - } |
| 1028 | - |
| 1029 | - public void |
| 1030 | - hide_unity () |
| 1031 | - { |
| 1032 | - |
| 1033 | - } |
| 1034 | - |
| 1035 | - public int |
| 1036 | - get_indicators_width () |
| 1037 | - { |
| 1038 | - // stub |
| 1039 | - return 0; |
| 1040 | - } |
| 1041 | - |
| 1042 | - public int |
| 1043 | - get_launcher_width_foobar () |
| 1044 | - { |
| 1045 | - // stub |
| 1046 | - return 0; |
| 1047 | - } |
| 1048 | - |
| 1049 | - public int |
| 1050 | - get_panel_height_foobar () |
| 1051 | - { |
| 1052 | - // stub |
| 1053 | - return 0; |
| 1054 | - } |
| 1055 | - |
| 1056 | - public void |
| 1057 | - ensure_input_region () |
| 1058 | - { |
| 1059 | - // stub |
| 1060 | - } |
| 1061 | - |
| 1062 | - public void |
| 1063 | - add_fullscreen_request (Object o) |
| 1064 | - { |
| 1065 | - // stub |
| 1066 | - } |
| 1067 | - |
| 1068 | - public bool |
| 1069 | - remove_fullscreen_request (Object o) |
| 1070 | - { |
| 1071 | - // stub |
| 1072 | - return false; |
| 1073 | - } |
| 1074 | - |
| 1075 | - public void |
| 1076 | - grab_keyboard (bool grab, uint32 timestamp) |
| 1077 | - { |
| 1078 | - // stub |
| 1079 | - } |
| 1080 | - |
| 1081 | - public void |
| 1082 | - about_to_show_places () |
| 1083 | - { |
| 1084 | - // stub |
| 1085 | - } |
| 1086 | - |
| 1087 | - public void |
| 1088 | - close_xids (Array<uint32> xids) |
| 1089 | - { |
| 1090 | - // stub |
| 1091 | - } |
| 1092 | - |
| 1093 | - public void |
| 1094 | - show_window (uint32 xid) |
| 1095 | - { |
| 1096 | - // stub |
| 1097 | - } |
| 1098 | - |
| 1099 | - public void |
| 1100 | - expose_xids (Array<uint32> xids) |
| 1101 | - { |
| 1102 | - // stub |
| 1103 | - } |
| 1104 | - |
| 1105 | - public void |
| 1106 | - stop_expose () |
| 1107 | - { |
| 1108 | - // stub |
| 1109 | - } |
| 1110 | - |
| 1111 | - public uint32 get_current_time () |
| 1112 | - { |
| 1113 | - return Clutter.get_current_event_time (); |
| 1114 | - } |
| 1115 | - } |
| 1116 | -} |
| 1117 | - |
| 1118 | |
| 1119 | === removed file 'vala_tests/ui/test-indicators.vala' |
| 1120 | --- vala_tests/ui/test-indicators.vala 2010-06-09 02:46:10 +0000 |
| 1121 | +++ vala_tests/ui/test-indicators.vala 1970-01-01 00:00:00 +0000 |
| 1122 | @@ -1,321 +0,0 @@ |
| 1123 | -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 1124 | -/* |
| 1125 | - * Copyright (C) 2010 Canonical Ltd |
| 1126 | - * |
| 1127 | - * This program is free software: you can redistribute it and/or modify |
| 1128 | - * it under the terms of the GNU General Public License version 3 as |
| 1129 | - * published by the Free Software Foundation. |
| 1130 | - * |
| 1131 | - * This program is distributed in the hope that it will be useful, |
| 1132 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1133 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1134 | - * GNU General Public License for more details. |
| 1135 | - * |
| 1136 | - * You should have received a copy of the GNU General Public License |
| 1137 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1138 | - * |
| 1139 | - * Authored by Jay Taoko <jay.taoko@canonical.com> |
| 1140 | - * |
| 1141 | - */ |
| 1142 | - |
| 1143 | -using Unity; |
| 1144 | -using Unity.Testing; |
| 1145 | -using Unity.Panel; |
| 1146 | -using Unity.Panel.Indicators; |
| 1147 | - |
| 1148 | -namespace Unity.Tests.UI |
| 1149 | -{ |
| 1150 | - public class FakeIndicatorObject: Indicator.Object |
| 1151 | - { |
| 1152 | - public Gee.ArrayList<Indicator.ObjectEntry> indicator_entry_array; |
| 1153 | - //GLib.List<Indicator.ObjectEntry> list; |
| 1154 | - |
| 1155 | - public Gtk.Label _label = null; |
| 1156 | - public Gtk.Image _image = null; |
| 1157 | - public Gtk.Menu _menu = null; |
| 1158 | - public int index {get; set construct;} |
| 1159 | - |
| 1160 | - public FakeIndicatorObject (int i) |
| 1161 | - { |
| 1162 | - Object(index:i); |
| 1163 | - } |
| 1164 | - |
| 1165 | - construct |
| 1166 | - { |
| 1167 | - START_FUNCTION (); |
| 1168 | - string index_string = "%d".printf(index); |
| 1169 | - indicator_entry_array = new Gee.ArrayList< unowned Indicator.ObjectEntry> (); |
| 1170 | - |
| 1171 | - _label = new Gtk.Label ("Indicator" + index_string); |
| 1172 | - _image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); |
| 1173 | - _menu = new Gtk.Menu (); |
| 1174 | - |
| 1175 | - END_FUNCTION (); |
| 1176 | - } |
| 1177 | - |
| 1178 | - public void add_entry(Indicator.ObjectEntry entry) |
| 1179 | - { |
| 1180 | - int pos = indicator_entry_array.index_of (entry); |
| 1181 | - if (pos != -1) |
| 1182 | - return; |
| 1183 | - |
| 1184 | - indicator_entry_array.add (entry); |
| 1185 | - entry_added (entry); |
| 1186 | - } |
| 1187 | - |
| 1188 | - public void remove_entry(Indicator.ObjectEntry entry) |
| 1189 | - { |
| 1190 | - int pos = indicator_entry_array.index_of (entry); |
| 1191 | - if (pos != -1) |
| 1192 | - { |
| 1193 | - indicator_entry_array.remove_at (pos); |
| 1194 | - entry_removed (entry); |
| 1195 | - } |
| 1196 | - } |
| 1197 | - |
| 1198 | - public override unowned Gtk.Label get_label () |
| 1199 | - { |
| 1200 | - return this._label; |
| 1201 | - } |
| 1202 | - |
| 1203 | - public override unowned Gtk.Image get_image () |
| 1204 | - { |
| 1205 | - return this._image; |
| 1206 | - } |
| 1207 | - |
| 1208 | - public override unowned Gtk.Menu get_menu () |
| 1209 | - { |
| 1210 | - return this._menu; |
| 1211 | - } |
| 1212 | - |
| 1213 | -// public override unowned GLib.List<Indicator.ObjectEntry> get_entries () |
| 1214 | -// { |
| 1215 | -// list = new GLib.List<Indicator.ObjectEntry> (); |
| 1216 | -// foreach(Indicator.ObjectEntry element in indicator_entry_array) |
| 1217 | -// { |
| 1218 | -// list.append (element); |
| 1219 | -// } |
| 1220 | -// return list; |
| 1221 | -// } |
| 1222 | - } |
| 1223 | - |
| 1224 | - public class FakeIndicatorsModel : IndicatorsModel |
| 1225 | - { |
| 1226 | - public Gee.HashMap<Indicator.Object, string> indicator_map; |
| 1227 | - public Gee.ArrayList<Indicator.Object> indicator_list; |
| 1228 | - |
| 1229 | - |
| 1230 | - public FakeIndicatorObject indicator_object_0; |
| 1231 | - public FakeIndicatorObject indicator_object_1; |
| 1232 | - |
| 1233 | - public FakeIndicatorsModel () |
| 1234 | - { |
| 1235 | - START_FUNCTION (); |
| 1236 | - |
| 1237 | - indicator_map = new Gee.HashMap<Indicator.Object, string> (); |
| 1238 | - indicator_list = new Gee.ArrayList<Indicator.Object> (); |
| 1239 | - |
| 1240 | - load_fake_indicators (); |
| 1241 | - |
| 1242 | - END_FUNCTION (); |
| 1243 | - } |
| 1244 | - |
| 1245 | - private void load_fake_indicators () |
| 1246 | - { |
| 1247 | - indicator_object_0 = new FakeIndicatorObject (0); |
| 1248 | - indicator_object_1 = new FakeIndicatorObject (1); |
| 1249 | - |
| 1250 | - this.indicator_map[indicator_object_0] = "fakeindicator0"; |
| 1251 | - indicator_list.add (indicator_object_0); |
| 1252 | - this.indicator_map[indicator_object_1] = "fakeindicator1"; |
| 1253 | - indicator_list.add (indicator_object_1); |
| 1254 | - |
| 1255 | - } |
| 1256 | - |
| 1257 | - public override Gee.ArrayList<Indicator.Object> get_indicators () |
| 1258 | - { |
| 1259 | - return indicator_list; |
| 1260 | - } |
| 1261 | - |
| 1262 | - public override string get_indicator_name (Indicator.Object o) |
| 1263 | - { |
| 1264 | - return indicator_map[o]; |
| 1265 | - } |
| 1266 | - } |
| 1267 | - |
| 1268 | - |
| 1269 | - public class IndicatorTestSuite : Object |
| 1270 | - { |
| 1271 | - private const string DOMAIN = "/UI/Indicators"; |
| 1272 | - |
| 1273 | - Unity.Testing.Window? window; |
| 1274 | - Clutter.Stage? stage; |
| 1275 | - Unity.Testing.Director director; |
| 1276 | - |
| 1277 | - public Indicator.ObjectEntry entry0; |
| 1278 | - public Indicator.ObjectEntry entry1; |
| 1279 | - |
| 1280 | - private Gtk.Menu menu0; |
| 1281 | - private Gtk.Label label0; |
| 1282 | - private Gtk.Image image0; |
| 1283 | - |
| 1284 | - private Gtk.Menu menu1; |
| 1285 | - private Gtk.Label label1; |
| 1286 | - private Gtk.Image image1; |
| 1287 | - |
| 1288 | - private Gtk.MenuItem item; |
| 1289 | - |
| 1290 | - public IndicatorTestSuite () |
| 1291 | - { |
| 1292 | - Logging.init_fatal_handler (); |
| 1293 | - |
| 1294 | - FakeIndicatorsModel fake_indicator_model = new FakeIndicatorsModel (); |
| 1295 | - IndicatorsModel.set_default (fake_indicator_model); |
| 1296 | - |
| 1297 | - |
| 1298 | - /* Testup the test window */ |
| 1299 | - window = new Unity.Testing.Window (true, 1024, 600); |
| 1300 | - window.init_test_mode (); |
| 1301 | - stage = window.stage; |
| 1302 | - window.title = "Indicators testing"; |
| 1303 | - window.show_all (); |
| 1304 | - |
| 1305 | - |
| 1306 | - director = new Unity.Testing.Director (stage); |
| 1307 | - |
| 1308 | - FakeIndicatorsModel indicator_model = IndicatorsModel.get_default () as FakeIndicatorsModel; |
| 1309 | - |
| 1310 | - menu0 = new Gtk.Menu (); |
| 1311 | - label0 = new Gtk.Label ("Entry0"); |
| 1312 | - image0 = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); |
| 1313 | - item = new Gtk.MenuItem.with_label ("MenuItem0"); |
| 1314 | - item.show(); |
| 1315 | - menu0.append (item); |
| 1316 | - item = new Gtk.MenuItem.with_label ("MenuItem1"); |
| 1317 | - item.show(); |
| 1318 | - menu0.append (item); |
| 1319 | - item = new Gtk.MenuItem.with_label ("MenuItem2"); |
| 1320 | - item.show(); |
| 1321 | - menu0.append (item); |
| 1322 | - item = new Gtk.MenuItem.with_label ("MenuItem3"); |
| 1323 | - item.show(); |
| 1324 | - menu0.append (item); |
| 1325 | - |
| 1326 | - entry0 = new Indicator.ObjectEntry (); |
| 1327 | - entry0.menu = menu0; |
| 1328 | - entry0.label = label0; |
| 1329 | - entry0.image = image0; |
| 1330 | - indicator_model.indicator_object_0.add_entry (entry0); |
| 1331 | - |
| 1332 | - menu1 = new Gtk.Menu (); |
| 1333 | - label1 = new Gtk.Label ("Entry1"); |
| 1334 | - image1 = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); |
| 1335 | - item = new Gtk.MenuItem.with_label ("MenuItem0"); |
| 1336 | - item.show(); |
| 1337 | - menu1.append (item); |
| 1338 | - item = new Gtk.MenuItem.with_label ("MenuItem1"); |
| 1339 | - item.show(); |
| 1340 | - menu1.append (item); |
| 1341 | - item = new Gtk.MenuItem.with_label ("MenuItem2"); |
| 1342 | - item.show(); |
| 1343 | - menu1.append (item); |
| 1344 | - item = new Gtk.MenuItem.with_label ("MenuItem3"); |
| 1345 | - item.show(); |
| 1346 | - menu1.append (item); |
| 1347 | - |
| 1348 | - entry1 = new Indicator.ObjectEntry (); |
| 1349 | - entry1.menu = menu1; |
| 1350 | - entry1.label = label1; |
| 1351 | - entry1.image = image1; |
| 1352 | - indicator_model.indicator_object_1.add_entry (entry1); |
| 1353 | - |
| 1354 | - Test.add_data_func (DOMAIN + "/IndicatorMouseEvent", test_indicators_mouse_event); |
| 1355 | - Test.add_data_func (DOMAIN + "/IndicatorKeyboardEvent", test_indicators_keyboard_event); |
| 1356 | - } |
| 1357 | - |
| 1358 | - |
| 1359 | - private void test_indicators_mouse_event () |
| 1360 | - { |
| 1361 | - ObjectRegistry registry = ObjectRegistry.get_default (); |
| 1362 | - Logging.init_fatal_handler (); |
| 1363 | - |
| 1364 | - FakeIndicatorsModel indicator_model = IndicatorsModel.get_default () as FakeIndicatorsModel; |
| 1365 | - |
| 1366 | - IndicatorBar indicator_bar = registry.lookup ("IndicatorBar").get (0) as IndicatorBar; |
| 1367 | - assert (indicator_bar != null); |
| 1368 | - |
| 1369 | - IndicatorObjectView indicator_object_view0 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_0); |
| 1370 | - assert (indicator_object_view0 != null); |
| 1371 | - IndicatorObjectView indicator_object_view1 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_1); |
| 1372 | - assert (indicator_object_view1 != null); |
| 1373 | - |
| 1374 | - /* Hack to remove the default entries: because get_entries has not been overriden in FakeIndicatorObject */ |
| 1375 | - indicator_object_view0.remove_first_entry (); |
| 1376 | - indicator_object_view1.remove_first_entry (); |
| 1377 | - |
| 1378 | - indicator_bar.do_queue_redraw (); |
| 1379 | - |
| 1380 | - IndicatorObjectEntryView object_entry0 = indicator_object_view0.get_entry_view (entry0); |
| 1381 | - assert (object_entry0 != null); |
| 1382 | - IndicatorObjectEntryView object_entry1 = indicator_object_view1.get_entry_view (entry1); |
| 1383 | - assert (object_entry1 != null); |
| 1384 | - |
| 1385 | - // Test button press on first indicator |
| 1386 | - director.button_press (object_entry0, 1, true, 1.0f, 1.0f, false); |
| 1387 | - assert (object_entry0.is_open () == true); |
| 1388 | - assert (object_entry1.is_open () == false); |
| 1389 | - director.do_wait_for_timeout (1000); |
| 1390 | - |
| 1391 | - // Test button press on second indicator |
| 1392 | - director.button_press (object_entry1, 1, true, 1.0f, 1.0f, false); |
| 1393 | - assert (object_entry0.is_open () == false); |
| 1394 | - assert (object_entry1.is_open () == true); |
| 1395 | - director.do_wait_for_timeout (1000); |
| 1396 | - |
| 1397 | - // Press to close |
| 1398 | - director.button_press (object_entry1, 1, true, 1.0f, 1.0f, false); |
| 1399 | - assert (object_entry0.is_open () == false); |
| 1400 | - assert (object_entry1.is_open () == false); |
| 1401 | - |
| 1402 | - } |
| 1403 | - |
| 1404 | - private void test_indicators_keyboard_event () |
| 1405 | - { |
| 1406 | - ObjectRegistry registry = ObjectRegistry.get_default (); |
| 1407 | - Logging.init_fatal_handler (); |
| 1408 | - |
| 1409 | - FakeIndicatorsModel indicator_model = IndicatorsModel.get_default () as FakeIndicatorsModel; |
| 1410 | - |
| 1411 | - IndicatorBar indicator_bar = registry.lookup ("IndicatorBar").get (0) as IndicatorBar; |
| 1412 | - assert (indicator_bar != null); |
| 1413 | - |
| 1414 | - IndicatorObjectView indicator_object_view0 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_0); |
| 1415 | - assert (indicator_object_view0 != null); |
| 1416 | - IndicatorObjectView indicator_object_view1 = indicator_bar.get_indicator_view_matching (indicator_model.indicator_object_1); |
| 1417 | - assert (indicator_object_view1 != null); |
| 1418 | - |
| 1419 | - IndicatorObjectEntryView object_entry0 = indicator_object_view0.get_entry_view (entry0); |
| 1420 | - assert (object_entry0 != null); |
| 1421 | - IndicatorObjectEntryView object_entry1 = indicator_object_view1.get_entry_view (entry1); |
| 1422 | - assert (object_entry1 != null); |
| 1423 | - |
| 1424 | - //Simulate key navigation |
| 1425 | - director.do_wait_for_timeout (1000); |
| 1426 | - director.button_press (object_entry0, 1, true, 1.0f, 1.0f, false); |
| 1427 | - assert (object_entry0.is_open () == true); |
| 1428 | - assert (object_entry1.is_open () == false); |
| 1429 | - director.do_wait_for_timeout (1000); |
| 1430 | - |
| 1431 | - object_entry0.entry.menu.move_current (Gtk.MenuDirectionType.CHILD); |
| 1432 | - assert (object_entry0.is_open () == false); |
| 1433 | - assert (object_entry1.is_open () == true); |
| 1434 | - director.do_wait_for_timeout (1000); |
| 1435 | - object_entry1.entry.menu.move_current (Gtk.MenuDirectionType.PARENT); |
| 1436 | - assert (object_entry0.is_open () == true); |
| 1437 | - assert (object_entry1.is_open () == false); |
| 1438 | - director.do_wait_for_timeout (1000); |
| 1439 | - |
| 1440 | - } |
| 1441 | - } |
| 1442 | -} |
| 1443 | - |
| 1444 | |
| 1445 | === removed file 'vala_tests/ui/test-quicklist.vala' |
| 1446 | --- vala_tests/ui/test-quicklist.vala 2010-07-08 12:08:51 +0000 |
| 1447 | +++ vala_tests/ui/test-quicklist.vala 1970-01-01 00:00:00 +0000 |
| 1448 | @@ -1,85 +0,0 @@ |
| 1449 | -/* |
| 1450 | - * Copyright (C) 2010 Canonical Ltd |
| 1451 | - * |
| 1452 | - * This program is free software: you can redistribute it and/or modify |
| 1453 | - * it under the terms of the GNU General Public License version 3 as |
| 1454 | - * published by the Free Software Foundation. |
| 1455 | - * |
| 1456 | - * This program is distributed in the hope that it will be useful, |
| 1457 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1458 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1459 | - * GNU General Public License for more details. |
| 1460 | - * |
| 1461 | - * You should have received a copy of the GNU General Public License |
| 1462 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1463 | - * |
| 1464 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 1465 | - * |
| 1466 | - */ |
| 1467 | - |
| 1468 | -using Unity; |
| 1469 | -using Unity.Testing; |
| 1470 | -using Unity.Launcher; |
| 1471 | - |
| 1472 | -namespace Unity.Tests.UI |
| 1473 | -{ |
| 1474 | - public class QuicklistSuite : Object |
| 1475 | - { |
| 1476 | - private const string DOMAIN = "/UI/Quicklist"; |
| 1477 | - |
| 1478 | - Unity.Testing.Window? window; |
| 1479 | - Clutter.Stage? stage; |
| 1480 | - |
| 1481 | - public QuicklistSuite () |
| 1482 | - { |
| 1483 | - Logging.init_fatal_handler (); |
| 1484 | - |
| 1485 | - /* Testup the test window */ |
| 1486 | - Unity.favorites_singleton = new TestFavorites (); |
| 1487 | - window = new Unity.Testing.Window (true, 1024, 600); |
| 1488 | - window.init_test_mode (); |
| 1489 | - stage = window.stage; |
| 1490 | - window.title = "Quicklist Tests"; |
| 1491 | - window.show_all (); |
| 1492 | - |
| 1493 | - Test.add_data_func (DOMAIN + "/ControllerShowLabel", |
| 1494 | - test_controller_show_label); |
| 1495 | - |
| 1496 | - |
| 1497 | - /* Keep this one last, it's a dummy to clean up the state as Vala cant |
| 1498 | - * deal with the standard TestSuite stuff properly |
| 1499 | - */ |
| 1500 | - Test.add_data_func (DOMAIN +"/Teardown", test_teardown); |
| 1501 | - } |
| 1502 | - |
| 1503 | - private void test_teardown () |
| 1504 | - { |
| 1505 | - //window.destroy (); |
| 1506 | - stage = null; |
| 1507 | - } |
| 1508 | - |
| 1509 | - private void test_controller_show_label () |
| 1510 | - { |
| 1511 | -/* |
| 1512 | - string img = TESTDIR + "/data/quicklist_controller_show_label.png"; |
| 1513 | - ObjectRegistry registry = ObjectRegistry.get_default (); |
| 1514 | - |
| 1515 | - Logging.init_fatal_handler (); |
| 1516 | - |
| 1517 | - ScrollerModel scroller = (registry.lookup ("UnityScrollerModel")[0]) as ScrollerModel; |
| 1518 | - ScrollerChild first = scroller[0] as ScrollerChild; |
| 1519 | - |
| 1520 | - QuicklistController qlcontroller = QuicklistController.get_default (); |
| 1521 | - qlcontroller.show_label ("Ubuntu Software Centre", first); |
| 1522 | - |
| 1523 | - while (Gtk.events_pending ()) |
| 1524 | - Gtk.main_iteration (); |
| 1525 | - |
| 1526 | - assert (Utils.compare_snapshot (stage, img, 54, 30, 200, 50)); |
| 1527 | - |
| 1528 | - qlcontroller.close_menu (); |
| 1529 | - */ |
| 1530 | - } |
| 1531 | - |
| 1532 | - } |
| 1533 | -} |
| 1534 | |
| 1535 | === removed file 'vala_tests/ui/test-ui.vala' |
| 1536 | --- vala_tests/ui/test-ui.vala 2010-07-01 11:23:01 +0000 |
| 1537 | +++ vala_tests/ui/test-ui.vala 1970-01-01 00:00:00 +0000 |
| 1538 | @@ -1,129 +0,0 @@ |
| 1539 | -/* |
| 1540 | - * Copyright (C) 2010 Canonical Ltd |
| 1541 | - * |
| 1542 | - * This program is free software: you can redistribute it and/or modify |
| 1543 | - * it under the terms of the GNU General Public License version 3 as |
| 1544 | - * published by the Free Software Foundation. |
| 1545 | - * |
| 1546 | - * This program is distributed in the hope that it will be useful, |
| 1547 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1548 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1549 | - * GNU General Public License for more details. |
| 1550 | - * |
| 1551 | - * You should have received a copy of the GNU General Public License |
| 1552 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1553 | - * |
| 1554 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 1555 | - * |
| 1556 | - */ |
| 1557 | -using Gee; |
| 1558 | -using Unity; |
| 1559 | -using Unity.Testing; |
| 1560 | -using Unity.Tests.UI; |
| 1561 | - |
| 1562 | -namespace Unity.Tests.UI |
| 1563 | -{ |
| 1564 | -public class TestFavorites : Unity.Favorites |
| 1565 | - { |
| 1566 | - public override ArrayList<string> get_favorites () |
| 1567 | - { |
| 1568 | - var retlist = new ArrayList<string> (); |
| 1569 | - retlist.add ("app-firefox"); |
| 1570 | - return retlist; |
| 1571 | - } |
| 1572 | - |
| 1573 | - public override string find_uid_for_desktop_file (string desktop_file) |
| 1574 | - { |
| 1575 | - return "app-firefox"; |
| 1576 | - } |
| 1577 | - |
| 1578 | - public override void add_favorite (string uid) |
| 1579 | - { |
| 1580 | - } |
| 1581 | - public override void remove_favorite (string uid) |
| 1582 | - { |
| 1583 | - } |
| 1584 | - public override bool is_favorite (string uid) |
| 1585 | - { |
| 1586 | - return true; |
| 1587 | - } |
| 1588 | - |
| 1589 | - public override string? get_string (string uid, string name) |
| 1590 | - { |
| 1591 | - if (name == "type") |
| 1592 | - return "application"; |
| 1593 | - |
| 1594 | - return "/usr/share/applications/firefox.desktop"; |
| 1595 | - } |
| 1596 | - |
| 1597 | - public override void set_string (string uid, string name, string value) |
| 1598 | - { |
| 1599 | - } |
| 1600 | - |
| 1601 | - public override int? get_int (string uid, string name) |
| 1602 | - { |
| 1603 | - return null; |
| 1604 | - } |
| 1605 | - public override void set_int (string uid, string name, int value) |
| 1606 | - { |
| 1607 | - } |
| 1608 | - |
| 1609 | - |
| 1610 | - public override float? get_float (string uid, string name) |
| 1611 | - { |
| 1612 | - return null; |
| 1613 | - } |
| 1614 | - public override void set_float (string uid, string name, float value) |
| 1615 | - { |
| 1616 | - } |
| 1617 | - |
| 1618 | - public override bool? get_bool (string uid, string name) |
| 1619 | - { |
| 1620 | - return null; |
| 1621 | - } |
| 1622 | - |
| 1623 | - public override void set_bool (string uid, string name, bool value) |
| 1624 | - { |
| 1625 | - } |
| 1626 | - } |
| 1627 | -} |
| 1628 | - |
| 1629 | -public class Main |
| 1630 | -{ |
| 1631 | - public static int main (string[] args) |
| 1632 | - { |
| 1633 | - Logging logger; |
| 1634 | - QuicklistSuite quicklist_suite; |
| 1635 | - HomeButtonSuite home_button_suite; |
| 1636 | - AutomationBasicTestSuite basic_test_suite; |
| 1637 | - IndicatorTestSuite indicator_test_suite; |
| 1638 | - |
| 1639 | - |
| 1640 | - Environment.set_variable ("UNITY_DISABLE_TRAY", "1", true); |
| 1641 | - Environment.set_variable ("UNITY_DISABLE_IDLES", "1", true); |
| 1642 | - Environment.set_variable ("UNITY_PANEL_INDICATORS_SKIP", "all", true); |
| 1643 | - |
| 1644 | - Gtk.init (ref args); |
| 1645 | - Gtk.Settings.get_default ().gtk_xft_dpi = 96 * 1024; |
| 1646 | - |
| 1647 | - Ctk.init (ref args); |
| 1648 | - Test.init (ref args); |
| 1649 | - |
| 1650 | - logger = new Logging (); |
| 1651 | - |
| 1652 | - basic_test_suite = new AutomationBasicTestSuite (); |
| 1653 | - quicklist_suite = new QuicklistSuite (); |
| 1654 | - home_button_suite = new HomeButtonSuite (); |
| 1655 | - indicator_test_suite = new IndicatorTestSuite (); |
| 1656 | - |
| 1657 | - Timeout.add_seconds (3, ()=> { |
| 1658 | - Test.run (); |
| 1659 | - Gtk.main_quit (); |
| 1660 | - return false; |
| 1661 | - }); |
| 1662 | - |
| 1663 | - Gtk.main (); |
| 1664 | - |
| 1665 | - return 0; |
| 1666 | - } |
| 1667 | -} |
| 1668 | |
| 1669 | === removed file 'vala_tests/unit/Makefile.am' |
| 1670 | --- vala_tests/unit/Makefile.am 2010-08-02 07:33:41 +0000 |
| 1671 | +++ vala_tests/unit/Makefile.am 1970-01-01 00:00:00 +0000 |
| 1672 | @@ -1,85 +0,0 @@ |
| 1673 | -SUBDIRS = data |
| 1674 | - |
| 1675 | -noinst_PROGRAMS = test-unit |
| 1676 | - |
| 1677 | -TESTDIR = $(top_srcdir)/tests/unit |
| 1678 | - |
| 1679 | -test_unit_CPPFLAGS = \ |
| 1680 | - -I$(top_srcdir) \ |
| 1681 | - -I$(top_srcdir)/unity \ |
| 1682 | - -I$(top_srcdir)/unity-private \ |
| 1683 | - -I$(top_srcdir)/src \ |
| 1684 | - -DTESTDIR=\"$(TESTDIR)\" \ |
| 1685 | - $(BASE_CFLAGS) |
| 1686 | - |
| 1687 | -test_unit_LDADD = \ |
| 1688 | - $(top_builddir)/unity/libunity.la \ |
| 1689 | - $(top_builddir)/unity-private/libunity-private.la \ |
| 1690 | - $(BASE_LIBS) \ |
| 1691 | - $(MAINTAINER_LIBS) |
| 1692 | - |
| 1693 | -test_unit_VALAFLAGS = \ |
| 1694 | - --vapidir=$(top_srcdir)/unity \ |
| 1695 | - --vapidir=$(top_srcdir)/unity-private \ |
| 1696 | - --vapidir=$(top_srcdir)/src \ |
| 1697 | - --vapidir=$(top_srcdir)/vapi/ \ |
| 1698 | - --vapidir=$(top_srcdir)/tests \ |
| 1699 | - --vapidir=$(top_srcdir)/tests/unit \ |
| 1700 | - --pkg gio-2.0 \ |
| 1701 | - --pkg Bamf-0.2 \ |
| 1702 | - --pkg clutter-1.0 \ |
| 1703 | - --pkg clutter-gtk-0.10 \ |
| 1704 | - --pkg config \ |
| 1705 | - --pkg dbus-glib-1 \ |
| 1706 | - --pkg Dbusmenu-Glib-0.2 \ |
| 1707 | - --pkg dee-1.0 \ |
| 1708 | - --pkg gtk+-2.0 \ |
| 1709 | - --pkg gdk-2.0 \ |
| 1710 | - --pkg gee-1.0 \ |
| 1711 | - --pkg x11 \ |
| 1712 | - --pkg gtk+-2.0 \ |
| 1713 | - --pkg gee-1.0 \ |
| 1714 | - --pkg indicator \ |
| 1715 | - --pkg clutk-0.3 \ |
| 1716 | - --pkg launcher-0.3 \ |
| 1717 | - --pkg posix \ |
| 1718 | - --pkg test-const \ |
| 1719 | - --pkg unique-1.0 \ |
| 1720 | - --pkg unity \ |
| 1721 | - --pkg unity-const \ |
| 1722 | - --pkg unity-private \ |
| 1723 | - $(MAINTAINER_VALAFLAGS) |
| 1724 | - |
| 1725 | -test_unit_SOURCES = \ |
| 1726 | - test-dbusmenu-quicklists.vala \ |
| 1727 | - test-launcher.vala \ |
| 1728 | - test-panel-indicator-object-entry-view.vala \ |
| 1729 | - test-panel-indicator-object-view.vala \ |
| 1730 | - test-places-place-file-model.vala \ |
| 1731 | - test-places-place.vala \ |
| 1732 | - test-places.vala \ |
| 1733 | - test-place.vala \ |
| 1734 | - test-place-browser.vala \ |
| 1735 | - test-io.vala \ |
| 1736 | - test-appinfo-manager.vala \ |
| 1737 | - test-unity-pixbuf-cache.vala \ |
| 1738 | - test-unit.vala |
| 1739 | - |
| 1740 | -# GTester stuff |
| 1741 | -XML_REPORT = test-unit-results.xml |
| 1742 | -HTML_REPORT = test-unit-results.html |
| 1743 | - |
| 1744 | -unit-tester: test-unit |
| 1745 | - @gtester -o=$(XML_REPORT) ./test-unit |
| 1746 | - |
| 1747 | -check-report: |
| 1748 | - @gtester -o=$(XML_REPORT) -k ./test-unit \ |
| 1749 | - && (gtester-report $(XML_REPORT) \ |
| 1750 | - | sed 's/GTester Unit Test Report</>GTester Unit Test Report (normal)</' \ |
| 1751 | - > $(HTML_REPORT)) \ |
| 1752 | - && xdg-open $(HTML_REPORT) |
| 1753 | - |
| 1754 | -check-local: unit-tester |
| 1755 | - |
| 1756 | -EXTRA_DIST = test-const.vapi |
| 1757 | -CLEANFILES = *.stamp $(XML_REPORT) $(HTML_REPORT) *.c |
| 1758 | |
| 1759 | === removed file 'vala_tests/unit/test-dbusmenu-quicklists.vala' |
| 1760 | --- vala_tests/unit/test-dbusmenu-quicklists.vala 2010-08-01 19:50:39 +0000 |
| 1761 | +++ vala_tests/unit/test-dbusmenu-quicklists.vala 1970-01-01 00:00:00 +0000 |
| 1762 | @@ -1,188 +0,0 @@ |
| 1763 | -/* |
| 1764 | - * test-launcher.vala |
| 1765 | - * Copyright (C) 2010 Canonical Ltd |
| 1766 | - * |
| 1767 | - * This program is free software; you can redistribute it and/or modify |
| 1768 | - * it under the terms of the GNU General Public License as published by |
| 1769 | - * the Free Software Foundation; either version 3 of the License, or |
| 1770 | - * (at your option) any later version. |
| 1771 | - * |
| 1772 | - * This program is distributed in the hope that it will be useful, |
| 1773 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1774 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1775 | - * GNU General Public License for more details. |
| 1776 | - * |
| 1777 | - * You should have received a copy of the GNU General Public License |
| 1778 | - * along with this program; if not, write to the Free Software |
| 1779 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 1780 | - * MA 02110-1301, USA. |
| 1781 | - * |
| 1782 | - * |
| 1783 | - * Authored by Gordon Allott <gord.allott@canonical.com> |
| 1784 | - */ |
| 1785 | -using Unity; |
| 1786 | -using Unity.Launcher; |
| 1787 | -using Unity.Testing; |
| 1788 | - |
| 1789 | -/* TODO - add more tests once we have bamf and can test the controllers */ |
| 1790 | -namespace Unity.Tests.Unit |
| 1791 | -{ |
| 1792 | - public class TestScrollerChildController : ScrollerChildController |
| 1793 | - { |
| 1794 | - public TestScrollerChildController (ScrollerChild child_) |
| 1795 | - { |
| 1796 | - Object (child: child_); |
| 1797 | - } |
| 1798 | - |
| 1799 | - construct |
| 1800 | - { |
| 1801 | - name = "Testing"; |
| 1802 | - } |
| 1803 | - |
| 1804 | - public override void get_menu_actions (ScrollerChildController.menu_cb callback) |
| 1805 | - { |
| 1806 | - // our actions menu goes as follows |
| 1807 | - // + Root |
| 1808 | - // - Checked Menu Item, unchecked, "Unchecked" |
| 1809 | - // - Checked Menu Item, checked, "Checked" |
| 1810 | - // - Separator |
| 1811 | - // - Label "A Label" |
| 1812 | - // - Radio Menu Item, checked, "Radio Active" |
| 1813 | - // - Radio Menu Item, unchecked, "Radio Unactive" |
| 1814 | - Dbusmenu.Menuitem root = new Dbusmenu.Menuitem (); |
| 1815 | - root.set_root (true); |
| 1816 | - |
| 1817 | - Dbusmenu.Menuitem menuitem = new Dbusmenu.Menuitem (); |
| 1818 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Unchecked"); |
| 1819 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_CHECK); |
| 1820 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1821 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1822 | - menuitem.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); |
| 1823 | - root.child_append (menuitem); |
| 1824 | - |
| 1825 | - menuitem = new Dbusmenu.Menuitem (); |
| 1826 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Checked"); |
| 1827 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_CHECK); |
| 1828 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1829 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1830 | - menuitem.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); |
| 1831 | - root.child_append (menuitem); |
| 1832 | - |
| 1833 | - menuitem = new Dbusmenu.Menuitem (); |
| 1834 | - menuitem.property_set ("type", Dbusmenu.CLIENT_TYPES_SEPARATOR); |
| 1835 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1836 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1837 | - root.child_append (menuitem); |
| 1838 | - |
| 1839 | - menuitem = new Dbusmenu.Menuitem (); |
| 1840 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "A Label"); |
| 1841 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1842 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1843 | - root.child_append (menuitem); |
| 1844 | - |
| 1845 | - menuitem = new Dbusmenu.Menuitem (); |
| 1846 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Radio Active"); |
| 1847 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_RADIO); |
| 1848 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1849 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1850 | - menuitem.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); |
| 1851 | - root.child_append (menuitem); |
| 1852 | - |
| 1853 | - menuitem = new Dbusmenu.Menuitem (); |
| 1854 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Radio Unactive"); |
| 1855 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_RADIO); |
| 1856 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1857 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1858 | - menuitem.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); |
| 1859 | - root.child_append (menuitem); |
| 1860 | - |
| 1861 | - callback (root); |
| 1862 | - } |
| 1863 | - |
| 1864 | - public override void get_menu_navigation (ScrollerChildController.menu_cb callback) |
| 1865 | - { |
| 1866 | - // just tests that the order is correct |
| 1867 | - Dbusmenu.Menuitem root = new Dbusmenu.Menuitem (); |
| 1868 | - root.set_root (true); |
| 1869 | - |
| 1870 | - Dbusmenu.Menuitem menuitem = new Dbusmenu.Menuitem (); |
| 1871 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "1"); |
| 1872 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1873 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1874 | - root.child_append (menuitem); |
| 1875 | - |
| 1876 | - menuitem = new Dbusmenu.Menuitem (); |
| 1877 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "2"); |
| 1878 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1879 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1880 | - root.child_append (menuitem); |
| 1881 | - |
| 1882 | - menuitem = new Dbusmenu.Menuitem (); |
| 1883 | - menuitem.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "3"); |
| 1884 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
| 1885 | - menuitem.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
| 1886 | - root.child_append (menuitem); |
| 1887 | - |
| 1888 | - callback (root); |
| 1889 | - } |
| 1890 | - |
| 1891 | - public override void activate () |
| 1892 | - { |
| 1893 | - } |
| 1894 | - |
| 1895 | - public override QuicklistController? get_menu_controller () |
| 1896 | - { |
| 1897 | - QuicklistController new_menu = new ApplicationQuicklistController (this); |
| 1898 | - return new_menu; |
| 1899 | - } |
| 1900 | - } |
| 1901 | - |
| 1902 | - public class QuicklistSuite |
| 1903 | - { |
| 1904 | - public QuicklistSuite () |
| 1905 | - { |
| 1906 | - Test.add_data_func ("/Unity/Launcher/TestDbusMenu", test_dbus_menu); |
| 1907 | - } |
| 1908 | - |
| 1909 | - private void test_dbus_menu() |
| 1910 | - { |
| 1911 | - ScrollerChild child = new TestScrollerChild (); |
| 1912 | - TestScrollerChildController controller = new TestScrollerChildController(child); |
| 1913 | - ApplicationQuicklistController menu = controller.get_menu_controller () as ApplicationQuicklistController; |
| 1914 | - menu.state = QuicklistControllerState.LABEL; |
| 1915 | - |
| 1916 | - unowned GLib.List<Ctk.MenuItem> menuitems = null; |
| 1917 | - assert (menuitems.length () == 0); |
| 1918 | - |
| 1919 | - menu.state = QuicklistControllerState.MENU; |
| 1920 | - |
| 1921 | - // this assert here will only work for our local dbusmenu's because they return |
| 1922 | - // immediately. remote dbusmenu's need to be slightly more clever |
| 1923 | - menuitems = menu.get_view ().get_items (); |
| 1924 | - assert (menuitems.length () >= 10); |
| 1925 | - |
| 1926 | - assert (menuitems.data is Ctk.CheckMenuItem); |
| 1927 | - assert ((menuitems.data as Ctk.CheckMenuItem).active == false); |
| 1928 | - menuitems = menuitems.next; |
| 1929 | - |
| 1930 | - assert (menuitems.data is Ctk.CheckMenuItem); |
| 1931 | - assert ((menuitems.data as Ctk.CheckMenuItem).active == true); |
| 1932 | - menuitems = menuitems.next; |
| 1933 | - |
| 1934 | - assert (menuitems.data is Ctk.MenuSeperator); |
| 1935 | - menuitems = menuitems.next; |
| 1936 | - |
| 1937 | - assert (menuitems.data is Ctk.MenuItem); |
| 1938 | - assert ((menuitems.data as Ctk.MenuItem).label == "A Label"); |
| 1939 | - menuitems = menuitems.next; |
| 1940 | - |
| 1941 | - assert (menuitems.data is Ctk.RadioMenuItem); |
| 1942 | - assert ((menuitems.data as Ctk.RadioMenuItem).active == true); |
| 1943 | - menuitems = menuitems.next; |
| 1944 | - |
| 1945 | - assert (menuitems.data is Ctk.RadioMenuItem); |
| 1946 | - assert ((menuitems.data as Ctk.RadioMenuItem).active == true); |
| 1947 | - menuitems = menuitems.next; |
| 1948 | - } |
| 1949 | - } |
| 1950 | -} |
| 1951 | |
| 1952 | === removed file 'vala_tests/unit/test-launcher.vala' |
| 1953 | --- vala_tests/unit/test-launcher.vala 2010-07-29 11:48:06 +0000 |
| 1954 | +++ vala_tests/unit/test-launcher.vala 1970-01-01 00:00:00 +0000 |
| 1955 | @@ -1,223 +0,0 @@ |
| 1956 | -/* |
| 1957 | - * test-launcher.vala |
| 1958 | - * Copyright (C) 2010 Canonical Ltd |
| 1959 | - * |
| 1960 | - * This program is free software; you can redistribute it and/or modify |
| 1961 | - * it under the terms of the GNU General Public License as published by |
| 1962 | - * the Free Software Foundation; either version 3 of the License, or |
| 1963 | - * (at your option) any later version. |
| 1964 | - * |
| 1965 | - * This program is distributed in the hope that it will be useful, |
| 1966 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1967 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1968 | - * GNU General Public License for more details. |
| 1969 | - * |
| 1970 | - * You should have received a copy of the GNU General Public License |
| 1971 | - * along with this program; if not, write to the Free Software |
| 1972 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 1973 | - * MA 02110-1301, USA. |
| 1974 | - * |
| 1975 | - * |
| 1976 | - * Authored by Gordon Allott <gord.allott@canonical.com> |
| 1977 | - */ |
| 1978 | -using Unity; |
| 1979 | -using Unity.Launcher; |
| 1980 | -using Unity.Testing; |
| 1981 | - |
| 1982 | -namespace Unity.Tests.Unit |
| 1983 | -{ |
| 1984 | - // can't use this code yet because bamf hates testing :'( |
| 1985 | -/* |
| 1986 | - public class TestBamfIndicator : Bamf.Indicator |
| 1987 | - { |
| 1988 | - public TestBamfIndicator () |
| 1989 | - { |
| 1990 | - } |
| 1991 | - |
| 1992 | - construct |
| 1993 | - { |
| 1994 | - } |
| 1995 | - |
| 1996 | - public new string get_dbus_menu_path () |
| 1997 | - { |
| 1998 | - return ""; |
| 1999 | - } |
| 2000 | - public new string get_remote_address () |
| 2001 | - { |
| 2002 | - return ""; |
| 2003 | - } |
| 2004 | - public new string get_remote_path () |
| 2005 | - { |
| 2006 | - return ""; |
| 2007 | - } |
| 2008 | - } |
| 2009 | -*/ |
| 2010 | - |
| 2011 | - public class TestBamfApplication : Bamf.Application |
| 2012 | - { |
| 2013 | - public bool test_is_active = true; |
| 2014 | - public bool test_is_urgent = false; |
| 2015 | - public bool test_user_visible = true; |
| 2016 | - public bool test_is_running = true; |
| 2017 | - |
| 2018 | - public string desktop_file = "firefox.desktop"; |
| 2019 | - public string name = "firefox"; |
| 2020 | - public string icon = "firefox"; |
| 2021 | - private GLib.List<Bamf.View> children; |
| 2022 | - |
| 2023 | - public TestBamfApplication () |
| 2024 | - { |
| 2025 | - Object (path: "/null"); |
| 2026 | - } |
| 2027 | - |
| 2028 | - construct |
| 2029 | - { |
| 2030 | - children = new GLib.List<Bamf.View> (); |
| 2031 | - } |
| 2032 | - |
| 2033 | - public new unowned string get_desktop_file () |
| 2034 | - { |
| 2035 | - return desktop_file; |
| 2036 | - } |
| 2037 | - |
| 2038 | - GLib.List<Object> temp_list; |
| 2039 | - public new unowned GLib.List get_windows () |
| 2040 | - { |
| 2041 | - temp_list = new GLib.List<Object> (); |
| 2042 | - return temp_list; |
| 2043 | - } |
| 2044 | - |
| 2045 | - public override GLib.List get_children () |
| 2046 | - { |
| 2047 | - GLib.List<Bamf.View> tmplist = new GLib.List<Bamf.View> (); |
| 2048 | - foreach (Bamf.View child in children) |
| 2049 | - { |
| 2050 | - tmplist.append (child); |
| 2051 | - } |
| 2052 | - return tmplist; |
| 2053 | - } |
| 2054 | - |
| 2055 | - public new GLib.Array get_xids () |
| 2056 | - { |
| 2057 | - Array<uint32> retarray = new Array<uint32> (true, false, (uint)sizeof (uint32)); |
| 2058 | - return retarray; |
| 2059 | - } |
| 2060 | - |
| 2061 | - public override string get_icon () |
| 2062 | - { |
| 2063 | - return icon; |
| 2064 | - } |
| 2065 | - |
| 2066 | - public override string get_name () |
| 2067 | - { |
| 2068 | - return name; |
| 2069 | - } |
| 2070 | - |
| 2071 | - public override bool is_active () |
| 2072 | - { |
| 2073 | - return test_is_active; |
| 2074 | - } |
| 2075 | - |
| 2076 | - public override bool is_running () |
| 2077 | - { |
| 2078 | - return test_is_running; |
| 2079 | - } |
| 2080 | - |
| 2081 | - public override bool is_urgent () |
| 2082 | - { |
| 2083 | - return test_is_urgent; |
| 2084 | - } |
| 2085 | - |
| 2086 | - public new bool user_visible () |
| 2087 | - { |
| 2088 | - return test_user_visible; |
| 2089 | - } |
| 2090 | - |
| 2091 | - public override unowned string view_type () |
| 2092 | - { |
| 2093 | - return "test"; |
| 2094 | - } |
| 2095 | - } |
| 2096 | - |
| 2097 | - public class TestScrollerChild : ScrollerChild |
| 2098 | - { |
| 2099 | - } |
| 2100 | - |
| 2101 | - public class LauncherSuite |
| 2102 | - { |
| 2103 | - public LauncherSuite () |
| 2104 | - { |
| 2105 | - Test.add_data_func ("/Unity/Launcher/TestScrollerModel", test_scroller_model); |
| 2106 | - Test.add_data_func ("/Unity/Launcher/TestScrollerChildController", test_scroller_child_controller); |
| 2107 | - } |
| 2108 | - |
| 2109 | - |
| 2110 | - // very basic tests for scroller model, makes sure its list interface works |
| 2111 | - // as expected |
| 2112 | - private void test_scroller_model () |
| 2113 | - { |
| 2114 | - ScrollerModel model = new ScrollerModel (); |
| 2115 | - ScrollerChild child_a = new TestScrollerChild (); |
| 2116 | - ScrollerChild child_b = new TestScrollerChild (); |
| 2117 | - ScrollerChild child_c = new TestScrollerChild (); |
| 2118 | - |
| 2119 | - model.add (child_a); |
| 2120 | - model.add (child_c); |
| 2121 | - model.insert (child_b, 1); |
| 2122 | - |
| 2123 | - // make sure each model is in the correct position |
| 2124 | - assert (model[1] == child_b); |
| 2125 | - assert (model[2] == child_c); |
| 2126 | - |
| 2127 | - // make sure non of the children got lost somehow |
| 2128 | - foreach (ScrollerChild child in model) |
| 2129 | - { |
| 2130 | - assert (child is ScrollerChild); |
| 2131 | - } |
| 2132 | - |
| 2133 | - assert (child_a in model); |
| 2134 | - |
| 2135 | - // make sure that after removing a child, everything is still in the correct order |
| 2136 | - model.remove (child_b); |
| 2137 | - assert (model[1] == child_c); |
| 2138 | - } |
| 2139 | - |
| 2140 | - private void test_scroller_child_controller () |
| 2141 | - { |
| 2142 | - TestBamfApplication test_app = new TestBamfApplication (); |
| 2143 | - ScrollerChild child = new TestScrollerChild (); |
| 2144 | - ApplicationController controller = new ApplicationController (Config.TESTUNITDIR + "/data/test_desktop_file.desktop", child); |
| 2145 | - |
| 2146 | - test_app.name = "Test Application-New"; |
| 2147 | - test_app.desktop_file = Config.TESTUNITDIR + "/data/test_desktop_file.desktop"; |
| 2148 | - test_app.icon = Config.TESTUNITDIR + "/data/test_desktop_icon.png"; |
| 2149 | - test_app.test_is_active = true; |
| 2150 | - test_app.test_is_urgent = false; |
| 2151 | - test_app.test_user_visible = true; |
| 2152 | - test_app.test_is_running = true; |
| 2153 | - |
| 2154 | - //assert that the controller set the model into the correct state |
| 2155 | - assert (child.running == false); |
| 2156 | - assert (child.active == false); |
| 2157 | - assert (child.needs_attention == false); |
| 2158 | - assert (controller.name == "Test Application"); |
| 2159 | - |
| 2160 | - // unfortunately we need to disable the bamf tests for now, bamf is not letting us subclass for fake objects |
| 2161 | -/* |
| 2162 | - controller.attach_application (test_app); |
| 2163 | - assert (child.running == true); |
| 2164 | - assert (child.active == true); |
| 2165 | - assert (controller.name == "Test Application-New"); |
| 2166 | - |
| 2167 | - test_app.test_is_active = false; |
| 2168 | - test_app.active_changed (test_app.test_is_active); |
| 2169 | - assert (child.active == false); |
| 2170 | - |
| 2171 | - test_app.test_is_running = false; |
| 2172 | - test_app.running_changed (test_app.test_is_running); |
| 2173 | - assert (child.running == false); |
| 2174 | - assert (controller.debug_is_application_attached () == false); |
| 2175 | -*/ |
| 2176 | - } |
| 2177 | - } |
| 2178 | -} |
| 2179 | |
| 2180 | === removed file 'vala_tests/unit/test-panel-indicator-object-entry-view.vala' |
| 2181 | --- vala_tests/unit/test-panel-indicator-object-entry-view.vala 2010-06-03 17:13:55 +0000 |
| 2182 | +++ vala_tests/unit/test-panel-indicator-object-entry-view.vala 1970-01-01 00:00:00 +0000 |
| 2183 | @@ -1,97 +0,0 @@ |
| 2184 | -/* |
| 2185 | - * Copyright (C) 2009 Canonical Ltd |
| 2186 | - * |
| 2187 | - * This program is free software: you can redistribute it and/or modify |
| 2188 | - * it under the terms of the GNU General Public License version 3 as |
| 2189 | - * published by the Free Software Foundation. |
| 2190 | - * |
| 2191 | - * This program is distributed in the hope that it will be useful, |
| 2192 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2193 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2194 | - * GNU General Public License for more details. |
| 2195 | - * |
| 2196 | - * You should have received a copy of the GNU General Public License |
| 2197 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2198 | - * |
| 2199 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 2200 | - * |
| 2201 | - */ |
| 2202 | -using Unity; |
| 2203 | -using Unity.Testing; |
| 2204 | -using Unity.Panel.Indicators; |
| 2205 | - |
| 2206 | -namespace Unity.Tests.Unit |
| 2207 | -{ |
| 2208 | - public class PanelIndicatorObjectEntryViewSuite : Object |
| 2209 | - { |
| 2210 | - public const string DOMAIN = "/Unit/Panel/Indicator/ObjectEntry"; |
| 2211 | - |
| 2212 | - private Indicator.ObjectEntry entry; |
| 2213 | - private Gtk.Menu menu; |
| 2214 | - private Gtk.Label label; |
| 2215 | - private Gtk.Image image; |
| 2216 | - |
| 2217 | - public PanelIndicatorObjectEntryViewSuite () |
| 2218 | - { |
| 2219 | - Logging.init_fatal_handler (); |
| 2220 | - |
| 2221 | - entry = new Indicator.ObjectEntry (); |
| 2222 | - |
| 2223 | - menu = new Gtk.Menu (); |
| 2224 | - entry.menu = menu; |
| 2225 | - |
| 2226 | - label = new Gtk.Label ("Test Label"); |
| 2227 | - entry.label = label; |
| 2228 | - |
| 2229 | - image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); |
| 2230 | - entry.image = image; |
| 2231 | - |
| 2232 | - Test.add_data_func (DOMAIN + "/Allocation", test_allocation); |
| 2233 | - Test.add_data_func (DOMAIN + "/LabelSync", test_label_sync); |
| 2234 | - Test.add_data_func (DOMAIN + "/ImageSync", test_image_sync); |
| 2235 | - } |
| 2236 | - |
| 2237 | - private void test_allocation () |
| 2238 | - { |
| 2239 | - var e = new IndicatorObjectEntryView (entry); |
| 2240 | - |
| 2241 | - assert (e is IndicatorObjectEntryView); |
| 2242 | - } |
| 2243 | - |
| 2244 | - private void test_label_sync () |
| 2245 | - { |
| 2246 | - var e = new IndicatorObjectEntryView (entry); |
| 2247 | - |
| 2248 | - assert (e is IndicatorObjectEntryView); |
| 2249 | - |
| 2250 | - /* Make sure text is in sync */ |
| 2251 | - assert (e.text.text == label.label); |
| 2252 | - |
| 2253 | - /* Update the label and check again */ |
| 2254 | - label.label = "Test Label 2"; |
| 2255 | - assert (e.text.text == label.label); |
| 2256 | - |
| 2257 | - label.label = "Test Label"; |
| 2258 | - } |
| 2259 | - |
| 2260 | - private void test_image_sync () |
| 2261 | - { |
| 2262 | - var e = new IndicatorObjectEntryView (entry); |
| 2263 | - assert (e is IndicatorObjectEntryView); |
| 2264 | - |
| 2265 | - /* Test that the icon name has synced */ |
| 2266 | - assert (e.image.stock_id == image.icon_name); |
| 2267 | - |
| 2268 | - /* Test that if it changes entry keeps it in sync */ |
| 2269 | - image.icon_name = "gtk-close"; |
| 2270 | - assert (e.image.stock_id == image.icon_name); |
| 2271 | - |
| 2272 | - /* Test pixbuf */ |
| 2273 | - var p = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 100, 100); |
| 2274 | - image.pixbuf = p; |
| 2275 | - assert (e.image.pixbuf == image.pixbuf); |
| 2276 | - |
| 2277 | - image.icon_name = "gtk-apply"; |
| 2278 | - } |
| 2279 | - } |
| 2280 | -} |
| 2281 | |
| 2282 | === removed file 'vala_tests/unit/test-panel-indicator-object-view.vala' |
| 2283 | --- vala_tests/unit/test-panel-indicator-object-view.vala 2010-06-08 04:30:19 +0000 |
| 2284 | +++ vala_tests/unit/test-panel-indicator-object-view.vala 1970-01-01 00:00:00 +0000 |
| 2285 | @@ -1,154 +0,0 @@ |
| 2286 | -/* |
| 2287 | - * Copyright (C) 2009 Canonical Ltd |
| 2288 | - * |
| 2289 | - * This program is free software: you can redistribute it and/or modify |
| 2290 | - * it under the terms of the GNU General Public License version 3 as |
| 2291 | - * published by the Free Software Foundation. |
| 2292 | - * |
| 2293 | - * This program is distributed in the hope that it will be useful, |
| 2294 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2295 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2296 | - * GNU General Public License for more details. |
| 2297 | - * |
| 2298 | - * You should have received a copy of the GNU General Public License |
| 2299 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2300 | - * |
| 2301 | - * Authored by Neil Jay Taoko <jay.taoko.patel@canonical.com> |
| 2302 | - * |
| 2303 | - */ |
| 2304 | -using Unity; |
| 2305 | -using Unity.Testing; |
| 2306 | -using Unity.Panel.Indicators; |
| 2307 | - |
| 2308 | -namespace Unity.Tests.Unit |
| 2309 | -{ |
| 2310 | - public class FakeIndicatorObject: Indicator.Object |
| 2311 | - { |
| 2312 | - public Gee.ArrayList<Indicator.ObjectEntry> indicator_entry_array; |
| 2313 | - public Gtk.Label _label; |
| 2314 | - public Gtk.Image _image; |
| 2315 | - public Gtk.Menu _menu; |
| 2316 | - |
| 2317 | - public FakeIndicatorObject () |
| 2318 | - { |
| 2319 | - Object(); |
| 2320 | - } |
| 2321 | - |
| 2322 | - construct |
| 2323 | - { |
| 2324 | - START_FUNCTION (); |
| 2325 | - indicator_entry_array = new Gee.ArrayList< unowned Indicator.ObjectEntry> (); |
| 2326 | - |
| 2327 | - _label = new Gtk.Label ("Test Label"); |
| 2328 | - _image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); |
| 2329 | - _menu = new Gtk.Menu (); |
| 2330 | - END_FUNCTION (); |
| 2331 | - } |
| 2332 | - |
| 2333 | - public void add_entry(Indicator.ObjectEntry entry) |
| 2334 | - { |
| 2335 | - int pos = indicator_entry_array.index_of (entry); |
| 2336 | - if (pos != -1) |
| 2337 | - return; |
| 2338 | - |
| 2339 | - indicator_entry_array.add (entry); |
| 2340 | - entry_added (entry); |
| 2341 | - } |
| 2342 | - |
| 2343 | - public void remove_entry(Indicator.ObjectEntry entry) |
| 2344 | - { |
| 2345 | - int pos = indicator_entry_array.index_of (entry); |
| 2346 | - if (pos != -1) |
| 2347 | - { |
| 2348 | - indicator_entry_array.remove_at (pos); |
| 2349 | - entry_removed (entry); |
| 2350 | - } |
| 2351 | - } |
| 2352 | - |
| 2353 | - public override unowned Gtk.Label get_label () |
| 2354 | - { |
| 2355 | - return this._label; |
| 2356 | - } |
| 2357 | - |
| 2358 | - public override unowned Gtk.Image get_image () |
| 2359 | - { |
| 2360 | - return this._image; |
| 2361 | - } |
| 2362 | - |
| 2363 | - public override unowned Gtk.Menu get_menu () |
| 2364 | - { |
| 2365 | - return this._menu; |
| 2366 | - } |
| 2367 | - |
| 2368 | -// public override GLib.List<unowned Indicator.ObjectEntry> get_entries () |
| 2369 | -// { |
| 2370 | -// GLib.List<unowned Indicator.ObjectEntry> list = new GLib.List<unowned Indicator.ObjectEntry> (); |
| 2371 | -// foreach(unowned Indicator.ObjectEntry element in indicator_entry_array) |
| 2372 | -// { |
| 2373 | -// list.append (element); |
| 2374 | -// } |
| 2375 | -// return list; |
| 2376 | -// } |
| 2377 | - } |
| 2378 | - |
| 2379 | - public class PanelIndicatorObjectViewSuite : Object |
| 2380 | - { |
| 2381 | - public const string DOMAIN = "/Unit/Panel/Indicator/ObjectView"; |
| 2382 | - |
| 2383 | - private Indicator.ObjectEntry entry; |
| 2384 | - private Gtk.Menu menu; |
| 2385 | - private Gtk.Label label; |
| 2386 | - private Gtk.Image image; |
| 2387 | - |
| 2388 | - public PanelIndicatorObjectViewSuite () |
| 2389 | - { |
| 2390 | - Logging.init_fatal_handler (); |
| 2391 | - |
| 2392 | - entry = new Indicator.ObjectEntry (); |
| 2393 | - |
| 2394 | - menu = new Gtk.Menu (); |
| 2395 | - entry.menu = menu; |
| 2396 | - |
| 2397 | - label = new Gtk.Label ("Test Label"); |
| 2398 | - entry.label = label; |
| 2399 | - |
| 2400 | - image = new Gtk.Image.from_icon_name ("gtk-apply", Gtk.IconSize.MENU); |
| 2401 | - entry.image = image; |
| 2402 | - |
| 2403 | - Test.add_data_func (DOMAIN + "/FakeIndicator", test_fake_indicator_object); |
| 2404 | - Test.add_data_func (DOMAIN + "/FakeIndicatorAddEntry", test_indicator_add_entry); |
| 2405 | - Test.add_data_func (DOMAIN + "/TestEntryView", test_indicator_enty_view); |
| 2406 | - } |
| 2407 | - |
| 2408 | - private void test_fake_indicator_object () |
| 2409 | - { |
| 2410 | - var fakeobject = new FakeIndicatorObject (); |
| 2411 | - |
| 2412 | - assert (fakeobject is FakeIndicatorObject); |
| 2413 | - } |
| 2414 | - |
| 2415 | - private void test_indicator_add_entry () |
| 2416 | - { |
| 2417 | - var fakeobject = new FakeIndicatorObject (); |
| 2418 | - var e = new IndicatorObjectView (fakeobject); |
| 2419 | - |
| 2420 | - fakeobject.add_entry (entry); |
| 2421 | - |
| 2422 | - assert (e.find_entry (entry)); |
| 2423 | - } |
| 2424 | - |
| 2425 | - private void test_indicator_enty_view () |
| 2426 | - { |
| 2427 | - var fakeobject = new FakeIndicatorObject (); |
| 2428 | - var e = new IndicatorObjectView (fakeobject); |
| 2429 | - |
| 2430 | - fakeobject.add_entry (entry); |
| 2431 | - IndicatorObjectEntryView? entry_view = e.get_entry_view (entry); |
| 2432 | - |
| 2433 | - assert (entry_view.entry == entry); |
| 2434 | - assert (entry_view.entry.label == entry.label); |
| 2435 | - assert (entry_view.entry.image == entry.image); |
| 2436 | - assert (entry_view.entry.menu == entry.menu); |
| 2437 | - } |
| 2438 | - } |
| 2439 | -} |
| 2440 | |
| 2441 | === removed file 'vala_tests/unit/test-places-place-file-model.vala' |
| 2442 | --- vala_tests/unit/test-places-place-file-model.vala 2010-07-29 11:48:06 +0000 |
| 2443 | +++ vala_tests/unit/test-places-place-file-model.vala 1970-01-01 00:00:00 +0000 |
| 2444 | @@ -1,43 +0,0 @@ |
| 2445 | -/* |
| 2446 | - * Copyright (C) 2010 Canonical Ltd |
| 2447 | - * |
| 2448 | - * This program is free software: you can redistribute it and/or modify |
| 2449 | - * it under the terms of the GNU General Public License version 3 as |
| 2450 | - * published by the Free Software Foundation. |
| 2451 | - * |
| 2452 | - * This program is distributed in the hope that it will be useful, |
| 2453 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2454 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2455 | - * GNU General Public License for more details. |
| 2456 | - * |
| 2457 | - * You should have received a copy of the GNU General Public License |
| 2458 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2459 | - * |
| 2460 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 2461 | - * |
| 2462 | - */ |
| 2463 | -using Unity; |
| 2464 | -using Unity.Testing; |
| 2465 | -using Unity.Places; |
| 2466 | - |
| 2467 | -namespace Unity.Tests.Unit |
| 2468 | -{ |
| 2469 | - public class PlacesPlaceFileModelSuite : Object |
| 2470 | - { |
| 2471 | - public const string DOMAIN = "/Unit/Places/PlaceFileModel"; |
| 2472 | - |
| 2473 | - public PlacesPlaceFileModelSuite () |
| 2474 | - { |
| 2475 | - Logging.init_fatal_handler (); |
| 2476 | - |
| 2477 | - Test.add_data_func (DOMAIN + "/Allocation", test_allocation); |
| 2478 | - } |
| 2479 | - |
| 2480 | - private void test_allocation () |
| 2481 | - { |
| 2482 | - var model = new PlaceFileModel.with_directory (Config.TESTUNITDIR+"/data"); |
| 2483 | - assert (model is PlaceFileModel); |
| 2484 | - assert (model.size == 2); |
| 2485 | - } |
| 2486 | - } |
| 2487 | -} |
| 2488 | |
| 2489 | === removed file 'vala_tests/unit/test-places-place.vala' |
| 2490 | --- vala_tests/unit/test-places-place.vala 2010-07-29 11:48:06 +0000 |
| 2491 | +++ vala_tests/unit/test-places-place.vala 1970-01-01 00:00:00 +0000 |
| 2492 | @@ -1,161 +0,0 @@ |
| 2493 | -/* |
| 2494 | - * Copyright (C) 2010 Canonical Ltd |
| 2495 | - * |
| 2496 | - * This program is free software: you can redistribute it and/or modify |
| 2497 | - * it under the terms of the GNU General Public License version 3 as |
| 2498 | - * published by the Free Software Foundation. |
| 2499 | - * |
| 2500 | - * This program is distributed in the hope that it will be useful, |
| 2501 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2502 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2503 | - * GNU General Public License for more details. |
| 2504 | - * |
| 2505 | - * You should have received a copy of the GNU General Public License |
| 2506 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2507 | - * |
| 2508 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 2509 | - * |
| 2510 | - */ |
| 2511 | -using Unity; |
| 2512 | -using Unity.Testing; |
| 2513 | -using Unity.Places; |
| 2514 | -using GLib.Test; |
| 2515 | - |
| 2516 | -namespace Unity.Tests.Unit |
| 2517 | -{ |
| 2518 | - public class PlacesPlaceSuite : Object |
| 2519 | - { |
| 2520 | - public const string DOMAIN = "/Unit/Places/Place"; |
| 2521 | - |
| 2522 | - public PlacesPlaceSuite () |
| 2523 | - { |
| 2524 | - Logging.init_fatal_handler (); |
| 2525 | - |
| 2526 | - Test.add_data_func (DOMAIN + "/Allocation", test_allocation); |
| 2527 | - Test.add_data_func (DOMAIN + "/SimplePlaceFile", test_simple_placefile); |
| 2528 | - Test.add_data_func (DOMAIN + "/AdvancedPlaceFile", test_advanced_place_file); |
| 2529 | - Test.add_data_func (DOMAIN + "/BadSimplePlaceFile", test_bad_simple_place_file); |
| 2530 | - Test.add_data_func (DOMAIN + "/BadAdvancedPlaceFile", test_bad_advanced_place_file); |
| 2531 | - } |
| 2532 | - |
| 2533 | - private void test_allocation () |
| 2534 | - { |
| 2535 | - var place = new Places.Place ("__name__", "__path__"); |
| 2536 | - assert (place is Places.Place); |
| 2537 | - assert (place.dbus_name == "__name__"); |
| 2538 | - assert (place.dbus_path == "__path__"); |
| 2539 | - } |
| 2540 | - |
| 2541 | - private void test_simple_placefile () |
| 2542 | - { |
| 2543 | - var file = new KeyFile (); |
| 2544 | - try { |
| 2545 | - file.load_from_file (Config.TESTUNITDIR + "/data/place0.place", |
| 2546 | - KeyFileFlags.NONE); |
| 2547 | - } catch (Error e) { |
| 2548 | - error ("Unable to load test place: %s", e.message); |
| 2549 | - } |
| 2550 | - |
| 2551 | - var place = Places.Place.new_from_keyfile (file); |
| 2552 | - assert (place is Places.Place); |
| 2553 | - |
| 2554 | - /* Test Place group was loaded properly */ |
| 2555 | - assert (place.dbus_name == "org.ayatana.Unity.Place0"); |
| 2556 | - assert (place.dbus_path == "/org/ayatana/Unity/Place0"); |
| 2557 | - |
| 2558 | - /* Test entries were loaded properly */ |
| 2559 | - assert (place.n_entries == 0); |
| 2560 | - } |
| 2561 | - |
| 2562 | - private void test_advanced_place_file () |
| 2563 | - { |
| 2564 | - var file = new KeyFile (); |
| 2565 | - try { |
| 2566 | - file.load_from_file (Config.TESTUNITDIR + "/data/place1.place", |
| 2567 | - KeyFileFlags.NONE); |
| 2568 | - } catch (Error error) { |
| 2569 | - warning ("Unable to load test place: %s", error.message); |
| 2570 | - } |
| 2571 | - |
| 2572 | - var place = Places.Place.new_from_keyfile (file); |
| 2573 | - assert (place is Places.Place); |
| 2574 | - |
| 2575 | - /* Test Place group was loaded properly */ |
| 2576 | - assert (place.dbus_name == "org.ayatana.Unity.Place1"); |
| 2577 | - assert (place.dbus_path == "/org/ayatana/Unity/Place1"); |
| 2578 | - |
| 2579 | - /* Test entries were loaded properly */ |
| 2580 | - assert (place.n_entries == 3); |
| 2581 | - |
| 2582 | - /* Test individual entry's properties were loaded correctly */ |
| 2583 | - PlaceEntryDbus? e; |
| 2584 | - |
| 2585 | - e = place.get_nth_entry (0) as PlaceEntryDbus;; |
| 2586 | - assert (e is PlaceEntry); |
| 2587 | - assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry1"); |
| 2588 | - assert (e.name == "One"); |
| 2589 | - assert (e.icon == "gtk-apply"); |
| 2590 | - assert (e.description == "One Description"); |
| 2591 | - assert (e.show_global == true); |
| 2592 | - assert (e.show_entry == false); |
| 2593 | - |
| 2594 | - e = place.get_nth_entry (1) as PlaceEntryDbus; |
| 2595 | - assert (e is PlaceEntry); |
| 2596 | - assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry2"); |
| 2597 | - assert (e.name == "Two"); |
| 2598 | - assert (e.icon == "gtk-close"); |
| 2599 | - assert (e.description == "Two Description"); |
| 2600 | - assert (e.show_global == false); |
| 2601 | - assert (e.show_entry == true); |
| 2602 | - |
| 2603 | - e = place.get_nth_entry (2) as PlaceEntryDbus; |
| 2604 | - assert (e is PlaceEntry); |
| 2605 | - assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry3"); |
| 2606 | - assert (e.name == "Three"); |
| 2607 | - assert (e.icon == "gtk-cancel"); |
| 2608 | - assert (e.description == "Three Description"); |
| 2609 | - assert (e.show_global == false); |
| 2610 | - assert (e.show_entry == false); |
| 2611 | - } |
| 2612 | - |
| 2613 | - private void test_bad_simple_place_file () |
| 2614 | - { |
| 2615 | - var file = new KeyFile (); |
| 2616 | - try { |
| 2617 | - file.load_from_file (Config.TESTUNITDIR + "/data/place0.badplace", |
| 2618 | - KeyFileFlags.NONE); |
| 2619 | - } catch (Error error) { |
| 2620 | - warning ("Unable to load test place: %s", error.message); |
| 2621 | - } |
| 2622 | - |
| 2623 | - if (trap_fork (0, TestTrapFlags.SILENCE_STDOUT | TestTrapFlags.SILENCE_STDERR)) |
| 2624 | - { |
| 2625 | - var place = Places.Place.new_from_keyfile (file); |
| 2626 | - assert (place is Places.Place); |
| 2627 | - Posix.exit (0); |
| 2628 | - } |
| 2629 | - trap_has_passed (); |
| 2630 | - trap_assert_stderr ("*Does not contain 'Place' grou*"); |
| 2631 | - } |
| 2632 | - |
| 2633 | - private void test_bad_advanced_place_file () |
| 2634 | - { |
| 2635 | - var file = new KeyFile (); |
| 2636 | - try { |
| 2637 | - file.load_from_file (Config.TESTUNITDIR + "/data/place1.badplace", |
| 2638 | - KeyFileFlags.NONE); |
| 2639 | - } catch (Error error) { |
| 2640 | - warning ("Unable to load test place: %s", error.message); |
| 2641 | - } |
| 2642 | - |
| 2643 | - if (trap_fork (0, TestTrapFlags.SILENCE_STDOUT | TestTrapFlags.SILENCE_STDERR)) |
| 2644 | - { |
| 2645 | - var place = Places.Place.new_from_keyfile (file); |
| 2646 | - assert (place is Places.Place); |
| 2647 | - Posix.exit (0); |
| 2648 | - } |
| 2649 | - trap_has_passed (); |
| 2650 | - trap_assert_stderr ("*Does not contain valid DBusObjectPat*"); |
| 2651 | - } |
| 2652 | - } |
| 2653 | -} |
| 2654 | |
| 2655 | === removed file 'vala_tests/unit/test-places.vala' |
| 2656 | --- vala_tests/unit/test-places.vala 2010-06-02 12:05:59 +0000 |
| 2657 | +++ vala_tests/unit/test-places.vala 1970-01-01 00:00:00 +0000 |
| 2658 | @@ -1,68 +0,0 @@ |
| 2659 | -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
| 2660 | -/* |
| 2661 | - * Copyright (C) 2009 Canonical Ltd |
| 2662 | - * |
| 2663 | - * This program is free software: you can redistribute it and/or modify |
| 2664 | - * it under the terms of the GNU General Public License version 3 as |
| 2665 | - * published by the Free Software Foundation. |
| 2666 | - * |
| 2667 | - * This program is distributed in the hope that it will be useful, |
| 2668 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2669 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2670 | - * GNU General Public License for more details. |
| 2671 | - * |
| 2672 | - * You should have received a copy of the GNU General Public License |
| 2673 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2674 | - * |
| 2675 | - * Authored by Neil Jagdish Patel <neil.patel@canonical.com> |
| 2676 | - * |
| 2677 | - */ |
| 2678 | -using Unity; |
| 2679 | -using Unity.Testing; |
| 2680 | - |
| 2681 | -namespace Unity.Tests.Unit |
| 2682 | -{ |
| 2683 | - public class PlacesSuite |
| 2684 | - { |
| 2685 | - public PlacesSuite () |
| 2686 | - { |
| 2687 | - /*Test.add_func ("/Unit/Places/TestPlace", () => { |
| 2688 | - |
| 2689 | - Logging.init_fatal_handler (); |
| 2690 | - |
| 2691 | - var place = new TestPlace (); |
| 2692 | - |
| 2693 | - assert (place is TestPlace); |
| 2694 | - |
| 2695 | - var loop = new MainLoop (null, false); |
| 2696 | - |
| 2697 | - try |
| 2698 | - { |
| 2699 | - DBus.Connection conn = DBus.Bus.get (DBus.BusType.SESSION); |
| 2700 | - |
| 2701 | - Utils.register_object_on_dbus (conn, |
| 2702 | - "/com/canonical/Unity/Place", |
| 2703 | - place); |
| 2704 | - loop.get_context ().iteration (true); |
| 2705 | - } |
| 2706 | - catch (Error e) |
| 2707 | - { |
| 2708 | - warning ("TestPlace error: %s", e.message); |
| 2709 | - } |
| 2710 | - });*/ |
| 2711 | - } |
| 2712 | - |
| 2713 | - /*public class TestPlace : Unity.Place |
| 2714 | - { |
| 2715 | - public TestPlace () |
| 2716 | - { |
| 2717 | - Object (name:"neil", icon_name:"gtk-apply", tooltip:"hello"); |
| 2718 | - } |
| 2719 | - |
| 2720 | - construct |
| 2721 | - { |
| 2722 | - this.is_active.connect ((a) => {print (@"$a\n");}); |
| 2723 | - } |
| 2724 | - }*/ |
| 2725 | - } |
| 2726 | -} |


some small comments; unity.vapi' , needed by `tests/ vala/test- unit.c' . Stop.
build won't work properly with -j<number>, requires you to make twice, because on the first build unity.vapi isn't built when something needs it (other jobs are still building libunity)
[ 1%] make[2]: *** No rule to make target `libunity/
not all tests pass
/Unit/ Place/TwoEntrie s: ** home/gord/ canonical/ unity/enable- vala-tests/ build/tests/ vala/test- place.c: 228:unity_ tests_unit_ place_suite_ test_two_ entries: assertion failed: (_vala_strcmp0 (entry_paths[0], entry_path1) == 0)
ERROR:/
FAIL