0023087: Upgrade of the OCCT test system
[occt.git] / tests / caf / tree / D2
1 #INTERFACE CAF
2 # Tree construction attributes
3 #
4 # Testing attribute: TDataStd_TreeNode
5 #
6 # Testing command:   AppendNode
7 #
8 # Testing command:   SetNode
9 # Testing command:   ChildNodeIterate
10 #
11
12 puts "caf005-D2"
13 set QA_DUP 0
14
15 # Add an attribute to a data framework
16 set aLabel_Root 0:2
17 set aName_Root Label_1
18 Label D ${aLabel_Root}
19 SetName D ${aLabel_Root} ${aName_Root}
20
21 set aName1 Label_1_1
22 ###set aChild1 [NewChild D ${aLabel_Root}]
23 set aChild1 0:2:1
24 Label D ${aChild1}
25 SetName D ${aChild1} ${aName1}
26
27 set aName2 Label_1_2
28 ###set aChild2 [NewChild D ${aLabel_Root}]
29 set aChild2 0:2:2
30 Label D ${aChild2}
31 SetName D ${aChild2} ${aName2}
32
33 set aName3 Label_1_1_1
34 ###set aChild3 [NewChild D ${aLabel_Root}]
35 set aChild3 0:2:3
36 Label D ${aChild3}
37 SetName D ${aChild3} ${aName3}
38
39 SetNode D ${aLabel_Root}
40 AppendNode D ${aLabel_Root} ${aChild1}
41 AppendNode D ${aLabel_Root} ${aChild2}
42 AppendNode D ${aLabel_Root} ${aChild3}
43
44 # Close/Open the transaction
45 NewCommand D
46
47 # Forget the attribute
48 ForgetAll D ${aLabel_Root}
49
50 # Close/Open the transaction
51 NewCommand D
52
53 # Undo-Redo-Undo
54 Undo D
55 Redo D
56 Undo D
57
58 # Get a value of the attribute
59 set IsDone [catch {set aListChildNodes [ChildNodeIterate D ${aLabel_Root} 1]} aResult]
60 if { ${IsDone} != 0 } {
61         puts ${aResult}
62         puts "Append TDataStd_TreeNode attribute: Error"
63         return
64 }
65 set aListChildNodesLength [llength ${aListChildNodes}]
66 if { ${aListChildNodesLength}!=[expr 3 + 0]} {
67         puts "aListChildNodes=${aListChildNodes}"
68         puts "aListChildNodesLength=${aListChildNodesLength}"
69         puts "Append TDataStd_TreeNode attribute: Error"
70         return
71 }
72 set aFirstChildNode [lindex ${aListChildNodes} 0]
73 set aSecondChildNode [lindex ${aListChildNodes} 1]
74 set aThirdChildNode [lindex ${aListChildNodes} 2]
75 if { ${aFirstChildNode}!=${aChild1} ||
76         ${aSecondChildNode}!=${aChild2} ||
77         ${aThirdChildNode}!=${aChild3}} {
78         puts "aFirstChildNode=${aFirstChildNode} aChild1=${aChild1}"
79         puts "aSecondChildNode=${aSecondChildNode} aChild2=${aChild2}"
80         puts "aThirdChildNode=${aThirdChildNode} aChild3=${aChild3}"
81         puts "Append TDataStd_TreeNode attribute: Error"
82         return
83 }
84
85 puts "Append TDataStd_TreeNode attribute: OK"