diff --git a/test/unittest/UTTest_auth_request_state.cpp b/test/unittest/UTTest_auth_request_state.cpp index 95c67b7a..ff0249f9 100644 --- a/test/unittest/UTTest_auth_request_state.cpp +++ b/test/unittest/UTTest_auth_request_state.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_auth_request_state.h b/test/unittest/UTTest_auth_request_state.h index 11896312..c32fcebc 100644 --- a/test/unittest/UTTest_auth_request_state.h +++ b/test/unittest/UTTest_auth_request_state.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_auth_response_state.cpp b/test/unittest/UTTest_auth_response_state.cpp index a1203f79..e4dea530 100644 --- a/test/unittest/UTTest_auth_response_state.cpp +++ b/test/unittest/UTTest_auth_response_state.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_auth_response_state.h b/test/unittest/UTTest_auth_response_state.h index 270e5caf..ba8ff298 100644 --- a/test/unittest/UTTest_auth_response_state.h +++ b/test/unittest/UTTest_auth_response_state.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index dca38cab..9442ac7c 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_device_manager_service.h b/test/unittest/UTTest_device_manager_service.h index 66143efc..fb3177e2 100644 --- a/test/unittest/UTTest_device_manager_service.h +++ b/test/unittest/UTTest_device_manager_service.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_device_manager_service_listener.cpp b/test/unittest/UTTest_device_manager_service_listener.cpp index 95e960fa..ae66dea1 100644 --- a/test/unittest/UTTest_device_manager_service_listener.cpp +++ b/test/unittest/UTTest_device_manager_service_listener.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_device_manager_service_listener.h b/test/unittest/UTTest_device_manager_service_listener.h index 47049207..f73024a9 100644 --- a/test/unittest/UTTest_device_manager_service_listener.h +++ b/test/unittest/UTTest_device_manager_service_listener.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -20,7 +20,6 @@ #include #include - #include #include "device_manager_service_listener.h" diff --git a/test/unittest/UTTest_device_message.cpp b/test/unittest/UTTest_device_message.cpp index a6d928af..15800fbc 100644 --- a/test/unittest/UTTest_device_message.cpp +++ b/test/unittest/UTTest_device_message.cpp @@ -50,7 +50,7 @@ HWTEST_F(AuthMessageProcessorTest, CreateNegotiateMessage_001, testing::ext::Tes std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); int32_t msgType = MSG_TYPE_NEGOTIATE; nlohmann::json jsonObj; jsonObj[TAG_VER] = DM_ITF_VER; @@ -78,12 +78,12 @@ HWTEST_F(AuthMessageProcessorTest, CreateSyncGroupMessage_001, testing::ext::Tes std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); - authMessageProcessor->authRequestContext_= std::make_shared(); + std::shared_ptr authMessageProcessor = std::make_shared(data); + authMessageProcessor->authRequestContext_ = std::make_shared(); nlohmann::json jsona; nlohmann::json jsonObj; authMessageProcessor->authRequestContext_->deviceId = "132416546"; - std::vector syncGroupList ; + std::vector syncGroupList; syncGroupList.push_back("1111"); authMessageProcessor->authRequestContext_->syncGroupList = syncGroupList; jsona[TAG_DEVICE_ID] = authMessageProcessor->authRequestContext_->deviceId; @@ -106,7 +106,7 @@ HWTEST_F(AuthMessageProcessorTest, CreateResponseAuthMessage_001, testing::ext:: std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsona; nlohmann::json jsonObj; @@ -144,11 +144,11 @@ HWTEST_F(AuthMessageProcessorTest, CreateResponseFinishMessage_001, testing::ext std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsona; nlohmann::json jsonObj; - authMessageProcessor->authResponseContext_->reply= 1; + authMessageProcessor->authResponseContext_->reply = 1; jsona[TAG_REPLY] = authMessageProcessor->authResponseContext_->reply; authMessageProcessor->CreateResponseFinishMessage(jsonObj); std::string str1 = jsona.dump(); @@ -168,9 +168,9 @@ HWTEST_F(AuthMessageProcessorTest, ParseResponseFinishMessage_001, testing::ext: std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); - std::shared_ptr authResponseContext= std::make_shared(); - authMessageProcessor->authResponseContext_= std::make_shared(); + std::shared_ptr authMessageProcessor = std::make_shared(data); + std::shared_ptr authResponseContext = std::make_shared(); + authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsonObj; authMessageProcessor->authResponseContext_->reply = 1; jsonObj[TAG_REPLY] = authMessageProcessor->authResponseContext_->reply; @@ -191,7 +191,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthResponseMessage_001, testing::ext::T std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); nlohmann::json jsona; authResponseContext->reply = 0; @@ -225,7 +225,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_001, testing::ext::Te std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->SetResponseContext(authResponseContext); nlohmann::json json; @@ -241,7 +241,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_001, testing::ext::Te jsonThumbnail[TAG_REPLY] = authResponseContext->reply; jsonThumbnail[TAG_AUTH_TYPE] = authResponseContext->authType; jsonThumbnail[TAG_NET_ID] = authResponseContext->networkId; - jsonThumbnail[TAG_GROUP_ID] = authResponseContext->groupId ; + jsonThumbnail[TAG_GROUP_ID] = authResponseContext->groupId; jsonThumbnail[TAG_GROUP_NAME] = authResponseContext->groupName; jsonThumbnail[TAG_REQUEST_ID] = authResponseContext->requestId; authMessageProcessor->authSplitJsonList_.push_back(jsonThumbnail); @@ -261,7 +261,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_002, testing::ext::Te std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->SetResponseContext(authResponseContext); nlohmann::json json; @@ -277,7 +277,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_002, testing::ext::Te jsonThumbnail[TAG_REPLY] = authResponseContext->reply; jsonThumbnail[TAG_AUTH_TYPE] = authResponseContext->authType; jsonThumbnail[TAG_NET_ID] = authResponseContext->networkId; - jsonThumbnail[TAG_GROUP_ID] = authResponseContext->groupId ; + jsonThumbnail[TAG_GROUP_ID] = authResponseContext->groupId; jsonThumbnail[TAG_GROUP_NAME] = authResponseContext->groupName; jsonThumbnail[TAG_REQUEST_ID] = authResponseContext->requestId; authMessageProcessor->authSplitJsonList_.push_back(jsonThumbnail); @@ -297,11 +297,11 @@ HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_001, testing::ext::Test std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsonObj; - jsonObj[TAG_CRYPTO_SUPPORT]="CRYPTOSUPPORT"; + jsonObj[TAG_CRYPTO_SUPPORT] = "CRYPTOSUPPORT"; jsonObj[TAG_CRYPTO_SUPPORT] = authMessageProcessor->authResponseContext_->cryptoSupport; authMessageProcessor->SetResponseContext(authResponseContext); authMessageProcessor->ParseNegotiateMessage(jsonObj); @@ -320,11 +320,11 @@ HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_002, testing::ext::Test std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsonObj; - jsonObj[TAG_CRYPTO_NAME]="CRYPTONAME"; + jsonObj[TAG_CRYPTO_NAME] = "CRYPTONAME"; jsonObj[TAG_CRYPTO_NAME] = authResponseContext->cryptoSupport; authMessageProcessor->SetResponseContext(authResponseContext); authMessageProcessor->ParseNegotiateMessage(jsonObj); @@ -343,11 +343,11 @@ HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_003, testing::ext::Test std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsonObj; - jsonObj[TAG_CRYPTO_VERSION]="CRYPTOVERSION"; + jsonObj[TAG_CRYPTO_VERSION] = "CRYPTOVERSION"; jsonObj[TAG_CRYPTO_VERSION] = authResponseContext->cryptoSupport; authMessageProcessor->SetResponseContext(authResponseContext); authMessageProcessor->ParseNegotiateMessage(jsonObj); @@ -366,11 +366,11 @@ HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_004, testing::ext::Test std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsonObj; - jsonObj[TAG_DEVICE_ID]="DEVICEID"; + jsonObj[TAG_DEVICE_ID] = "DEVICEID"; jsonObj[TAG_DEVICE_ID] = authResponseContext->deviceId; authMessageProcessor->SetResponseContext(authResponseContext); authMessageProcessor->ParseNegotiateMessage(jsonObj); @@ -389,11 +389,11 @@ HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_005, testing::ext::Test std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr data = std::make_shared(softbusConnector, listener); - std::shared_ptr authMessageProcessor= std::make_shared(data); + std::shared_ptr authMessageProcessor = std::make_shared(data); std::shared_ptr authResponseContext = std::make_shared(); authMessageProcessor->authResponseContext_ = std::make_shared(); nlohmann::json jsonObj; - jsonObj[TAG_LOCAL_DEVICE_ID]="LOCALDEVICEID"; + jsonObj[TAG_LOCAL_DEVICE_ID] = "LOCALDEVICEID"; jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId; authMessageProcessor->SetResponseContext(authResponseContext); authMessageProcessor->ParseNegotiateMessage(jsonObj); @@ -504,10 +504,10 @@ HWTEST_F(AuthMessageProcessorTest, GetResponseContext_002, testing::ext::TestSiz std::shared_ptr data = std::make_shared(softbusConnector, listener); std::shared_ptr authMessageProcessor = std::make_shared(data); authMessageProcessor->authResponseContext_ = std::make_shared(); - std::shared_ptr authResponseContext = authMessageProcessor->GetResponseContext(); + std::shared_ptr authResponseContext = authMessageProcessor->GetResponseContext(); ASSERT_NE(authResponseContext, nullptr); sleep(15); } -} -} -} +} // namespace +} // namespace DistributedHardware +} // namespace OHOS diff --git a/test/unittest/UTTest_device_message.h b/test/unittest/UTTest_device_message.h index 1e6e647f..9e9bf0b8 100644 --- a/test/unittest/UTTest_device_message.h +++ b/test/unittest/UTTest_device_message.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -31,6 +31,6 @@ public: virtual void SetUp() override; virtual void TearDown() override; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif // OHOS_DEVICE_MESSAGE_TEST_H \ No newline at end of file diff --git a/test/unittest/UTTest_dm_auth_manager.cpp b/test/unittest/UTTest_dm_auth_manager.cpp index 03791758..090b642f 100644 --- a/test/unittest/UTTest_dm_auth_manager.cpp +++ b/test/unittest/UTTest_dm_auth_manager.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -38,11 +38,11 @@ void DmAuthManagerTest::TearDownTestCase() } namespace { - std::string AUTHENTICATE_TIMEOUT_TASK = "authenticateTimeoutTask"; - std::string NEGOTIATE_TIMEOUT_TASK = "negotiateTimeoutTask"; - std::string CONFIRM_TIMEOUT_TASK = "confirmTimeoutTask"; - std::string INPUT_TIMEOUT_TASK = "inputTimeoutTask"; - std::string ADD_TIMEOUT_TASK = "addTimeoutTask"; +std::string AUTHENTICATE_TIMEOUT_TASK = "authenticateTimeoutTask"; +std::string NEGOTIATE_TIMEOUT_TASK = "negotiateTimeoutTask"; +std::string CONFIRM_TIMEOUT_TASK = "confirmTimeoutTask"; +std::string INPUT_TIMEOUT_TASK = "inputTimeoutTask"; +std::string ADD_TIMEOUT_TASK = "addTimeoutTask"; /** * @tc.name: DmAuthManager::AuthenticateDevice_001 @@ -129,7 +129,7 @@ HWTEST_F(DmAuthManagerTest, AuthenticateDevice_004, testing::ext::TestSize.Level int32_t authType = 4; const std::string deviceId = "222"; const std::string extra = "targetPkgName"; - authRequestContext->targetPkgName = "targetPkgName"; + authRequestContext->targetPkgName = "targetPkgName"; int32_t ret = authManager->AuthenticateDevice(pkgName, authType, deviceId, extra); ASSERT_EQ(ret, DM_INPUT_PARA_EMPTY); } @@ -152,8 +152,8 @@ HWTEST_F(DmAuthManagerTest, AuthenticateDevice_005, testing::ext::TestSize.Level int32_t authType = 1; const std::string deviceId = "222"; const std::string extra = "targetPkgName"; - authRequestContext->targetPkgName = "targetPkgName"; - json[TARGET_PKG_NAME_KEY] = authRequestContext->targetPkgName; + authRequestContext->targetPkgName = "targetPkgName"; + json[TARGET_PKG_NAME_KEY] = authRequestContext->targetPkgName; int32_t ret = authManager->AuthenticateDevice(pkgName, authType, deviceId, extra); ASSERT_EQ(ret, DM_OK); } @@ -176,8 +176,8 @@ HWTEST_F(DmAuthManagerTest, AuthenticateDevice_006, testing::ext::TestSize.Level int32_t authType = 1; const std::string deviceId = "222"; const std::string extra = "appName"; - authRequestContext->targetPkgName = "appName"; - json[APP_NAME_KEY] = authRequestContext->targetPkgName; + authRequestContext->targetPkgName = "appName"; + json[APP_NAME_KEY] = authRequestContext->targetPkgName; int32_t ret = authManager->AuthenticateDevice(pkgName, authType, deviceId, extra); ASSERT_EQ(ret, DM_OK); } @@ -200,8 +200,8 @@ HWTEST_F(DmAuthManagerTest, AuthenticateDevice_007, testing::ext::TestSize.Level int32_t authType = 1; const std::string deviceId = "222"; const std::string extra = "appDescription"; - authRequestContext->targetPkgName = "appDescription"; - json[APP_DESCRIPTION_KEY] = authRequestContext->targetPkgName; + authRequestContext->targetPkgName = "appDescription"; + json[APP_DESCRIPTION_KEY] = authRequestContext->targetPkgName; int32_t ret = authManager->AuthenticateDevice(pkgName, authType, deviceId, extra); ASSERT_EQ(ret, DM_OK); } @@ -224,8 +224,8 @@ HWTEST_F(DmAuthManagerTest, AuthenticateDevice_008, testing::ext::TestSize.Level int32_t authType = 1; const std::string deviceId = "222"; const std::string extra = "appThumbnail"; - authRequestContext->targetPkgName = "appThumbnail"; - json[APP_THUMBNAIL] = authRequestContext->targetPkgName; + authRequestContext->targetPkgName = "appThumbnail"; + json[APP_THUMBNAIL] = authRequestContext->targetPkgName; int32_t ret = authManager->AuthenticateDevice(pkgName, authType, deviceId, extra); ASSERT_EQ(ret, DM_OK); } @@ -248,8 +248,8 @@ HWTEST_F(DmAuthManagerTest, AuthenticateDevice_009, testing::ext::TestSize.Level int32_t authType = 1; const std::string deviceId = "222"; const std::string extra = "appIcon"; - authRequestContext->targetPkgName = "appIcon"; - json[APP_ICON_KEY] = authRequestContext->targetPkgName; + authRequestContext->targetPkgName = "appIcon"; + json[APP_ICON_KEY] = authRequestContext->targetPkgName; int32_t ret = authManager->AuthenticateDevice(pkgName, authType, deviceId, extra); ASSERT_EQ(ret, DM_OK); } @@ -290,7 +290,7 @@ HWTEST_F(DmAuthManagerTest, VerifyAuthentication_001, testing::ext::TestSize.Lev authManager->authResponseContext_ = std::make_shared(); authManager->authRequestContext_ = std::make_shared(); authManager->authRequestState_ = std::make_shared(); - authManager->authResponseContext_=nullptr; + authManager->authResponseContext_ = nullptr; authManager->SetAuthRequestState(authRequestState); int32_t ret = authManager->HandleAuthenticateTimeout(); ASSERT_EQ(ret, DM_FAILED); @@ -311,7 +311,7 @@ HWTEST_F(DmAuthManagerTest, HandleAuthenticateTimeout_001, testing::ext::TestSiz authManager->authResponseContext_ = std::make_shared(); authManager->authRequestContext_ = std::make_shared(); authManager->authRequestState_ = std::make_shared(); - authManager->authResponseContext_=nullptr; + authManager->authResponseContext_ = nullptr; authManager->SetAuthRequestState(authRequestState); int32_t ret = authManager->HandleAuthenticateTimeout(); ASSERT_EQ(ret, DM_FAILED); @@ -373,11 +373,12 @@ HWTEST_F(DmAuthManagerTest, SendAuthRequest_001, testing::ext::TestSize.Level0) std::shared_ptr negotiateStartTimer = std::make_shared(NEGOTIATE_TIMEOUT_TASK); authManager->timerMap_[NEGOTIATE_TIMEOUT_TASK] = negotiateStartTimer; authManager->authMessageProcessor_ = std::make_shared(authManager); - authManager->authResponseContext_ = std::make_shared();; + authManager->authResponseContext_ = std::make_shared(); + ; authManager->authRequestState_ = std::make_shared(); authManager->authResponseContext_->cryptoSupport = true; authManager->SetAuthRequestState(authRequestState); - int32_t sessionId=1; + int32_t sessionId = 1; int32_t ret = authManager->SendAuthRequest(sessionId); ASSERT_EQ(ret, DM_FAILED); } @@ -420,7 +421,7 @@ HWTEST_F(DmAuthManagerTest, StartAuthProcess_002, testing::ext::TestSize.Level0) authManager->authResponseState_ = std::make_shared(); authManager->authMessageProcessor_ = std::make_shared(authManager); authManager->SetAuthResponseState(authResponseState); - authManager->authResponseContext_->sessionId=111; + authManager->authResponseContext_->sessionId = 111; int32_t action = 1; int32_t ret = authManager->StartAuthProcess(action); ASSERT_EQ(ret, DM_OK); @@ -444,8 +445,8 @@ HWTEST_F(DmAuthManagerTest, CreateGroup_001, testing::ext::TestSize.Level0) authManager->authResponseState_ = std::make_shared(); authManager->authMessageProcessor_ = std::make_shared(authManager); authManager->SetAuthResponseState(authResponseState); - authManager->authResponseContext_->requestId=111; - authManager->authResponseContext_->groupName="111"; + authManager->authResponseContext_->requestId = 111; + authManager->authResponseContext_->groupName = "111"; int32_t action = 1; int32_t ret = authManager->StartAuthProcess(action); ASSERT_EQ(ret, DM_OK); @@ -470,11 +471,11 @@ HWTEST_F(DmAuthManagerTest, AddMember_001, testing::ext::TestSize.Level0) authManager->authMessageProcessor_ = std::make_shared(authManager); authManager->authResponseContext_ = std::make_shared(); nlohmann::json jsonObject; - authManager->authResponseContext_->groupId="111"; - authManager->authResponseContext_->groupName="222"; - authManager->authResponseContext_->code=123; - authManager->authResponseContext_->requestId=234; - authManager->authResponseContext_->deviceId="234"; + authManager->authResponseContext_->groupId = "111"; + authManager->authResponseContext_->groupName = "222"; + authManager->authResponseContext_->code = 123; + authManager->authResponseContext_->requestId = 234; + authManager->authResponseContext_->deviceId = "234"; jsonObject[TAG_GROUP_ID] = authManager->authResponseContext_->groupId; jsonObject[TAG_GROUP_NAME] = authManager->authResponseContext_->groupName; jsonObject[PIN_CODE_KEY] = authManager->authResponseContext_->code; @@ -556,10 +557,11 @@ HWTEST_F(DmAuthManagerTest, GetPinCode_001, testing::ext::TestSize.Level0) std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr authManager = std::make_shared(softbusConnector, listener); - authManager->authResponseContext_ = std::make_shared();; + authManager->authResponseContext_ = std::make_shared(); + ; int32_t ret = authManager->GetPinCode(); ASSERT_EQ(ret, authManager->authResponseContext_->code); } -} -} -} +} // namespace +} // namespace DistributedHardware +} // namespace OHOS diff --git a/test/unittest/UTTest_dm_auth_manager.h b/test/unittest/UTTest_dm_auth_manager.h index 19952e4f..179b2ae2 100644 --- a/test/unittest/UTTest_dm_auth_manager.h +++ b/test/unittest/UTTest_dm_auth_manager.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #ifndef OHOS_DM_AUTH_MANAGER_TEST_H #define OHOS_DM_AUTH_MANAGER_TEST_H @@ -35,7 +35,7 @@ namespace OHOS { namespace DistributedHardware { -class DmAuthManagerTest : public testing::Test { +class DmAuthManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); diff --git a/test/unittest/UTTest_dm_device_info_manager.cpp b/test/unittest/UTTest_dm_device_info_manager.cpp index 78eb44e8..5dedde90 100644 --- a/test/unittest/UTTest_dm_device_info_manager.cpp +++ b/test/unittest/UTTest_dm_device_info_manager.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_dm_device_info_manager.h b/test/unittest/UTTest_dm_device_info_manager.h index ea6f69e2..2af71bfb 100644 --- a/test/unittest/UTTest_dm_device_info_manager.h +++ b/test/unittest/UTTest_dm_device_info_manager.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_dm_device_state_manager.cpp b/test/unittest/UTTest_dm_device_state_manager.cpp index d2e15740..ab9ba753 100644 --- a/test/unittest/UTTest_dm_device_state_manager.cpp +++ b/test/unittest/UTTest_dm_device_state_manager.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include "dm_log.h" #include "dm_constants.h" @@ -27,25 +27,26 @@ namespace OHOS { namespace DistributedHardware { -void DmDeviceStateManagerTest::SetUp() +void DmDeviceStateManagerTest::SetUp() { } -void DmDeviceStateManagerTest::TearDown() +void DmDeviceStateManagerTest::TearDown() { } -void DmDeviceStateManagerTest::SetUpTestCase() +void DmDeviceStateManagerTest::SetUpTestCase() { } -void DmDeviceStateManagerTest::TearDownTestCase() +void DmDeviceStateManagerTest::TearDownTestCase() { } namespace { -std::shared_ptr softbusConnector = std::make_shared(); +std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener_ = std::make_shared(); -std::shared_ptr dmDeviceStateManager = std::make_shared(softbusConnector, listener_); +std::shared_ptr dmDeviceStateManager = + std::make_shared(softbusConnector, listener_); /** * @tc.name: DmDeviceStateManager_001 @@ -53,7 +54,7 @@ std::shared_ptr dmDeviceStateManager = std::make_shared p = std::make_shared(softbusConnector, listener_); ASSERT_NE(p, nullptr); @@ -65,7 +66,7 @@ HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_001, testing::ext::TestS * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_002, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_002, testing::ext::TestSize.Level0) { std::shared_ptr p = std::make_shared(softbusConnector, listener_); p.reset(); @@ -74,17 +75,18 @@ HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_002, testing::ext::TestS /** * @tc.name: OnDeviceOnline_001 - * @tc.desc: set info.deviceId to some para, and return it + * @tc.desc: set info.deviceId to some para, and return it * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, OnDeviceOnline_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, OnDeviceOnline_001, testing::ext::TestSize.Level0) { std::string pkgName = "123"; - DmDeviceInfo info ; - strncpy (info.deviceId, "123", sizeof(info.deviceId)); + DmDeviceInfo info; + strncpy(info.deviceId, "123", sizeof(info.deviceId)); dmDeviceStateManager->OnDeviceOnline(pkgName, info); - std::shared_ptr pReq = std::static_pointer_cast (listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); DmDeviceInfo ret = pReq->GetDeviceInfo(); int result = strcmp(info.deviceId, ret.deviceId); EXPECT_EQ(result, 0); @@ -92,17 +94,18 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceOnline_001, testing::ext::TestSize.Le /** * @tc.name: OnDeviceOffline_001 - * @tc.desc: set info.deviceId to some para, and return it + * @tc.desc: set info.deviceId to some para, and return it * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, OnDeviceOffline_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, OnDeviceOffline_001, testing::ext::TestSize.Level0) { std::string pkgName; DmDeviceInfo info; strncpy(info.deviceId, "123", sizeof(info.deviceId)); dmDeviceStateManager->OnDeviceOffline(pkgName, info); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); DmDeviceInfo ret = pReq->GetDeviceInfo(); int result = strcmp(info.deviceId, ret.deviceId); EXPECT_EQ(result, 0); @@ -110,17 +113,18 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceOffline_001, testing::ext::TestSize.L /** * @tc.name: OnDeviceChanged_001 - * @tc.desc: set info.deviceId to some para, and return it + * @tc.desc: set info.deviceId to some para, and return it * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_001, testing::ext::TestSize.Level0) { std::string pkgName; - DmDeviceInfo info ; - strncpy (info.deviceId, "123", sizeof(info.deviceId)); + DmDeviceInfo info; + strncpy(info.deviceId, "123", sizeof(info.deviceId)); dmDeviceStateManager->OnDeviceChanged(pkgName, info); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); DmDeviceInfo ret = pReq->GetDeviceInfo(); int result = strcmp(info.deviceId, ret.deviceId); EXPECT_EQ(result, 0); @@ -128,18 +132,19 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_001, testing::ext::TestSize.L /** * @tc.name: OnDeviceReady_001 - * @tc.desc: set info.deviceId to some para, and return it + * @tc.desc: set info.deviceId to some para, and return it * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, OnProfileReady_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, OnProfileReady_001, testing::ext::TestSize.Level0) { std::string pkgName; std::string deviceId; - DmDeviceInfo info ; - strncpy (info.deviceId, "123", sizeof(info.deviceId)); + DmDeviceInfo info; + strncpy(info.deviceId, "123", sizeof(info.deviceId)); dmDeviceStateManager->OnProfileReady(pkgName, deviceId); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); DmDeviceInfo ret = pReq->GetDeviceInfo(); int result = strcmp(info.deviceId, ret.deviceId); ASSERT_GE(result, 0); @@ -151,13 +156,14 @@ HWTEST_F(DmDeviceStateManagerTest, OnProfileReady_001, testing::ext::TestSize.Le * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, OnDeviceReady_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, OnDeviceReady_001, testing::ext::TestSize.Level0) { std::string pkgName; - DmDeviceInfo info ; - strncpy (info.deviceId, "123", sizeof(info.deviceId)); + DmDeviceInfo info; + strncpy(info.deviceId, "123", sizeof(info.deviceId)); dmDeviceStateManager->OnDeviceReady(pkgName, info); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); DmDeviceInfo ret = pReq->GetDeviceInfo(); int result = strcmp(info.deviceId, ret.deviceId); ASSERT_GE(result, 0); @@ -169,13 +175,14 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceReady_001, testing::ext::TestSize.Lev * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_002, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_002, testing::ext::TestSize.Level0) { std::string pkgName; - DmDeviceInfo info ; + DmDeviceInfo info; strncpy(info.deviceId, "123", sizeof(info.deviceId)); dmDeviceStateManager->OnDeviceChanged(pkgName, info); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); DmDeviceInfo ret = pReq->GetDeviceInfo(); int result = strcmp(info.deviceId, ret.deviceId); ASSERT_GE(result, 0); @@ -187,11 +194,11 @@ HWTEST_F(DmDeviceStateManagerTest, OnDeviceChanged_002, testing::ext::TestSize.L * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDeviceStateManagerTest, RegisterSoftbusStateCallback_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDeviceStateManagerTest, RegisterSoftbusStateCallback_001, testing::ext::TestSize.Level0) { int ret = dmDeviceStateManager->RegisterSoftbusStateCallback(); EXPECT_EQ(ret, DM_OK); } -} -} -} \ No newline at end of file +} // namespace +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/UTTest_dm_device_state_manager.h b/test/unittest/UTTest_dm_device_state_manager.h index 47821fab..7ecc0950 100644 --- a/test/unittest/UTTest_dm_device_state_manager.h +++ b/test/unittest/UTTest_dm_device_state_manager.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -33,6 +33,6 @@ public: virtual void SetUp() override; virtual void TearDown() override; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/test/unittest/UTTest_dm_discovery_manager.cpp b/test/unittest/UTTest_dm_discovery_manager.cpp index ff58930f..f3de7311 100644 --- a/test/unittest/UTTest_dm_discovery_manager.cpp +++ b/test/unittest/UTTest_dm_discovery_manager.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -27,16 +27,20 @@ namespace OHOS { namespace DistributedHardware { -void DmDiscoveryManagerTest::SetUp() { +void DmDiscoveryManagerTest::SetUp() +{ } -void DmDiscoveryManagerTest::TearDown() { +void DmDiscoveryManagerTest::TearDown() +{ } -void DmDiscoveryManagerTest::SetUpTestCase() { +void DmDiscoveryManagerTest::SetUpTestCase() +{ } -void DmDiscoveryManagerTest::TearDownTestCase() { +void DmDiscoveryManagerTest::TearDownTestCase() +{ } namespace { @@ -50,7 +54,8 @@ std::shared_ptr discoveryMgr_ = std::make_shared Test = std::make_shared(softbusConnector_, listener_); ASSERT_NE(Test, nullptr); } @@ -61,7 +66,7 @@ HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_001, testing::ext::TestSize. * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_002, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_002, testing::ext::TestSize.Level0) { std::shared_ptr Test = std::make_shared(softbusConnector_, listener_); Test.reset(); @@ -70,29 +75,29 @@ HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_002, testing::ext::TestSize. /** * @tc.name:StartDeviceDiscovery_001 - * @tc.desc: keeping pkgame unchanged, call StartDeviceDiscovery twice + * @tc.desc: keeping pkgame unchanged, call StartDeviceDiscovery twice * so that its discoveryQueue is not empty and return DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; DmSubscribeInfo subscribeInfo; const std::string extra; discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); int32_t ret = discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ (ret, DM_DISCOVERY_REPEATED); + EXPECT_EQ(ret, DM_DISCOVERY_REPEATED); } /** * @tc.name:StartDeviceDiscovery_002 - * @tc.desc: pkgame changed, call StartDeviceDiscovery twice + * @tc.desc: pkgame changed, call StartDeviceDiscovery twice * so that its discoveryQueue is not empty and return DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_002, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_002, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; std::string extra; @@ -110,7 +115,7 @@ HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_002, testing::ext::TestSiz * @tc.require: AR000GHSJK */ // doing -HWTEST_F(DmDiscoveryManagerTest, StopDeviceDiscovery_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, StopDeviceDiscovery_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; const std::string extra; @@ -127,18 +132,19 @@ HWTEST_F(DmDiscoveryManagerTest, StopDeviceDiscovery_001, testing::ext::TestSize * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, OnDeviceFound_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, OnDeviceFound_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; uint16_t aaa = 11; - DmDiscoveryContext context{ pkgName, "121110", aaa }; + DmDiscoveryContext context{pkgName, "121110", aaa}; discoveryMgr_->discoveryContextMap_[pkgName] = context; sleep(1); DmDeviceInfo info; info.deviceId[0] = '\0'; info.deviceName[0] = '\0'; discoveryMgr_->OnDeviceFound(pkgName, info); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); int ret1 = discoveryMgr_->discoveryContextMap_.count(pkgName); EXPECT_EQ(ret1, 1); std ::string ret = pReq->GetPkgName(); @@ -147,20 +153,21 @@ HWTEST_F(DmDiscoveryManagerTest, OnDeviceFound_001, testing::ext::TestSize.Level /** * @tc.name: OnDeviceFound_002 - * @tc.desc: set pkgName not null and discoveryContextMap_ null and return + * @tc.desc: set pkgName not null and discoveryContextMap_ null and return * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, OnDeviceFound_002, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, OnDeviceFound_002, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; DmDeviceInfo info; discoveryMgr_->OnDeviceFound(pkgName, info); int ret1 = discoveryMgr_->discoveryContextMap_.count(pkgName); - EXPECT_EQ (ret1, 1); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + EXPECT_EQ(ret1, 1); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); std ::string ret = pReq->GetPkgName(); - EXPECT_EQ (ret, pkgName); + EXPECT_EQ(ret, pkgName); } /** @@ -169,15 +176,16 @@ HWTEST_F(DmDiscoveryManagerTest, OnDeviceFound_002, testing::ext::TestSize.Level * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, OnDiscoveryFailed_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, OnDiscoveryFailed_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; int32_t subscribeId = 1; int32_t failedReason = 3; discoveryMgr_->OnDiscoveryFailed(pkgName, subscribeId, failedReason); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); std ::string ret = pReq->GetPkgName(); - EXPECT_EQ (ret, pkgName); + EXPECT_EQ(ret, pkgName); } /** @@ -186,16 +194,18 @@ HWTEST_F(DmDiscoveryManagerTest, OnDiscoveryFailed_001, testing::ext::TestSize.L * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, OnDiscoveryFailed_002, testing::ext::TestSize.Level0) { +HWTEST_F(DmDiscoveryManagerTest, OnDiscoveryFailed_002, testing::ext::TestSize.Level0) +{ std::string pkgName; int32_t subscribeId = 1; int32_t failedReason = 3; - discoveryMgr_->OnDiscoveryFailed(pkgName, subscribeId, failedReason); + discoveryMgr_->OnDiscoveryFailed(pkgName, subscribeId, failedReason); int ret1 = discoveryMgr_->discoveryContextMap_.count(pkgName); - EXPECT_EQ (ret1, 0); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + EXPECT_EQ(ret1, 0); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); std ::string ret = pReq->GetPkgName(); - EXPECT_EQ (ret, pkgName); + EXPECT_EQ(ret, pkgName); } /** @@ -204,14 +214,15 @@ HWTEST_F(DmDiscoveryManagerTest, OnDiscoveryFailed_002, testing::ext::TestSize.L * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, OnDiscoverySuccess_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, OnDiscoverySuccess_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; int32_t subscribeId = 1; discoveryMgr_->OnDiscoverySuccess(pkgName, subscribeId); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); std ::string ret = pReq->GetPkgName(); - EXPECT_EQ (ret, pkgName); + EXPECT_EQ(ret, pkgName); } /** @@ -220,16 +231,17 @@ HWTEST_F(DmDiscoveryManagerTest, OnDiscoverySuccess_001, testing::ext::TestSize. * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, OnDiscoverySuccess_002, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, OnDiscoverySuccess_002, testing::ext::TestSize.Level0) { - std::string pkgName ; + std::string pkgName; int32_t subscribeId = 1; discoveryMgr_->OnDiscoverySuccess(pkgName, subscribeId); int ret1 = discoveryMgr_->discoveryContextMap_.count(pkgName); - EXPECT_EQ (ret1, 1); - std::shared_ptr pReq = std::static_pointer_cast(listener_->ipcServerListener_.req_); + EXPECT_EQ(ret1, 1); + std::shared_ptr pReq = + std::static_pointer_cast(listener_->ipcServerListener_.req_); std ::string ret = pReq->GetPkgName(); - EXPECT_EQ (ret, pkgName); + EXPECT_EQ(ret, pkgName); } /** @@ -238,13 +250,13 @@ HWTEST_F(DmDiscoveryManagerTest, OnDiscoverySuccess_002, testing::ext::TestSize. * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DmDiscoveryManagerTest, HandleDiscoveryTimeout_001, testing::ext::TestSize.Level0) +HWTEST_F(DmDiscoveryManagerTest, HandleDiscoveryTimeout_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.helloworld"; - discoveryMgr_->HandleDiscoveryTimeout() ; + discoveryMgr_->HandleDiscoveryTimeout(); int ret = discoveryMgr_->discoveryContextMap_.count(pkgName); - EXPECT_EQ (ret, 1); -} -} -} + EXPECT_EQ(ret, 1); } +} // namespace +} // namespace DistributedHardware +} // namespace OHOS diff --git a/test/unittest/UTTest_dm_discovery_manager.h b/test/unittest/UTTest_dm_discovery_manager.h index 358594c9..7aa66148 100644 --- a/test/unittest/UTTest_dm_discovery_manager.h +++ b/test/unittest/UTTest_dm_discovery_manager.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -29,14 +29,13 @@ #define private public namespace OHOS { namespace DistributedHardware { -class DmDiscoveryManagerTest : public testing::Test -{ +class DmDiscoveryManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif // OHOS_UTTEST_DM_DISCOVERY_MANAGER_H \ No newline at end of file diff --git a/test/unittest/UTTest_hichain_connector.cpp b/test/unittest/UTTest_hichain_connector.cpp index 8aa85931..cfb11112 100644 --- a/test/unittest/UTTest_hichain_connector.cpp +++ b/test/unittest/UTTest_hichain_connector.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -28,16 +28,16 @@ namespace OHOS { namespace DistributedHardware { -void HichainConnectorTest::SetUp() +void HichainConnectorTest::SetUp() { } -void HichainConnectorTest::TearDown() +void HichainConnectorTest::TearDown() { } -void HichainConnectorTest::SetUpTestCase() +void HichainConnectorTest::SetUpTestCase() { } -void HichainConnectorTest::TearDownTestCase() +void HichainConnectorTest::TearDownTestCase() { } namespace { @@ -47,12 +47,12 @@ namespace { * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, CreateGroup_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, CreateGroup_001, testing::ext::TestSize.Level0) { int64_t requestId = 123456; std::string groupName = "dfggg"; - std::shared_ptr hichainConnector = std::make_shared(); - hichainConnector-> deviceGroupManager_ = nullptr; + std::shared_ptr hichainConnector = std::make_shared(); + hichainConnector->deviceGroupManager_ = nullptr; int ret = hichainConnector->CreateGroup(requestId, groupName); EXPECT_EQ(ret, DM_INVALID_VALUE); } @@ -63,11 +63,11 @@ HWTEST_F(HichainConnectorTest, CreateGroup_001, testing::ext::TestSize.Level0) * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, CreateGroup_002, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, CreateGroup_002, testing::ext::TestSize.Level0) { int64_t requestId = 123456; std::string groupName = "uuiioo"; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->CreateGroup(requestId, groupName); EXPECT_EQ(ret, DM_OK); } @@ -78,9 +78,9 @@ HWTEST_F(HichainConnectorTest, CreateGroup_002, testing::ext::TestSize.Level0) * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, GetGroupInfo_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, GetGroupInfo_001, testing::ext::TestSize.Level0) { - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); std::string groupName = "dcdkdkd1"; nlohmann::json jsonObj; jsonObj[FIELD_GROUP_NAME] = groupName.c_str(); @@ -106,7 +106,7 @@ HWTEST_F(HichainConnectorTest, GetGroupInfo_003, testing::ext::TestSize.Level0) aa.groupName = "afa"; std::vector groupList; groupList.push_back(aa); - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetGroupInfo(queryParams, groupList); EXPECT_EQ(ret, 0); } @@ -119,7 +119,7 @@ HWTEST_F(HichainConnectorTest, GetGroupInfo_003, testing::ext::TestSize.Level0) * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, IsGroupInfoInvalid_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, IsGroupInfoInvalid_001, testing::ext::TestSize.Level0) { GroupInfo group; group.groupName = "dkdkkdkdk"; @@ -139,7 +139,7 @@ HWTEST_F(HichainConnectorTest, IsGroupInfoInvalid_001, testing::ext::TestSize.Le * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, IsGroupInfoInvalid_002, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, IsGroupInfoInvalid_002, testing::ext::TestSize.Level0) { GroupInfo group; group.groupName = "test"; @@ -160,7 +160,7 @@ HWTEST_F(HichainConnectorTest, IsGroupInfoInvalid_002, testing::ext::TestSize.Le */ HWTEST_F(HichainConnectorTest, DelMemberFromGroup_001, testing::ext::TestSize.Level0) { - std::string groupId ; + std::string groupId; std::string deviceId; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->DelMemberFromGroup(groupId, deviceId); @@ -177,7 +177,7 @@ HWTEST_F(HichainConnectorTest, DelMemberFromGroup_002, testing::ext::TestSize.Le { std::string groupId = "34451"; std::string deviceId = "123"; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->DelMemberFromGroup(groupId, deviceId); EXPECT_EQ(ret, DM_OK); } @@ -188,7 +188,7 @@ HWTEST_F(HichainConnectorTest, DelMemberFromGroup_002, testing::ext::TestSize.Le * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, GenRequestId_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, GenRequestId_001, testing::ext::TestSize.Level0) { std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GenRequestId(); @@ -201,7 +201,7 @@ HWTEST_F(HichainConnectorTest, GenRequestId_001, testing::ext::TestSize.Level0) * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, from_json_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, from_json_001, testing::ext::TestSize.Level0) { GroupInfo groupInfo; groupInfo.groupName = "aaaa"; @@ -210,12 +210,12 @@ HWTEST_F(HichainConnectorTest, from_json_001, testing::ext::TestSize.Level0) groupInfo.groupType = 5; groupInfo.groupVisibility = 5; nlohmann::json jsonObject; - jsonObject[FIELD_GROUP_NAME] = groupInfo.groupName; - jsonObject[FIELD_GROUP_ID] = groupInfo.groupId ; - jsonObject[ FIELD_GROUP_OWNER] = groupInfo.groupOwner; - jsonObject[ FIELD_GROUP_TYPE] = groupInfo.groupType; + jsonObject[FIELD_GROUP_NAME] = groupInfo.groupName; + jsonObject[FIELD_GROUP_ID] = groupInfo.groupId; + jsonObject[FIELD_GROUP_OWNER] = groupInfo.groupOwner; + jsonObject[FIELD_GROUP_TYPE] = groupInfo.groupType; jsonObject[FIELD_GROUP_VISIBILITY] = groupInfo.groupVisibility; - from_json(jsonObject, groupInfo); + from_json(jsonObject, groupInfo); EXPECT_EQ(groupInfo.groupName, "aaaa"); EXPECT_EQ(groupInfo.groupId, "345678"); EXPECT_EQ(groupInfo.groupOwner, "lllll"); @@ -229,7 +229,7 @@ HWTEST_F(HichainConnectorTest, from_json_001, testing::ext::TestSize.Level0) * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, HiChainConnector_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, HiChainConnector_001, testing::ext::TestSize.Level0) { std::shared_ptr m_HiChainConnector = std::make_shared(); ASSERT_NE(m_HiChainConnector, nullptr); @@ -241,7 +241,7 @@ HWTEST_F(HichainConnectorTest, HiChainConnector_001, testing::ext::TestSize.Leve * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, HiChainConnector_002, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, HiChainConnector_002, testing::ext::TestSize.Level0) { std::shared_ptr m_HiChainConnector = std::make_shared(); m_HiChainConnector.reset(); @@ -254,14 +254,15 @@ HWTEST_F(HichainConnectorTest, HiChainConnector_002, testing::ext::TestSize.Leve * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, RegisterHiChainCallback_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, RegisterHiChainCallback_001, testing::ext::TestSize.Level0) { std::string pkgName = "com.softbus.test"; std::shared_ptr listener_ = std::make_shared(); - std::shared_ptr softbusConnector = std::make_shared(); + std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr discoveryMgr_ = std::make_shared(softbusConnector, listener_); std::shared_ptr hichainConnector = std::make_shared(); - int ret = hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr(discoveryMgr_)); + int ret = + hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr(discoveryMgr_)); int ret1 = HiChainConnector::hiChainConnectorCallbackMap_.count(pkgName); EXPECT_EQ(ret1, 1); EXPECT_EQ(ret, DM_OK); @@ -272,15 +273,15 @@ HWTEST_F(HichainConnectorTest, RegisterHiChainCallback_001, testing::ext::TestSi * @tc.desc: Call the RegisterHiChainCallback function with a return value of DM_OK * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, IsGroupCreated_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, IsGroupCreated_001, testing::ext::TestSize.Level0) { std::string groupName = "dcdkdkd1"; nlohmann::json jsonObj; jsonObj[FIELD_GROUP_NAME] = groupName.c_str(); std::string queryParams = jsonObj.dump(); - std::vector groupList ; - GroupInfo groupInfo; - std::shared_ptr hichainConnector = std::make_shared(); + std::vector groupList; + GroupInfo groupInfo; + std::shared_ptr hichainConnector = std::make_shared(); bool ret = hichainConnector->IsGroupCreated(groupName, groupInfo); EXPECT_EQ(ret, false); } @@ -293,9 +294,9 @@ HWTEST_F(HichainConnectorTest, IsGroupCreated_001, testing::ext::TestSize.Level0 */ HWTEST_F(HichainConnectorTest, AddMember_001, testing::ext::TestSize.Level0) { - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); hichainConnector->deviceGroupManager_ = nullptr; - std::string deviceId ; + std::string deviceId; std::string connectInfo; int ret = hichainConnector->AddMember(deviceId, connectInfo); EXPECT_EQ(ret, -1); @@ -311,7 +312,7 @@ HWTEST_F(HichainConnectorTest, AddMember_002, testing::ext::TestSize.Level0) { std::string deviceId; std::string connectInfo; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->AddMember(deviceId, connectInfo); EXPECT_EQ(ret, DM_FAILED); } @@ -326,7 +327,7 @@ HWTEST_F(HichainConnectorTest, AddMember3, testing::ext::TestSize.Level0) { std::string deviceId = "123456"; std::string connectInfo = "dkdkk"; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->AddMember(deviceId, connectInfo); ASSERT_GE(ret, 1); } @@ -352,13 +353,13 @@ HWTEST_F(HichainConnectorTest, onRequest_001, testing::ext::TestSize.Level0) * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, GetConnectPara_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, GetConnectPara_001, testing::ext::TestSize.Level0) { std::string pkgName = "softbus"; std::shared_ptr listener_ = std::make_shared(); - std::shared_ptr softbusConnector = std::make_shared(); + std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr discoveryMgr_ = std::make_shared(softbusConnector, listener_); - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr(discoveryMgr_)); std::string deviceId = "23445"; std::string reqDeviceId = "234566"; @@ -379,9 +380,9 @@ HWTEST_F(HichainConnectorTest, GetConnectPara_002, testing::ext::TestSize.Level0 std::string reqDeviceId = "234566"; std::string pkgName = "softbus"; std::shared_ptr listener_ = std::make_shared(); - std::shared_ptr softbusConnector = std::make_shared(); + std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr discoveryMgr_ = std::make_shared(softbusConnector, listener_); - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr(discoveryMgr_)); std::string ret = hichainConnector->GetConnectPara(deviceId, reqDeviceId); EXPECT_EQ(ret, ""); @@ -393,10 +394,10 @@ HWTEST_F(HichainConnectorTest, GetConnectPara_002, testing::ext::TestSize.Level0 * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, DeleteGroup_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, DeleteGroup_001, testing::ext::TestSize.Level0) { std::string groupId = "34567"; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->DeleteGroup(groupId); EXPECT_EQ(ret, DM_OK); } @@ -411,7 +412,7 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_001, testing::ext::TestSize.Leve { std::string DeviceId = "123"; std::vector groupList; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetRelatedGroups(DeviceId, groupList); EXPECT_EQ(ret, DM_FAILED); } @@ -426,7 +427,7 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_003, testing::ext::TestSize.Leve { std::string DeviceId = "12345"; std::vector groupList; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetRelatedGroups(DeviceId, groupList); EXPECT_EQ(ret, DM_FAILED); } @@ -437,11 +438,11 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_003, testing::ext::TestSize.Leve * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, SyncGroups_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, SyncGroups_001, testing::ext::TestSize.Level0) { std::string deviceId = "34567"; std::vector remoteGroupIdList; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->SyncGroups(deviceId, remoteGroupIdList); EXPECT_EQ(ret, DM_OK); } @@ -452,11 +453,11 @@ HWTEST_F(HichainConnectorTest, SyncGroups_001, testing::ext::TestSize.Level0) * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, GetSyncGroupList_001, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, GetSyncGroupList_001, testing::ext::TestSize.Level0) { std::vector groupList; std::vector syncGroupList; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetSyncGroupList(groupList, syncGroupList); EXPECT_EQ(ret, DM_FAILED); } @@ -467,22 +468,21 @@ HWTEST_F(HichainConnectorTest, GetSyncGroupList_001, testing::ext::TestSize.Lev * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(HichainConnectorTest, GetSyncGroupList_002, testing::ext::TestSize.Level0) +HWTEST_F(HichainConnectorTest, GetSyncGroupList_002, testing::ext::TestSize.Level0) { std::vector groupList; GroupInfo groupList1; groupList1.groupName = "hichainconnector"; groupList1.groupId = "123456"; - groupList1.groupOwner ="doftbus"; + groupList1.groupOwner = "doftbus"; groupList1.groupType = 1; groupList1.groupVisibility = 2; groupList.push_back(groupList1); std::vector syncGroupList; - std::shared_ptr hichainConnector = std::make_shared(); + std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetSyncGroupList(groupList, syncGroupList); EXPECT_EQ(ret, DM_OK); } -} -} -} - +} // namespace +} // namespace DistributedHardware +} // namespace OHOS diff --git a/test/unittest/UTTest_hichain_connector.h b/test/unittest/UTTest_hichain_connector.h index f691d343..9e706061 100644 --- a/test/unittest/UTTest_hichain_connector.h +++ b/test/unittest/UTTest_hichain_connector.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index 6ba65882..44a3bfd1 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_softbus_connector.h b/test/unittest/UTTest_softbus_connector.h index b32d13b2..e890244c 100644 --- a/test/unittest/UTTest_softbus_connector.h +++ b/test/unittest/UTTest_softbus_connector.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/UTTest_softbus_session.cpp b/test/unittest/UTTest_softbus_session.cpp index c81b47b0..5294129f 100644 --- a/test/unittest/UTTest_softbus_session.cpp +++ b/test/unittest/UTTest_softbus_session.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -136,34 +136,6 @@ HWTEST_F(SoftbusSessionTest, SoftbusSession_002, testing::ext::TestSize.Level0) EXPECT_EQ(m_SoftbusSession, nullptr); } -/** - * @tc.name: OnSessionClosed_001 - * @tc.desc: set some corrort para,and return DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -// HWTEST_F(SoftbusSessionTest, OnSessionClosed_001, testing::ext::TestSize.Level0) -// { -// int32_t sessionId = 3; -// int ret = softbusSession->OnSessionClosed(sessionId); -// EXPECT_EQ(ret, DM_OK); -// } - -/** - * @tc.name: OnBytesReceived_002 - * @tc.desc: set sessionId = 3 and return DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -// HWTEST_F(SoftbusSessionTest, OnBytesReceived_002, testing::ext::TestSize.Level0) -// { -// int32_t sessionId = 3; -// void *data; -// uint32_t dataLen = 1; -// int ret = softbusSession->OnBytesReceived(sessionId, data, dataLen); -// EXPECT_EQ(ret, DM_OK); -// } - /** * @tc.name: CloseAuthSession_001 * @tc.desc: set sessionId = 3, and return DM_OK diff --git a/test/unittest/UTTest_softbus_session.h b/test/unittest/UTTest_softbus_session.h index e8eee61d..5497647b 100644 --- a/test/unittest/UTTest_softbus_session.h +++ b/test/unittest/UTTest_softbus_session.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/auth_request_state.cpp b/test/unittest/auth_request_state.cpp index bab92c0b..9c13881e 100644 --- a/test/unittest/auth_request_state.cpp +++ b/test/unittest/auth_request_state.cpp @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/device_manager_impl_test.cpp b/test/unittest/device_manager_impl_test.cpp index 8402ec4d..0c3a8f5e 100644 --- a/test/unittest/device_manager_impl_test.cpp +++ b/test/unittest/device_manager_impl_test.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -53,8 +53,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice1, testing::ext::TestSize.Leve DmDeviceInfo dmDeviceInfo; std::string extra = ""; std::shared_ptr callback = nullptr; - int32_t ret = - DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); + int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); ASSERT_EQ(ret, DM_INVALID_VALUE); } @@ -70,8 +69,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Leve EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) .WillOnce(testing::Return(DM_FAILED)); - int32_t ret = - DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); + int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); ASSERT_EQ(ret, DM_IPC_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -88,8 +86,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice3, testing::ext::TestSize.Leve EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) .WillOnce(testing::Return(DM_OK)); - int32_t ret = - DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); + int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); ASSERT_EQ(ret, DM_OK); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } diff --git a/test/unittest/device_manager_impl_test.h b/test/unittest/device_manager_impl_test.h index ffcb70e3..56c490b4 100644 --- a/test/unittest/device_manager_impl_test.h +++ b/test/unittest/device_manager_impl_test.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/mock/device_auth.cpp b/test/unittest/mock/device_auth.cpp index 4782f055..b18839a3 100644 --- a/test/unittest/mock/device_auth.cpp +++ b/test/unittest/mock/device_auth.cpp @@ -1,7 +1,22 @@ +/* + * 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. + */ + #include "device_auth.h" #include "dm_constants.h" -int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disbandParams) +int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disbandParams) { if (disbandParams == 0) { return DM_FAILED; @@ -10,13 +25,12 @@ int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disband return DM_OK; } -int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum) +int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum) { - return 0; + return 0; } - -int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createParams) +int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createParams) { if (requestId == 0) { return DM_FAILED; @@ -24,8 +38,7 @@ int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createP return 0; } - -int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum) +int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum) { if (peerDeviceId == "123") { returnGroupVec = nullptr; diff --git a/test/unittest/mock/device_auth.h b/test/unittest/mock/device_auth.h index 0fd7ad08..570d5df1 100644 --- a/test/unittest/mock/device_auth.h +++ b/test/unittest/mock/device_auth.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -20,7 +20,7 @@ #include #if defined(__LINUX__) || defined(_UNIX) -#define DEVICE_AUTH_API_PUBLIC __attribute__ ((visibility("default"))) +#define DEVICE_AUTH_API_PUBLIC __attribute__((visibility("default"))) #else #define DEVICE_AUTH_API_PUBLIC #endif @@ -98,11 +98,7 @@ typedef enum { CREDENTIAL_QUERY = 3, } CredentialCode; -typedef enum { - DEVICE_TYPE_ACCESSORY = 0, - DEVICE_TYPE_CONTROLLER = 1, - DEVICE_TYPE_PROXY = 2 -} UserType; +typedef enum { DEVICE_TYPE_ACCESSORY = 0, DEVICE_TYPE_CONTROLLER = 1, DEVICE_TYPE_PROXY = 2 } UserType; typedef enum { REQUEST_REJECTED = 0x80000005, @@ -130,11 +126,11 @@ typedef struct { typedef struct { int32_t (*processData)(int64_t authReqId, const uint8_t *data, uint32_t dataLen, - const DeviceAuthCallback *gaCallback); + const DeviceAuthCallback *gaCallback); int32_t (*queryTrustedDeviceNum)(void); bool (*isTrustedDevice)(const char *udid); - int32_t (*getAuthState)(int64_t authReqId, const char *groupId, const char *peerUdid, - uint8_t *out, uint32_t *outLen); + int32_t (*getAuthState)(int64_t authReqId, const char *groupId, const char *peerUdid, uint8_t *out, + uint32_t *outLen); int32_t (*authDevice)(int64_t authReqId, const char *authParams, const DeviceAuthCallback *gaCallback); void (*informDeviceDisconnection)(const char *udid); } GroupAuthManager; @@ -160,7 +156,7 @@ typedef struct { int32_t (*getLocalConnectInfo)(char *returnInfo, int32_t bufLen); int32_t (*checkAccessToGroup)(const char *appId, const char *groupId); int32_t (*getPkInfoList)(const char *appId, const char *queryParams, char **returnInfoList, - uint32_t *returnInfoNum); + uint32_t *returnInfoNum); int32_t (*addGroupManager)(const char *appId, const char *groupId, const char *managerAppId); int32_t (*addGroupFriend)(const char *appId, const char *groupId, const char *friendAppId); int32_t (*deleteGroupManager)(const char *appId, const char *groupId, const char *managerAppId); @@ -171,8 +167,7 @@ typedef struct { int32_t (*getGroupInfo)(const char *appId, const char *queryParams, char **returnGroupVec, uint32_t *groupNum); int32_t (*getJoinedGroups)(const char *appId, int groupType, char **returnGroupVec, uint32_t *groupNum); int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum); - int32_t (*getDeviceInfoById)(const char *appId, const char *deviceId, const char *groupId, - char **returnDeviceInfo); + int32_t (*getDeviceInfoById)(const char *appId, const char *deviceId, const char *groupId, char **returnDeviceInfo); int32_t (*getTrustedDevices)(const char *appId, const char *groupId, char **returnDevInfoVec, uint32_t *deviceNum); bool (*isDeviceInGroup)(const char *appId, const char *groupId, const char *deviceId); void (*destroyInfo)(char **returnInfo); diff --git a/test/unittest/mock/ipc_server_listener.cpp b/test/unittest/mock/ipc_server_listener.cpp index 4928b3b7..20d7611d 100644 --- a/test/unittest/mock/ipc_server_listener.cpp +++ b/test/unittest/mock/ipc_server_listener.cpp @@ -4,7 +4,7 @@ * 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 + * 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, @@ -25,7 +25,7 @@ int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr int32_t IpcServerListener::SendAll(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { req_ = req; - std::cout<GetPkgName()<<"\n"; + std::cout << req_->GetPkgName() << "\n"; return 0; } } // namespace DistributedHardware diff --git a/test/unittest/mock/ipc_server_listener.h b/test/unittest/mock/ipc_server_listener.h index 20462fac..79372b30 100644 --- a/test/unittest/mock/ipc_server_listener.h +++ b/test/unittest/mock/ipc_server_listener.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -27,6 +27,7 @@ class IpcServerListener { public: IpcServerListener() = default; virtual ~IpcServerListener() = default; + public: int32_t SendRequest(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp); int32_t SendAll(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp); diff --git a/test/unittest/mock/mock_ipc_client_proxy.h b/test/unittest/mock/mock_ipc_client_proxy.h index ece83e9f..fd134ac2 100644 --- a/test/unittest/mock/mock_ipc_client_proxy.h +++ b/test/unittest/mock/mock_ipc_client_proxy.h @@ -4,7 +4,7 @@ * 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 + * 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, diff --git a/test/unittest/mock/parameter.cpp b/test/unittest/mock/parameter.cpp index c3b8136f..a51d9ed9 100644 --- a/test/unittest/mock/parameter.cpp +++ b/test/unittest/mock/parameter.cpp @@ -1,3 +1,18 @@ +/* + * 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. + */ + #include "parameter.h" int GetParameter(const char *key, const char *def, char *value, unsigned int len) diff --git a/test/unittest/mock/parameter.h b/test/unittest/mock/parameter.h index 68f0b5d8..23da1b6a 100644 --- a/test/unittest/mock/parameter.h +++ b/test/unittest/mock/parameter.h @@ -1,3 +1,18 @@ +/* + * 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 PARAMETER__H #define PARAMETER__H @@ -7,7 +22,6 @@ extern "C" { #endif #endif /* __cplusplus */ - int GetParameter(const char *key, const char *def, char *value, unsigned int len); int SetParameter(const char *key, const char *value); diff --git a/test/unittest/mock/session.h b/test/unittest/mock/session.h index d9934401..15c5a155 100644 --- a/test/unittest/mock/session.h +++ b/test/unittest/mock/session.h @@ -4,7 +4,7 @@ * 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 + * 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, @@ -25,7 +25,7 @@ * * @since 1.0 * @version 1.0 -*/ + */ /** * @file session.h @@ -62,7 +62,7 @@ typedef enum { TYPE_BUTT, } SessionType; -typedef enum { +typedef enum { INVALID = -1, /* * Send any segment of a frame each time. @@ -82,7 +82,7 @@ typedef enum { VIDEO_SLICE_STREAM, } StreamType; -typedef enum { +typedef enum { LINK_TYPE_WIFI_WLAN_5G = 1, LINK_TYPE_WIFI_WLAN_2G = 2, LINK_TYPE_WIFI_P2P = 3, @@ -124,15 +124,10 @@ typedef struct { } FrameInfo; typedef struct { - int (*OnSessionOpened)(int sessionId, int result); - void (*OnSessionClosed)(int sessionId); - void (*OnBytesReceived)(int sessionId, const void *data, unsigned int dataLen); - void (*OnMessageReceived)(int sessionId, const void *data, unsigned int dataLen); - void (*OnStreamReceived)(int sessionId, const StreamData *data, const StreamData *ext, const FrameInfo *param); } ISessionListener; @@ -153,8 +148,8 @@ int CreateSessionServer(const char *pkgName, const char *sessionName, const ISes int RemoveSessionServer(const char *pkgName, const char *sessionName); -int OpenSession(const char *mySessionName, const char *peerSessionName, const char *peerDeviceId, - const char *groupId, const SessionAttribute* attr); +int OpenSession(const char *mySessionName, const char *peerSessionName, const char *peerDeviceId, const char *groupId, + const SessionAttribute *attr); void CloseSession(int sessionId); @@ -168,13 +163,12 @@ int GetMySessionName(int sessionId, char *sessionName, unsigned int len); int GetPeerSessionName(int sessionId, char *sessionName, unsigned int len); - int GetPeerDeviceId(int sessionId, char *devId, unsigned int len); int GetSessionSide(int sessionId); -int SetFileReceiveListener(const char *pkgName, const char *sessionName, - const IFileReceiveListener *recvListener, const char *rootDir); +int SetFileReceiveListener(const char *pkgName, const char *sessionName, const IFileReceiveListener *recvListener, + const char *rootDir); int SetFileSendListener(const char *pkgName, const char *sessionName, const IFileSendListener *sendListener); @@ -182,4 +176,4 @@ int SendFile(int sessionId, const char *sFileList[], const char *dFileList[], ui #ifdef __cplusplus } #endif -#endif // SESSION_H +#endif // SESSION_H diff --git a/test/unittest/mock/softbus_bus_center.cpp b/test/unittest/mock/softbus_bus_center.cpp index 59170bf9..47385bc4 100644 --- a/test/unittest/mock/softbus_bus_center.cpp +++ b/test/unittest/mock/softbus_bus_center.cpp @@ -1,15 +1,29 @@ +/* + * 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. + */ + #include "softbus_connector.h" - - -int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId, NodeDeivceInfoKey key, uint8_t *info, int32_t infoLen) +int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId, NodeDeivceInfoKey key, uint8_t *info, + int32_t infoLen) { - return 0; + return 0; } - -int32_t RegNodeDeviceStateCb(const char *pkgName, INodeStateCb *callback){ - return 0; +int32_t RegNodeDeviceStateCb(const char *pkgName, INodeStateCb *callback) +{ + return 0; }; int32_t GetAllNodeDeviceInfo(const char *pkgName, NodeBasicInfo **info, int32_t *infoNum)