21 import com.nokia.carbide.cpp.epoc.engine.DocumentFactory; |
21 import com.nokia.carbide.cpp.epoc.engine.DocumentFactory; |
22 import com.nokia.carbide.cpp.epoc.engine.model.*; |
22 import com.nokia.carbide.cpp.epoc.engine.model.*; |
23 import com.nokia.carbide.cpp.epoc.engine.preprocessor.*; |
23 import com.nokia.carbide.cpp.epoc.engine.preprocessor.*; |
24 import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.*; |
24 import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.*; |
25 import com.nokia.carbide.internal.cpp.epoc.engine.model.pkg.PKGView; |
25 import com.nokia.carbide.internal.cpp.epoc.engine.model.pkg.PKGView; |
|
26 import com.nokia.cpp.internal.api.utils.core.HostOS; |
26 import com.nokia.cpp.internal.api.utils.core.Logging; |
27 import com.nokia.cpp.internal.api.utils.core.Logging; |
27 |
28 |
28 import org.eclipse.core.runtime.*; |
29 import org.eclipse.core.runtime.*; |
29 import org.eclipse.jface.text.IDocument; |
30 import org.eclipse.jface.text.IDocument; |
30 |
31 |
65 private static final String ESCAPABLE_FILES = |
66 private static final String ESCAPABLE_FILES = |
66 "&EN,FR\n" + |
67 "&EN,FR\n" + |
67 "{\"c:\\users\\E0192828\\back.txt\", \"c:\\users\\E0FG\\front.txt\"}-\"sp ac es.txt\"\r\n" + |
68 "{\"c:\\users\\E0192828\\back.txt\", \"c:\\users\\E0FG\\front.txt\"}-\"sp ac es.txt\"\r\n" + |
68 "\"c:\\users\\E0192828\\back.txt\" - \"sp ac es.txt\""; |
69 "\"c:\\users\\E0192828\\back.txt\" - \"sp ac es.txt\""; |
69 |
70 |
70 private static final Map<String, String> lang2SrcFileMap = new HashMap(); |
71 private static final Map<String, String> lang2SrcFileMap = new HashMap<String, String>(); |
71 static { |
72 static { |
72 for (String[] lang2SrcFileSpec : LANG_TO_SRC_FILES) { |
73 for (String[] lang2SrcFileSpec : LANG_TO_SRC_FILES) { |
73 lang2SrcFileMap.put(lang2SrcFileSpec[0], lang2SrcFileSpec[1]); |
74 lang2SrcFileMap.put(lang2SrcFileSpec[0], lang2SrcFileSpec[1]); |
74 } |
75 } |
75 }; |
76 }; |
83 } |
84 } |
84 |
85 |
85 @Override |
86 @Override |
86 protected void setUp() throws Exception { |
87 protected void setUp() throws Exception { |
87 super.setUp(); |
88 super.setUp(); |
88 this.path = new Path("c:\\symbian\\9.4\\epoc32\\tools\\Test.PKG"); |
89 this.path = new Path(getTokenAbsolutePath()).append("/symbian/9.4/epoc32/tools/Test.PKG"); |
89 |
90 |
90 config = new IViewConfiguration() { |
91 config = new IViewConfiguration() { |
91 |
92 |
92 public IViewFilter getViewFilter() { |
93 public IViewFilter getViewFilter() { |
93 return new AcceptedNodesViewFilter(); |
94 return new AcceptedNodesViewFilter(); |
94 } |
95 } |
95 |
96 |
96 public Collection<IDefine> getMacros() { |
97 public Collection<IDefine> getMacros() { |
97 return Collections.EMPTY_LIST ; |
98 return Collections.emptyList() ; |
98 } |
99 } |
99 |
100 |
100 public IViewParserConfiguration getViewParserConfiguration() { |
101 public IViewParserConfiguration getViewParserConfiguration() { |
101 return parserConfig; |
102 return parserConfig; |
102 } |
103 } |
137 assertNotNull(installFileList); |
138 assertNotNull(installFileList); |
138 assertEquals(2, installFileList.size()); |
139 assertEquals(2, installFileList.size()); |
139 |
140 |
140 // first install file is language dependent |
141 // first install file is language dependent |
141 IPKGInstallFile installFile = installFileList.get(0); |
142 IPKGInstallFile installFile = installFileList.get(0); |
142 assertEquals(new Path(LANG_DEST_FILE), installFile.getDestintationFile()); |
143 assertEquals(HostOS.createPathFromString(LANG_DEST_FILE), installFile.getDestintationFile()); |
143 List<EPKGLanguage> langs = view.getLanguages(); |
144 List<EPKGLanguage> langs = view.getLanguages(); |
144 assertEquals(2, langs.size()); |
145 assertEquals(2, langs.size()); |
145 Map<EPKGLanguage, IPath> sourceFiles = installFile.getSourceFiles(); |
146 Map<EPKGLanguage, IPath> sourceFiles = installFile.getSourceFiles(); |
146 for (EPKGLanguage lang : langs) { |
147 for (EPKGLanguage lang : langs) { |
147 IPath srcFilePath = sourceFiles.get(lang); |
148 IPath srcFilePath = sourceFiles.get(lang); |
148 String srcFile = lang2SrcFileMap.get(lang.getCode()); |
149 String srcFile = lang2SrcFileMap.get(lang.getCode()); |
149 assertEquals(new Path(srcFile), srcFilePath); |
150 assertEquals(HostOS.createPathFromString(srcFile), srcFilePath); |
150 } |
151 } |
151 |
152 |
152 // second install file is language independent |
153 // second install file is language independent |
153 installFile = installFileList.get(1); |
154 installFile = installFileList.get(1); |
154 assertEquals(new Path(NO_LANG_DEST_FILE), installFile.getDestintationFile()); |
155 assertEquals(HostOS.createPathFromString(NO_LANG_DEST_FILE), installFile.getDestintationFile()); |
155 sourceFiles = installFile.getSourceFiles(); |
156 sourceFiles = installFile.getSourceFiles(); |
156 assertEquals(1, sourceFiles.size()); |
157 assertEquals(1, sourceFiles.size()); |
157 assertTrue(sourceFiles.containsKey(EPKGLanguage.INDEPENDENT)); |
158 assertTrue(sourceFiles.containsKey(EPKGLanguage.INDEPENDENT)); |
158 IPath srcFilePath = sourceFiles.get(EPKGLanguage.INDEPENDENT); |
159 IPath srcFilePath = sourceFiles.get(EPKGLanguage.INDEPENDENT); |
159 assertEquals(new Path(NO_LANG_SRC_FILE), srcFilePath); |
160 assertEquals(HostOS.createPathFromString(NO_LANG_SRC_FILE), srcFilePath); |
160 assertEquals(1, installFile.getOptions().size()); |
161 assertEquals(1, installFile.getOptions().size()); |
161 assertEquals(NO_LANG_OPTION, installFile.getOptions().get(0)); |
162 assertEquals(NO_LANG_OPTION, installFile.getOptions().get(0)); |
162 |
163 |
163 commitTest(view, modelText); |
164 commitTest(view, modelText); |
164 } |
165 } |
184 } |
185 } |
185 assertNotNull(conditionalInstallFile); |
186 assertNotNull(conditionalInstallFile); |
186 IPath destintationFile = conditionalInstallFile.getDestintationFile(); |
187 IPath destintationFile = conditionalInstallFile.getDestintationFile(); |
187 assertTrue(destintationFile.isEmpty()); |
188 assertTrue(destintationFile.isEmpty()); |
188 assertEquals(1, conditionalInstallFile.getSourceFiles().size()); |
189 assertEquals(1, conditionalInstallFile.getSourceFiles().size()); |
189 assertEquals(new Path(CONDITIONAL_SRC_FILE), conditionalInstallFile.getSourceFiles().get(EPKGLanguage.INDEPENDENT)); |
190 assertEquals(HostOS.createPathFromString(CONDITIONAL_SRC_FILE), conditionalInstallFile.getSourceFiles().get(EPKGLanguage.INDEPENDENT)); |
190 assertEquals(2, conditionalInstallFile.getOptions().size()); |
191 assertEquals(2, conditionalInstallFile.getOptions().size()); |
191 |
192 |
192 commitTest(view, modelText); |
193 commitTest(view, modelText); |
193 } |
194 } |
194 |
195 |
197 makeModel(modelText); |
198 makeModel(modelText); |
198 IPKGView view = getView(config); |
199 IPKGView view = getView(config); |
199 |
200 |
200 // fully create and add a language independent install file statement |
201 // fully create and add a language independent install file statement |
201 IPKGInstallFile installFile1 = view.createInstallFile(null); |
202 IPKGInstallFile installFile1 = view.createInstallFile(null); |
202 installFile1.getSourceFiles().put(EPKGLanguage.INDEPENDENT, new Path(NO_LANG_SRC_FILE)); |
203 installFile1.getSourceFiles().put(EPKGLanguage.INDEPENDENT, HostOS.createPathFromString(NO_LANG_SRC_FILE)); |
203 installFile1.getOptions().add(NO_LANG_OPTION); |
204 installFile1.getOptions().add(NO_LANG_OPTION); |
204 installFile1.setDestinationFile(new Path(NO_LANG_DEST_FILE)); |
205 installFile1.setDestinationFile(HostOS.createPathFromString(NO_LANG_DEST_FILE)); |
205 view.addInstallFile(installFile1); |
206 view.addInstallFile(installFile1); |
206 |
207 |
207 // create a language dependent install file and modify after add |
208 // create a language dependent install file and modify after add |
208 IPKGInstallFile installFile2 = view.createInstallFile(null); |
209 IPKGInstallFile installFile2 = view.createInstallFile(null); |
209 view.addInstallFile(installFile2); |
210 view.addInstallFile(installFile2); |
210 for (String[] lang2SrcFileArray : LANG_TO_SRC_FILES) { |
211 for (String[] lang2SrcFileArray : LANG_TO_SRC_FILES) { |
211 installFile2.getSourceFiles().put( |
212 installFile2.getSourceFiles().put( |
212 EPKGLanguage.forLangCode(lang2SrcFileArray[0]), new Path(lang2SrcFileArray[1])); |
213 EPKGLanguage.forLangCode(lang2SrcFileArray[0]), HostOS.createPathFromString(lang2SrcFileArray[1])); |
213 } |
214 } |
214 installFile2.setDestinationFile(new Path(LANG_DEST_FILE)); |
215 installFile2.setDestinationFile(HostOS.createPathFromString(LANG_DEST_FILE)); |
215 |
216 |
216 // NOTE: the newlines are lost and shouldn't be |
217 // NOTE: the newlines are lost and shouldn't be |
217 //String modifiedModelText = modelText + NO_LANG_INSTALL_FILE_STATEMENT + "\n" + LANG_INSTALL_FILE_STATEMENT; |
218 //String modifiedModelText = modelText + NO_LANG_INSTALL_FILE_STATEMENT + "\n" + LANG_INSTALL_FILE_STATEMENT; |
218 String modifiedModelText = |
219 String modifiedModelText = |
219 ";Languages\n" + |
220 ";Languages\n" + |
242 IPKGInstallFile[] installFiles = view.getAllInstallFiles(); |
243 IPKGInstallFile[] installFiles = view.getAllInstallFiles(); |
243 assertEquals(2, installFiles.length); |
244 assertEquals(2, installFiles.length); |
244 |
245 |
245 IPKGInstallFile file = installFiles[0]; |
246 IPKGInstallFile file = installFiles[0]; |
246 assertEquals(2, file.getSourceFiles().size()); |
247 assertEquals(2, file.getSourceFiles().size()); |
247 assertEquals(new Path("c:\\users\\E0192828\\back.txt"), file.getSourceFiles().get(EPKGLanguage.EN)); |
248 assertEquals(new Path("c:/users/E0192828/back.txt"), file.getSourceFiles().get(EPKGLanguage.EN)); |
248 assertEquals(new Path("c:\\users\\E0FG\\front.txt"), file.getSourceFiles().get(EPKGLanguage.FR)); |
249 assertEquals(new Path("c:/users/E0FG/front.txt"), file.getSourceFiles().get(EPKGLanguage.FR)); |
249 assertEquals(new Path("sp ac es.txt"), file.getDestintationFile()); |
250 assertEquals(new Path("sp ac es.txt"), file.getDestintationFile()); |
250 |
251 |
251 file = installFiles[1]; |
252 file = installFiles[1]; |
252 assertEquals(1, file.getSourceFiles().size()); |
253 assertEquals(1, file.getSourceFiles().size()); |
253 assertEquals(new Path("c:\\users\\E0192828\\back.txt"), file.getSourceFiles().get(EPKGLanguage.INDEPENDENT)); |
254 assertEquals(new Path("c:/users/E0192828/back.txt"), file.getSourceFiles().get(EPKGLanguage.INDEPENDENT)); |
254 assertEquals(new Path("sp ac es.txt"), file.getDestintationFile()); |
255 assertEquals(new Path("sp ac es.txt"), file.getDestintationFile()); |
255 |
256 |
256 commitTest(view, ESCAPABLE_FILES); |
257 commitTest(view, ESCAPABLE_FILES); |
257 } |
258 } |
258 |
259 |