• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "include/cpp/abckit_cpp.h"
17 #include "tests/mock/check_mock.h"
18 #include "src/mock/mock_values.h"
19 #include "tests/mock/cpp_helpers_mock.h"
20 #include <gtest/gtest.h>
21 
22 namespace libabckit::cpp_test {
23 
24 class LibAbcKitCppMockCoreTestExportDescriptor : public ::testing::Test {};
25 
26 // Test: test-kind=mock, api=ExportDescriptor::GetFile, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestExportDescriptor,ExportDescriptor_GetFile)27 TEST_F(LibAbcKitCppMockCoreTestExportDescriptor, ExportDescriptor_GetFile)
28 {
29     ASSERT_TRUE(CheckMockedStackEmpty());
30     {
31         abckit::File f(DEFAULT_PATH);
32         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
33         abckit::mock::helpers::GetMockCoreExportDescriptor(f).GetFile();
34     }
35     ASSERT_TRUE(CheckMockedApi("CloseFile"));
36     ASSERT_TRUE(CheckMockedStackEmpty());
37 }
38 
39 // Test: test-kind=mock, api=ExportDescriptor::GetName, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestExportDescriptor,ExportDescriptor_GetName)40 TEST_F(LibAbcKitCppMockCoreTestExportDescriptor, ExportDescriptor_GetName)
41 {
42     ASSERT_TRUE(CheckMockedStackEmpty());
43     {
44         abckit::File f(DEFAULT_PATH);
45         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
46         abckit::mock::helpers::GetMockCoreExportDescriptor(f).GetName();
47         ASSERT_TRUE(CheckMockedApi("AbckitStringToString"));
48         ASSERT_TRUE(CheckMockedApi("ExportDescriptorGetName"));
49     }
50     ASSERT_TRUE(CheckMockedApi("CloseFile"));
51     ASSERT_TRUE(CheckMockedStackEmpty());
52 }
53 
54 // Test: test-kind=mock, api=ExportDescriptor::GetExportingModule, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestExportDescriptor,ExportDescriptor_GetExportingModule)55 TEST_F(LibAbcKitCppMockCoreTestExportDescriptor, ExportDescriptor_GetExportingModule)
56 {
57     ASSERT_TRUE(CheckMockedStackEmpty());
58     {
59         abckit::File f(DEFAULT_PATH);
60         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
61         abckit::mock::helpers::GetMockCoreExportDescriptor(f).GetExportingModule();
62         ASSERT_TRUE(CheckMockedApi("ExportDescriptorGetExportingModule"));
63     }
64     ASSERT_TRUE(CheckMockedApi("CloseFile"));
65     ASSERT_TRUE(CheckMockedStackEmpty());
66 }
67 
68 // Test: test-kind=mock, api=ExportDescriptor::GetExportedModule, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestExportDescriptor,ExportDescriptor_GetExportedModule)69 TEST_F(LibAbcKitCppMockCoreTestExportDescriptor, ExportDescriptor_GetExportedModule)
70 {
71     ASSERT_TRUE(CheckMockedStackEmpty());
72     {
73         abckit::File f(DEFAULT_PATH);
74         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
75         abckit::mock::helpers::GetMockCoreExportDescriptor(f).GetExportedModule();
76         ASSERT_TRUE(CheckMockedApi("ExportDescriptorGetExportedModule"));
77     }
78     ASSERT_TRUE(CheckMockedApi("CloseFile"));
79     ASSERT_TRUE(CheckMockedStackEmpty());
80 }
81 
82 // Test: test-kind=mock, api=ExportDescriptor::GetAlias, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestExportDescriptor,ExportDescriptor_GetAlias)83 TEST_F(LibAbcKitCppMockCoreTestExportDescriptor, ExportDescriptor_GetAlias)
84 {
85     ASSERT_TRUE(CheckMockedStackEmpty());
86     {
87         abckit::File f(DEFAULT_PATH);
88         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
89         abckit::mock::helpers::GetMockCoreExportDescriptor(f).GetAlias();
90         ASSERT_TRUE(CheckMockedApi("AbckitStringToString"));
91         ASSERT_TRUE(CheckMockedApi("ExportDescriptorGetAlias"));
92     }
93     ASSERT_TRUE(CheckMockedApi("CloseFile"));
94     ASSERT_TRUE(CheckMockedStackEmpty());
95 }
96 
97 }  // namespace libabckit::cpp_test