1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Testing class for Encoder |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracecompiler.decodeplugins.dictionary.encoder; |
|
20 |
|
21 /** |
|
22 * Testing class for Encoder |
|
23 * |
|
24 */ |
|
25 public class TestEncoder { |
|
26 |
|
27 /** |
|
28 * |
|
29 */ |
|
30 private static final String DICTIONARY1 = "c:\\Temp\\traces.xml"; //$NON-NLS-1$ |
|
31 |
|
32 /** |
|
33 * |
|
34 */ |
|
35 private static final String DICTIONARY2 = "c:\\Temp\\traces2.xml"; //$NON-NLS-1$ |
|
36 |
|
37 /** |
|
38 * @param args |
|
39 */ |
|
40 public static void main(String[] args) { |
|
41 TraceDictionaryEncoder encoder = new TraceDictionaryEncoder(); |
|
42 encoder.createNewDictionary(DICTIONARY1); |
|
43 Dictionary.startDictionary(); |
|
44 Dictionary.startMetaData(); |
|
45 Dictionary.writeMetaData("name", "<Metadata>"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
46 Dictionary.writeMetaData("id", "1"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
47 Dictionary.endMetaData(); |
|
48 TypeDefStore.startTypeDefs(); |
|
49 TypeDefStore.writeExternalDefFile("<?xml version=\"1.0\" encoding=" //$NON-NLS-1$ |
|
50 + "\"UTF-8\"?> <external>c:\\Temp\\ExternalDef.xml</external>"); //$NON-NLS-1$ |
|
51 TypeDefStore.startTypeDef("TBool", 1, null, DataType.BINARY); //$NON-NLS-1$ |
|
52 TypeDef.writeTypeMember(0, "EFalse", "BOOL"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
53 TypeDef.writeTypeMember(-1, "iX", "TInt"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
54 TypeDef.writeTypeMember(0, "EFalse", null); //$NON-NLS-1$ |
|
55 TypeDefStore.endTypeDef(); |
|
56 TypeDefStore.startTypeDef("TPoint", -1, null, DataType.COMPOUND); //$NON-NLS-1$ |
|
57 TypeDef.writeTypeMember(-1, "iX", "TInt"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
58 TypeDef.writeTypeMember(-1, "iY", "TInt"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
59 TypeDefStore.endTypeDef(); |
|
60 TypeDefStore.writeTypeDef("TPixel", 1, "u", DataType.RAW); //$NON-NLS-1$ //$NON-NLS-2$ |
|
61 TypeDefStore.endTypeDefs(); |
|
62 TraceDataStore.startDataStore(); |
|
63 TraceDataStore.writeData(3, DataType.HEX, "<hex> value is 0xFF"); //$NON-NLS-1$ CodForChk_Dis_Magic |
|
64 TraceDataStore.writeData(2, DataType.OCTAL, "<octal> value is 8"); //$NON-NLS-1$ CodForChk_Dis_Magic |
|
65 TraceDataStore.writeData(1, DataType.BINARY, "<binary> value is 0"); //$NON-NLS-1$ |
|
66 TraceDataStore.endDataStore(); |
|
67 LocationStore.startLocations(); |
|
68 LocationStore.startPath("<?xml version=\"1.0\" encoding=" //$NON-NLS-1$ |
|
69 + "\"UTF-8\"?><file>C:\\Temp\\</file>"); //$NON-NLS-1$ |
|
70 LocationStore.writeFile(1, "<?xml version=\"1.0\" encoding=" //$NON-NLS-1$ |
|
71 + "\"UTF-8\"?><file>C:\\Temp\\file1.txt</file>"); //$NON-NLS-1$ |
|
72 LocationStore.writeFile(2, "<?xml version=\"1.0\" encoding=" //$NON-NLS-1$ CodForChk_Dis_Magic |
|
73 + "\"UTF-8\"?><file>C:\\Temp\\file2.txt</file>"); //$NON-NLS-1$ |
|
74 LocationStore.endPath(); |
|
75 LocationStore.endLocations(); |
|
76 Dictionary.startComponent(666, "Satan", null, null); //$NON-NLS-1$ CodForChk_Dis_Magic |
|
77 TraceComponent.startOptions(); |
|
78 TraceComponent.writeOption("background", "red"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
79 TraceComponent.startGroup(1, "Group UNO", "pre", "suf"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
80 TraceGroup.startOptions(); |
|
81 TraceGroup.writeOption("JeesTag", "<Tampura>"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
82 TraceGroup.writeOption("NoTag", "<Ilkves>"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
83 TraceGroup.endOptions(); |
|
84 TraceGroup.startTrace(-1, null); |
|
85 Trace.startOptions(); |
|
86 Trace.writeOption("MyTag", "Value"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
87 Trace.endOptions(); |
|
88 Trace.writeInstance(99, 1, 22, "testMethod", "testClass"); //$NON-NLS-1$ //$NON-NLS-2$ CodForChk_Dis_Magic |
|
89 TraceGroup.endTrace(); |
|
90 TraceGroup.startTrace(-1, null); |
|
91 Trace.writeInstance(100, 1, 235, "heyBabe", "auts"); //$NON-NLS-1$ //$NON-NLS-2$ CodForChk_Dis_Magic |
|
92 Trace.writeInstance(100, 2, 291, "heyBabe2", "auts2"); //$NON-NLS-1$ //$NON-NLS-2$ CodForChk_Dis_Magic |
|
93 TraceGroup.endTrace(); |
|
94 TraceComponent.endGroup(); |
|
95 Dictionary.endComponent(); |
|
96 Dictionary.endDictionary(); |
|
97 |
|
98 TraceDictionaryEncoder encoder2 = new TraceDictionaryEncoder(); |
|
99 encoder2.createNewDictionary(DICTIONARY2); |
|
100 Dictionary.startDictionary(); |
|
101 Dictionary.startMetaData(); |
|
102 Dictionary.writeMetaData("id", "1"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
103 Dictionary.writeMetaData("name", "Metadata Example"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
104 Dictionary.endMetaData(); |
|
105 TypeDefStore.startTypeDefs(); |
|
106 TypeDefStore.writeExternalDefFile("StandardTypeDefs.xml"); //$NON-NLS-1$ |
|
107 TypeDefStore.writeTypeDef("TUint", 4, "u", DataType.ENUM); //$NON-NLS-1$ //$NON-NLS-2$ CodForChk_Dis_Magic |
|
108 TypeDefStore.startTypeDef("TBool", 1, null, DataType.ENUM); //$NON-NLS-1$ |
|
109 TypeDef.writeTypeMember(0, "EFalse", null); //$NON-NLS-1$ |
|
110 TypeDef.writeTypeMember(1, "ETrue", null); //$NON-NLS-1$ |
|
111 TypeDefStore.endTypeDef(); |
|
112 TraceDataStore.startDataStore(); |
|
113 TraceDataStore.writeData(1, DataType.STRING, "My integer value: %d"); //$NON-NLS-1$ |
|
114 TraceDataStore.endDataStore(); |
|
115 LocationStore.startLocations(); |
|
116 LocationStore.startPath("../src"); //$NON-NLS-1$ |
|
117 LocationStore.writeFile(1, "foo.cpp"); //$NON-NLS-1$ |
|
118 LocationStore.writeFile(2, "foo2.cpp"); //$NON-NLS-1$ CodForChk_Dis_Magic |
|
119 LocationStore.endPath(); |
|
120 LocationStore.endLocations(); |
|
121 Dictionary.startComponent(12345678, "ComName", "ComPrefix", null); //$NON-NLS-1$ //$NON-NLS-2$ CodForChk_Dis_Magic |
|
122 TraceComponent.startGroup(1, "Flow", "GroupPrefix", "GroupSuffix"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
123 TraceGroup.startTrace(1, null); |
|
124 Trace.writeInstance(1, 1, 14, "MyGlobalMethodL", null); //$NON-NLS-1$ CodForChk_Dis_Magic |
|
125 Trace.writeInstance(2, 1, 214, "MyClassMethod", null); //$NON-NLS-1$ CodForChk_Dis_Magic |
|
126 TraceGroup.endTrace(); |
|
127 TraceComponent.endGroup(); |
|
128 Dictionary.endComponent(); |
|
129 Dictionary.endDictionary(); |
|
130 |
|
131 } |
|
132 |
|
133 } |
|