Zim

Merge lp:~fmos/zim/bugfixes into lp:~jaap.karssenberg/zim/pyzim

Proposed by Fabian Stanke
Status: Merged
Merged at revision: 549
Proposed branch: lp:~fmos/zim/bugfixes
Merge into: lp:~jaap.karssenberg/zim/pyzim
Diff against target: 66 lines (+34/-2)
3 files modified
tests/data/notebook-wiki.xml (+4/-0)
tests/gui.py (+26/-1)
zim/gui/pageindex.py (+4/-1)
To merge this branch: bzr merge lp:~fmos/zim/bugfixes
Reviewer Review Type Date Requested Status
Jaap Karssenberg Pending
Review via email: mp+106306@code.launchpad.net

Description of the change

Test covering GUI updates during a page move.
Bug fix for index update causing crash when trying to update the moved (and thus non-existing) row in PageTreeStore.select_page.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/data/notebook-wiki.xml'
2--- tests/data/notebook-wiki.xml 2012-02-09 03:38:46 +0000
3+++ tests/data/notebook-wiki.xml 2012-05-18 05:32:28 +0000
4@@ -370,4 +370,8 @@
5 <page name="Parent:Daughter:SomeOne:Bar">For page.menu template variable test</page>
6 <page name="Parent:Child:Grandchild">For page.menu template variable test</page>
7
8+<page name="Movers">Subpages will be moved</page>
9+<page name="Movers:Stator">Non-mover</page>
10+<page name="Movers:Stator:Mover">Move me</page>
11+
12 </pagelist>
13
14=== modified file 'tests/gui.py'
15--- tests/gui.py 2012-05-17 17:14:44 +0000
16+++ tests/gui.py 2012-05-18 05:32:28 +0000
17@@ -579,7 +579,32 @@
18 self.ui.save_page()
19 self.assertFalse(self.ui.page.get_parsetree() is None)
20
21- # TODO notebook manipulation (new (sub)page, move, rename, delete ..)
22+ def testPageMove(self):
23+ oldpath, newpath = Path('Movers:Stator:Mover'), Path('Movers:Mover')
24+
25+ # Open page and process message queue to sync tree view
26+ indexpath = self.ui.notebook.index.lookup_path(oldpath)
27+ self.ui.open_page(indexpath)
28+ while gtk.events_pending():
29+ gtk.main_iteration(False)
30+
31+ # Test actual moving
32+ page = self.ui.notebook.get_page(oldpath)
33+ text = page.dump('wiki')
34+ self.ui.notebook.index.ensure_update()
35+ self.ui.notebook.move_page(oldpath, newpath)
36+ self.ui.notebook.index.ensure_update()
37+
38+ # newpath should exist and look like the old one
39+ page = self.ui.notebook.get_page(newpath)
40+ self.assertEqual(page.dump('wiki'), text)
41+
42+ # oldpath should be deleted
43+ page = self.ui.notebook.get_page(oldpath)
44+ self.assertFalse(page.haschildren)
45+ self.assertFalse(page.hascontent)
46+
47+ # TODO notebook manipulation (new (sub)page, rename, delete ..)
48 # merge with tests for dialogs (?)
49
50 def testClipboard(self):
51
52=== modified file 'zim/gui/pageindex.py'
53--- zim/gui/pageindex.py 2012-03-27 19:00:32 +0000
54+++ zim/gui/pageindex.py 2012-05-18 05:32:28 +0000
55@@ -204,7 +204,10 @@
56 if mypath:
57 treepath = self.get_treepath(mypath)
58 if treepath:
59- treeiter = self.get_iter(treepath)
60+ try:
61+ treeiter = self.get_iter(treepath)
62+ except ValueError:
63+ continue
64 self.emit('row-changed', treepath, treeiter)
65
66 def on_get_flags(self):