• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SEC_COMP_STUB_TEST_H
17 #define SEC_COMP_STUB_TEST_H
18 
19 #include <gtest/gtest.h>
20 #define private public
21 #include "sec_comp_service_stub.h"
22 #undef private
23 
24 namespace OHOS {
25 namespace Security {
26 namespace SecurityComponent {
27 // stub is abstract class
28 struct SecCompStubMock : public SecCompServiceStub {
29 public:
RegisterSecurityComponentSecCompStubMock30     int32_t RegisterSecurityComponent(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
31     {
32         return 0;
33     };
34 
UpdateSecurityComponentSecCompStubMock35     int32_t UpdateSecurityComponent(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
36     {
37         return 0;
38     };
39 
UnregisterSecurityComponentSecCompStubMock40     int32_t UnregisterSecurityComponent(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
41     {
42         return 0;
43     };
44 
ReportSecurityComponentClickEventSecCompStubMock45     int32_t ReportSecurityComponentClickEvent(const sptr<IRemoteObject>& callerToken,
46         const sptr<IRemoteObject>& dialogCall, const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
47     {
48         return 0;
49     };
50 
VerifySavePermissionSecCompStubMock51     int32_t VerifySavePermission(uint32_t tokenId, bool& isGranted) override
52     {
53         return true;
54     };
55 
PreRegisterSecCompProcessSecCompStubMock56     int32_t PreRegisterSecCompProcess(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
57     {
58         return 0;
59     };
60 };
61 
62 class SecCompStubTest : public testing::Test {
63 public:
64     static void SetUpTestCase();
65 
66     static void TearDownTestCase();
67 
68     void SetUp();
69 
70     void TearDown();
71 
72     sptr<SecCompStubMock> stub_ = nullptr;
73 };
74 }  // namespace SecurityComponent
75 }  // namespace Security
76 }  // namespace OHOS
77 #endif  // SEC_COMP_STUB_TEST_H
78