author | Radek Brich <radek.brich@devl.cz> |
Thu, 08 Sep 2011 11:37:27 +0200 | |
changeset 13 | 19ebde2fd594 |
parent 11 | 762513aacc87 |
child 19 | 5e78d52ebb24 |
permissions | -rwxr-xr-x |
11
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
from tuikit.treeview import * |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import unittest |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
class TestTreeView(unittest.TestCase): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
def test_treemodel(self): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
'''Build tree model, iterate through the tree, test result.''' |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
# build tree model |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
# root |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
# ├ a |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
# │ ├ c |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
# │ └ d |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
# │ ├ e |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
# │ │ └ g |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
# │ └ f |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
# │ └ h |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
# └ b |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
model = TreeModel() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
model.add('/', ['a', 'b']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
model.add('/a', ['c', 'd']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
model.add((0,1), ['e', 'f']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
model.add('/0/1/0', 'g') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
model.add('/a/d/f', 'h') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
res = '' |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
for l, i, c, n in model: |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
res += str(l) + str(i) + str(c) + n.name |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
self.assertEqual(res, '112a212c222d312e411g322f411h122b') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
if __name__ == '__main__': |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
unittest.main() |