1 /*
2 * Copyright (c) 2023 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
16 #include <gtest/gtest.h>
17 #define private public
18 #define protected public
19 #include "util/options.h"
20 #include "codegen/code_generator.h"
21 #undef protected
22 #undef private
23
24 using namespace testing;
25 using namespace testing::ext;
26 using namespace OHOS::Idl;
27
28 namespace OHOS {
29 namespace idl {
30 class CodeGeneratorUnitTest : public testing::Test {
31 public:
CodeGeneratorUnitTest()32 CodeGeneratorUnitTest() {}
~CodeGeneratorUnitTest()33 virtual ~CodeGeneratorUnitTest() {}
34 static void SetUpTestCase();
35 static void TearDownTestCase();
36 void SetUp();
37 void TearDown();
38 };
39
SetUpTestCase()40 void CodeGeneratorUnitTest::SetUpTestCase() {}
TearDownTestCase()41 void CodeGeneratorUnitTest::TearDownTestCase() {}
SetUp()42 void CodeGeneratorUnitTest::SetUp() {}
TearDown()43 void CodeGeneratorUnitTest::TearDown() {}
44
45 /*
46 * @tc.name: CodeGeneratorUnitTest_0100
47 * @tc.desc: Verify the initialization in CodeGeneratorUnitTest function.
48 * @tc.type: FUNC
49 */
50 HWTEST_F(CodeGeneratorUnitTest, CodeGeneratorUnitTest_0100, Function | MediumTest | Level1)
51 {
52 /**
53 * @tc.steps: step1. Initialization parameters.
54 */
55 MetaComponent mc;
56 String language = "cpp";
57 String dir = "this dir";
58 Options::Attribute att;
59 att.hitraceTag = "hitraceTag";
60 att.doHitrace = true;
61 att.logTag = "logTag";
62 att.domainId = "domainId";
63
64 /**
65 * @tc.steps: step2. Create codeGenerator object.
66 * @tc.expected: Can obtain the correct logOn_.
67 */
68 CodeGenerator codeGenerator(&mc, language, dir, att);
69 EXPECT_FALSE(codeGenerator.emitter_->logOn_);
70 }
71 }
72 }