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 "sec_comp_stub.h" 22 #undef private 23 24 namespace OHOS { 25 namespace Security { 26 namespace SecurityComponent { 27 // stub is abstract class 28 struct SecCompStubMock : public SecCompStub { 29 public: RegisterSecurityComponentSecCompStubMock30 int32_t RegisterSecurityComponent(SecCompType type, 31 const std::string& componentInfo, int32_t& scId) override 32 { 33 return 0; 34 }; 35 UpdateSecurityComponentSecCompStubMock36 int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) override 37 { 38 return 0; 39 }; 40 UnregisterSecurityComponentSecCompStubMock41 int32_t UnregisterSecurityComponent(int32_t scId) override 42 { 43 return 0; 44 }; 45 ReportSecurityComponentClickEventSecCompStubMock46 int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, 47 SecCompClickEvent& clickInfo, sptr<IRemoteObject> callerToken, 48 sptr<IRemoteObject> dialogCall) override 49 { 50 return 0; 51 }; 52 VerifySavePermissionSecCompStubMock53 bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override 54 { 55 return true; 56 }; 57 GetEnhanceRemoteObjectSecCompStubMock58 sptr<IRemoteObject> GetEnhanceRemoteObject() override 59 { 60 return nullptr; 61 }; 62 PreRegisterSecCompProcessSecCompStubMock63 int32_t PreRegisterSecCompProcess() override 64 { 65 return 0; 66 }; 67 }; 68 69 class SecCompStubMockTest : public testing::Test { 70 public: 71 static void SetUpTestCase(); 72 73 static void TearDownTestCase(); 74 75 void SetUp(); 76 77 void TearDown(); 78 79 sptr<SecCompStubMock> stub_ = nullptr; 80 }; 81 } // namespace SecurityComponent 82 } // namespace Security 83 } // namespace OHOS 84 #endif // SEC_COMP_STUB_MOCK_TEST_H 85