• 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 "include/cpp/headers/core/annotation_element.h"
18 #include "tests/mock/check_mock.h"
19 #include "src/mock/mock_values.h"
20 #include "tests/mock/cpp_helpers_mock.h"
21 #include <gtest/gtest.h>
22 
23 namespace libabckit::cpp_test {
24 
25 class LibAbcKitCppMockCoreTestAnnotation : public ::testing::Test {};
26 
27 // Test: test-kind=mock, api=Annotation::GetInterface, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestAnnotation,Annotation_GetInterface)28 TEST_F(LibAbcKitCppMockCoreTestAnnotation, Annotation_GetInterface)
29 {
30     ASSERT_TRUE(CheckMockedStackEmpty());
31     {
32         abckit::File f(DEFAULT_PATH);
33         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
34         abckit::mock::helpers::GetMockCoreAnnotation(f).GetInterface();
35         ASSERT_TRUE(CheckMockedApi("AnnotationGetInterface"));
36     }
37     ASSERT_TRUE(CheckMockedApi("CloseFile"));
38     ASSERT_TRUE(CheckMockedStackEmpty());
39 }
40 
41 // Test: test-kind=mock, api=Annotation::EnumerateElements, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockCoreTestAnnotation,Annotation_EnumerateElements)42 TEST_F(LibAbcKitCppMockCoreTestAnnotation, Annotation_EnumerateElements)
43 {
44     ASSERT_TRUE(CheckMockedStackEmpty());
45     {
46         abckit::File f(DEFAULT_PATH);
47         ASSERT_TRUE(CheckMockedApi("OpenAbc"));
48         abckit::mock::helpers::GetMockCoreAnnotation(f).EnumerateElements(
49             DEFAULT_LAMBDA(abckit::core::AnnotationElement));
50         ASSERT_TRUE(CheckMockedApi("AnnotationEnumerateElements"));
51     }
52     ASSERT_TRUE(CheckMockedApi("CloseFile"));
53     ASSERT_TRUE(CheckMockedStackEmpty());
54 }
55 
56 }  // namespace libabckit::cpp_test
57