1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { readProjectPropertiesByCollectedPaths, ReseverdSetForArkguard } from '../../../src/common/ApiReader';
17import { assert } from 'chai';
18import { NameGeneratorType } from '../../../src/generator/NameFactory';
19
20describe('test for ApiReader', function () {
21  describe('test for readProjectPropertiesByCollectedPaths', function () {
22    const fileList: Set<string> = new Set([
23      "test/ut/utils/apiTest_readProjectPropertiesByCollectedPaths/block_enum_test.ts",
24      "test/ut/utils/apiTest_readProjectPropertiesByCollectedPaths/enum_test.ts",
25      "test/ut/utils/apiTest_readProjectPropertiesByCollectedPaths/export_enum_test.ts",
26      "test/ut/utils/apiTest_readProjectPropertiesByCollectedPaths/namespace_enum_test.ts"
27    ]);
28
29    it('-enable-export-obfuscation + -enable-property-obfuscation', function () {
30      let projectAndLibs: ReseverdSetForArkguard =
31        readProjectPropertiesByCollectedPaths(fileList,
32        {
33          mNameObfuscation: {
34            mEnable: true,
35            mReservedProperties: [],
36            mRenameProperties: true,
37            mKeepStringProperty: false,
38            mNameGeneratorType: NameGeneratorType.ORDERED,
39            mReservedNames: [], 
40            mReservedToplevelNames: []
41          },
42          mExportObfuscation: true,
43          mKeepFileSourceCode: {
44            mKeepSourceOfPaths: new Set(),
45            mkeepFilesAndDependencies: new Set(),
46          },
47          
48        }, true);
49      let enumPropertySet = projectAndLibs.enumPropertySet;
50      assert.strictEqual(enumPropertySet.has('BLOCK_PARAM1'), true);
51      assert.strictEqual(enumPropertySet.has('BLOCK_PARAM2'), true);
52      assert.strictEqual(enumPropertySet.has('ENUM_PARAM1'), true);
53      assert.strictEqual(enumPropertySet.has('ENUM_PARAM2'), true);
54      assert.strictEqual(enumPropertySet.has('NS_PARAM1'), true);
55      assert.strictEqual(enumPropertySet.has('NS_PARAM2'), true);
56      assert.strictEqual(enumPropertySet.has('EXPORT_PARAM1'), true);
57      assert.strictEqual(enumPropertySet.has('EXPORT_PARAM2'), true);
58    });
59
60    it('-enable-property-obfuscation', function () {
61      let projectAndLibs: ReseverdSetForArkguard =
62        readProjectPropertiesByCollectedPaths(fileList,
63        {
64          mNameObfuscation: {
65            mEnable: true,
66            mReservedProperties: [],
67            mRenameProperties: true,
68            mKeepStringProperty: false,
69            mNameGeneratorType: NameGeneratorType.ORDERED,
70            mReservedNames: [], 
71            mReservedToplevelNames: []
72          },
73          mExportObfuscation: false,
74          mKeepFileSourceCode: {
75            mKeepSourceOfPaths: new Set(),
76            mkeepFilesAndDependencies: new Set(),
77          }
78        }, true);
79      let enumPropertySet = projectAndLibs.enumPropertySet;
80      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
81      assert.strictEqual(enumPropertySet.has('BLOCK_PARAM1'), true);
82      assert.strictEqual(enumPropertySet.has('BLOCK_PARAM2'), true);
83      assert.strictEqual(enumPropertySet.has('ENUM_PARAM1'), true);
84      assert.strictEqual(enumPropertySet.has('ENUM_PARAM2'), true);
85      assert.strictEqual(enumPropertySet.has('NS_PARAM1'), true);
86      assert.strictEqual(enumPropertySet.has('NS_PARAM2'), true);
87      assert.strictEqual(enumPropertySet.has('EXPORT_PARAM1'), true);
88      assert.strictEqual(enumPropertySet.has('EXPORT_PARAM2'), true);
89      assert.strictEqual(exportNameAndPropSet.has('ExportEnum'), true);
90      assert.strictEqual(exportNameAndPropSet.has('EXPORT_PARAM1'), true);
91      assert.strictEqual(exportNameAndPropSet.has('EXPORT_PARAM2'), true);
92    });
93
94    it('-enable-export-obfuscation', function () {
95      let projectAndLibs: ReseverdSetForArkguard =
96        readProjectPropertiesByCollectedPaths(fileList,
97        {
98          mNameObfuscation: {
99            mEnable: true,
100            mReservedProperties: [],
101            mRenameProperties: false,
102            mKeepStringProperty: false,
103            mNameGeneratorType: NameGeneratorType.ORDERED,
104            mReservedNames: [], 
105            mReservedToplevelNames: []
106          },
107          mExportObfuscation: true,
108          mKeepFileSourceCode: {
109            mKeepSourceOfPaths: new Set(),
110            mkeepFilesAndDependencies: new Set(),
111          }
112        }, true);
113      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
114      let exportNameSet = projectAndLibs.exportNameSet;
115      assert.strictEqual(exportNameAndPropSet, undefined);
116      assert.strictEqual(exportNameSet.has('ExportEnum'), false);
117    });
118  });
119
120  describe('test for -keep and export obfuscation', function () {
121    const fileList: Set<string> = new Set([
122      "test/ut/utils/keep_export/exportFile1.ts"
123    ]);
124
125    it('-enable-export-obfuscation', function () {
126      let projectAndLibs: ReseverdSetForArkguard =
127        readProjectPropertiesByCollectedPaths(fileList,
128        {
129          mNameObfuscation: {
130            mEnable: true,
131            mReservedProperties: [],
132            mRenameProperties: false,
133            mKeepStringProperty: false,
134            mNameGeneratorType: NameGeneratorType.ORDERED,
135            mReservedNames: [], 
136            mReservedToplevelNames: []
137          },
138          mExportObfuscation: true,
139          mKeepFileSourceCode: {
140            mKeepSourceOfPaths: new Set(),
141            mkeepFilesAndDependencies: new Set([
142              "test/ut/utils/keep_export/exportFile1.ts"
143            ]),
144          }
145        }, true);
146      let exportNameSet = projectAndLibs.exportNameSet;
147      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
148      assert.strictEqual(exportNameSet.has('TestClass'), true);
149      assert.strictEqual(exportNameSet.has('prop1'), false);
150      assert.strictEqual(exportNameSet.has('prop2'), false);
151      assert.strictEqual(exportNameSet.has('objProp'), false);
152      assert.strictEqual(exportNameSet.has('innerProp2'), false);
153      assert.strictEqual(exportNameSet.has('var1'), true);
154      assert.strictEqual(exportNameSet.has('var2'), false);
155      assert.strictEqual(exportNameSet.has('foo'), true);
156      assert.strictEqual(exportNameSet.has('ns'), false);
157      assert.strictEqual(exportNameSet.has('var3'), true);
158      assert.strictEqual(exportNameSet.has('nsFunction'), true);
159      assert.strictEqual(exportNameSet.has('TestInterface'), true);
160      assert.strictEqual(exportNameSet.has('feature1'), false);
161      assert.strictEqual(exportNameSet.has('feature2'), false);
162      assert.strictEqual(exportNameSet.has('TestClass2'), false);
163      assert.strictEqual(exportNameSet.has('prop4'), false);
164      assert.strictEqual(exportNameSet.has('propObj'), false);
165      assert.strictEqual(exportNameSet.has('innerProp'), false);
166      assert.strictEqual(exportNameSet.has('TestClass3'), false);
167      assert.strictEqual(exportNameSet.has('exportProp1'), false);
168      assert.strictEqual(exportNameSet.has('exportPropObj'), false);
169      assert.strictEqual(exportNameSet.has('exportInnerProp'), false);
170      assert.strictEqual(exportNameSet.has('v2'), true);
171      assert.strictEqual(exportNameSet.has('default'), true);
172      assert.strictEqual(exportNameSet.has('t3'), true);
173      assert.strictEqual(exportNameSet.has('outterElement1'), true);
174      assert.strictEqual(exportNameSet.has('outterElement2'), true);
175      assert.strictEqual(exportNameSet.has('o2'), true);
176      assert.strictEqual(exportNameAndPropSet, undefined);
177    });
178
179    it('-enable-property-obfuscation', function () {
180      let projectAndLibs: ReseverdSetForArkguard =
181        readProjectPropertiesByCollectedPaths(fileList,
182        {
183          mNameObfuscation: {
184            mEnable: true,
185            mReservedProperties: [],
186            mRenameProperties: true,
187            mKeepStringProperty: false,
188            mNameGeneratorType: NameGeneratorType.ORDERED,
189            mReservedNames: [], 
190            mReservedToplevelNames: []
191          },
192          mExportObfuscation: false,
193          mKeepFileSourceCode: {
194            mKeepSourceOfPaths: new Set(),
195            mkeepFilesAndDependencies: new Set([
196              "test/ut/utils/keep_export/exportFile1.ts"
197            ]),
198          }
199        }, true);
200      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
201      let exportNameSet = projectAndLibs.exportNameSet;
202      assert.strictEqual(exportNameAndPropSet.has('TestClass'), true);
203      assert.strictEqual(exportNameAndPropSet.has('prop1'), true);
204      assert.strictEqual(exportNameAndPropSet.has('prop2'), true);
205      assert.strictEqual(exportNameAndPropSet.has('objProp'), true);
206      assert.strictEqual(exportNameAndPropSet.has('innerProp2'), true);
207      assert.strictEqual(exportNameAndPropSet.has('var1'), true);
208      assert.strictEqual(exportNameAndPropSet.has('var2'), false);
209      assert.strictEqual(exportNameAndPropSet.has('foo'), true);
210      assert.strictEqual(exportNameAndPropSet.has('ns'), false);
211      assert.strictEqual(exportNameAndPropSet.has('var3'), true);
212      assert.strictEqual(exportNameAndPropSet.has('nsFunction'), true);
213      assert.strictEqual(exportNameAndPropSet.has('TestInterface'), true);
214      assert.strictEqual(exportNameAndPropSet.has('feature1'), true);
215      assert.strictEqual(exportNameAndPropSet.has('feature2'), true);
216      assert.strictEqual(exportNameAndPropSet.has('TestClass2'), false);
217      assert.strictEqual(exportNameAndPropSet.has('prop4'), false);
218      assert.strictEqual(exportNameAndPropSet.has('propObj'), false);
219      assert.strictEqual(exportNameAndPropSet.has('innerProp'), false);
220      assert.strictEqual(exportNameAndPropSet.has('TestClass3'), false);
221      assert.strictEqual(exportNameAndPropSet.has('exportProp1'), true);
222      assert.strictEqual(exportNameAndPropSet.has('exportPropObj'), true);
223      assert.strictEqual(exportNameAndPropSet.has('exportInnerProp'), true);
224      assert.strictEqual(exportNameAndPropSet.has('v2'), true);
225      assert.strictEqual(exportNameAndPropSet.has('default'), true);
226      assert.strictEqual(exportNameAndPropSet.has('t3'), true);
227      assert.strictEqual(exportNameAndPropSet.has('outterElement1'), true);
228      assert.strictEqual(exportNameAndPropSet.has('outterElement2'), false);
229      assert.strictEqual(exportNameAndPropSet.has('o2'), true);
230      assert.strictEqual(exportNameSet, undefined);
231    });
232
233    it('-enable-toplevel-obfuscation', function () {
234      let projectAndLibs: ReseverdSetForArkguard =
235        readProjectPropertiesByCollectedPaths(fileList,
236        {
237          mNameObfuscation: {
238            mEnable: true,
239            mReservedProperties: [],
240            mRenameProperties: false,
241            mKeepStringProperty: false,
242            mTopLevel: true,
243            mNameGeneratorType: NameGeneratorType.ORDERED,
244            mReservedNames: [], 
245            mReservedToplevelNames: []
246          },
247          mExportObfuscation: false,
248          mKeepFileSourceCode: {
249            mKeepSourceOfPaths: new Set(),
250            mkeepFilesAndDependencies: new Set([
251              "test/ut/utils/keep_export/exportFile1.ts"
252            ]),
253          }
254        }, true);
255      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
256      let exportNameSet = projectAndLibs.exportNameSet;
257      assert.strictEqual(exportNameAndPropSet, undefined);
258      assert.strictEqual(exportNameSet, undefined);
259    });
260
261    it('-enable-toplevel-obfuscation -enable-export-obfuscation', function () {
262      let projectAndLibs: ReseverdSetForArkguard =
263        readProjectPropertiesByCollectedPaths(fileList,
264        {
265          mNameObfuscation: {
266            mEnable: true,
267            mReservedProperties: [],
268            mRenameProperties: false,
269            mKeepStringProperty: false,
270            mTopLevel: true,
271            mNameGeneratorType: NameGeneratorType.ORDERED,
272            mReservedNames: [], 
273            mReservedToplevelNames: []
274          },
275          mExportObfuscation: true,
276          mKeepFileSourceCode: {
277            mKeepSourceOfPaths: new Set(),
278            mkeepFilesAndDependencies: new Set([
279              "test/ut/utils/keep_export/exportFile1.ts"
280            ]),
281          }
282        }, true);
283      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
284      let exportNameSet = projectAndLibs.exportNameSet;
285      assert.strictEqual(exportNameSet.has('TestClass'), true);
286      assert.strictEqual(exportNameSet.has('prop1'), false);
287      assert.strictEqual(exportNameSet.has('prop2'), false);
288      assert.strictEqual(exportNameSet.has('objProp'), false);
289      assert.strictEqual(exportNameSet.has('innerProp2'), false);
290      assert.strictEqual(exportNameSet.has('var1'), true);
291      assert.strictEqual(exportNameSet.has('var2'), false);
292      assert.strictEqual(exportNameSet.has('foo'), true);
293      assert.strictEqual(exportNameSet.has('ns'), false);
294      assert.strictEqual(exportNameSet.has('var3'), true);
295      assert.strictEqual(exportNameSet.has('nsFunction'), true);
296      assert.strictEqual(exportNameSet.has('TestInterface'), true);
297      assert.strictEqual(exportNameSet.has('feature1'), false);
298      assert.strictEqual(exportNameSet.has('feature2'), false);
299      assert.strictEqual(exportNameSet.has('TestClass2'), false);
300      assert.strictEqual(exportNameSet.has('prop4'), false);
301      assert.strictEqual(exportNameSet.has('propObj'), false);
302      assert.strictEqual(exportNameSet.has('innerProp'), false);
303      assert.strictEqual(exportNameSet.has('TestClass3'), false);
304      assert.strictEqual(exportNameSet.has('exportProp1'), false);
305      assert.strictEqual(exportNameSet.has('exportPropObj'), false);
306      assert.strictEqual(exportNameSet.has('exportInnerProp'), false);
307      assert.strictEqual(exportNameSet.has('v2'), true);
308      assert.strictEqual(exportNameSet.has('default'), true);
309      assert.strictEqual(exportNameSet.has('t3'), true);
310      assert.strictEqual(exportNameSet.has('outterElement1'), true);
311      assert.strictEqual(exportNameSet.has('outterElement2'), true);
312      assert.strictEqual(exportNameSet.has('o2'), true);
313      assert.strictEqual(exportNameAndPropSet, undefined);
314    });
315
316    it('-enable-property-obfuscation -enable-export-obfuscation', function () {
317      let projectAndLibs: ReseverdSetForArkguard =
318        readProjectPropertiesByCollectedPaths(fileList,
319        {
320          mNameObfuscation: {
321            mEnable: true,
322            mReservedProperties: [],
323            mRenameProperties: true,
324            mKeepStringProperty: false,
325            mTopLevel: false,
326            mNameGeneratorType: NameGeneratorType.ORDERED,
327            mReservedNames: [], 
328            mReservedToplevelNames: []
329          },
330          mExportObfuscation: true,
331          mKeepFileSourceCode: {
332            mKeepSourceOfPaths: new Set(),
333            mkeepFilesAndDependencies: new Set([
334              "test/ut/utils/keep_export/exportFile1.ts"
335            ]),
336          }
337        }, true);
338      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
339      let exportNameSet = projectAndLibs.exportNameSet;
340      assert.strictEqual(exportNameSet.has('TestClass'), true);
341      assert.strictEqual(exportNameSet.has('prop1'), false);
342      assert.strictEqual(exportNameSet.has('prop2'), false);
343      assert.strictEqual(exportNameSet.has('objProp'), false);
344      assert.strictEqual(exportNameSet.has('innerProp2'), false);
345      assert.strictEqual(exportNameSet.has('var1'), true);
346      assert.strictEqual(exportNameSet.has('var2'), false);
347      assert.strictEqual(exportNameSet.has('foo'), true);
348      assert.strictEqual(exportNameSet.has('ns'), false);
349      assert.strictEqual(exportNameSet.has('var3'), true);
350      assert.strictEqual(exportNameSet.has('nsFunction'), true);
351      assert.strictEqual(exportNameSet.has('TestInterface'), true);
352      assert.strictEqual(exportNameSet.has('feature1'), false);
353      assert.strictEqual(exportNameSet.has('feature2'), false);
354      assert.strictEqual(exportNameSet.has('TestClass2'), false);
355      assert.strictEqual(exportNameSet.has('prop4'), false);
356      assert.strictEqual(exportNameSet.has('propObj'), false);
357      assert.strictEqual(exportNameSet.has('innerProp'), false);
358      assert.strictEqual(exportNameSet.has('TestClass3'), false);
359      assert.strictEqual(exportNameSet.has('exportProp1'), false);
360      assert.strictEqual(exportNameSet.has('exportPropObj'), false);
361      assert.strictEqual(exportNameSet.has('exportInnerProp'), false);
362      assert.strictEqual(exportNameSet.has('v2'), true);
363      assert.strictEqual(exportNameSet.has('default'), true);
364      assert.strictEqual(exportNameSet.has('t3'), true);
365      assert.strictEqual(exportNameSet.has('outterElement1'), true);
366      assert.strictEqual(exportNameSet.has('outterElement2'), true);
367      assert.strictEqual(exportNameSet.has('o2'), true);
368      assert.strictEqual(exportNameAndPropSet.has('TestClass'), true);
369      assert.strictEqual(exportNameAndPropSet.has('prop1'), true);
370      assert.strictEqual(exportNameAndPropSet.has('prop2'), true);
371      assert.strictEqual(exportNameAndPropSet.has('objProp'), true);
372      assert.strictEqual(exportNameAndPropSet.has('innerProp2'), true);
373      assert.strictEqual(exportNameAndPropSet.has('var1'), true);
374      assert.strictEqual(exportNameAndPropSet.has('var2'), false);
375      assert.strictEqual(exportNameAndPropSet.has('foo'), true);
376      assert.strictEqual(exportNameAndPropSet.has('ns'), false);
377      assert.strictEqual(exportNameAndPropSet.has('var3'), true);
378      assert.strictEqual(exportNameAndPropSet.has('nsFunction'), true);
379      assert.strictEqual(exportNameAndPropSet.has('TestInterface'), true);
380      assert.strictEqual(exportNameAndPropSet.has('feature1'), true);
381      assert.strictEqual(exportNameAndPropSet.has('feature2'), true);
382      assert.strictEqual(exportNameAndPropSet.has('TestClass2'), false);
383      assert.strictEqual(exportNameAndPropSet.has('prop4'), false);
384      assert.strictEqual(exportNameAndPropSet.has('propObj'), false);
385      assert.strictEqual(exportNameAndPropSet.has('innerProp'), false);
386      assert.strictEqual(exportNameAndPropSet.has('TestClass3'), false);
387      assert.strictEqual(exportNameAndPropSet.has('exportProp1'), true);
388      assert.strictEqual(exportNameAndPropSet.has('exportPropObj'), true);
389      assert.strictEqual(exportNameAndPropSet.has('exportInnerProp'), true);
390      assert.strictEqual(exportNameAndPropSet.has('v2'), true);
391      assert.strictEqual(exportNameAndPropSet.has('default'), true);
392      assert.strictEqual(exportNameAndPropSet.has('t3'), true);
393      assert.strictEqual(exportNameAndPropSet.has('outterElement1'), true);
394      assert.strictEqual(exportNameAndPropSet.has('outterElement2'), false);
395      assert.strictEqual(exportNameAndPropSet.has('o2'), true);
396    });
397
398    it('-enable-property-obfuscation -enable-export-obfuscation -enable-toplevel-obfuscation', function () {
399      let projectAndLibs: ReseverdSetForArkguard =
400        readProjectPropertiesByCollectedPaths(fileList,
401        {
402          mNameObfuscation: {
403            mEnable: true,
404            mReservedProperties: [],
405            mRenameProperties: true,
406            mKeepStringProperty: false,
407            mTopLevel: true,
408            mNameGeneratorType: NameGeneratorType.ORDERED,
409            mReservedNames: [], 
410            mReservedToplevelNames: []
411          },
412          mExportObfuscation: true,
413          mKeepFileSourceCode: {
414            mKeepSourceOfPaths: new Set(),
415            mkeepFilesAndDependencies: new Set([
416              "test/ut/utils/keep_export/exportFile1.ts"
417            ]),
418          }
419        }, true);
420      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
421      let exportNameSet = projectAndLibs.exportNameSet;
422      assert.strictEqual(exportNameSet.has('TestClass'), true);
423      assert.strictEqual(exportNameSet.has('prop1'), false);
424      assert.strictEqual(exportNameSet.has('prop2'), false);
425      assert.strictEqual(exportNameSet.has('objProp'), false);
426      assert.strictEqual(exportNameSet.has('innerProp2'), false);
427      assert.strictEqual(exportNameSet.has('var1'), true);
428      assert.strictEqual(exportNameSet.has('var2'), false);
429      assert.strictEqual(exportNameSet.has('foo'), true);
430      assert.strictEqual(exportNameSet.has('ns'), false);
431      assert.strictEqual(exportNameSet.has('var3'), true);
432      assert.strictEqual(exportNameSet.has('nsFunction'), true);
433      assert.strictEqual(exportNameSet.has('TestInterface'), true);
434      assert.strictEqual(exportNameSet.has('feature1'), false);
435      assert.strictEqual(exportNameSet.has('feature2'), false);
436      assert.strictEqual(exportNameSet.has('TestClass2'), false);
437      assert.strictEqual(exportNameSet.has('prop4'), false);
438      assert.strictEqual(exportNameSet.has('propObj'), false);
439      assert.strictEqual(exportNameSet.has('innerProp'), false);
440      assert.strictEqual(exportNameSet.has('TestClass3'), false);
441      assert.strictEqual(exportNameSet.has('exportProp1'), false);
442      assert.strictEqual(exportNameSet.has('exportPropObj'), false);
443      assert.strictEqual(exportNameSet.has('exportInnerProp'), false);
444      assert.strictEqual(exportNameSet.has('v2'), true);
445      assert.strictEqual(exportNameSet.has('default'), true);
446      assert.strictEqual(exportNameSet.has('t3'), true);
447      assert.strictEqual(exportNameSet.has('outterElement1'), true);
448      assert.strictEqual(exportNameSet.has('outterElement2'), true);
449      assert.strictEqual(exportNameSet.has('o2'), true);
450      assert.strictEqual(exportNameAndPropSet.has('TestClass'), true);
451      assert.strictEqual(exportNameAndPropSet.has('prop1'), true);
452      assert.strictEqual(exportNameAndPropSet.has('prop2'), true);
453      assert.strictEqual(exportNameAndPropSet.has('objProp'), true);
454      assert.strictEqual(exportNameAndPropSet.has('innerProp2'), true);
455      assert.strictEqual(exportNameAndPropSet.has('var1'), true);
456      assert.strictEqual(exportNameAndPropSet.has('var2'), false);
457      assert.strictEqual(exportNameAndPropSet.has('foo'), true);
458      assert.strictEqual(exportNameAndPropSet.has('ns'), false);
459      assert.strictEqual(exportNameAndPropSet.has('var3'), true);
460      assert.strictEqual(exportNameAndPropSet.has('nsFunction'), true);
461      assert.strictEqual(exportNameAndPropSet.has('TestInterface'), true);
462      assert.strictEqual(exportNameAndPropSet.has('feature1'), true);
463      assert.strictEqual(exportNameAndPropSet.has('feature2'), true);
464      assert.strictEqual(exportNameAndPropSet.has('TestClass2'), false);
465      assert.strictEqual(exportNameAndPropSet.has('prop4'), false);
466      assert.strictEqual(exportNameAndPropSet.has('propObj'), false);
467      assert.strictEqual(exportNameAndPropSet.has('innerProp'), false);
468      assert.strictEqual(exportNameAndPropSet.has('TestClass3'), false);
469      assert.strictEqual(exportNameAndPropSet.has('exportProp1'), true);
470      assert.strictEqual(exportNameAndPropSet.has('exportPropObj'), true);
471      assert.strictEqual(exportNameAndPropSet.has('exportInnerProp'), true);
472      assert.strictEqual(exportNameAndPropSet.has('v2'), true);
473      assert.strictEqual(exportNameAndPropSet.has('default'), true);
474      assert.strictEqual(exportNameAndPropSet.has('t3'), true);
475      assert.strictEqual(exportNameAndPropSet.has('outterElement1'), true);
476      assert.strictEqual(exportNameAndPropSet.has('outterElement2'), false);
477      assert.strictEqual(exportNameAndPropSet.has('o2'), true);
478    });
479
480    it('oh_modules test', function () {
481      const ohModulesFileList: Set<string> = new Set([
482        "test/ut/utils/oh_modules/exportFile1.ts"
483      ]);
484      let projectAndLibs: ReseverdSetForArkguard =
485        readProjectPropertiesByCollectedPaths(ohModulesFileList,
486        {
487          mNameObfuscation: {
488            mEnable: true,
489            mReservedProperties: [],
490            mRenameProperties: true,
491            mKeepStringProperty: false,
492            mTopLevel: true,
493            mNameGeneratorType: NameGeneratorType.ORDERED,
494            mReservedNames: [], 
495            mReservedToplevelNames: []
496          },
497          mExportObfuscation: true,
498          mKeepFileSourceCode: {
499            mKeepSourceOfPaths: new Set(),
500            mkeepFilesAndDependencies: new Set(),
501          }
502        }, true);
503      let exportNameAndPropSet = projectAndLibs.exportNameAndPropSet;
504      let exportNameSet = projectAndLibs.exportNameSet;
505      assert.strictEqual(exportNameSet.has('ModuleNs'), true);
506      assert.strictEqual(exportNameSet.has('nsProp1'), true);
507      assert.strictEqual(exportNameSet.has('nsFunc'), true);
508      assert.strictEqual(exportNameSet.has('ModuleClass'), true);
509      assert.strictEqual(exportNameSet.has('classProp1'), false);
510      assert.strictEqual(exportNameSet.has('objProp'), false);
511      assert.strictEqual(exportNameSet.has('innerProp'), false);
512      assert.strictEqual(exportNameSet.has('TestClass'), false);
513      assert.strictEqual(exportNameSet.has('prop4'), false);
514      assert.strictEqual(exportNameSet.has('propObj'), false);
515      assert.strictEqual(exportNameSet.has('innerProp1'), false);
516      assert.strictEqual(exportNameSet.has('TestClass2'), true);
517      assert.strictEqual(exportNameSet.has('prop1'), false);
518      assert.strictEqual(exportNameSet.has('objProp1'), false);
519      assert.strictEqual(exportNameSet.has('innerProp2'), false);
520      assert.strictEqual(exportNameSet.has('default'), true);
521      assert.strictEqual(exportNameSet.has('mc'), true);
522      assert.strictEqual(exportNameSet.has('otherElement1'), true);
523      assert.strictEqual(exportNameSet.has('otherElement2'), true);
524      assert.strictEqual(exportNameSet.has('o2'), true);
525      assert.strictEqual(exportNameAndPropSet.has('ModuleNs'), false);
526      assert.strictEqual(exportNameAndPropSet.has('nsProp1'), true);
527      assert.strictEqual(exportNameAndPropSet.has('nsFunc'), true);
528      assert.strictEqual(exportNameAndPropSet.has('ModuleClass'), false);
529      assert.strictEqual(exportNameAndPropSet.has('classProp1'), true);
530      assert.strictEqual(exportNameAndPropSet.has('objProp'), true);
531      assert.strictEqual(exportNameAndPropSet.has('innerProp'), true);
532      assert.strictEqual(exportNameAndPropSet.has('TestClass'), false);
533      assert.strictEqual(exportNameAndPropSet.has('prop4'), false);
534      assert.strictEqual(exportNameAndPropSet.has('propObj'), false);
535      assert.strictEqual(exportNameAndPropSet.has('innerProp1'), false);
536      assert.strictEqual(exportNameAndPropSet.has('TestClass2'), true);
537      assert.strictEqual(exportNameAndPropSet.has('prop1'), true);
538      assert.strictEqual(exportNameAndPropSet.has('objProp1'), true);
539      assert.strictEqual(exportNameAndPropSet.has('innerProp2'), true);
540      assert.strictEqual(exportNameAndPropSet.has('default'), true);
541      assert.strictEqual(exportNameAndPropSet.has('mc'), true);
542      assert.strictEqual(exportNameAndPropSet.has('otherElement1'), true);
543      assert.strictEqual(exportNameAndPropSet.has('otherElement2'), false);
544      assert.strictEqual(exportNameAndPropSet.has('o2'), true);
545    });
546  });
547});