From ab5a40ad49a0b223ae2dee6ee481d585ed54ad50 Mon Sep 17 00:00:00 2001 From: l60055366 Date: Sat, 28 Dec 2024 14:36:37 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84ci=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- common/src/dm_anonymous.cpp | 20 +++++++++---------- .../UTTest_discovery_manager.cpp | 14 ++++++------- test/commonunittest/UTTest_dm_anonymous.cpp | 6 +++--- .../UTTest_softbus_listener.cpp | 20 +++++++++---------- .../UTTest_device_manager_service_impl.cpp | 12 +++++------ test/unittest/UTTest_dm_pin_holder.h | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 2ee4165d9..c1766bbb1 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -27,25 +27,25 @@ constexpr uint32_t MAX_ID_LEN = 256; std::string GetAnonyString(const std::string &value) { - const int32_t INT32_SHORT_ID_LENGTH = 20; - const int32_t INT32_PLAINTEXT_LENGTH = 4; - const int32_t INT32_MIN_ID_LENGTH = 3; + const int32_t int32ShortIdLength = 20; + const int32_t int32PlaintextLength = 4; + const int32_t int32MinIdLength = 3; std::string tmpStr("******"); size_t strLen = value.length(); - if (strLen < INT32_MIN_ID_LENGTH) { + if (strLen < int32MinIdLength) { return tmpStr; } std::string res; - if (strLen <= INT32_SHORT_ID_LENGTH) { + if (strLen <= int32ShortIdLength) { res += value[0]; res += tmpStr; res += value[strLen - 1]; } else { - res.append(value, 0, INT32_PLAINTEXT_LENGTH); + res.append(value, 0, int32PlaintextLength); res += tmpStr; - res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); + res.append(value, strLen - int32PlaintextLength, int32PlaintextLength); } return res; @@ -102,11 +102,11 @@ bool IsNumberString(const std::string &inputString) LOGE("inputString is Null or inputString length is too long"); return false; } - const int32_t MIN_ASCII_NUM = 48; - const int32_t MAX_ASCII_NUM = 57; + const int32_t minAsciiNum = 48; + const int32_t maxAsciiNum = 57; for (size_t i = 0; i < inputString.length(); i++) { int num = (int)inputString[i]; - if (num >= MIN_ASCII_NUM && num <= MAX_ASCII_NUM) { + if (num >= minAsciiNum && num <= maxAsciiNum) { continue; } else { return false; diff --git a/test/commonunittest/UTTest_discovery_manager.cpp b/test/commonunittest/UTTest_discovery_manager.cpp index 95f3f90eb..f1bde1034 100644 --- a/test/commonunittest/UTTest_discovery_manager.cpp +++ b/test/commonunittest/UTTest_discovery_manager.cpp @@ -50,7 +50,7 @@ namespace { std::shared_ptr listener = std::make_shared(); std::shared_ptr manager = std::make_shared(softbusListener, listener); -bool checkSoftbusRes(int32_t ret) +bool CheckSoftbusRes(int32_t ret) { return ret == SOFTBUS_INVALID_PARAM || ret == SOFTBUS_NETWORK_NOT_INIT || ret == SOFTBUS_NETWORK_LOOPER_ERR; } @@ -72,7 +72,7 @@ HWTEST_F(DiscoveryManagerTest, EnableDiscoveryListener_002, testing::ext::TestSi discoverParam.insert(std::pair("SUBSCRIBE_ID", "ohos.test")); std::map filterOptions; int32_t ret = manager->EnableDiscoveryListener(pkgName, discoverParam, filterOptions); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(DiscoveryManagerTest, EnableDiscoveryListener_003, testing::ext::TestSize.Level0) @@ -81,7 +81,7 @@ HWTEST_F(DiscoveryManagerTest, EnableDiscoveryListener_003, testing::ext::TestSi std::map discoverParam; std::map filterOptions; int32_t ret = manager->EnableDiscoveryListener(pkgName, discoverParam, filterOptions); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(DiscoveryManagerTest, DisableDiscoveryListener_001, testing::ext::TestSize.Level0) @@ -99,7 +99,7 @@ HWTEST_F(DiscoveryManagerTest, DisableDiscoveryListener_002, testing::ext::TestS extraParam.insert(std::pair("META_TYPE", "ohos.test")); extraParam.insert(std::pair("SUBSCRIBE_ID", "ohos.test")); int32_t ret = manager->DisableDiscoveryListener(pkgName, extraParam); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(DiscoveryManagerTest, DisableDiscoveryListener_003, testing::ext::TestSize.Level0) @@ -107,7 +107,7 @@ HWTEST_F(DiscoveryManagerTest, DisableDiscoveryListener_003, testing::ext::TestS std::string pkgName = "pkgName"; std::map extraParam; int32_t ret = manager->DisableDiscoveryListener(pkgName, extraParam); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(DiscoveryManagerTest, StartDiscovering_001, testing::ext::TestSize.Level0) @@ -129,7 +129,7 @@ HWTEST_F(DiscoveryManagerTest, StartDiscovering_002, testing::ext::TestSize.Leve discoverParam.insert(std::pair("FILTER_OPTIONS", "ohos.test")); std::map filterOptions; int32_t ret = manager->StartDiscovering(pkgName, discoverParam, filterOptions); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(DiscoveryManagerTest, StartDiscovering_003, testing::ext::TestSize.Level0) @@ -245,7 +245,7 @@ HWTEST_F(DiscoveryManagerTest, StopDiscovering_002, testing::ext::TestSize.Level DiscoveryContext context; manager->discoveryContextMap_.emplace(pkgName, context); int32_t ret = manager->StopDiscovering(pkgName, subscribeId); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(DiscoveryManagerTest, OnDeviceFound_001, testing::ext::TestSize.Level0) diff --git a/test/commonunittest/UTTest_dm_anonymous.cpp b/test/commonunittest/UTTest_dm_anonymous.cpp index d66adfad2..793878560 100644 --- a/test/commonunittest/UTTest_dm_anonymous.cpp +++ b/test/commonunittest/UTTest_dm_anonymous.cpp @@ -394,15 +394,15 @@ HWTEST_F(DmAnonymousTest, IsBool_002, testing::ext::TestSize.Level0) */ HWTEST_F(DmAnonymousTest, ConvertCharArray2String_001, testing::ext::TestSize.Level0) { - constexpr uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024; + constexpr uint32_t maxMessageLen = 40 * 1024 * 1024; char *srcData = nullptr; uint32_t srcLen = 0; std::string ret = ConvertCharArray2String(srcData, srcLen); EXPECT_EQ(ret, ""); - ret = ConvertCharArray2String(srcData, MAX_MESSAGE_LEN + 1); + ret = ConvertCharArray2String(srcData, maxMessageLen + 1); EXPECT_EQ(ret, ""); char srcData2[20] = {"1234"}; - ret = ConvertCharArray2String(srcData2, MAX_MESSAGE_LEN + 1); + ret = ConvertCharArray2String(srcData2, maxMessageLen + 1); EXPECT_EQ(ret, ""); uint32_t srcLen2 = 20; ret = ConvertCharArray2String(srcData2, srcLen); diff --git a/test/softbusunittest/UTTest_softbus_listener.cpp b/test/softbusunittest/UTTest_softbus_listener.cpp index 783bc0362..03f321cd8 100644 --- a/test/softbusunittest/UTTest_softbus_listener.cpp +++ b/test/softbusunittest/UTTest_softbus_listener.cpp @@ -48,7 +48,7 @@ void SoftbusListenerTest::TearDownTestCase() namespace { std::shared_ptr softbusListener = std::make_shared(); -bool checkSoftbusRes(int32_t ret) +bool CheckSoftbusRes(int32_t ret) { return ret == SOFTBUS_INVALID_PARAM || ret == SOFTBUS_NETWORK_NOT_INIT || ret == SOFTBUS_NETWORK_LOOPER_ERR || ret == SOFTBUS_IPC_ERR; @@ -262,7 +262,7 @@ HWTEST_F(SoftbusListenerTest, PublishSoftbusLNN_001, testing::ext::TestSize.Leve softbusListener = std::make_shared(); } int32_t ret = softbusListener->PublishSoftbusLNN(dmPubInfo, capability, customData); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, StopPublishSoftbusLNN_001, testing::ext::TestSize.Level0) @@ -272,7 +272,7 @@ HWTEST_F(SoftbusListenerTest, StopPublishSoftbusLNN_001, testing::ext::TestSize. softbusListener = std::make_shared(); } int32_t ret = softbusListener->StopPublishSoftbusLNN(publishId); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, RegisterSoftbusLnnOpsCbk_001, testing::ext::TestSize.Level0) @@ -315,7 +315,7 @@ HWTEST_F(SoftbusListenerTest, GetUdidByNetworkId_001, testing::ext::TestSize.Lev softbusListener = std::make_shared(); } int32_t ret = softbusListener->GetUdidByNetworkId(networkId.c_str(), udid); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, GetUuidByNetworkId_001, testing::ext::TestSize.Level0) @@ -326,7 +326,7 @@ HWTEST_F(SoftbusListenerTest, GetUuidByNetworkId_001, testing::ext::TestSize.Lev softbusListener = std::make_shared(); } int32_t ret = softbusListener->GetUuidByNetworkId(networkId.c_str(), udid); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, ConvertDeviceInfoToDmDevice_001, testing::ext::TestSize.Level0) @@ -789,7 +789,7 @@ HWTEST_F(SoftbusListenerTest, GetDeviceInfo_001, testing::ext::TestSize.Level0) softbusListener = std::make_shared(); } int32_t ret = softbusListener->GetDeviceInfo(networkId, info); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Level0) @@ -799,7 +799,7 @@ HWTEST_F(SoftbusListenerTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Lev softbusListener = std::make_shared(); } int32_t ret = softbusListener->GetLocalDeviceInfo(info); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, ConvertBytesToUpperCaseHexString_001, testing::ext::TestSize.Level0) @@ -998,7 +998,7 @@ HWTEST_F(SoftbusListenerTest, RefreshSoftbusLNN_001, testing::ext::TestSize.Leve type = NodeStatusType::TYPE_AUTH_STATUS; softbusListener->OnDeviceScreenStatusChanged(type, status); int32_t ret = softbusListener->RefreshSoftbusLNN(pkgName.c_str(), dmSubInfo, customData); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, StopRefreshSoftbusLNN_001, testing::ext::TestSize.Level0) @@ -1030,7 +1030,7 @@ HWTEST_F(SoftbusListenerTest, StopRefreshSoftbusLNN_001, testing::ext::TestSize. std::string deviceList2; deviceTypeId = 0xA2F; softbusListener->CredentialAuthStatusProcess(deviceList2, deviceTypeId, errcode); - EXPECT_EQ(true, checkSoftbusRes(ret)); + EXPECT_EQ(true, CheckSoftbusRes(ret)); } HWTEST_F(SoftbusListenerTest, GetNetworkIdByUdid_001, testing::ext::TestSize.Level0) @@ -1072,7 +1072,7 @@ HWTEST_F(SoftbusListenerTest, GetDeviceScreenStatus_001, testing::ext::TestSize. softbusListener = std::make_shared(); } int32_t ret = softbusListener->GetDeviceScreenStatus(networkId.c_str(), screenStatus); - EXPECT_TRUE(checkSoftbusRes(ret)); + EXPECT_TRUE(CheckSoftbusRes(ret)); softbusListener = nullptr; } diff --git a/test/unittest/UTTest_device_manager_service_impl.cpp b/test/unittest/UTTest_device_manager_service_impl.cpp index 1a85404c2..969ca2d97 100644 --- a/test/unittest/UTTest_device_manager_service_impl.cpp +++ b/test/unittest/UTTest_device_manager_service_impl.cpp @@ -31,7 +31,7 @@ void DeviceManagerServiceImplTest::SetUp() } deviceManagerServiceImpl_->Initialize(listener_); } -const std::string testID("111111"); +const std::string TEST_ID("111111"); void DeviceManagerServiceImplTest::TearDown() { @@ -840,7 +840,7 @@ HWTEST_F(DeviceManagerServiceImplTest, HandleOffline_002, testing::ext::TestSize { DmDeviceState devState = DmDeviceState::DEVICE_INFO_READY; DmDeviceInfo devInfo; - strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, testID.c_str()); + strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, TEST_ID.c_str()); devInfo.networkId[sizeof(devInfo.networkId) - 1] = '\0'; if (deviceManagerServiceImpl_ == nullptr) { deviceManagerServiceImpl_ = std::make_shared(); @@ -872,7 +872,7 @@ HWTEST_F(DeviceManagerServiceImplTest, HandleOnline_002, testing::ext::TestSize. { DmDeviceState devState = DmDeviceState::DEVICE_INFO_READY; DmDeviceInfo devInfo; - strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, testID.c_str()); + strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, TEST_ID.c_str()); devInfo.networkId[sizeof(devInfo.networkId) - 1] = '\0'; if (deviceManagerServiceImpl_ == nullptr) { deviceManagerServiceImpl_ = std::make_shared(); @@ -1302,7 +1302,7 @@ HWTEST_F(DeviceManagerServiceImplTest, ScreenCommonEventCallback_001, testing::e */ HWTEST_F(DeviceManagerServiceImplTest, HandleDeviceNotTrust_001, testing::ext::TestSize.Level0) { - std::string udid = testID; + std::string udid = TEST_ID; deviceManagerServiceImpl_->HandleDeviceNotTrust(udid); EXPECT_NE(deviceManagerServiceImpl_->authMgr_, nullptr); } @@ -1565,7 +1565,7 @@ HWTEST_F(DeviceManagerServiceImplTest, HandleOnline_003, testing::ext::TestSize. if (deviceManagerServiceImpl_->softbusConnector_ == nullptr) { deviceManagerServiceImpl_->Initialize(listener_); } - strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, testID.c_str()); + strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, TEST_ID.c_str()); devInfo.networkId[sizeof(devInfo.networkId) - 1] = '\0'; EXPECT_CALL(*softbusConnectorMock_, GetUdidByNetworkId(_, _)).WillOnce(Return(ERR_DM_FAILED)); deviceManagerServiceImpl_->HandleOnline(devState, devInfo); @@ -1605,7 +1605,7 @@ HWTEST_F(DeviceManagerServiceImplTest, HandleOffline_003, testing::ext::TestSize { DmDeviceState devState = DmDeviceState::DEVICE_INFO_READY; DmDeviceInfo devInfo; - strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, testID.c_str()); + strcpy_s(devInfo.networkId, sizeof(devInfo.networkId) - 1, TEST_ID.c_str()); devInfo.networkId[sizeof(devInfo.networkId) - 1] = '\0'; if (deviceManagerServiceImpl_->deviceStateMgr_ == nullptr) { deviceManagerServiceImpl_->Initialize(listener_); diff --git a/test/unittest/UTTest_dm_pin_holder.h b/test/unittest/UTTest_dm_pin_holder.h index 5fcd67186..28fac18aa 100644 --- a/test/unittest/UTTest_dm_pin_holder.h +++ b/test/unittest/UTTest_dm_pin_holder.h @@ -216,7 +216,7 @@ public: (void)processInfo; } - virtual void OnDevStateCallbackAdd(const ProcessInfo &processInfo, + void OnDevStateCallbackAdd(const ProcessInfo &processInfo, const std::vector &deviceList) override { (void)processInfo; -- Gitee From 331ac93299204f9fe0ca5ce6d2b1aa98d0885af4 Mon Sep 17 00:00:00 2001 From: l60055366 Date: Thu, 2 Jan 2025 17:10:48 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84ci=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- common/src/dm_anonymous.cpp | 21 +++++++++---------- .../UTTest_permission_manager.cpp | 10 ++++----- test/unittest/UTTest_dm_transport.cpp | 8 ++++++- test/unittest/UTTest_dm_transport.h | 5 ----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index c1766bbb1..0793e84da 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -23,29 +23,30 @@ constexpr uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024; constexpr uint32_t MAX_MAP_LEN = 1000; constexpr uint32_t MAX_INT_LEN = 20; constexpr uint32_t MAX_ID_LEN = 256; +constexpr int32_t INT32_SHORT_ID_LENGTH = 20; +constexpr int32_t INT32_PLAINTEXT_LENGTH = 4; +constexpr int32_t INT32_MIN_ID_LENGTH = 3; +constexpr int32_t MIN_ASCLL_NUM = 48; +constexpr int32_t MAX_ASCLL_NUM = 57; } std::string GetAnonyString(const std::string &value) { - const int32_t int32ShortIdLength = 20; - const int32_t int32PlaintextLength = 4; - const int32_t int32MinIdLength = 3; - std::string tmpStr("******"); size_t strLen = value.length(); - if (strLen < int32MinIdLength) { + if (strLen < INT32_MIN_ID_LENGTH) { return tmpStr; } std::string res; - if (strLen <= int32ShortIdLength) { + if (strLen <= INT32_SHORT_ID_LENGTH) { res += value[0]; res += tmpStr; res += value[strLen - 1]; } else { - res.append(value, 0, int32PlaintextLength); + res.append(value, 0, INT32_PLAINTEXT_LENGTH); res += tmpStr; - res.append(value, strLen - int32PlaintextLength, int32PlaintextLength); + res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); } return res; @@ -102,11 +103,9 @@ bool IsNumberString(const std::string &inputString) LOGE("inputString is Null or inputString length is too long"); return false; } - const int32_t minAsciiNum = 48; - const int32_t maxAsciiNum = 57; for (size_t i = 0; i < inputString.length(); i++) { int num = (int)inputString[i]; - if (num >= minAsciiNum && num <= maxAsciiNum) { + if (num >= MIN_ASCLL_NUM && num <= MAX_ASCLL_NUM) { continue; } else { return false; diff --git a/test/commonunittest/UTTest_permission_manager.cpp b/test/commonunittest/UTTest_permission_manager.cpp index 4c44794cc..58c043cbb 100644 --- a/test/commonunittest/UTTest_permission_manager.cpp +++ b/test/commonunittest/UTTest_permission_manager.cpp @@ -46,7 +46,7 @@ void PermissionManagerTest::SetUp() constexpr int32_t PAKAGE_NAME_SIZE_MAX = 256; #define SYSTEM_SA_WHITE_LIST_NUM (4) -constexpr const static char systemSaWhiteList[SYSTEM_SA_WHITE_LIST_NUM][PAKAGE_NAME_SIZE_MAX] = { +constexpr const static char SYSTEM_SA_WHITE_LIST[SYSTEM_SA_WHITE_LIST_NUM][PAKAGE_NAME_SIZE_MAX] = { "Samgr_Networking", "ohos.distributeddata.service", "ohos.dslm", @@ -116,16 +116,16 @@ HWTEST_F(PermissionManagerTest, CheckWhiteListSystemSA_001, testing::ext::TestSi */ HWTEST_F(PermissionManagerTest, CheckWhiteListSystemSA_002, testing::ext::TestSize.Level0) { - std::string pkgName1(systemSaWhiteList[0]); + std::string pkgName1(SYSTEM_SA_WHITE_LIST[0]); bool ret = PermissionManager::GetInstance().CheckWhiteListSystemSA(pkgName1); ASSERT_EQ(ret, true); - std::string pkgName2(systemSaWhiteList[1]); + std::string pkgName2(SYSTEM_SA_WHITE_LIST[1]); ret = PermissionManager::GetInstance().CheckWhiteListSystemSA(pkgName2); ASSERT_EQ(ret, true); - std::string pkgName3(systemSaWhiteList[2]); + std::string pkgName3(SYSTEM_SA_WHITE_LIST[2]); ret = PermissionManager::GetInstance().CheckWhiteListSystemSA(pkgName3); ASSERT_EQ(ret, true); - std::string pkgName4(systemSaWhiteList[3]); + std::string pkgName4(SYSTEM_SA_WHITE_LIST[3]); ret = PermissionManager::GetInstance().CheckWhiteListSystemSA(pkgName4); ASSERT_EQ(ret, true); } diff --git a/test/unittest/UTTest_dm_transport.cpp b/test/unittest/UTTest_dm_transport.cpp index 534d17d7f..00f7e2fb0 100644 --- a/test/unittest/UTTest_dm_transport.cpp +++ b/test/unittest/UTTest_dm_transport.cpp @@ -30,7 +30,12 @@ void DMTransportTest::TearDownTestCase() { } -/** +namespace { +constexpr int32_t ERR_DM_FAILED = 96929744; +constexpr int32_t ERR_DM_INPUT_PARA_INVALID = 96929749; +constexpr uint32_t MAX_SEND_MSG_LENGTH = 4 * 1024 * 1024; +constexpr int32_t DM_OK = 0; + /** * @tc.name: CreateClientSocket_InvalidInput * @tc.type: FUNC */ @@ -203,5 +208,6 @@ HWTEST_F(DMTransportTest, Send_SessionNotOpened_Failure, testing::ext::TestSize. int32_t result = dmTransport.Send(notOpenedId, payload, 0); EXPECT_EQ(result, ERR_DM_FAILED); } +} } // DistributedHardware } // OHOS \ No newline at end of file diff --git a/test/unittest/UTTest_dm_transport.h b/test/unittest/UTTest_dm_transport.h index fcfebeb98..2e2bbd5b5 100644 --- a/test/unittest/UTTest_dm_transport.h +++ b/test/unittest/UTTest_dm_transport.h @@ -35,11 +35,6 @@ protected: std::shared_ptr dmCommTool; std::shared_ptr dmCommToolPtr = std::make_shared(); DMTransport dmTransport = DMTransport(dmCommToolPtr); - - int32_t ERR_DM_FAILED = 96929744; - int32_t ERR_DM_INPUT_PARA_INVALID = 96929749; - uint32_t MAX_SEND_MSG_LENGTH = 4 * 1024 * 1024; - int32_t DM_OK = 0; }; } // namespace DistributedHardware } // namespace OHOS -- Gitee From be285483f82d383ac199ab82acfdd28d5c92f8d0 Mon Sep 17 00:00:00 2001 From: l60055366 Date: Thu, 2 Jan 2025 17:15:43 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84ci=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- common/src/dm_anonymous.cpp | 6 +++--- test/commonunittest/UTTest_dm_anonymous.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 0793e84da..96800eb69 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -26,8 +26,8 @@ constexpr uint32_t MAX_ID_LEN = 256; constexpr int32_t INT32_SHORT_ID_LENGTH = 20; constexpr int32_t INT32_PLAINTEXT_LENGTH = 4; constexpr int32_t INT32_MIN_ID_LENGTH = 3; -constexpr int32_t MIN_ASCLL_NUM = 48; -constexpr int32_t MAX_ASCLL_NUM = 57; +constexpr int32_t MIN_ASCII_NUM = 48; +constexpr int32_t MAX_ASCII_NUM = 57; } std::string GetAnonyString(const std::string &value) @@ -105,7 +105,7 @@ bool IsNumberString(const std::string &inputString) } for (size_t i = 0; i < inputString.length(); i++) { int num = (int)inputString[i]; - if (num >= MIN_ASCLL_NUM && num <= MAX_ASCLL_NUM) { + if (num >= MIN_ASCII_NUM && num <= MAX_ASCII_NUM) { continue; } else { return false; diff --git a/test/commonunittest/UTTest_dm_anonymous.cpp b/test/commonunittest/UTTest_dm_anonymous.cpp index 793878560..42a08cd6c 100644 --- a/test/commonunittest/UTTest_dm_anonymous.cpp +++ b/test/commonunittest/UTTest_dm_anonymous.cpp @@ -32,6 +32,7 @@ void DmAnonymousTest::TearDownTestCase() } namespace { +constexpr uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024; /** * @tc.name: GetAnonyString_001 * @tc.desc: Return size of anony string @@ -394,15 +395,14 @@ HWTEST_F(DmAnonymousTest, IsBool_002, testing::ext::TestSize.Level0) */ HWTEST_F(DmAnonymousTest, ConvertCharArray2String_001, testing::ext::TestSize.Level0) { - constexpr uint32_t maxMessageLen = 40 * 1024 * 1024; char *srcData = nullptr; uint32_t srcLen = 0; std::string ret = ConvertCharArray2String(srcData, srcLen); EXPECT_EQ(ret, ""); - ret = ConvertCharArray2String(srcData, maxMessageLen + 1); + ret = ConvertCharArray2String(srcData, MAX_MESSAGE_LEN + 1); EXPECT_EQ(ret, ""); char srcData2[20] = {"1234"}; - ret = ConvertCharArray2String(srcData2, maxMessageLen + 1); + ret = ConvertCharArray2String(srcData2, MAX_MESSAGE_LEN + 1); EXPECT_EQ(ret, ""); uint32_t srcLen2 = 20; ret = ConvertCharArray2String(srcData2, srcLen); -- Gitee From 935dcf68e89bcd01eb04ffde18aec31b893bcc8e Mon Sep 17 00:00:00 2001 From: l60055366 Date: Thu, 2 Jan 2025 17:17:14 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84ci=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- common/src/dm_anonymous.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 96800eb69..bb4fa5c3a 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -105,7 +105,7 @@ bool IsNumberString(const std::string &inputString) } for (size_t i = 0; i < inputString.length(); i++) { int num = (int)inputString[i]; - if (num >= MIN_ASCII_NUM && num <= MAX_ASCII_NUM) { + if (num >= MIN_ASCII_NUM && num <= MAX_ASCII_NUM) { continue; } else { return false; -- Gitee From 6e036c5adca7d6d11f3d1075c079dda9156b6774 Mon Sep 17 00:00:00 2001 From: l60055366 Date: Thu, 2 Jan 2025 17:18:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84ci=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- test/unittest/UTTest_dm_transport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/UTTest_dm_transport.cpp b/test/unittest/UTTest_dm_transport.cpp index 00f7e2fb0..204518c84 100644 --- a/test/unittest/UTTest_dm_transport.cpp +++ b/test/unittest/UTTest_dm_transport.cpp @@ -35,7 +35,7 @@ constexpr int32_t ERR_DM_FAILED = 96929744; constexpr int32_t ERR_DM_INPUT_PARA_INVALID = 96929749; constexpr uint32_t MAX_SEND_MSG_LENGTH = 4 * 1024 * 1024; constexpr int32_t DM_OK = 0; - /** +/** * @tc.name: CreateClientSocket_InvalidInput * @tc.type: FUNC */ -- Gitee From 3820299b85ccaa76d14387991839d678e0c8919a Mon Sep 17 00:00:00 2001 From: l60055366 Date: Thu, 2 Jan 2025 18:00:13 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84ci=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l60055366 --- test/unittest/UTTest_dm_transport.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unittest/UTTest_dm_transport.cpp b/test/unittest/UTTest_dm_transport.cpp index 204518c84..0f372df1a 100644 --- a/test/unittest/UTTest_dm_transport.cpp +++ b/test/unittest/UTTest_dm_transport.cpp @@ -33,7 +33,6 @@ void DMTransportTest::TearDownTestCase() namespace { constexpr int32_t ERR_DM_FAILED = 96929744; constexpr int32_t ERR_DM_INPUT_PARA_INVALID = 96929749; -constexpr uint32_t MAX_SEND_MSG_LENGTH = 4 * 1024 * 1024; constexpr int32_t DM_OK = 0; /** * @tc.name: CreateClientSocket_InvalidInput -- Gitee