author | Radek Brich <radek.brich@devl.cz> |
Fri, 07 Oct 2011 12:02:33 +0200 | |
changeset 19 | 5e78d52ebb24 |
parent 11 | 762513aacc87 |
child 37 | 54dd866b8951 |
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 |
|
19 | 3 |
import sys |
4 |
sys.path.append('..') |
|
5 |
||
11
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
from tuikit.treeview import * |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
import unittest |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
19 | 9 |
|
11
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
class TestTreeView(unittest.TestCase): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
def test_treemodel(self): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
'''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
|
13 |
# build tree model |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
# root |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
# ├ a |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
# │ ├ c |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
# │ └ d |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
# │ ├ e |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
# │ │ └ g |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
# │ └ f |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
# │ └ h |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
# └ b |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
model = TreeModel() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
model.add('/', ['a', 'b']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
model.add('/a', ['c', 'd']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
model.add((0,1), ['e', 'f']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
model.add('/0/1/0', 'g') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
model.add('/a/d/f', 'h') |
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 |
res = '' |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
for l, i, c, n in model: |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
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
|
33 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
self.assertEqual(res, '112a212c222d312e411g322f411h122b') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
if __name__ == '__main__': |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
unittest.main() |
19 | 39 |