• 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 #ifndef SEC_COMP_STUB_MOCK_TEST_H
17 #define SEC_COMP_STUB_MOCK_TEST_H
18 
19 #include <gtest/gtest.h>
20 #define private public
21 #include "access_token.h"
22 #include "sec_comp_service_stub.h"
23 #undef private
24 
25 namespace OHOS {
26 namespace Security {
27 namespace SecurityComponent {
28 // stub is abstract class
29 struct SecCompStubMock : public SecCompServiceStub {
30 public:
RegisterSecurityComponentSecCompStubMock31     int32_t RegisterSecurityComponent(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
32     {
33         return 0;
34     };
35 
UpdateSecurityComponentSecCompStubMock36     int32_t UpdateSecurityComponent(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
37     {
38         return 0;
39     };
40 
UnregisterSecurityComponentSecCompStubMock41     int32_t UnregisterSecurityComponent(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
42     {
43         return 0;
44     };
45 
ReportSecurityComponentClickEventSecCompStubMock46     int32_t ReportSecurityComponentClickEvent(const sptr<IRemoteObject>& callerToken,
47         const sptr<IRemoteObject>& dialogCall, const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
48     {
49         return 0;
50     };
51 
VerifySavePermissionSecCompStubMock52     int32_t VerifySavePermission(AccessToken::AccessTokenID tokenId, bool& isGranted) override
53     {
54         return true;
55     };
56 
PreRegisterSecCompProcessSecCompStubMock57     int32_t PreRegisterSecCompProcess(const SecCompRawdata& rawData, SecCompRawdata& rawReply) override
58     {
59         return 0;
60     };
61 };
62 
63 class SecCompStubMockTest : public testing::Test {
64 public:
65     static void SetUpTestCase();
66 
67     static void TearDownTestCase();
68 
69     void SetUp();
70 
71     void TearDown();
72 
73     sptr<SecCompStubMock> stub_ = nullptr;
74 };
75 }  // namespace SecurityComponent
76 }  // namespace Security
77 }  // namespace OHOS
78 #endif  // SEC_COMP_STUB_MOCK_TEST_H
79