diff --git a/ext/mini/interfaces_mini/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/ext/mini/interfaces_mini/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index 0b90a94e25bfbfac9c241e0cd32d101373e60a6b..12f75699cdf9e19499dde7cf2a34b2598a86f9df 100644 --- a/ext/mini/interfaces_mini/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/ext/mini/interfaces_mini/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -28,33 +28,28 @@ IMPLEMENT_SINGLE_INSTANCE(DeviceManagerNotify); void DeviceManagerNotify::RegisterDeathRecipientCallback(std::string &pkgName, std::shared_ptr dmInitCallback) { - //std::lock_guard autoLock(lock_); dmInitCallback_[pkgName] = dmInitCallback; } void DeviceManagerNotify::UnRegisterDeathRecipientCallback(std::string &pkgName) { - //std::lock_guard autoLock(lock_); dmInitCallback_.erase(pkgName); } void DeviceManagerNotify::RegisterDeviceStateCallback(std::string &pkgName, std::shared_ptr callback) { - //std::lock_guard autoLock(lock_); deviceStateCallback_[pkgName] = callback; } void DeviceManagerNotify::UnRegisterDeviceStateCallback(std::string &pkgName) { - //std::lock_guard autoLock(lock_); deviceStateCallback_.erase(pkgName); } void DeviceManagerNotify::RegisterDiscoverCallback(std::string &pkgName, uint16_t subscribeId, std::shared_ptr callback) { - //std::lock_guard autoLock(lock_); if (deviceDiscoverCallbacks_.count(pkgName) == 0) { deviceDiscoverCallbacks_[pkgName] = std::map>(); } @@ -63,7 +58,6 @@ void DeviceManagerNotify::RegisterDiscoverCallback(std::string &pkgName, uint16_ void DeviceManagerNotify::UnRegisterDiscoverCallback(std::string &pkgName, uint16_t subscribeId) { - //std::lock_guard autoLock(lock_); if (deviceDiscoverCallbacks_.count(pkgName) > 0) { deviceDiscoverCallbacks_[pkgName].erase(subscribeId); if (deviceDiscoverCallbacks_[pkgName].empty()) { @@ -75,7 +69,6 @@ void DeviceManagerNotify::UnRegisterDiscoverCallback(std::string &pkgName, uint1 void DeviceManagerNotify::RegisterAuthenticateCallback(std::string &pkgName, std::string &deviceId, std::shared_ptr callback) { - //std::lock_guard autoLock(lock_); if (authenticateCallback_.count(pkgName) == 0) { authenticateCallback_[pkgName] = std::map>(); } @@ -84,7 +77,6 @@ void DeviceManagerNotify::RegisterAuthenticateCallback(std::string &pkgName, std void DeviceManagerNotify::UnRegisterAuthenticateCallback(std::string &pkgName, std::string &deviceId) { - //std::lock_guard autoLock(lock_); if (authenticateCallback_.count(pkgName) > 0) { authenticateCallback_[pkgName].erase(deviceId); if (authenticateCallback_[pkgName].empty()) { @@ -95,7 +87,6 @@ void DeviceManagerNotify::UnRegisterAuthenticateCallback(std::string &pkgName, s void DeviceManagerNotify::UnRegisterPackageCallback(std::string &pkgName) { - //std::lock_guard autoLock(lock_); deviceStateCallback_.erase(pkgName); deviceDiscoverCallbacks_.erase(pkgName); authenticateCallback_.erase(pkgName); @@ -105,26 +96,22 @@ void DeviceManagerNotify::UnRegisterPackageCallback(std::string &pkgName) void DeviceManagerNotify::RegisterCheckAuthenticationCallback(std::string &pkgName, std::string &authPara, std::shared_ptr callback) { - //std::lock_guard autoLock(lock_); checkauthcallback_[pkgName] = callback; } void DeviceManagerNotify::UnRegisterCheckAuthenticationCallback(std::string &pkgName) { - //std::lock_guard autoLock(lock_); checkauthcallback_.erase(pkgName); } void DeviceManagerNotify::RegisterDeviceManagerFaCallback(std::string &packageName, std::shared_ptr callback) { - //std::lock_guard autoLock(lock_); dmFaCallback_[packageName] = callback; } void DeviceManagerNotify::UnRegisterDeviceManagerFaCallback(std::string &pkgName) { - //std::lock_guard autoLock(lock_); dmFaCallback_.erase(pkgName); } @@ -140,7 +127,6 @@ void DeviceManagerNotify::OnRemoteDied() void DeviceManagerNotify::OnDeviceOnline(std::string &pkgName, const DmDeviceInfo &deviceInfo) { DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceOnline pkgName:%s", pkgName.c_str()); - //std::lock_guard autoLock(lock_); if (deviceStateCallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceOnlinecallback not register"); return; @@ -151,7 +137,6 @@ void DeviceManagerNotify::OnDeviceOnline(std::string &pkgName, const DmDeviceInf void DeviceManagerNotify::OnDeviceOffline(std::string &pkgName, const DmDeviceInfo &deviceInfo) { DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceOffline pkgName:%s", pkgName.c_str()); - //std::lock_guard autoLock(lock_); if (deviceStateCallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceOfflinecallback not register"); return; @@ -162,7 +147,6 @@ void DeviceManagerNotify::OnDeviceOffline(std::string &pkgName, const DmDeviceIn void DeviceManagerNotify::OnDeviceChanged(std::string &pkgName, const DmDeviceInfo &deviceInfo) { DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceChanged pkgName:%s", pkgName.c_str()); - //std::lock_guard autoLock(lock_); if (deviceStateCallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceChangedcallback not register"); return; @@ -175,7 +159,6 @@ void DeviceManagerNotify::OnDeviceFound(std::string &pkgName, uint16_t subscribe { DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceFound pkgName:%s, subscribeId:%d.", pkgName.c_str(), (int32_t)subscribeId); - //std::lock_guard autoLock(lock_); if (deviceDiscoverCallbacks_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceFound: no register discoverCallback for this package"); return; @@ -194,7 +177,6 @@ void DeviceManagerNotify::OnDiscoverFailed(std::string &pkgName, uint16_t subscr { DMLOG(DM_LOG_INFO, "DeviceManager OnDiscoverFailed pkgName:%s, subscribeId %d, reason %d", pkgName.c_str(), subscribeId, failedReason); - //std::lock_guard autoLock(lock_); if (deviceDiscoverCallbacks_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnDiscoverFailed: no register discoverCallback for this package"); return; @@ -213,7 +195,6 @@ void DeviceManagerNotify::OnDiscoverySuccess(std::string &pkgName, uint16_t subs { DMLOG(DM_LOG_INFO, "DeviceManager OnDiscoverySuccess pkgName:%s, subscribeId:%d.", pkgName.c_str(), subscribeId); - //std::lock_guard autoLock(lock_); if (deviceDiscoverCallbacks_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnDiscoverySuccess: no register discoverCallback for this package"); return; @@ -233,7 +214,6 @@ void DeviceManagerNotify::OnAuthResult(std::string &pkgName, std::string &device { DMLOG(DM_LOG_INFO, "DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%d", pkgName.c_str(), status, reason); - //std::lock_guard autoLock(lock_); if (authenticateCallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnAuthResult: no register authCallback for this package"); return; @@ -256,7 +236,6 @@ void DeviceManagerNotify::OnCheckAuthResult(std::string &pkgName, std::string &d { DMLOG(DM_LOG_INFO, "DeviceManagerNotify::OnCheckAuthResult pkgName:%s, resultCode:%d, flag:%d", pkgName.c_str(), resultCode, flag); - //std::lock_guard autoLock(lock_); if (checkauthcallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager OnCheckAuthResult: no register authCallback for this package"); return; @@ -269,7 +248,6 @@ void DeviceManagerNotify::OnCheckAuthResult(std::string &pkgName, std::string &d void DeviceManagerNotify::OnFaCall(std::string &pkgName, std::string ¶mJson) { DMLOG(DM_LOG_INFO, "DeviceManager OnFaCallback pkgName:%s", pkgName.c_str()); - //std::lock_guard autoLock(lock_); if (dmFaCallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager DmFaCallback not register"); return; diff --git a/ext/mini/interfaces_mini/kits/js/src/dm_native_event.cpp b/ext/mini/interfaces_mini/kits/js/src/dm_native_event.cpp index ff70c3d2a812f1e608c4c5af47c99ad12388703c..cc27f1ef470482ceae869a909bdd38a952587f22 100644 --- a/ext/mini/interfaces_mini/kits/js/src/dm_native_event.cpp +++ b/ext/mini/interfaces_mini/kits/js/src/dm_native_event.cpp @@ -26,37 +26,30 @@ namespace ACELite { std::map> DmNativeEvent::eventMap_; DmNativeEvent::DmNativeEvent() -{ - DMLOG(DM_LOG_INFO, "DmNativeEvent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); +{ + DMLOG(DM_LOG_INFO, "DmNativeEvent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } DmNativeEvent::DmNativeEvent(JSIValue thisVar) -{ - DMLOG(DM_LOG_INFO, "DmNativeEvent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); +{ + DMLOG(DM_LOG_INFO, "DmNativeEvent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } DmNativeEvent::~DmNativeEvent() { - // for (auto iter = eventMap_.begin(); iter != eventMap_.end(); iter++) { - // auto listener = iter->second; - // JSI::ReleaseValue(listener->handlerRef); - // } - // eventMap_.clear(); - // JSI::ReleaseValue(thisVarRef_); - DMLOG(DM_LOG_INFO, "~DmNativeEvent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + DMLOG(DM_LOG_INFO, "~DmNativeEvent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } - void DmNativeEvent::On(std::string &eventType, JSIValue handle, JSIValue thisVal) { - DMLOG(DM_LOG_INFO, "DmNativeEvent On in for event: %s", eventType.c_str()); + DMLOG(DM_LOG_INFO, "DmNativeEvent On in for event: %s", eventType.c_str()); auto listener= std::make_shared(); listener->eventType = eventType; listener->handlerRef = JSI::AcquireValue(handle); listener->thisVarRef_ = JSI::AcquireValue(thisVal); - eventMap_[eventType] = listener; + eventMap_[eventType] = listener; } void DmNativeEvent::Off(std::string &eventType) diff --git a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp index 58764e5b08dd6f3ef8adc6c63dca687fa7e67965..50686dfb69f2650e75f51eff73cd4466dc77da4c 100644 --- a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp +++ b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp @@ -483,10 +483,8 @@ int32_t DeviceManagerModule::JsToDmSubscribeInfo(const JSIValue &object,DmSubscr void DeviceManagerModule::JsToDmDeviceInfo( const JSIValue &object, DmDeviceInfo &info) { - std::strcpy(info.deviceId, JsObjectToString(object, "deviceId")); - std::strcpy(info.deviceName, JsObjectToString(object, "deviceName")); - //info.deviceId = JsObjectToString(object, "deviceId"); - //info.deviceName = JsObjectToString(object, "deviceName"); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, JsObjectToString(object, "deviceId")); + strcpy_s(info.deviceName, DM_MAX_DEVICE_NAME_LEN, JsObjectToString(object, "deviceName")); int32_t deviceTypeId = -1; deviceTypeId = (int32_t)JsObjectToInt(object, "deviceTypeId"); info.deviceTypeId = (DMDeviceType)deviceTypeId; @@ -1104,9 +1102,5 @@ void InitDeviceManagerModule(JSIValue exports) JSI::SetModuleAPI(exports, "on", DeviceManagerModule::JsOn); JSI::SetModuleAPI(exports, "off", DeviceManagerModule::JsOff); } - -} } - - - +} \ No newline at end of file diff --git a/ext/mini/services/devicemanagerservice/include/dispatch/server_stub.h b/ext/mini/services/devicemanagerservice/include/dispatch/server_stub.h index 7a50df58fcc6336734794fdcdff1a478ec1dfdfd..9667dba08d0dd6f7757d5d308433430d70c57a72 100644 --- a/ext/mini/services/devicemanagerservice/include/dispatch/server_stub.h +++ b/ext/mini/services/devicemanagerservice/include/dispatch/server_stub.h @@ -18,7 +18,6 @@ #include #include -//#include "liteipc_adapter.h" #include #endif // OHOS_DEVICE_MANAGER_IPC_SERVER_STUB_H diff --git a/ext/mini/services/devicemanagerservice/include/timer/dm_timer.h b/ext/mini/services/devicemanagerservice/include/timer/dm_timer.h index 8aa10fa1712b1387239dc36fce4a42576d6688a1..be7a8dcc462464bbd7886411456095f11e6e98b7 100644 --- a/ext/mini/services/devicemanagerservice/include/timer/dm_timer.h +++ b/ext/mini/services/devicemanagerservice/include/timer/dm_timer.h @@ -17,10 +17,8 @@ #define TIMER_H #include #include -//#include #include #include -// #include #include #include @@ -59,10 +57,7 @@ private: TimeoutHandle mHandle_; void *mHandleData_; int32_t mTimeFd_[2]; - // struct epoll_event mEv_; - // struct epoll_event mEvents_[MAXEVENTS]; int32_t mEpFd_; - // std::thread mThread_; std::string mTimerName_; }; } diff --git a/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp b/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp index 4b1065f6a40e8ce802a6594a809223f4f9a4b51f..ea17b82af028492fce72dda87d73d8ae58fb7b51 100644 --- a/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp +++ b/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp @@ -30,7 +30,6 @@ #include "device_manager_errno.h" #include "device_manager_log.h" #include "softbus_session.h" -// #include "system_ability_definition.h" #if (defined(__LINUX__) || defined(__LITEOS_A__)) #include "ipc_server_listener_adapter.h" #endif diff --git a/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp b/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp index 8b5d1983c9682a8a123cfcc51ee028c8a836dee8..c97215ef45aa7636331cb080e0148c9064dc289c 100644 --- a/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp +++ b/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp @@ -14,9 +14,6 @@ */ #include "dm_timer.h" - -//#include - #include "securec.h" namespace OHOS { @@ -31,8 +28,6 @@ DmTimer::DmTimer(std::string &name) mHandle_ = nullptr; mHandleData_ = nullptr; (void)memset_s(mTimeFd_, sizeof(mTimeFd_), 0, sizeof(mTimeFd_)); - // (void)memset_s(&mEv_, sizeof(mEv_), 0, sizeof(mEv_)); - // (void)memset_s(mEvents_, sizeof(mEvents_), 0, sizeof(mEvents_)); mEpFd_ = 0; mTimerName_ = name; } @@ -59,8 +54,6 @@ DmTimerStatus DmTimer::Start(uint32_t timeOut, TimeoutHandle handle, void *data) } mStatus_ = DmTimerStatus::DM_STATUS_RUNNING; - // mThread_ = std::thread(&DmTimer::WiteforTimeout, this); - // mThread_.detach(); return mStatus_; } @@ -83,26 +76,6 @@ void DmTimer::Stop(int32_t code) void DmTimer::WiteforTimeout() { DMLOG(DM_LOG_INFO, "DmTimer %s start timer at (%d)s", mTimerName_.c_str(), mTimeOutSec_); - - // int32_t nfds = epoll_wait(mEpFd_, mEvents_, MAXEVENTS, mTimeOutSec_ * MILL_SECONDS_PER_SECOND); - // if (nfds < 0) { - // DMLOG(DM_LOG_ERROR, "DmTimer %s epoll_wait returned n=%d, error: %d", mTimerName_.c_str(), nfds, errno); - // } - - char event = 0; - // if (nfds > 0) { - // if (mEvents_[0].events & EPOLLIN) { - // int num = read(mTimeFd_[0], &event, 1); - // if (num > 0) { - // DMLOG(DM_LOG_INFO, "DmTimer %s exit with event %d", mTimerName_.c_str(), event); - // } else { - // DMLOG(DM_LOG_ERROR, "DmTimer %s exit with errno %d", mTimerName_.c_str(), errno); - // } - // } - // Release(); - // return; - // } - mHandle_(mHandleData_); Release(); @@ -113,23 +86,7 @@ void DmTimer::WiteforTimeout() int32_t DmTimer::CreateTimeFd() { DMLOG(DM_LOG_INFO, "DmTimer %s creatTimeFd", mTimerName_.c_str()); - int ret = 0; - - // ret = pipe(mTimeFd_); - // if (ret < 0) { - // DMLOG(DM_LOG_ERROR, "DmTimer %s CreateTimeFd fail:(%d) errno(%d)", mTimerName_.c_str(), ret, errno); - // return ret; - // } - - // mEv_.data.fd = mTimeFd_[0]; - // mEv_.events = EPOLLIN | EPOLLET; - // mEpFd_ = epoll_create(MAXEVENTS); - // ret = epoll_ctl(mEpFd_, EPOLL_CTL_ADD, mTimeFd_[0], &mEv_); - // if (ret != 0) { - // Release(); - // } - - return ret; + return 0; } void DmTimer::Release() diff --git a/test/unittest/UTTest_dm_device_state_manager.cpp b/test/unittest/UTTest_dm_device_state_manager.cpp index af0a2addaf096b8bf9b6444cee400e0810685ef2..725b0e44f8f2951efb473fc1eadc546e76416ca5 100644 --- a/test/unittest/UTTest_dm_device_state_manager.cpp +++ b/test/unittest/UTTest_dm_device_state_manager.cpp @@ -87,7 +87,7 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceOnline_001, testing::ext::TestSize.Le { std::string pkgName = "123"; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); dmDeviceStateManager->OnDeviceOnline(pkgName, info); std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); @@ -106,7 +106,7 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceOffline_001, testing::ext::TestSize.L { std::string pkgName; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); dmDeviceStateManager->OnDeviceOffline(pkgName, info); std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); @@ -125,7 +125,7 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_001, testing::ext::TestSize.L { std::string pkgName; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); dmDeviceStateManager->OnDeviceChanged(pkgName, info); std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); @@ -145,7 +145,7 @@ HWTEST_F(DmDeviceStateManagerTest, OnProfileReady_001, testing::ext::TestSize.Le std::string pkgName; std::string deviceId; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); dmDeviceStateManager->OnProfileReady(pkgName, deviceId); std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); @@ -164,7 +164,7 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceReady_001, testing::ext::TestSize.Lev { std::string pkgName; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); dmDeviceStateManager->OnDeviceReady(pkgName, info); std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); @@ -183,7 +183,7 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_002, testing::ext::TestSize.L { std::string pkgName; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); dmDeviceStateManager->OnDeviceChanged(pkgName, info); std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index c31bae3431bad61456ce272bb77e61a6507802fe..f03c4cd9b608c724b40fe241fb9020a157f5e646 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -66,8 +66,8 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0) instance->dmInterface_ = dmInterface; // 3. call ClientInit int ret = instance->ClientInit(); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is DM_OK + ASSERT_EQ(ret, DM_OK); } /** @@ -84,8 +84,8 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); // 3. call ClientInit int ret = instance->ClientInit(); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is DM_OK + ASSERT_EQ(ret, DM_OK); } /** @@ -109,8 +109,8 @@ HWTEST_F(IpcClientManagerTest, Init_001, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 4. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 5. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 5. check ret is DM_OK + ASSERT_EQ(ret, DM_OK); } /** diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index c3ff9a86af5a16ac1811da346c4b342dddfa9552..0a42bb6666a629be2e2cb0812f4578e40d5b1bb8 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -72,9 +72,8 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_001, testing::ext::TestSize.Level0) int code = 999; sptr instance = new IpcClientStub(); // 3. call IpcClientStub OnRemoteRequest with parameter - int32_t ret = instance->OnRemoteRequest(code, data, reply, option); - int32_t result = DM_OK; - if (ret != result) { + int32_t result = instance->OnRemoteRequest(code, data, reply, option); + if (result != DM_OK) { result = DM_FAILED; } // 4. check result is DM_FAILED @@ -106,7 +105,7 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) // 3. call IpcClientStub OnRemoteRequest with parameter int ret = instance->OnRemoteRequest(code, data, reply, option); // 4. check result is DM_OK - ASSERT_EQ(ret, DM_OK); + ASSERT_NE(ret, DM_OK); } /** @@ -115,7 +114,7 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) * set req is nullptr * set rsp is nullptr * 2. call IpcClientStub SendCmd with parameter - * 3. check result is DM_OK + * 3. check result is DM_IPC_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -130,7 +129,7 @@ HWTEST_F(IpcClientStubTest, SendCmd_001, testing::ext::TestSize.Level0) sptr instance = new IpcClientStub(); // 2. call IpcClientStub SendCmd with parameter int ret = instance->SendCmd(cmdCode, req, rsp); - // 3. check result is DM_OK + // 3. check result is DM_IPC_FAILED ASSERT_EQ(ret, DM_IPC_FAILED); } } // namespace diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index 9bd4cf34970f9798567968783cf8e56577dacfdb..1b25c056ecbc9d541d03f35c1362f56f455c5811 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -169,7 +169,7 @@ HWTEST_F(IpcServerStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) // 2. Call IpcServerStub OnRemoteRequest with param ret = IpcServerStub::GetInstance().OnRemoteRequest(code, data, reply, option); // 3. check ret not DM_OK - ASSERT_EQ(ret, DM_OK); + ASSERT_NE(ret, DM_OK); } /** diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index 740b4e8e03a3b621b7a15ea307dba9121f7dea3e..f1a1ad6abeb7f29226e0a394d10ec5c522348463 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -169,8 +169,6 @@ HWTEST_F(SoftbusConnectorTest, IsDeviceOnLine_001, testing::ext::TestSize.Level0 HWTEST_F(SoftbusConnectorTest, IsDeviceOnLine_002, testing::ext::TestSize.Level0) { std::string deviceId = "145677"; - NodeBasicInfo Info; - strncpy(Info.networkId, "145677", sizeof(Info.networkId)); bool ret = softbusConnector->IsDeviceOnLine(deviceId); EXPECT_EQ(ret, false); }