From 4dbe163dc3b98932c746f2d1418b606678c63dcb Mon Sep 17 00:00:00 2001 From: jerry Date: Wed, 6 Dec 2023 15:10:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E6=9C=BA=E4=B8=8E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=87=8D=E5=90=AFUT=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jerry Change-Id: I7c0fed70510c1d63fbda5bd00834d5f614fbd43f --- .../device_control_proxy_test.cpp | 6 ------ .../edm_plugin/src/reboot_plugin_test.cpp | 18 ++++++++++-------- .../edm_plugin/src/shutdown_plugin_test.cpp | 18 ++++++++++-------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/test/unittest/device_control_proxy/device_control_proxy_test.cpp b/test/unittest/device_control_proxy/device_control_proxy_test.cpp index 023c31fe6..cb9e63324 100644 --- a/test/unittest/device_control_proxy/device_control_proxy_test.cpp +++ b/test/unittest/device_control_proxy/device_control_proxy_test.cpp @@ -136,9 +136,6 @@ HWTEST_F(DeviceControlProxyTest, TestLockScreenFail, TestSize.Level1) */ HWTEST_F(DeviceControlProxyTest, TestShutdownSuc, TestSize.Level1) { - GTEST_LOG_(WARNING) << "warning: to avoid affectd others case, TestShutdownSuc case will not run."; - ASSERT_TRUE(true); - return; OHOS::AppExecFwk::ElementName admin; admin.SetBundleName(ADMIN_PACKAGENAME); EXPECT_CALL(*object_, SendRequest(_, _, _, _)) @@ -169,9 +166,6 @@ HWTEST_F(DeviceControlProxyTest, TestShutdownFail, TestSize.Level1) */ HWTEST_F(DeviceControlProxyTest, TestRebootSuc, TestSize.Level1) { - GTEST_LOG_(WARNING) << "warning: to avoid affectd others case, TestRebootSuc case will not run."; - ASSERT_TRUE(true); - return; OHOS::AppExecFwk::ElementName admin; admin.SetBundleName(ADMIN_PACKAGENAME); EXPECT_CALL(*object_, SendRequest(_, _, _, _)) diff --git a/test/unittest/edm_plugin/src/reboot_plugin_test.cpp b/test/unittest/edm_plugin/src/reboot_plugin_test.cpp index f3d7fba9d..68d941762 100644 --- a/test/unittest/edm_plugin/src/reboot_plugin_test.cpp +++ b/test/unittest/edm_plugin/src/reboot_plugin_test.cpp @@ -26,7 +26,6 @@ namespace EDM { namespace TEST { void RebootPluginTest::SetUpTestSuite(void) { - Utils::SetEdmInitialEnv(); } void RebootPluginTest::TearDownTestSuite(void) @@ -38,17 +37,20 @@ void RebootPluginTest::TearDownTestSuite(void) /** * @tc.name: TestShutdown - * @tc.desc: Test ShutdownPlugin::OnSetPolicy function success. + * @tc.desc: Test ShutdownPlugin::OnSetPolicy function fail. * @tc.type: FUNC */ HWTEST_F(RebootPluginTest, TestReboot, TestSize.Level1) { - GTEST_LOG_(WARNING) << "warning: to avoid affectd others case, TestReboot case will not run."; - ASSERT_TRUE(true); - return; - RebootPlugin plugin; - ErrCode ret = plugin.OnSetPolicy(); - ASSERT_TRUE(ret == ERR_OK); + Utils::ResetTokenTypeAndUid(); + std::shared_ptr plugin = ShutdownPlugin::GetPlugin(); + bool isChanged = false; + uint32_t code = POLICY_FUNC_CODE((std::uint32_t)FuncOperateType::SET, EdmInterfaceCode::REBOOT); + std::string policyData{""}; + MessageParcel data; + MessageParcel reply; + ErrCode ret = plugin->OnHandlePolicy(code, data, reply, policyData, isChanged, DEFAULT_USER_ID); + ASSERT_TRUE(ret == EdmReturnErrCode::SYSTEM_ABNORMALLY); } } // namespace TEST } // namespace EDM diff --git a/test/unittest/edm_plugin/src/shutdown_plugin_test.cpp b/test/unittest/edm_plugin/src/shutdown_plugin_test.cpp index 3ade530fa..7e00d2d66 100644 --- a/test/unittest/edm_plugin/src/shutdown_plugin_test.cpp +++ b/test/unittest/edm_plugin/src/shutdown_plugin_test.cpp @@ -26,7 +26,6 @@ namespace EDM { namespace TEST { void ShutdownPluginTest::SetUpTestSuite(void) { - Utils::SetEdmInitialEnv(); } void ShutdownPluginTest::TearDownTestSuite(void) @@ -38,17 +37,20 @@ void ShutdownPluginTest::TearDownTestSuite(void) /** * @tc.name: TestShutdown - * @tc.desc: Test ShutdownPlugin::OnSetPolicy function success. + * @tc.desc: Test ShutdownPlugin::OnSetPolicy function fail. * @tc.type: FUNC */ HWTEST_F(ShutdownPluginTest, TestShutdown, TestSize.Level1) { - GTEST_LOG_(WARNING) << "warning: to avoid affectd others case, TestShutdown case will not run."; - ASSERT_TRUE(true); - return; - ShutdownPlugin plugin; - ErrCode ret = plugin.OnSetPolicy(); - ASSERT_TRUE(ret == ERR_OK); + Utils::ResetTokenTypeAndUid(); + std::shared_ptr plugin = ShutdownPlugin::GetPlugin(); + bool isChanged = false; + uint32_t code = POLICY_FUNC_CODE((std::uint32_t)FuncOperateType::SET, EdmInterfaceCode::SHUTDOWN); + std::string policyData{""}; + MessageParcel data; + MessageParcel reply; + ErrCode ret = plugin->OnHandlePolicy(code, data, reply, policyData, isChanged, DEFAULT_USER_ID); + ASSERT_TRUE(ret == EdmReturnErrCode::SYSTEM_ABNORMALLY); } } // namespace TEST } // namespace EDM -- Gitee