b72372ba0969e669bf827fa893131f1178fcd49f
[occt.git] / tests / bugs / caf / bug31839_1
1 puts "==========="
2 puts "0031839: Application Framework - Add ability to partially load OCAF document"
3 puts "==========="
4
5 # This test checks partial opening of the document with integer and real attributes
6 # and then partial appending (reading into the same document).
7
8 NewDocument D0 BinOcaf
9 UndoLimit D0 10
10
11 # number of labels of objects in the document
12 set labs 100
13 # number of sub-labels of each object
14 set sublabs 10
15
16 NewCommand D0
17
18 # store at each object-label sub-labels with two attributes at each
19 set creation_time [lindex [time {
20   for {set i 1} {$i <= $labs} {incr i} {
21     set lab [Label D0 0:1:${i}]
22     SetName D0 ${lab} Object$i
23     for {set ii 1} {$ii <= $sublabs} {incr ii} {
24       set sublab [Label D0 ${lab}:$ii]
25       SetInteger D0 ${sublab} 10
26       SetReal D0 ${sublab} 12.3
27     }
28   }
29 }] 0]
30
31 set commit_time [lindex [time {
32   CommitCommand D0
33 }] 0]
34
35
36 puts "Tree creation time $creation_time mcs"
37 puts "Creation commit time $commit_time mcs"
38
39 set docname ${imagedir}/doc_${casename}.cbf
40 SaveAs D0 ${docname}
41 Close D0
42
43 set open_time [lindex [time {
44   Open ${docname} D1
45 }] 0]
46
47 puts "Full document open time $open_time mcs"
48
49 set attributes [Attributes D1 0:1:1:1]
50 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} {
51   puts "Error: full document is opened incorrectly"
52 }
53
54 Close D1
55
56 set open_noint_time [lindex [time {
57   Open ${docname} D2 -skipTDataStd_Integer
58 }] 0]
59
60 puts "Document without integers open time $open_noint_time mcs"
61
62 set attributes [Attributes D2 0:1:1:1]
63 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] >= 0} {
64   puts "Error: document open without integers contains wrong attributes"
65 }
66
67 set open_oneint_time [lindex [time {
68   Open ${docname} D2 -append -read0:1:1:1
69 }] 0]
70
71 puts "Read of one integer time $open_oneint_time mcs"
72
73 set attributes [Attributes D2 0:1:1:1]
74 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} {
75   puts "Error: document open with one integer contains wrong attributes"
76 }
77
78 set attributes [Attributes D2 0:1:1:10]
79 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] >= 0} {
80   puts "Error: document open with one integer contains wrong attributes at label 10"
81 }
82
83 set open_nineint_time [lindex [time {
84   Open ${docname} D2 -append -read0:1:1
85 }] 0]
86 puts "Read of nine integer time $open_nineint_time mcs"
87
88 set attributes [Attributes D2 0:1:1:10]
89 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} {
90   puts "Error: document open with nine integer contains wrong attributes at label 10"
91 }
92
93 set attributes [Attributes D2 0:1:1:5]
94 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] < 0} {
95   puts "Error: document open with nine integer contains wrong attributes at label 5"
96 }
97
98 set attributes [Attributes D2 0:1:2:5]
99 if {[lsearch $attributes TDataStd_Real] < 0 || [lsearch $attributes TDataStd_Integer] >= 0} {
100   puts "Error: document open with nine integer contains wrong attributes at the second object"
101 }
102
103 SetInteger D2 0:1:1:5 21
104 SetReal D2 0:1:1:7 32.1
105
106 set open_overwrite_time [lindex [time {
107   Open ${docname} D2 -overwrite -read0:1:1
108 }] 0]
109 puts "Overwrite of ten integers time $open_overwrite_time mcs"
110
111
112 set value [GetInteger D2 0:1:1:5]
113 if {$value != 10} {
114   puts "Error: integer is overwritten incorrectly"
115 }
116
117 set value [GetReal D2 0:1:1:7]
118 if {$value != 12.3} {
119   puts "Error: real is overwritten incorrectly"
120 }
121
122 SetInteger D2 0:1:1:5 21
123 SetReal D2 0:1:1:7 32.1
124
125 set open_append_time [lindex [time {
126   Open ${docname} D2 -append -read0:1:1
127 }] 0]
128 puts "Append of ten integers time $open_overwrite_time mcs"
129
130
131 set value [GetInteger D2 0:1:1:5]
132 if {$value != 21} {
133   puts "Error: integer is overwritten by append"
134 }
135
136 set value [GetReal D2 0:1:1:7]
137 if {$value != 32.1} {
138   puts "Error: real is overwritten by append"
139 }
140
141 Close D2