1 /* 2 * Copyright (c) 2022-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 EDM_UNIT_TEST_PLUGIN_MANAGER_TEST_H 17 #define EDM_UNIT_TEST_PLUGIN_MANAGER_TEST_H 18 19 #include <gtest/gtest.h> 20 #include <iremote_object.h> 21 #include "edm_log.h" 22 #include "iplugin.h" 23 24 namespace OHOS { 25 namespace EDM { 26 namespace TEST { 27 class TestPlugin : public IPlugin { 28 public: TestPlugin()29 TestPlugin() 30 { 31 policyCode_ = 0; 32 policyName_ = "TestPlugin"; 33 permission_ = "ohos.permission.EDM_TEST_PERMISSION"; 34 permissionType_ = IPlugin::PermissionType::NORMAL_DEVICE_ADMIN; 35 EDMLOGD("TestPlugin constructor"); 36 } 37 OnHandlePolicy(std::uint32_t funcCode,MessageParcel & data,MessageParcel & reply,std::string & policyData,bool & isChanged,int32_t userId)38 ErrCode OnHandlePolicy(std::uint32_t funcCode, MessageParcel &data, MessageParcel &reply, std::string &policyData, 39 bool &isChanged, int32_t userId) override 40 { 41 return ERR_OK; 42 } 43 MergePolicyData(const std::string & adminName,std::string & policyData)44 ErrCode MergePolicyData(const std::string &adminName, std::string &policyData) override 45 { 46 return IPlugin::MergePolicyData(adminName, policyData); 47 } 48 OnHandlePolicyDone(std::uint32_t funcCode,const std::string & adminName,bool isGlobalChanged,int32_t userId)49 void OnHandlePolicyDone(std::uint32_t funcCode, const std::string &adminName, bool isGlobalChanged, 50 int32_t userId) override {} 51 OnAdminRemove(const std::string & adminName,const std::string & policyData,int32_t userId)52 ErrCode OnAdminRemove(const std::string &adminName, const std::string &policyData, int32_t userId) override 53 { 54 return ERR_OK; 55 } 56 OnAdminRemoveDone(const std::string & adminName,const std::string & policyData,int32_t userId)57 void OnAdminRemoveDone(const std::string &adminName, const std::string &policyData, int32_t userId) override {} 58 WritePolicyToParcel(const std::string & policyData,MessageParcel & reply)59 ErrCode WritePolicyToParcel(const std::string &policyData, MessageParcel &reply) override 60 { 61 return IPlugin::WritePolicyToParcel(policyData, reply); 62 } 63 OnGetPolicy(std::string & policyData,MessageParcel & data,MessageParcel & reply,int32_t userId)64 ErrCode OnGetPolicy(std::string &policyData, MessageParcel &data, MessageParcel &reply, int32_t userId) 65 { 66 return ERR_OK; 67 } 68 69 ~TestPlugin() override = default; 70 }; 71 72 class PluginManagerTest : public testing::Test { 73 protected: 74 virtual void SetUp() override; 75 76 virtual void TearDown() override; 77 }; 78 } // namespace TEST 79 } // namespace EDM 80 } // namespace OHOS 81 #endif // EDM_UNIT_TEST_PLUGIN_MANAGER_TEST_H 82