dedbb2982ab89c16ccba8c4405306e7e65b3443f
[occt.git] / tests / caf / basic / P7
1 #INTERFACE CAF
2 # Basic attributes
3 # TDataStd_ByteArray
4 #
5 # Testing attribute: User defined (additional GUID) TDataStd_ByteArray
6 #
7 # Testing command:   SetByteArray
8 # Testing command:   GetByteArray
9 #
10
11 puts "caf001-P7"
12 set QA_DUP 0
13
14 # Add an attribute to a data framework
15 set aFrom1 1
16 set aTo1 2
17 set aSetAttr11 10
18 set aSetAttr12 12
19 set aLabel 0:2
20 set isDelta 0
21 set aGuid1 "12e94517-6dbc-11d4-b9c8-0060b0ee281b"
22
23 SetByteArray D ${aLabel} ${isDelta} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12}
24 SetByteArray D ${aLabel} ${isDelta} -g ${aGuid1} ${aFrom1} ${aTo1} ${aSetAttr11} ${aSetAttr12}
25
26 # Close/Open the transaction
27 NewCommand D
28
29 # Forget the attribute
30 ForgetAll D ${aLabel}
31
32 # Close/Open the transaction
33 NewCommand D
34
35 # Undo-Redo-Undo
36 Undo D
37 Redo D
38 Undo D
39
40 # Save Document
41 Format D XmlOcaf
42 set aFile ${imagedir}/caf001-P7.xml
43 SaveAs D  ${aFile}
44 Close D
45
46 #Open a document
47 Open ${aFile} D
48
49
50 # Get a value of the attribute
51 set IsGood 1
52 set aMessage1 "Add TDataStd_ByteArray attribute: Error"
53 set aGetAttr1 [GetByteArray D ${aLabel}]
54 set aLen1 [llength ${aGetAttr1}]
55 set aGetAttr2 [GetByteArray D ${aLabel} ${aGuid1}]
56 set aLen2 [llength ${aGetAttr2}]
57
58 if { ${aLen1} != [expr ${aTo1} - ${aFrom1} + 1] } {
59    set IsGood 0
60    puts "aLen1=${aLen1}"
61    puts ${aMessage1}
62 }
63 if { ${aLen2} != [expr ${aTo1} - ${aFrom1} + 1] } {
64    set IsGood 0
65    puts "aLen2=${aLen2}"
66    puts ${aMessage1}
67 }
68
69 set aGetAttr11 [lindex ${aGetAttr1} 0]
70 set aGetAttr21 [lindex ${aGetAttr2} 0]
71 if { ${aGetAttr11} != ${aGetAttr21} } {
72    set IsGood 0
73    puts "aGetAttr11=${aGetAttr11}"
74    puts "aGetAttr21=${aGetAttr21}"
75    puts ${aMessage1}
76 }
77 set aGetAttr12 [lindex ${aGetAttr1} 1]
78 set aGetAttr22 [lindex ${aGetAttr2} 1]
79 if { ${aGetAttr12} != ${aGetAttr22} } {
80    set IsGood 0
81    puts "aGetAttr12=${aGetAttr12}"
82    puts "aGetAttr22=${aGetAttr22}"
83    puts ${aMessage1}
84 }
85
86 if { ${IsGood} == 0} {
87   puts "Add TDataStd_ByteArray attribute: Error"
88 } else {
89   puts "Add TDataStd_ByteArray attribute: OK"
90 }