1 /*
2 * Copyright (c) 2022 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 #include <gtest/gtest.h>
16 #include "idl_common.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20 using namespace OHOS::Idl::TestCommon;
21
22 namespace OHOS {
23 namespace Idl {
24 namespace ModuleTest {
25 class TsCodeEmitterTest : public testing::Test, public IdlCommon {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase()33 void TsCodeEmitterTest::SetUpTestCase()
34 {}
35
TearDownTestCase()36 void TsCodeEmitterTest::TearDownTestCase()
37 {}
38
SetUp()39 void TsCodeEmitterTest::SetUp()
40 {}
41
TearDown()42 void TsCodeEmitterTest::TearDown()
43 {}
44
45 /*
46 * Feature: idl
47 * Function: Ready
48 * SubFunction: NA
49 * FunctionPoints: no license test
50 * EnvConditions: NA
51 * CaseDescription: no license and void type resolution succeeded
52 */
53 HWTEST_F(TsCodeEmitterTest, Ready_001, TestSize.Level1)
54 {
55 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_VOID_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
56 int argc = 6;
57 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
58 ParameterArgv parameters(argvArray, argc);
59 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
60 }
61
62 /*
63 * Feature: idl
64 * Function: Ready
65 * SubFunction: NA
66 * FunctionPoints: no license test
67 * EnvConditions: NA
68 * CaseDescription: no license and bool type resolution succeeded
69 */
70 HWTEST_F(TsCodeEmitterTest, Ready_002, TestSize.Level1)
71 {
72 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_BOOL_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
73 int argc = 6;
74 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
75 ParameterArgv parameters(argvArray, argc);
76 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
77 }
78
79 /*
80 * Feature: idl
81 * Function: Ready
82 * SubFunction: NA
83 * FunctionPoints: no license test
84 * EnvConditions: NA
85 * CaseDescription: no license and return int type resolution succeeded
86 */
87 HWTEST_F(TsCodeEmitterTest, Ready_003, TestSize.Level1)
88 {
89 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_INT_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
90 int argc = 6;
91 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
92 ParameterArgv parameters(argvArray, argc);
93 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
94 }
95
96 /*
97 * Feature: idl
98 * Function: Ready
99 * SubFunction: NA
100 * FunctionPoints: no license test
101 * EnvConditions: NA
102 * CaseDescription: no license and return string resolution succeeded
103 */
104 HWTEST_F(TsCodeEmitterTest, Ready_004, TestSize.Level1)
105 {
106 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_STRING_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
107 int argc = 6;
108 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
109 ParameterArgv parameters(argvArray, argc);
110 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
111 }
112
113 /*
114 * Feature: idl
115 * Function: Ready
116 * SubFunction: NA
117 * FunctionPoints: no license test
118 * EnvConditions: NA
119 * CaseDescription: no license and interface type resolution succeeded
120 */
121 HWTEST_F(TsCodeEmitterTest, Ready_005, TestSize.Level1)
122 {
123 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_INTERFACE_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
124 int argc = 6;
125 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
126 ParameterArgv parameters(argvArray, argc);
127 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
128 }
129
130 /*
131 * Feature: idl
132 * Function: Ready
133 * SubFunction: NA
134 * FunctionPoints: no license test
135 * EnvConditions: NA
136 * CaseDescription: no license and in keywords resolution succeeded
137 */
138 HWTEST_F(TsCodeEmitterTest, Ready_006, TestSize.Level1)
139 {
140 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_IN_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
141 int argc = 6;
142 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
143 ParameterArgv parameters(argvArray, argc);
144 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
145 }
146
147 /*
148 * Feature: idl
149 * Function: Ready
150 * SubFunction: NA
151 * FunctionPoints: no license test
152 * EnvConditions: NA
153 * CaseDescription: no license and out keywords resolution succeeded
154 */
155 HWTEST_F(TsCodeEmitterTest, Ready_007, TestSize.Level1)
156 {
157 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_OUT_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
158 int argc = 6;
159 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
160 ParameterArgv parameters(argvArray, argc);
161 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
162 }
163
164 /*
165 * Feature: idl
166 * Function: Ready
167 * SubFunction: NA
168 * FunctionPoints: no license test
169 * EnvConditions: NA
170 * CaseDescription: no license and oneway keywords resolution succeeded
171 */
172 HWTEST_F(TsCodeEmitterTest, Ready_008, TestSize.Level1)
173 {
174 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_ONEWAY_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
175 int argc = 6;
176 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
177 ParameterArgv parameters(argvArray, argc);
178 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
179 }
180
181 /*
182 * Feature: idl
183 * Function: Ready
184 * SubFunction: NA
185 * FunctionPoints: no license test
186 * EnvConditions: NA
187 * CaseDescription: no license and sequenceable type resolution succeeded
188 */
189 HWTEST_F(TsCodeEmitterTest, Ready_009, TestSize.Level1)
190 {
191 EXPECT_EQ(PrepareIdlFile(
192 NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_SEQUENCEABLE_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
193 int argc = 6;
194 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
195 ParameterArgv parameters(argvArray, argc);
196 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
197 }
198
199 /*
200 * Feature: idl
201 * Function: Ready
202 * SubFunction: NA
203 * FunctionPoints: no license test
204 * EnvConditions: NA
205 * CaseDescription: no license and map type resolution succeeded
206 */
207 HWTEST_F(TsCodeEmitterTest, Ready_010, TestSize.Level1)
208 {
209 EXPECT_EQ(PrepareIdlFile(NO_LICENSE_IDL_NAME.c_str(), NO_LICENSE_MAP_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
210 int argc = 6;
211 const char* argvArray[] = {"./idl", "-c", NO_LICENSE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
212 ParameterArgv parameters(argvArray, argc);
213 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
214 }
215
216 /*
217 * Feature: idl
218 * Function: Ready
219 * SubFunction: NA
220 * FunctionPoints: no interface test
221 * EnvConditions: NA
222 * CaseDescription: no interface and void type parsing failed
223 */
224 HWTEST_F(TsCodeEmitterTest, Ready_011, TestSize.Level1)
225 {
226 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_VOID_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
227 int argc = 6;
228 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
229 ParameterArgv parameters(argvArray, argc);
230 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
231 }
232
233 /*
234 * Feature: idl
235 * Function: Ready
236 * SubFunction: NA
237 * FunctionPoints: no interface test
238 * EnvConditions: NA
239 * CaseDescription: no interface and bool type parsing failed
240 */
241 HWTEST_F(TsCodeEmitterTest, Ready_012, TestSize.Level1)
242 {
243 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_BOOL_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
244 int argc = 6;
245 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
246 ParameterArgv parameters(argvArray, argc);
247 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
248 }
249
250 /*
251 * Feature: idl
252 * Function: Ready
253 * SubFunction: NA
254 * FunctionPoints: no interface test
255 * EnvConditions: NA
256 * CaseDescription: no interface and int type parsing failed
257 */
258 HWTEST_F(TsCodeEmitterTest, Ready_013, TestSize.Level1)
259 {
260 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_INT_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
261 int argc = 6;
262 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
263 ParameterArgv parameters(argvArray, argc);
264 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
265 }
266
267 /*
268 * Feature: idl
269 * Function: Ready
270 * SubFunction: NA
271 * FunctionPoints: no interface test
272 * EnvConditions: NA
273 * CaseDescription: no interface and string type parsing failed
274 */
275 HWTEST_F(TsCodeEmitterTest, Ready_014, TestSize.Level1)
276 {
277 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_STRING_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
278 int argc = 6;
279 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
280 ParameterArgv parameters(argvArray, argc);
281 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
282 }
283
284 /*
285 * Feature: idl
286 * Function: Ready
287 * SubFunction: NA
288 * FunctionPoints: no interface test
289 * EnvConditions: NA
290 * CaseDescription: no interface and interface type parsing failed
291 */
292 HWTEST_F(TsCodeEmitterTest, Ready_015, TestSize.Level1)
293 {
294 EXPECT_EQ(PrepareIdlFile(
295 NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_INTERFACE_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
296 int argc = 6;
297 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
298 ParameterArgv parameters(argvArray, argc);
299 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
300 }
301
302 /*
303 * Feature: idl
304 * Function: Ready
305 * SubFunction: NA
306 * FunctionPoints: no interface test
307 * EnvConditions: NA
308 * CaseDescription: no interface and in keywords parsing failed
309 */
310 HWTEST_F(TsCodeEmitterTest, Ready_016, TestSize.Level1)
311 {
312 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_IN_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
313 int argc = 6;
314 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
315 ParameterArgv parameters(argvArray, argc);
316 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
317 }
318
319 /*
320 * Feature: idl
321 * Function: Ready
322 * SubFunction: NA
323 * FunctionPoints: no interface test
324 * EnvConditions: NA
325 * CaseDescription: no interface and out keywords parsing failed
326 */
327 HWTEST_F(TsCodeEmitterTest, Ready_017, TestSize.Level1)
328 {
329 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_OUT_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
330 int argc = 6;
331 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
332 ParameterArgv parameters(argvArray, argc);
333 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
334 }
335
336 /*
337 * Feature: idl
338 * Function: Ready
339 * SubFunction: NA
340 * FunctionPoints: no interface test
341 * EnvConditions: NA
342 * CaseDescription: no interface and oneway keywords parsing failed.
343 */
344 HWTEST_F(TsCodeEmitterTest, Ready_018, TestSize.Level1)
345 {
346 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_ONEWAY_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
347 int argc = 6;
348 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
349 ParameterArgv parameters(argvArray, argc);
350 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
351 }
352
353 /*
354 * Feature: idl
355 * Function: Ready
356 * SubFunction: NA
357 * FunctionPoints: no interface test
358 * EnvConditions: NA
359 * CaseDescription: no interface and sequenceable type parsing failed.
360 */
361 HWTEST_F(TsCodeEmitterTest, Ready_019, TestSize.Level1)
362 {
363 EXPECT_EQ(PrepareIdlFile(
364 NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_SEQUENCEABLE_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
365 int argc = 6;
366 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
367 ParameterArgv parameters(argvArray, argc);
368 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
369 }
370
371 /*
372 * Feature: idl
373 * Function: Ready
374 * SubFunction: NA
375 * FunctionPoints: no interface test
376 * EnvConditions: NA
377 * CaseDescription: no interface and map type parsing failed.
378 */
379 HWTEST_F(TsCodeEmitterTest, Ready_020, TestSize.Level1)
380 {
381 EXPECT_EQ(PrepareIdlFile(NO_INTERFACE_IDL_NAME.c_str(), NO_INTERFACE_MAP_TYPE_IDL_CONTENT.c_str(), ""), ERR_OK);
382 int argc = 6;
383 const char* argvArray[] = {"./idl", "-c", NO_INTERFACE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
384 ParameterArgv parameters(argvArray, argc);
385 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
386 }
387
388 /*
389 * Feature: idl
390 * Function: Ready
391 * SubFunction: NA
392 * FunctionPoints: Detect keyword capitalization issues test
393 * EnvConditions: NA
394 * CaseDescription: Uppercase void type parsing failed
395 */
396 HWTEST_F(TsCodeEmitterTest, Ready_021, TestSize.Level1)
397 {
398 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_VOID_TYPE_IDL_CONTENT.c_str()), ERR_OK);
399 int argc = 6;
400 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
401 ParameterArgv parameters(argvArray, argc);
402 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
403 }
404
405 /*
406 * Feature: idl
407 * Function: Ready
408 * SubFunction: NA
409 * FunctionPoints: Detect keyword capitalization issues test
410 * EnvConditions: NA
411 * CaseDescription: Uppercase bool type parsing failed
412 */
413 HWTEST_F(TsCodeEmitterTest, Ready_022, TestSize.Level1)
414 {
415 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_BOOL_TYPE_IDL_CONTENT.c_str()), ERR_OK);
416 int argc = 6;
417 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
418 ParameterArgv parameters(argvArray, argc);
419 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
420 }
421
422 /*
423 * Feature: idl
424 * Function: Ready
425 * SubFunction: NA
426 * FunctionPoints: Detect keyword capitalization issues test
427 * EnvConditions: NA
428 * CaseDescription: Uppercase int type parsing failed
429 */
430 HWTEST_F(TsCodeEmitterTest, Ready_023, TestSize.Level1)
431 {
432 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_INT_TYPE_IDL_CONTENT.c_str()), ERR_OK);
433 int argc = 6;
434 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
435 ParameterArgv parameters(argvArray, argc);
436 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
437 }
438
439 /*
440 * Feature: idl
441 * Function: Ready
442 * SubFunction: NA
443 * FunctionPoints: Detect keyword capitalization issues test
444 * EnvConditions: NA
445 * CaseDescription: Uppercase string type parsing failed
446 */
447 HWTEST_F(TsCodeEmitterTest, Ready_024, TestSize.Level1)
448 {
449 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_STRING_TYPE_IDL_CONTENT.c_str()), ERR_OK);
450 int argc = 6;
451 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
452 ParameterArgv parameters(argvArray, argc);
453 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
454 }
455
456 /*
457 * Feature: idl
458 * Function: Ready
459 * SubFunction: NA
460 * FunctionPoints: Detect keyword capitalization issues test
461 * EnvConditions: NA
462 * CaseDescription: Uppercase interface type parsing failed
463 */
464 HWTEST_F(TsCodeEmitterTest, Ready_025, TestSize.Level1)
465 {
466 EXPECT_EQ(PrepareIdlFile(
467 CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_INTERFACE_TYPE_IDL_CONTENT.c_str()), ERR_OK);
468 int argc = 6;
469 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
470 ParameterArgv parameters(argvArray, argc);
471 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
472 }
473
474 /*
475 * Feature: idl
476 * Function: Ready
477 * SubFunction: NA
478 * FunctionPoints: Detect keyword capitalization issues test
479 * EnvConditions: NA
480 * CaseDescription: Uppercase in keywords parsing failed
481 */
482 HWTEST_F(TsCodeEmitterTest, Ready_026, TestSize.Level1)
483 {
484 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_IN_TYPE_IDL_CONTENT.c_str()), ERR_OK);
485 int argc = 6;
486 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
487 ParameterArgv parameters(argvArray, argc);
488 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
489 }
490
491 /*
492 * Feature: idl
493 * Function: Ready
494 * SubFunction: NA
495 * FunctionPoints: Detect keyword capitalization issues test
496 * EnvConditions: NA
497 * CaseDescription: Uppercase out keywords parsing failed
498 */
499 HWTEST_F(TsCodeEmitterTest, Ready_027, TestSize.Level1)
500 {
501 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_OUT_TYPE_IDL_CONTENT.c_str()), ERR_OK);
502 int argc = 6;
503 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
504 ParameterArgv parameters(argvArray, argc);
505 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
506 }
507
508 /*
509 * Feature: idl
510 * Function: Ready
511 * SubFunction: NA
512 * FunctionPoints: Detect keyword capitalization issues test
513 * EnvConditions: NA
514 * CaseDescription: Uppercase oneway keywords parsing failed
515 */
516 HWTEST_F(TsCodeEmitterTest, Ready_028, TestSize.Level1)
517 {
518 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_ONEWAY_TYPE_IDL_CONTENT.c_str()), ERR_OK);
519 int argc = 6;
520 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
521 ParameterArgv parameters(argvArray, argc);
522 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
523 }
524
525 /*
526 * Feature: idl
527 * Function: Ready
528 * SubFunction: NA
529 * FunctionPoints: Detect keyword capitalization issues test
530 * EnvConditions: NA
531 * CaseDescription: Uppercase sequenceable type parsing failed
532 */
533 HWTEST_F(TsCodeEmitterTest, Ready_029, TestSize.Level1)
534 {
535 EXPECT_EQ(PrepareIdlFile(
536 CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_SEQUENCEABLE_TYPE_IDL_CONTENT.c_str()), ERR_OK);
537 int argc = 6;
538 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
539 ParameterArgv parameters(argvArray, argc);
540 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
541 }
542
543 /*
544 * Feature: idl
545 * Function: Ready
546 * SubFunction: NA
547 * FunctionPoints: Detect keyword capitalization issues test
548 * EnvConditions: NA
549 * CaseDescription: Uppercase map type parsing failed
550 */
551 HWTEST_F(TsCodeEmitterTest, Ready_030, TestSize.Level1)
552 {
553 EXPECT_EQ(PrepareIdlFile(CAPITALIZATION_IDL_NAME.c_str(), CAPITALIZATION_MAP_TYPE_IDL_CONTENT.c_str()), ERR_OK);
554 int argc = 6;
555 const char* argvArray[] = {"./idl", "-c", CAPITALIZATION_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
556 ParameterArgv parameters(argvArray, argc);
557 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
558 }
559
560 /*
561 * Feature: idl
562 * Function: Ready
563 * SubFunction: NA
564 * FunctionPoints: abnormal scene test
565 * EnvConditions: NA
566 * CaseDescription: in keyword after type parsing failed
567 */
568 HWTEST_F(TsCodeEmitterTest, Ready_031, TestSize.Level1)
569 {
570 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), IN_KEYWORD_AFTER_TYPE_IDL_CONTENT.c_str()), ERR_OK);
571 int argc = 6;
572 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
573 ParameterArgv parameters(argvArray, argc);
574 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
575 }
576
577 /*
578 * Feature: idl
579 * Function: Ready
580 * SubFunction: NA
581 * FunctionPoints: abnormal scene test
582 * EnvConditions: NA
583 * CaseDescription: not equal to filename parsing failed
584 */
585 HWTEST_F(TsCodeEmitterTest, Ready_032, TestSize.Level1)
586 {
587 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), NOT_EQUAL_TO_FILENAME_IDL_CONTENT.c_str()), ERR_OK);
588 int argc = 6;
589 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
590 ParameterArgv parameters(argvArray, argc);
591 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
592 }
593
594 /*
595 * Feature: idl
596 * Function: Ready
597 * SubFunction: NA
598 * FunctionPoints: abnormal scene test
599 * EnvConditions: NA
600 * CaseDescription: The file name does not match the interface name
601 */
602 HWTEST_F(TsCodeEmitterTest, Ready_033, TestSize.Level1)
603 {
604 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_SCENE_IDL_NAME.c_str(), ABNORMAL_SCENE_IDL_CONTENT.c_str()), ERR_OK);
605 int argc = 6;
606 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_SCENE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
607 ParameterArgv parameters(argvArray, argc);
608 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
609 }
610
611 /*
612 * Feature: idl
613 * Function: Ready
614 * SubFunction: NA
615 * FunctionPoints: abnormal scene test
616 * EnvConditions: NA
617 * CaseDescription: unsigned char type parsing failed
618 */
619 HWTEST_F(TsCodeEmitterTest, Ready_034, TestSize.Level1)
620 {
621 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), UNSIGNED_CHAR_IDL_CONTENT.c_str()), ERR_OK);
622 int argc = 6;
623 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
624 ParameterArgv parameters(argvArray, argc);
625 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
626 }
627
628 /*
629 * Feature: idl
630 * Function: Ready
631 * SubFunction: NA
632 * FunctionPoints: abnormal scene test
633 * EnvConditions: NA
634 * CaseDescription: unsigned short type parsing failed
635 */
636 HWTEST_F(TsCodeEmitterTest, Ready_035, TestSize.Level1)
637 {
638 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), UNSIGNED_SHORT_IDL_CONTENT.c_str()), ERR_OK);
639 int argc = 6;
640 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
641 ParameterArgv parameters(argvArray, argc);
642 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
643 }
644
645 /*
646 * Feature: idl
647 * Function: Ready
648 * SubFunction: NA
649 * FunctionPoints: abnormal scene test
650 * EnvConditions: NA
651 * CaseDescription: unsigned int type parsing failed
652 */
653 HWTEST_F(TsCodeEmitterTest, Ready_036, TestSize.Level1)
654 {
655 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), UNSIGNED_INT_IDL_CONTENT.c_str()), ERR_OK);
656 int argc = 6;
657 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
658 ParameterArgv parameters(argvArray, argc);
659 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
660 }
661
662 /*
663 * Feature: idl
664 * Function: Ready
665 * SubFunction: NA
666 * FunctionPoints: abnormal scene test
667 * EnvConditions: NA
668 * CaseDescription: unsigned long type parsing failed
669 */
670 HWTEST_F(TsCodeEmitterTest, Ready_037, TestSize.Level1)
671 {
672 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), UNSIGNED_LONG_IDL_CONTENT.c_str()), ERR_OK);
673 int argc = 6;
674 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
675 ParameterArgv parameters(argvArray, argc);
676 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
677 }
678
679 /*
680 * Feature: idl
681 * Function: Ready
682 * SubFunction: NA
683 * FunctionPoints: abnormal scene test
684 * EnvConditions: NA
685 * CaseDescription: empty content parsing failed
686 */
687 HWTEST_F(TsCodeEmitterTest, Ready_038, TestSize.Level1)
688 {
689 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), EMPTY_IDL_CONTENT.c_str()), ERR_OK);
690 int argc = 6;
691 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
692 ParameterArgv parameters(argvArray, argc);
693 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
694 }
695
696 /*
697 * Feature: idl
698 * Function: Ready
699 * SubFunction: NA
700 * FunctionPoints: abnormal scene test
701 * EnvConditions: NA
702 * CaseDescription: no return value parsing failed
703 */
704 HWTEST_F(TsCodeEmitterTest, Ready_039, TestSize.Level1)
705 {
706 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), NOT_RETURN_IDL_CONTENT.c_str()), ERR_OK);
707 int argc = 6;
708 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
709 ParameterArgv parameters(argvArray, argc);
710 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
711 }
712
713 /*
714 * Feature: idl
715 * Function: Ready
716 * SubFunction: NA
717 * FunctionPoints: abnormal scene test
718 * EnvConditions: NA
719 * CaseDescription: No function name resolution failed
720 */
721 HWTEST_F(TsCodeEmitterTest, Ready_040, TestSize.Level1)
722 {
723 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), NOT_FUNCTION_IDL_CONTENT.c_str()), ERR_OK);
724 int argc = 6;
725 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
726 ParameterArgv parameters(argvArray, argc);
727 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
728 }
729
730 /*
731 * Feature: idl
732 * Function: Ready
733 * SubFunction: NA
734 * FunctionPoints: abnormal scene test
735 * EnvConditions: NA
736 * CaseDescription: Same function name prasing successed
737 */
738 HWTEST_F(TsCodeEmitterTest, Ready_041, TestSize.Level1)
739 {
740 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), SAME_FUNCTION_IDL_CONTENT.c_str()), ERR_OK);
741 int argc = 6;
742 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
743 ParameterArgv parameters(argvArray, argc);
744 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
745 }
746
747 /*
748 * Feature: idl
749 * Function: Ready
750 * SubFunction: NA
751 * FunctionPoints: abnormal scene test
752 * EnvConditions: NA
753 * CaseDescription: The function name is too long and the parsing is successful
754 */
755 HWTEST_F(TsCodeEmitterTest, Ready_042, TestSize.Level1)
756 {
757 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), FUNCTION_NAME_TOO_LONG_IDL_CONTENT.c_str()), ERR_OK);
758 int argc = 6;
759 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
760 ParameterArgv parameters(argvArray, argc);
761 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
762 }
763
764 /*
765 * Feature: idl
766 * Function: Ready
767 * SubFunction: NA
768 * FunctionPoints: abnormal scene test
769 * EnvConditions: NA
770 * CaseDescription: The variable name is too long and the parsing succeeded
771 */
772 HWTEST_F(TsCodeEmitterTest, Ready_043, TestSize.Level1)
773 {
774 EXPECT_EQ(PrepareIdlFile(I_ABNORMAL_IDL_NAME.c_str(), VARIABLE_NAME_TOO_LONG_IDL_CONTENT.c_str()), ERR_OK);
775 int argc = 6;
776 const char* argvArray[] = {"./idl", "-c", I_ABNORMAL_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
777 ParameterArgv parameters(argvArray, argc);
778 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
779 }
780
781
782 /*
783 * Feature: idl
784 * Function: Ready
785 * SubFunction: NA
786 * FunctionPoints: Detect namespace issues test
787 * EnvConditions: NA
788 * CaseDescription: Use multiple namespaces failed
789 */
790 HWTEST_F(TsCodeEmitterTest, Ready_044, TestSize.Level1)
791 {
792 EXPECT_EQ(PrepareIdlFile(UNKNOW_TYPE_IDL_NAME.c_str(), MULTIPLE_NAMESPACES_IDL_CONTENT.c_str()), ERR_OK);
793 int argc = 6;
794 const char* argvArray[] = {"./idl", "-c", UNKNOW_TYPE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
795 ParameterArgv parameters(argvArray, argc);
796 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
797 }
798
799 /*
800 * Feature: idl
801 * Function: Ready
802 * SubFunction: NA
803 * FunctionPoints: Detect Keyword grammar problems Test
804 * EnvConditions: NA
805 * CaseDescription: Keyword 'in' 'out' sepatate failed
806 */
807 HWTEST_F(TsCodeEmitterTest, Ready_045, TestSize.Level1)
808 {
809 EXPECT_EQ(PrepareIdlFile(UNKNOW_TYPE_IDL_NAME.c_str(), INOUT_SEPARATE_IDL_CONTENT.c_str()), ERR_OK);
810 int argc = 6;
811 const char* argvArray[] = {"./idl", "-c", UNKNOW_TYPE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
812 ParameterArgv parameters(argvArray, argc);
813 EXPECT_EQ(Ready(argc, parameters.GetArgv()), ERR_OK);
814 }
815
816 /*
817 * Feature: idl
818 * Function: Ready
819 * SubFunction: NA
820 * FunctionPoints: Detect Keyword grammar problems Test
821 * EnvConditions: NA
822 * CaseDescription: Interface no content failed
823 */
824 HWTEST_F(TsCodeEmitterTest, Ready_046, TestSize.Level1)
825 {
826 EXPECT_EQ(PrepareIdlFile(UNKNOW_TYPE_IDL_NAME.c_str(), INTERFACE_NO_CONTENT_IDL_CONTENT.c_str()), ERR_OK);
827 int argc = 6;
828 const char* argvArray[] = {"./idl", "-c", UNKNOW_TYPE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
829 ParameterArgv parameters(argvArray, argc);
830 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
831 }
832
833 /*
834 * Feature: idl
835 * Function: Ready
836 * SubFunction: NA
837 * FunctionPoints: Detect Keyword grammar problems Test
838 * EnvConditions: NA
839 * CaseDescription: Paramter no keyword 'in' 'out' failed
840 */
841 HWTEST_F(TsCodeEmitterTest, Ready_047, TestSize.Level1)
842 {
843 EXPECT_EQ(PrepareIdlFile(UNKNOW_TYPE_IDL_NAME.c_str(), PARAM_NO_INOUT_IDL_CONTENT.c_str()), ERR_OK);
844 int argc = 6;
845 const char* argvArray[] = {"./idl", "-c", UNKNOW_TYPE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
846 ParameterArgv parameters(argvArray, argc);
847 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
848 }
849
850 /*
851 * Feature: idl
852 * Function: Ready
853 * SubFunction: NA
854 * FunctionPoints: Detect Keyword grammar problems Test
855 * EnvConditions: NA
856 * CaseDescription: Keyword 'in' 'out' not use big parentheses failed
857 */
858 HWTEST_F(TsCodeEmitterTest, Ready_048, TestSize.Level1)
859 {
860 EXPECT_EQ(PrepareIdlFile(UNKNOW_TYPE_IDL_NAME.c_str(), INOUT_NO_BIGPARANTHESES_IDL_CONTENT.c_str()), ERR_OK);
861 int argc = 6;
862 const char* argvArray[] = {"./idl", "-c", UNKNOW_TYPE_IDL_NAME.c_str(), "-gen-ts", "-d", "."};
863 ParameterArgv parameters(argvArray, argc);
864 EXPECT_NE(Ready(argc, parameters.GetArgv()), ERR_OK);
865 }
866 } // namespace ModuleTest
867 } // namespace Idl
868 } // namespace OHOS
869