diff --git a/frameworks/test/moduletest/ans_fw_module_test.cpp b/frameworks/test/moduletest/ans_fw_module_test.cpp index 456841aff132e8555d822c14d24d1d35ee53f7dd..d108d7d6d3b05f908f2ef594096af30b76d7aea4 100644 --- a/frameworks/test/moduletest/ans_fw_module_test.cpp +++ b/frameworks/test/moduletest/ans_fw_module_test.cpp @@ -31,7 +31,6 @@ #include "datetime_ex.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" -#include "mock_ipc_skeleton.h" #include "mock_single_kv_store.h" #include "notification_content.h" #include "notification_helper.h" @@ -2321,7 +2320,6 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00600, Function | MediumTest | Lev HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07100, Function | MediumTest | Level1) { - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); TestAnsSubscriber subscriber; EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK); @@ -2342,7 +2340,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07100, Function EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_NE((int)notifications.size(), (int)0); int32_t id = notifications[0]->GetId(); - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); EXPECT_EQ(NotificationHelper::CancelContinuousTaskNotification(NOTIFICATION_LABEL_0, id), ERR_OK); EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_EQ((int)notifications.size(), (int)0); @@ -2355,12 +2352,10 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07100, Function EXPECT_TRUE(eventParser.GetWaitOnCanceledWithSortingMapAndDeleteReason()); subscriber.ClearEvents(); SleepForFC(); - MockIPCSkeleton::SetCallingUid(1); } HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07200, Function | MediumTest | Level1) { - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); TestAnsSubscriber subscriber; EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK); @@ -2383,7 +2378,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07200, Function std::string key = notifications[0]->GetKey().c_str(); EXPECT_EQ(NotificationHelper::RemoveNotification(key), (int)ERR_OK); int32_t id = notifications[0]->GetId(); - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); EXPECT_EQ(NotificationHelper::CancelContinuousTaskNotification(NOTIFICATION_LABEL_0, id), ERR_OK); EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_EQ((int)notifications.size(), (int)0); @@ -2396,12 +2390,10 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07200, Function EXPECT_TRUE(eventParser.GetWaitOnCanceledWithSortingMapAndDeleteReason()); subscriber.ClearEvents(); SleepForFC(); - MockIPCSkeleton::SetCallingUid(1); } HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07300, Function | MediumTest | Level1) { - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); TestAnsSubscriber subscriber; EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK); @@ -2423,7 +2415,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07300, Function EXPECT_NE((int)notifications.size(), (int)0); int32_t id = notifications[0]->GetId(); EXPECT_EQ(NotificationHelper::CancelNotification(id), (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); EXPECT_EQ(NotificationHelper::CancelContinuousTaskNotification(NOTIFICATION_LABEL_0, id), ERR_OK); EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_EQ((int)notifications.size(), (int)0); @@ -2436,7 +2427,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07300, Function EXPECT_TRUE(eventParser.GetWaitOnCanceledWithSortingMapAndDeleteReason()); subscriber.ClearEvents(); SleepForFC(); - MockIPCSkeleton::SetCallingUid(1); } HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07400, Function | MediumTest | Level1) @@ -2487,7 +2477,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07500, Function HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07600, Function | MediumTest | Level1) { - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); TestAnsSubscriber subscriber; EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK); @@ -2512,12 +2501,10 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07600, Function EXPECT_EQ(NotificationHelper::UnSubscribeNotification(subscriber), ERR_OK); SleepForFC(); subscriber.ClearEvents(); - MockIPCSkeleton::SetCallingUid(1); } HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07700, Function | MediumTest | Level1) { - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); TestAnsSubscriber subscriber; EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK); @@ -2539,7 +2526,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07700, Function EXPECT_NE((int)notifications.size(), (int)0); int32_t id = notifications[0]->GetId(); EXPECT_EQ(NotificationHelper::CancelAllNotifications(), (int)ERR_OK); - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_NE((int)notifications.size(), (int)0); EXPECT_EQ(NotificationHelper::CancelContinuousTaskNotification(NOTIFICATION_LABEL_0, id), ERR_OK); @@ -2554,12 +2540,10 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07700, Function EXPECT_TRUE(eventParser.GetWaitOnCanceledWithSortingMapAndDeleteReason()); subscriber.ClearEvents(); SleepForFC(); - MockIPCSkeleton::SetCallingUid(1); } HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07800, Function | MediumTest | Level1) { - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); TestAnsSubscriber subscriber; EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK); @@ -2583,7 +2567,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07800, Function EXPECT_EQ(NotificationHelper::RemoveNotifications(), (int)ERR_OK); EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_NE((int)notifications.size(), (int)0); - MockIPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID); EXPECT_EQ(NotificationHelper::CancelContinuousTaskNotification(NOTIFICATION_LABEL_0, id), ERR_OK); EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK); EXPECT_EQ((int)notifications.size(), (int)0); @@ -2596,7 +2579,6 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PublishContinuousTask_07800, Function EXPECT_TRUE(eventParser.GetWaitOnCanceledWithSortingMapAndDeleteReason()); subscriber.ClearEvents(); SleepForFC(); - MockIPCSkeleton::SetCallingUid(1); } } // namespace Notification } // namespace OHOS \ No newline at end of file diff --git a/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp b/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp index 75936592578aff0e47ee9c489a293768a57d7b37..cf378536434ba4f6c4a56ba13fe1b92c77210e70 100644 --- a/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp +++ b/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp @@ -25,7 +25,6 @@ #include "notification_helper.h" #include "notification_json_convert.h" #include "mock_bundle_manager.h" -#include "mock_ipc_skeleton.h" #include "system_ability_definition.h" #include "want_agent_info.h" #include "want_agent_helper.h" @@ -57,7 +56,6 @@ const int32_t CASE_THIRTEEN = 13; const int32_t CASE_FOURTEEN = 14; const int32_t CASE_FIFTEEN = 15; const int32_t CASE_SIXTEEN = 16; -const int32_t CALLING_UID = 9999; const int32_t PIXEL_MAP_TEST_WIDTH = 32; const int32_t PIXEL_MAP_TEST_HEIGHT = 32; @@ -372,9 +370,9 @@ private: { std::shared_ptr notiTemplate = notificationRequest.GetTemplate(); if (notiTemplate != nullptr) { - EXPECT_EQ("process", notiTemplate->GetTemplateName()); + EXPECT_EQ("downloadTemplate", notiTemplate->GetTemplateName()); std::shared_ptr param = notiTemplate->GetTemplateData(); - int value = AAFwk::Integer::Unbox(AAFwk::IInteger::Query(param->GetParam("process"))); + int value = AAFwk::Integer::Unbox(AAFwk::IInteger::Query(param->GetParam("downloadTemplate"))); EXPECT_EQ(20, value); // 20 test input } EXPECT_EQ(NotificationConstant::OTHER, notificationRequest.GetSlotType()); @@ -430,7 +428,6 @@ void AnsInnerKitsModulePublishTest::SetUpTestCase() sptr service = OHOS::Notification::AdvancedNotificationService::GetInstance(); OHOS::ISystemAbilityManager::SAExtraProp saExtraProp; systemAbilityManager->AddSystemAbility(OHOS::ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, service, saExtraProp); - MockIPCSkeleton::SetCallingUid(CALLING_UID); } void AnsInnerKitsModulePublishTest::TearDownTestCase() @@ -1285,10 +1282,10 @@ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Publish_04000, Function std::shared_ptr notiTemplate = std::make_shared(); EXPECT_NE(notiTemplate, nullptr); - notiTemplate->SetTemplateName("process"); - // [{'process':20}] + notiTemplate->SetTemplateName("downloadTemplate"); + // [{'downloadTemplate':20}] AAFwk::WantParams wantParams; - std::string key("process"); + std::string key("downloadTemplate"); int resultValue = 20; wantParams.SetParam(key, AAFwk::Integer::Box(resultValue)); notiTemplate->SetTemplateData(std::make_shared(wantParams)); @@ -1461,6 +1458,7 @@ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Publish_06000, Function */ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Slot_Enalbe_00100, Function | MediumTest | Level1) { + GTEST_LOG_(INFO) << "ANS_Interface_MT_Slot_Enalbe_00100::start:"; NotificationSlot slot(NotificationConstant::CONTENT_INFORMATION); EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot)); @@ -1479,6 +1477,7 @@ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Slot_Enalbe_00100, Func NotificationBundleOption bo("bundleName", 1); EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::CONTENT_INFORMATION, enable)); EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::CONTENT_INFORMATION, enable)); + GTEST_LOG_(INFO) << "ANS_Interface_MT_Slot_Enalbe_00100::end:" << enable; EXPECT_EQ(enable, false); EXPECT_EQ(ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_ENABLED, NotificationHelper::PublishNotification(req)); } @@ -1491,6 +1490,7 @@ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Slot_Enalbe_00100, Func */ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Slot_Enalbe_00200, Function | MediumTest | Level1) { + GTEST_LOG_(INFO) << "ANS_Interface_MT_Slot_Enalbe_00200::start:"; NotificationSlot slot(NotificationConstant::SERVICE_REMINDER); EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot)); @@ -1507,6 +1507,7 @@ HWTEST_F(AnsInnerKitsModulePublishTest, ANS_Interface_MT_Slot_Enalbe_00200, Func bool enable = false; NotificationBundleOption bo("bundleName", 1); + GTEST_LOG_(INFO) << "ANS_Interface_MT_Slot_Enalbe_00200::end:" << enable; EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SERVICE_REMINDER, enable)); EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SERVICE_REMINDER, enable)); EXPECT_EQ(enable, false); diff --git a/frameworks/test/moduletest/ans_innerkits_module_setting_test.cpp b/frameworks/test/moduletest/ans_innerkits_module_setting_test.cpp index 2284850490265a6761b514e641258aca37ac1873..01fccfbe188f84f3980ac203eec6e64df11077db 100644 --- a/frameworks/test/moduletest/ans_innerkits_module_setting_test.cpp +++ b/frameworks/test/moduletest/ans_innerkits_module_setting_test.cpp @@ -22,7 +22,6 @@ #include "iservice_registry.h" #include "notification_helper.h" #include "mock_bundle_manager.h" -#include "mock_ipc_skeleton.h" #include "system_ability_definition.h" using namespace testing::ext; @@ -45,7 +44,6 @@ void AnsInnerKitsModuleSettingTest::SetUpTestCase() sptr service = OHOS::Notification::AdvancedNotificationService::GetInstance(); OHOS::ISystemAbilityManager::SAExtraProp saExtraProp; systemAbilityManager->AddSystemAbility(OHOS::ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, service, saExtraProp); - MockIPCSkeleton::SetCallingUid(CALLING_UID); } void AnsInnerKitsModuleSettingTest::TearDownTestCase() diff --git a/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp b/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp index 1605499adce59b50df6f36f69e7606269780fffe..41d4d23677a1d909e4e3158f6f485659b3e0f3d0 100644 --- a/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp +++ b/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp @@ -22,7 +22,6 @@ #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "mock_bundle_manager.h" -#include "mock_ipc_skeleton.h" #include "notification_helper.h" #include "system_ability_definition.h" @@ -31,7 +30,6 @@ namespace OHOS { namespace Notification { static sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); -const int32_t CALLING_UID = 9998; class AnsInnerKitsModuleSlotTest : public testing::Test { public: @@ -46,7 +44,6 @@ void AnsInnerKitsModuleSlotTest::SetUpTestCase() sptr service = OHOS::Notification::AdvancedNotificationService::GetInstance(); OHOS::ISystemAbilityManager::SAExtraProp saExtraProp; systemAbilityManager->AddSystemAbility(OHOS::ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, service, saExtraProp); - MockIPCSkeleton::SetCallingUid(CALLING_UID); } void AnsInnerKitsModuleSlotTest::TearDownTestCase() @@ -512,7 +509,7 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00 EXPECT_EQ(spSlot->GetEnable(), true); bool enable = false; - NotificationBundleOption bo("bundleName", CALLING_UID); + NotificationBundleOption bo("bundlename", 1); EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable)); EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable)); EXPECT_EQ(enable, false); @@ -527,7 +524,7 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00200, Function | MediumTest | Level1) { bool enable = true; - NotificationBundleOption bo("bundleName", CALLING_UID); + NotificationBundleOption bo("hello", 1); EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable)); enable = false; EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable)); @@ -548,7 +545,7 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00300, Function | MediumTest | Level1) { bool enable = false; - NotificationBundleOption bo("bundleName", CALLING_UID); + NotificationBundleOption bo("bundleName", 1); EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SERVICE_REMINDER, enable)); enable = true; EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SERVICE_REMINDER, enable)); diff --git a/frameworks/test/moduletest/mock/include/mock_ipc_skeleton.h b/frameworks/test/moduletest/mock/include/mock_ipc_skeleton.h deleted file mode 100644 index daa5f1daa9f7fd6d8b48ff2434862ad55ffb4f5f..0000000000000000000000000000000000000000 --- a/frameworks/test/moduletest/mock/include/mock_ipc_skeleton.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_IPC_IPC_SKELETON_H -#define OHOS_IPC_IPC_SKELETON_H - -#include "iremote_object.h" - -namespace OHOS { -class MockIPCSkeleton { -public: - MockIPCSkeleton() = default; - ~MockIPCSkeleton() = default; - - /** - * @brief Set the max number of work thread. - * Default max is 4, only if you need a customize value. - * - * @param maxThreadNum Indicates the max number of work thread - * @return Indicates the result. - */ - static bool SetMaxWorkThreadNum(int maxThreadNum); - - /** - * @brief Join current thread into work loop. - */ - static void JoinWorkThread(); - - /** - * @brief Remove current thread from work loop. - */ - static void StopWorkThread(); - - /** - * @brief Get calling pid. - * - * @return Indicates the calling pid. - */ - static int GetCallingPid(); - - /** - * @brief Get calling uid. - * - * @return Indicates the calling uid. - */ - static int GetCallingUid(); - - /** - * @brief Get the ID of local device. - * - * @return Indicates the ID of local device. - */ - static std::string GetLocalDeviceID(); - - /** - * @brief Get the ID of calling device. - * - * @return Indicates the ID of calling device. - */ - static std::string GetCallingDeviceID(); - - /** - * @brief Whether it is locally calling. - * - * @return Return ture for calling from local, otherwise false. - */ - static bool IsLocalCalling(); - - /** - * @brief Get the instance. - * - * @return Indicates the instance. - */ - static MockIPCSkeleton &GetInstance(); - - /** - * @brief Get the object of context. - * - * @return Indicates the context cobject. - */ - static sptr GetContextObject(); - - /** - * @brief Set the object of context. - * - * @param object Indicates the context cobject. - * @return Indicates the result. - */ - static bool SetContextObject(sptr &object); - - /** - * @brief Flush the commands. - * - * @param object Indicates the object. - * @return Indicates the result. - */ - static int FlushCommands(IRemoteObject *object); - - /** - * @brief Reset calling identity. - * - * @return Indicates the result. - */ - static std::string ResetCallingIdentity(); - - /** - * @brief Set calling identity. - * - * @param identity Indicates the identity. - * @return Indicates the result. - */ - static bool SetCallingIdentity(std::string &identity); - - /** - * @brief Set calling uid. - * - * @param uid Indicates the uid. - */ - static void SetCallingUid(int uid); -}; -} // namespace OHOS -#endif // OHOS_IPC_IPC_SKELETON_H diff --git a/frameworks/test/moduletest/mock/mock_ipc.cpp b/frameworks/test/moduletest/mock/mock_ipc.cpp index 102f1665bb42a9024e866e10c3dcf182ef0caf56..60f30db5a0acf716bc2410d2ae666c952ce1b858 100644 --- a/frameworks/test/moduletest/mock/mock_ipc.cpp +++ b/frameworks/test/moduletest/mock/mock_ipc.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "mock_ipc_skeleton.h" +#include "ipc_skeleton.h" namespace OHOS { #ifdef CONFIG_IPC_SINGLE @@ -22,19 +22,14 @@ using namespace IPC_SINGLE; int uid_ = 1; -int MockIPCSkeleton::GetCallingUid() +int IPCSkeleton::GetCallingUid() { return uid_; } -int MockIPCSkeleton::GetCallingPid() +int IPCSkeleton::GetCallingPid() { uid_ = 1; return uid_; } - -void MockIPCSkeleton::SetCallingUid(int uid) -{ - uid_ = uid; -} } // namespace OHOS