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_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, sptr<IRemoteObject> dialogCall) override 48 { 49 return 0; 50 }; 51 VerifySavePermissionSecCompStubMock52 bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override 53 { 54 return true; 55 }; 56 GetEnhanceRemoteObjectSecCompStubMock57 sptr<IRemoteObject> GetEnhanceRemoteObject() override 58 { 59 return nullptr; 60 }; 61 PreRegisterSecCompProcessSecCompStubMock62 int32_t PreRegisterSecCompProcess() override 63 { 64 return 0; 65 }; 66 }; 67 68 class SecCompStubTest : public testing::Test { 69 public: 70 static void SetUpTestCase(); 71 72 static void TearDownTestCase(); 73 74 void SetUp(); 75 76 void TearDown(); 77 78 sptr<SecCompStubMock> stub_ = nullptr; 79 }; 80 } // namespace SecurityComponent 81 } // namespace Security 82 } // namespace OHOS 83 #endif // SEC_COMP_STUB_TEST_H 84