Merge lp://staging/~awn-core/libdesktop-agnostic/various-fixes into lp://staging/libdesktop-agnostic
- various-fixes
- Merge into trunk
Status: | Superseded | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp://staging/~awn-core/libdesktop-agnostic/various-fixes | ||||||||||||||||||||||||||||||||
Merge into: | lp://staging/libdesktop-agnostic | ||||||||||||||||||||||||||||||||
Diff against target: | None lines | ||||||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp://staging/~awn-core/libdesktop-agnostic/various-fixes | ||||||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mark Lee | Needs Resubmitting | ||
Review via email: mp+10003@code.staging.launchpad.net |
This proposal has been superseded by a proposal from 2009-08-13.
Commit message
Description of the change
Michal Hruby (mhr3) wrote : | # |
- 245. By Mark Lee
-
Config (GConf): Only call GConf's notify_add() once (used for all keys).
- 246. By Mark Lee
-
Tests (Config): add mainloop support, needed for testing GConf's notify support. Concept by mhr3.
- 247. By Mark Lee
-
Config (GConf): Make the module pass the invalid key test in test-config.
- 248. By Mark Lee
-
Merge from <lp:~rcryderman/libdesktop-agnostic/lda_stripextensionsfromdesktopitementryiconfield>, revision 245.
Mark Lee (malept) wrote : | # |
> This branch contains currently fixes to the test-config.vala program and the
> new python test-config script (see bug 411879).
Please resubmit when you have updated your branch against latest trunk (r248), as I have committed a better version of your test-config.vala fix.
- 249. By Mark Lee
-
Desktop Entry (GNOME): DesktopItemLoad
Flags.ONLY_ IF_EXISTS doesn't mean what you'd think it means. Thanks to moonbeam for spotting it (again - see <lp:awn>, revision 10.1.157). - 250. By Mark Lee
-
Python: fix compiler warnings.
- 251. By Mark Lee
-
Python: add the GROUP_DEFAULT constant to the config module.
- 252. By Mark Lee
-
Config (memory): Fix compile error introduced in Vala 0.7.5 (requires a fix in Vala 0.7.6).
- 253. By Mark Lee
-
Desktop Entry: the string list getter/setter now deals with GStrv values only.
- 254. By Mark Lee
-
Python: add minimal bindings for VFS.
- 255. By Mark Lee
-
lda-schema-
to-gconf: emit a better error message when the gconf module could not be loaded. - 256. By Mark Lee
-
Build system: add configure flag with enables extra C compiler warnings.
- 257. By Mark Lee
-
Config: ensure empty arrays are handled correctly in both the schemas and when setting them via the API.
- 258. By Mark Lee
-
Tests (Config): add tests for empty strings/arrays.
- 259. By Mark Lee
-
Build system (Debian): revert part of revision 234, as it doesn't appear to work on Ubuntu for some bizarre reason.
- 260. By Mark Lee
-
Merge from <lp:~gilir/libdesktop-agnostic/debian-packaging>, revision 265 (with one change - add SONAME to the desktop-specific modules as well).
- 261. By Mark Lee
-
Desktop Entry: the return values for string (array) getters are nullable.
- 262. By Mark Lee
-
Desktop Entry (GLib): Emit a proper warning when an error occurs trying to retrieve the value of a desktop entry key.
- 263. By Mark Lee
-
VFS (Thunar VFS): fix compiler warnings.
- 264. By Mark Lee
-
Docs: update the known issues.
- 265. By Mark Lee
-
Desktop Entry: the icon property now returns NULL if it doesn't exist in the desktop entry.
- 266. By Mark Lee
-
Desktop Entry: add API which checks to see if a key exists in a desktop entry.
- 267. By Mark Lee
-
Desktop Entry (GLib): emit a warning and default to FALSE when a boolean key is not found, instead of hitting an assert.
- 268. By Mark Lee
-
Tests (Desktop Entry): link to and initialize GDK, which is needed for the GNOME module.
- 269. By Mark Lee
-
Tests (Config): refactor to not use Idle.add, as it's not strictly necessary.
- 270. By Mark Lee
-
Build system: don't add SONAMEs to the modules.
- 271. By Mark Lee
-
Config (GConf): refactor reset() and remove().
- 272. By Mark Lee
-
Config Bridge: ensure that objects are properly unbound and that the bridge does not hold any references to the object; add a test for this behavior; replace the messages in the test program with asserts.
- 273. By Mark Lee
-
Ignore generated GConf schemas.
- 274. By Mark Lee
-
Module: only emit debug messages when the proper environment variable is set.
- 275. By Mark Lee
-
Build system: update basedir-header support (now called includedir), which will be in Vala 0.7.6.
- 276. By Mark Lee
-
Tests (Config): Catch the exception thrown from creating the schema object.
- 277. By Mark Lee
-
Config Bridge: Make error more verbose.
- 278. By Mark Lee
-
Config: convert Values which are not floats or ints but can be transformed into those types, to get around limitations in certain bindings.
- 279. By Mark Lee
-
Tests (Config Bridge): consolidate code, add tests for floats/bools (and a disabled list test).
- 280. By Mark Lee
-
Config (KeyFile): remove extra call to save_config().
- 281. By Mark Lee
-
Config (KeyFile): don't autosave when updating the config from a keyfile change.
- 282. By Mark Lee
-
Config (KeyFile): when setting a value, ensure that it has changed before writing to disk.
- 283. By Mark Lee
-
Merge from <lp:~mhr3/libdesktop-agnostic/various-fixes>, revision 259.
- 284. By Mark Lee
-
Python (Config): Fix FTBFS.
- 285. By Mark Lee
-
Config: same as revision 278, but also for lists.
- 286. By Mark Lee
-
Python (Config): make sure that byte/unicode strings passed to set_value() are not marked as arrays.
- 287. By Mark Lee
-
Tests (Python Config Client): refactor to remove redundant code; add set_value() tests.
- 288. By Mark Lee
-
Tests (Python Config Client): refactor into a unittest TestCase.
- 289. By Mark Lee
-
Config Bridge: optimize string building.
- 290. By Mark Lee
-
Tests (Config Bridge): fix accidental commit of commented out throws clause.
- 291. By Mark Lee
-
Config Bridge: minor code cleanup.
- 292. By Mark Lee
-
Config Bridge: refactor to avoid segfaults caused by revision 272.
* Move binding destruction code to its proper place in the Binding destructor method.
* Properly remove Bindings from the bindings list.
* Add comments regarding code that should not be written.
* Add a cleaner method of dealing with the config notify callbacks. - 293. By Mark Lee
-
Tests (Config Bridge): add regression tests which test the various states that the internal binding lists could be in.
- 294. By Mark Lee
-
Config Bridge: Use prepend to populate the bindings to remove list, in case a key is bound to more than one property of an object. Add a test for this in the test program.
- 295. By Mark Lee
-
Config Bridge: only deal with config notify functions when a binding list is being created or destroyed.
- 296. By Mark Lee
-
Config: fix throws clauses.
- 297. By Mark Lee
-
Config Bridge: consolidate the config notify callback code.
- 298. By Mark Lee
-
Tests (VFS File): link with GDK so that the Thunar VFS module can be tested properly.
- 299. By Mark Lee
-
Build system: fix installing defs files.
- 300. By Mark Lee
-
Desktop Entry: annotate the file, keyfile, and data properties as also being construct properties.
- 301. By Mark Lee
-
Build system (Python): fix handling of local load types and register flags.
- 302. By Mark Lee
-
Python: add bindings/tests for VFS.File, VFS.FileMonitor, and FDO.DesktopEntry.
- 303. By Mark Lee
-
Python (FDO): add compatibility code for PyGObject installations without PyGLib.
- 304. By Mark Lee
-
Build system (Debian): add a rule to 'fix' VAPIs generated with Vala < 0.7.6.
- 305. By Mark Lee
-
Python: fix typo.
- 306. By Mark Lee
-
Config Client: add a constructor that takes a config schema and an optional instance ID.
- 307. By Mark Lee
-
Python (Desktop Entry): bind the key_exists() method.
- 308. By Mark Lee
-
Config Bridge: add support for binding enumerations.
- 309. By Mark Lee
-
Color: fix the default alpha value when parsing a color string without an alpha value.
- 310. By Mark Lee
-
Color: fix the channel property types.
- 311. By Mark Lee
-
Remove trailing whitespace.
- 312. By Mark Lee
-
Revert accidentally committed code.
- 313. By Mark Lee
-
Config Schema: make the invalid schema section error easier to understand.
- 314. By Mark Lee
-
Config Client: properly implement BindMethod.BOTH.
- 315. By Mark Lee
-
Tests (Config Client): fix license.
- 316. By Mark Lee
-
Desktop Entry (GLib): fix the case where the file doesn't exist.
- 317. By Mark Lee
-
Tests (Config Bridge): add test for adding property notify callbacks pre- and post-bind.
- 318. By Mark Lee
-
Config Bridge: make sure that a config key is not bound to the same property more than once.
- 319. By Mark Lee
-
Python (VFS): fix error enum.
- 320. By Mark Lee
-
VFS.File: add the copy() method (copies the file, not the object).
- 321. By Mark Lee
-
Tests (VFS.File): test launch() or remove(), but not both at once.
- 322. By Mark Lee
-
Python (VFS): add trash bindings.
- 323. By Mark Lee
-
VFS Volume (GIO): remove warning message.
- 324. By Mark Lee
-
Config Bridge (bind): use the canonical property name when possible, not the user-supplied one.
- 325. By Mark Lee
-
Config Bridge: allow two different object instances with the same property name to bind to the same config key.
- 326. By Mark Lee
-
Config Client: Add a short description of the class.
- 327. By Mark Lee
-
Config (KeyFile): use unowned variables for schema-related stuff when possible.
- 328. By Mark Lee
-
Config (KeyFile): fix a bunch of segfaults.
- 329. By Mark Lee
-
VFS File: add support for querying the access rights of the current user, for a given file.
- 330. By Mark Lee
-
Add a wrapper for Gtk.ColorButton that can use DesktopAgnostic
.Color objects. - 331. By Mark Lee
-
Build system: add libdesktop-
agnostic- gtk to the pkgconfig file. - 332. By Mark Lee
-
GTK: install a glade3 catalog when configured to do so.
- 333. By Mark Lee
-
Color: attempt to fix FTBFS, given Vala < 0.7.6.
- 334. By Mark Lee
-
GTK (ColorButton): provide a default value for the da_color property.
- 335. By Mark Lee
-
VAPI: Update the thunar-vfs bindings.
- 336. By Mark Lee
-
VFS Volume (Thunar VFS): add a constructor, due to changes to Object.new in Vala 0.7.6.
- 337. By Mark Lee
-
Config (GConf): throw a key not found error in gconfvalue_
to_gvalue if the config key doesn't exist in the schema. - 338. By Mark Lee
-
Tools (lda-schema-
to-gconf) : ensure that the schema-ini file exists. - 339. By Mark Lee
-
VFS Trash (GNOME VFS): fix summary.
- 340. By Mark Lee
-
VFS Trash (GNOME VFS): close directory handle when finished.
- 341. By Mark Lee
-
VFS File: add enumerate_
children( ) method. - 342. By Mark Lee
-
VFS Volume (GIO): handle the case where the volume mount is NULL.
- 343. By Mark Lee
-
Add an icon chooser dialog, an associated button, a launcher editor dialog, and an associated binary.
- 344. By Mark Lee
-
Build system (Debian): add manpage for lda-desktop-
entry-editor. - 345. By Mark Lee
-
VFS: fixes for Vala 0.7.6.
- 346. By Mark Lee
-
Tests (GTK): add tests for using GTK.ColorButton with GtkBuilder.
- 347. By Mark Lee
-
Tests (Python): update Color test so that it asserts that the color property is a gdk.Color.
- 348. By Mark Lee
-
GTK Color Button (glade3): use @get-type-function instead of parent.
- 349. By Mark Lee
-
GTK (ColorButton): ensure that the DesktopAgnostic
.Color object and color/alpha properties are synced, even if the custom constructor isn't used or the da-color property is NULL. - 350. By Mark Lee
-
Python (Config): update call due to changes in Vala 0.7.6.
- 351. By Mark Lee
-
Build system (tests): forgot to add test-gtk-
colorbutton- gtkbuilder to the build system. - 352. By Mark Lee
-
VFS (Volume): fix methods using VolumeCallback, due to changes in Vala 0.7.6.
- 353. By Mark Lee
-
Build system: requires Vala 0.7.7 or later now, as Vala 0.7.6 is rather broken (in terms of this library).
- 354. By Mark Lee
-
Config Schema: fix Vala compiler warnings.
- 355. By Mark Lee
-
Config Schema Option: default_value, upper_boundary, and lower_boundary are now automatic properties.
- 356. By Mark Lee
-
Config Schema Option: fix the declaration of the whitelist and blacklist properties.
- 357. By Mark Lee
-
Config Schema Option: retrieve the localized version of the summary and description, and use the non-translated version as fallback.
- 358. By Mark Lee
-
Documentation: update dependency information; add specific instructions for Debian/Ubuntu.
- 359. By Mark Lee
-
Config Schema Option: fix typo.
- 360. By Mark Lee
-
Module: update delegates due to changes in Vala >= 0.7.6.
- 361. By Mark Lee
-
Module (load_from_path): restructure to emit more errors.
- 362. By Mark Lee
-
Glade3: apparently get-type-function is not needed, as glade3 generates the correct function name.
- 363. By Mark Lee
-
Glade3: annotate which library needs to be loaded (thanks to mhr3).
- 364. By Mark Lee
-
GTK (ColorButton): fix notify property name (thanks to mhr3).
- 365. By Mark Lee
-
GTK (ColorButton): only disconnect the signal if it's still connected.
- 366. By Mark Lee
-
GTK (ColorButton): the destructor is not needed (according to mhr3).
- 367. By Mark Lee
-
Python (FDO): fix human-readable method names.
- 368. By Mark Lee
-
Config Notify Delegate: fix compile warning.
- 369. By Mark Lee
-
Config (KeyFile): don't set global-only options in an instance config object.
- 370. By Mark Lee
-
Module: allow the module directory environment variable to take precedence over the 'hardcoded' paths.
- 371. By Mark Lee
-
Config: when dealing with ValueArrays, use foreach instead of for.
- 372. By Mark Lee
-
Debian: remove obsolete sed commands.
- 373. By Mark Lee
-
GTK/UI: rename the gtk library/namespace to UI, so that using the widgets via GtkBuilder doesn't fail.
- 374. By Mark Lee
-
UI (Icon Button): Port the clicked signal handler of GtkColorButton, to fix modal/focus issues. (reported by mhr3).
- 375. By Mark Lee
-
Merge from <lp:~mhr3/libdesktop-agnostic/various-fixes>, revision 369.
- 376. By Mark Lee
-
UI (LauncherEditor
Dialog) : remove a block out of a try-catch statement that does not need to be there. - 377. By Mark Lee
-
VAPI (ThunarVfs): update.
- 378. By Mark Lee
-
VAPI (ThunarVfs): fix Path parent handling attributes.
- 379. By Mark Lee
-
VFS: add support for retrieving the parent file of a given file (or NULL if the file is the root directory).
- 380. By Mark Lee
-
UI (LauncherEditor
Dialog) : refactor the code that determines whether the output file can be written to so that it is more robust. - 381. By Mark Lee
-
UI (Icon Chooser Dialog): only use the case folded path to check the path's suffix.
- 382. By Mark Lee
-
UI (Color Button): make sure all of the color buttons don't reference one object.
- 383. By Mark Lee
-
VFS Trash (GIO): fix recursion bug.
- 384. By Michal Hruby
-
Fix memleaks in Config.Bridge.
Fix binding when using multiple instances. - 385. By Michal Hruby
-
Fix FTBFS
- 386. By Michal Hruby
-
Workaround the leaky gconf bindings
- 387. By Michal Hruby
-
Minor cleanup.
- 388. By Michal Hruby
-
Adapt to GConf bindings changes in Vala 0.7.10
- 389. By Michal Hruby
-
A couple of fixes for Vala 0.7.10
- 390. By Michal Hruby
-
Require vala 0.7.10
- 391. By Michal Hruby
-
Fix keyfile config backend monitoring
- 392. By Michal Hruby
-
Bump version to 0.3.9
- 393. By Michal Hruby
-
Merge from <lp:~gilir/libdesktop-agnostic/debian-fixes>
- 394. By Michal Hruby
-
Bump Vala requirement to 0.7.10
- 395. By Michal Hruby
-
Support current locale in DesktopEntry.
get_localestrin g - 396. By Michal Hruby
-
Use size of string on relevant places to fix problems with utf8 encoded data
- 397. By Michal Hruby
-
Use gnu_dirs tool to simplify packagers' lives
- 398. By Michal Hruby
-
Remove empty constructor
- 399. By Michal Hruby
-
Valadoc fixes
- 400. By Michal Hruby
-
Make sure dist includes Vala-generated sources
- 401. By Michal Hruby
-
Fix crasher in gnome-vfs trash implementation
- 402. By Michal Hruby
-
Merge trunk
- 403. By Michal Hruby
-
Fix unwanted exception during keyfile creation
- 404. By Michal Hruby
-
Fix compability with Vala 0.8.1
- 405. By Michal Hruby
-
Merge trunk
- 406. By Michal Hruby
-
Fix leaks in python bindings
- 407. By onox
-
Fix compability with Vala 0.9.1
- 408. By Michal Hruby
-
Make this actually work... Though it's nasty
- 409. By Michal Hruby
-
Fix for recent Vala version
- 410. By Michal Hruby
-
Add --disable-gi option to allow building with older GI
- 411. By Michal Hruby
-
Fix compability with Vala 0.9.7
- 412. By Michal Hruby
-
Add FDO gio backend
- 413. By Michal Hruby
-
Recognize Terminal key in FDO glib backend
- 414. By Michal Hruby
-
Support launching also Link-type desktop entries in FDO gio backend
- 415. By Michal Hruby
-
Fix focus chain in launcher editor
- 416. By Michal Hruby
-
Make theme selection active by default in IconChooserDialog, support resize, implement lazy pixbuf loading
- 417. By Michal Hruby
-
Update known issues
- 418. By Michal Hruby
-
Try to fix thunar-vfs compile errors
- 419. By Michal Hruby
-
Change LauncherEditorD
ialog to support both Applications and Links - 420. By Michal Hruby
-
Add a couple of methods to VFS.File and bump version number
- 421. By Michal Hruby
-
Add python bindings for the new methods
- 422. By Michal Hruby
-
Add also get_thumbnail_path
- 423. By Julien Lavergne
-
debian: Build-depends on gir-repository-dev (>= 0.6.3)
- 424. By Michal Hruby
-
Whoops, did I remove gilir's commit?
- 425. By Michal Hruby
-
PEP8 changes to wscript
Unmerged revisions
Preview Diff
1 | === added file 'tests/test-config.py' |
2 | --- tests/test-config.py 1970-01-01 00:00:00 +0000 |
3 | +++ tests/test-config.py 2009-08-11 21:03:59 +0000 |
4 | @@ -0,0 +1,155 @@ |
5 | +#!/usr/bin/env python |
6 | + |
7 | +# for some reason the gtk import is necessary for gconf notifications to work! |
8 | +import glib |
9 | +import time |
10 | +import desktopagnostic.config |
11 | + |
12 | +class TestCase: |
13 | + def __init__(self): |
14 | + self.ml = glib.MainLoop() |
15 | + self.notify_counter = 0 |
16 | + self.client = desktopagnostic.config.Client("test-config.schema-ini") |
17 | + self.client.reset(False) |
18 | + |
19 | + def test_defaults(self): |
20 | + expected = True |
21 | + actual = self.client.get_bool("numeric", "boolean") |
22 | + v = self.client.get_value("numeric", "boolean") |
23 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
24 | + assert actual == v |
25 | + |
26 | + expected = 3 |
27 | + actual = self.client.get_int("numeric", "integer") |
28 | + v = self.client.get_value("numeric", "integer") |
29 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
30 | + assert actual == v |
31 | + |
32 | + expected = round (3.14, 3) |
33 | + actual = self.client.get_float("numeric", "float") |
34 | + v = self.client.get_value("numeric", "float") |
35 | + actual = round(actual, 3) |
36 | + v = round(v, 3) |
37 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
38 | + assert actual == v |
39 | + |
40 | + expected = "Foo bar" |
41 | + actual = self.client.get_string("misc", "string") |
42 | + v = self.client.get_value("misc", "string") |
43 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
44 | + assert actual == v |
45 | + |
46 | + expected = [True, False] |
47 | + actual = self.client.get_list("list", "boolean") |
48 | + v = self.client.get_value("list", "boolean") |
49 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
50 | + assert actual == v |
51 | + |
52 | + expected = [1,2,3] |
53 | + actual = self.client.get_list("list", "integer") |
54 | + v = self.client.get_value("list", "integer") |
55 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
56 | + assert actual == v |
57 | + |
58 | + expected = [1.618, 2.718, 3.141] |
59 | + expected = map (lambda x: round (x, 3), expected) |
60 | + actual = self.client.get_list("list", "float") |
61 | + actual = map (lambda x: round (x, 3), actual) |
62 | + v = self.client.get_value("list", "float") |
63 | + v = map (lambda x: round (x, 3), v) |
64 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
65 | + assert actual == v |
66 | + |
67 | + expected = ["foo", "bar"] |
68 | + actual = self.client.get_list("list", "string") |
69 | + v = self.client.get_value("list", "string") |
70 | + assert expected == actual, "Fail! Expected value: %s, actual: %s" % (str(expected), str(actual)) |
71 | + assert actual == v |
72 | + |
73 | + def test_set(self): |
74 | + expected = False |
75 | + self.client.set_bool ("numeric", "boolean", expected) |
76 | + assert expected == self.client.get_value ("numeric", "boolean") |
77 | + assert expected == self.client.get_bool ("numeric", "boolean") |
78 | + |
79 | + expected = 10 |
80 | + self.client.set_int ("numeric", "integer", expected) |
81 | + assert expected == self.client.get_value ("numeric", "integer") |
82 | + assert expected == self.client.get_int ("numeric", "integer") |
83 | + |
84 | + expected = round (2.718, 3) |
85 | + self.client.set_float ("numeric", "float", expected) |
86 | + assert expected == round (self.client.get_value ("numeric", "float"), 3) |
87 | + assert expected == round (self.client.get_float ("numeric", "float"), 3) |
88 | + |
89 | + expected = "Quux baz" |
90 | + self.client.set_string ("misc", "string", expected) |
91 | + assert expected == self.client.get_value ("misc", "string") |
92 | + assert expected == self.client.get_string ("misc", "string") |
93 | + |
94 | + expected = [False, True, False] |
95 | + self.client.set_list ("list", "boolean", expected) |
96 | + assert expected == self.client.get_value ("list", "boolean") |
97 | + assert expected == self.client.get_list ("list", "boolean") |
98 | + |
99 | + expected = [10, 20, 30] |
100 | + self.client.set_list ("list", "integer", expected) |
101 | + assert expected == self.client.get_value ("list", "integer") |
102 | + assert expected == self.client.get_list ("list", "integer") |
103 | + |
104 | + #expected = [10.5, 20.6, 30.7] |
105 | + #expected = map (lambda x: round (x, 3), expected) |
106 | + #self.client.set_list ("list", "float", expected) |
107 | + #assert expected == map (lambda x: round (x, 3), self.client.get_value ("list", "float")) |
108 | + #assert expected == map (lambda x: round (x, 3), self.client.get_list ("list", "float")) |
109 | + |
110 | + expected = ["Quux", "Baz", "Foo"] |
111 | + self.client.set_list ("list", "string", expected) |
112 | + assert expected == self.client.get_value ("list", "string") |
113 | + assert expected == self.client.get_list ("list", "string") |
114 | + |
115 | + def string_changed(self, group, key, value): |
116 | + self.notify_counter = self.notify_counter + 1 |
117 | + |
118 | + def string_changed2(self, group, key, value): |
119 | + if (value.find ("quux") != -1): |
120 | + self.notify_counter = self.notify_counter + 3 |
121 | + |
122 | + def test_notify(self): |
123 | + ctx = self.ml.get_context() |
124 | + |
125 | + self.client.notify_add ("misc", "string", self.string_changed) |
126 | + self.client.notify_add ("misc", "string", self.string_changed2) |
127 | + |
128 | + self.client.set_string ("misc", "string", "Bar foo") |
129 | + # wait for the notification |
130 | + time.sleep(0.25) |
131 | + while ctx.pending(): ctx.iteration() |
132 | + assert self.notify_counter == 1, "Counter is: %d" % self.notify_counter |
133 | + |
134 | + self.client.set_string ("misc", "string", "Foo quux") |
135 | + # wait for the notification |
136 | + time.sleep(0.25) |
137 | + while ctx.pending(): ctx.iteration() |
138 | + assert self.notify_counter == 5, "Counter is: %d" % self.notify_counter |
139 | + |
140 | + self.client.notify_remove ("misc", "string", self.string_changed) |
141 | + self.client.set_string ("misc", "string", "Bar quux") |
142 | + # wait for the notification |
143 | + time.sleep(0.25) |
144 | + while ctx.pending(): ctx.iteration() |
145 | + assert self.notify_counter == 8, "Counter is: %d" % self.notify_counter |
146 | + |
147 | + self.client.notify_remove ("misc", "string", self.string_changed2) |
148 | + self.client.set_string ("misc", "string", "Baz foo") |
149 | + # wait for the notification (though it shouldn't come) |
150 | + time.sleep(0.25) |
151 | + while ctx.pending(): ctx.iteration() |
152 | + assert self.notify_counter == 8, "Counter is: %d" % self.notify_counter |
153 | + |
154 | +if __name__ == "__main__": |
155 | + t = TestCase() |
156 | + t.test_defaults() |
157 | + t.test_set() |
158 | + t.test_notify() |
159 | + print "All tests finished successfully." |
160 | |
161 | === modified file 'tests/test-config.vala' |
162 | --- tests/test-config.vala 2009-08-10 19:47:10 +0000 |
163 | +++ tests/test-config.vala 2009-08-11 21:01:14 +0000 |
164 | @@ -33,12 +33,14 @@ |
165 | { |
166 | Config.Backend cfg; |
167 | uint notify_counter; |
168 | + MainLoop ml; |
169 | |
170 | public TestCase () |
171 | { |
172 | Config.Schema schema = new Config.Schema ("test-config.schema-ini"); |
173 | this.cfg = Config.new ((owned)schema); |
174 | this.notify_counter = 0; |
175 | + this.ml = new MainLoop (null, false); |
176 | } |
177 | |
178 | void |
179 | @@ -121,21 +123,27 @@ |
180 | |
181 | cfg.reset (); |
182 | |
183 | + message ("==== Defaults tests ===="); |
184 | + |
185 | expected = true; |
186 | assert_equals (expected, cfg.get_value ("numeric", "boolean")); |
187 | assert ((bool)expected == cfg.get_bool ("numeric", "boolean")); |
188 | + message (" Boolean: OK"); |
189 | |
190 | expected = 3; |
191 | assert_equals (expected, cfg.get_value ("numeric", "integer")); |
192 | assert ((int)expected == cfg.get_int ("numeric", "integer")); |
193 | + message (" Integer: OK"); |
194 | |
195 | expected = 3.14f; |
196 | assert_equals (expected, cfg.get_value ("numeric", "float")); |
197 | assert ((float)expected == cfg.get_float ("numeric", "float")); |
198 | + message (" Float: OK"); |
199 | |
200 | expected = "Foo bar"; |
201 | assert_equals (expected, cfg.get_value ("misc", "string")); |
202 | assert ((string)expected == cfg.get_string ("misc", "string")); |
203 | + message (" String: OK"); |
204 | |
205 | expected_array = new ValueArray (2); |
206 | item_1 = true; |
207 | @@ -146,6 +154,7 @@ |
208 | assert_equals (expected, cfg.get_value ("list", "boolean")); |
209 | assert (array_equals ((ValueArray)expected, |
210 | cfg.get_list ("list", "boolean"))); |
211 | + message (" List of booleans: OK"); |
212 | |
213 | expected_array = new ValueArray (3); |
214 | item_1 = 1; |
215 | @@ -158,6 +167,7 @@ |
216 | assert_equals (expected, cfg.get_value ("list", "integer")); |
217 | assert (array_equals ((ValueArray)expected, |
218 | cfg.get_list ("list", "integer"))); |
219 | + message (" List of integers: OK"); |
220 | |
221 | expected_array = new ValueArray (3); |
222 | item_1 = 1.618f; |
223 | @@ -170,6 +180,7 @@ |
224 | assert_equals (expected, cfg.get_value ("list", "float")); |
225 | assert (array_equals ((ValueArray)expected, |
226 | cfg.get_list ("list", "float"))); |
227 | + message (" List of floats: OK"); |
228 | |
229 | expected_array = new ValueArray (2); |
230 | item_1 = "foo"; |
231 | @@ -180,6 +191,7 @@ |
232 | assert_equals (expected, cfg.get_value ("list", "string")); |
233 | assert (array_equals ((ValueArray)expected, |
234 | cfg.get_list ("list", "string"))); |
235 | + message (" List of strings: OK"); |
236 | } |
237 | |
238 | void |
239 | @@ -188,25 +200,31 @@ |
240 | Value expected, item_1, item_2, item_3; |
241 | ValueArray expected_array; |
242 | |
243 | + message ("==== Set & Get tests ===="); |
244 | + |
245 | expected = false; |
246 | cfg.set_bool ("numeric", "boolean", (bool)expected); |
247 | assert_equals (expected, cfg.get_value ("numeric", "boolean")); |
248 | assert ((bool)expected == cfg.get_bool ("numeric", "boolean")); |
249 | + message (" Boolean: OK"); |
250 | |
251 | expected = 10; |
252 | cfg.set_int ("numeric", "integer", (int)expected); |
253 | assert_equals (expected, cfg.get_value ("numeric", "integer")); |
254 | assert ((int)expected == cfg.get_int ("numeric", "integer")); |
255 | + message (" Integer: OK"); |
256 | |
257 | expected = 2.718f; |
258 | cfg.set_float ("numeric", "float", (float)expected); |
259 | assert_equals (expected, cfg.get_value ("numeric", "float")); |
260 | assert ((float)expected == cfg.get_float ("numeric", "float")); |
261 | + message (" Float: OK"); |
262 | |
263 | expected = "Quux baz"; |
264 | cfg.set_string ("misc", "string", (string)expected); |
265 | assert_equals (expected, cfg.get_value ("misc", "string")); |
266 | assert ((string)expected == cfg.get_string ("misc", "string")); |
267 | + message (" String: OK"); |
268 | |
269 | expected_array = new ValueArray (3); |
270 | item_1 = false; |
271 | @@ -220,6 +238,7 @@ |
272 | assert_equals (expected, cfg.get_value ("list", "boolean")); |
273 | assert (array_equals ((ValueArray)expected, |
274 | cfg.get_list ("list", "boolean"))); |
275 | + message (" List of booleans: OK"); |
276 | |
277 | expected_array = new ValueArray (3); |
278 | item_1 = 10; |
279 | @@ -233,6 +252,7 @@ |
280 | assert_equals (expected, cfg.get_value ("list", "integer")); |
281 | assert (array_equals ((ValueArray)expected, |
282 | cfg.get_list ("list", "integer"))); |
283 | + message (" List of integers: OK"); |
284 | |
285 | expected_array = new ValueArray (3); |
286 | item_1 = 10.5f; |
287 | @@ -246,6 +266,7 @@ |
288 | assert_equals (expected, cfg.get_value ("list", "float")); |
289 | assert (array_equals ((ValueArray)expected, |
290 | cfg.get_list ("list", "float"))); |
291 | + message (" List of floats: OK"); |
292 | |
293 | expected_array = new ValueArray (3); |
294 | item_1 = "Quux"; |
295 | @@ -259,23 +280,42 @@ |
296 | assert_equals (expected, cfg.get_value ("list", "string")); |
297 | assert (array_equals ((ValueArray)expected, |
298 | cfg.get_list ("list", "string"))); |
299 | + message (" List of strings: OK"); |
300 | } |
301 | |
302 | void |
303 | test_notify () throws AssertionError, Error |
304 | { |
305 | + message ("==== Notify tests ===="); |
306 | + unowned MainContext ctx = ml.get_context(); |
307 | + |
308 | cfg.notify_add ("misc", "string", this.on_string_changed); |
309 | cfg.notify_add ("misc", "string", this.on_string_changed2); |
310 | cfg.set_string ("misc", "string", "Bar foo"); |
311 | + Thread.usleep (250000); |
312 | + while (ctx.pending ()) ctx.iteration (false); |
313 | assert (this.notify_counter == 1); |
314 | + message (" Notify test 1: OK"); |
315 | + |
316 | cfg.set_string ("misc", "string", "Foo quux"); |
317 | + Thread.usleep (250000); |
318 | + while (ctx.pending ()) ctx.iteration (false); |
319 | assert (this.notify_counter == 5); |
320 | + message (" Notify test 2: OK"); |
321 | + |
322 | cfg.notify_remove ("misc", "string", this.on_string_changed); |
323 | cfg.set_string ("misc", "string", "Bar quux"); |
324 | + Thread.usleep (250000); |
325 | + while (ctx.pending ()) ctx.iteration (false); |
326 | assert (this.notify_counter == 8); |
327 | + message (" Notify test 3: OK"); |
328 | + |
329 | cfg.notify_remove ("misc", "string", this.on_string_changed2); |
330 | cfg.set_string ("misc", "string", "Baz foo"); |
331 | + Thread.usleep (250000); |
332 | + while (ctx.pending ()) ctx.iteration (false); |
333 | assert (this.notify_counter == 8); |
334 | + message (" Notify test 4: OK"); |
335 | } |
336 | |
337 | private static delegate void GetCfgFunc (Config.Backend cfg, string group, string key) throws Error; |
338 | @@ -310,13 +350,14 @@ |
339 | public static int |
340 | main (string[] args) |
341 | { |
342 | + TestCase test = new TestCase (); |
343 | try |
344 | { |
345 | - TestCase test = new TestCase (); |
346 | test.test_defaults (); |
347 | test.test_set (); |
348 | test.test_notify (); |
349 | test.test_invalid (); |
350 | + print ("All tests finished successfully.\n"); |
351 | } |
352 | catch (AssertionError assertion) |
353 | { |
This branch contains currently fixes to the test-config.vala program and the new python test-config script (see bug 411879).