代码格式化修复编程规范问题

Signed-off-by: puhui <puhui1@huawei.com>
This commit is contained in:
puhui
2022-01-14 09:41:04 +08:00
parent e6b825a852
commit e2ba2a2964
36 changed files with 350 additions and 316 deletions
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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 <gtest/gtest.h>
#include <refbase.h>
#include <string>
#include "device_manager_service_listener.h"
+29 -29
View File
@@ -50,7 +50,7 @@ HWTEST_F(AuthMessageProcessorTest, CreateNegotiateMessage_001, testing::ext::Tes
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
authMessageProcessor->authRequestContext_= std::make_shared<DmAuthRequestContext>();
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
authMessageProcessor->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
nlohmann::json jsona;
nlohmann::json jsonObj;
authMessageProcessor->authRequestContext_->deviceId = "132416546";
std::vector<std::string> syncGroupList ;
std::vector<std::string> 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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
nlohmann::json jsona;
nlohmann::json jsonObj;
@@ -144,11 +144,11 @@ HWTEST_F(AuthMessageProcessorTest, CreateResponseFinishMessage_001, testing::ext
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext= std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_= std::make_shared<DmAuthResponseContext>();
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
nlohmann::json jsona;
authResponseContext->reply = 0;
@@ -225,7 +225,7 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_001, testing::ext::Te
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor= std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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<DmAuthManager> data = std::make_shared<DmAuthManager>(softbusConnector, listener);
std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
std::shared_ptr<DmAuthResponseContext> authResponseContext = authMessageProcessor->GetResponseContext();
std::shared_ptr<DmAuthResponseContext> authResponseContext = authMessageProcessor->GetResponseContext();
ASSERT_NE(authResponseContext, nullptr);
sleep(15);
}
}
}
}
} // namespace
} // namespace DistributedHardware
} // namespace OHOS
+3 -3
View File
@@ -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
+35 -33
View File
@@ -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<DmAuthResponseContext>();
authManager->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
authManager->authRequestState_ = std::make_shared<AuthRequestNetworkState>();
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<DmAuthResponseContext>();
authManager->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
authManager->authRequestState_ = std::make_shared<AuthRequestNetworkState>();
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<DmTimer> negotiateStartTimer = std::make_shared<DmTimer>(NEGOTIATE_TIMEOUT_TASK);
authManager->timerMap_[NEGOTIATE_TIMEOUT_TASK] = negotiateStartTimer;
authManager->authMessageProcessor_ = std::make_shared<AuthMessageProcessor>(authManager);
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();;
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
;
authManager->authRequestState_ = std::make_shared<AuthRequestFinishState>();
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<AuthResponseConfirmState>();
authManager->authMessageProcessor_ = std::make_shared<AuthMessageProcessor>(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<AuthResponseConfirmState>();
authManager->authMessageProcessor_ = std::make_shared<AuthMessageProcessor>(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<AuthMessageProcessor>(authManager);
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmAuthManager> authManager = std::make_shared<DmAuthManager>(softbusConnector, listener);
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();;
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
;
int32_t ret = authManager->GetPinCode();
ASSERT_EQ(ret, authManager->authResponseContext_->code);
}
}
}
}
} // namespace
} // namespace DistributedHardware
} // namespace OHOS
+3 -3
View File
@@ -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();
@@ -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,
@@ -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,
@@ -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<iostream>
#include <iostream>
#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> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DeviceManagerServiceListener> listener_ = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<DmDeviceStateManager> dmDeviceStateManager = std::make_shared<DmDeviceStateManager>(softbusConnector, listener_);
std::shared_ptr<DmDeviceStateManager> dmDeviceStateManager =
std::make_shared<DmDeviceStateManager>(softbusConnector, listener_);
/**
* @tc.name: DmDeviceStateManager_001
@@ -53,7 +54,7 @@ std::shared_ptr<DmDeviceStateManager> dmDeviceStateManager = std::make_shared<D
* @tc.type: FUNC
* @tc.require: AR000GHSJK
*/
HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_001, testing::ext::TestSize.Level0)
HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_001, testing::ext::TestSize.Level0)
{
std::shared_ptr<DmDeviceStateManager> p = std::make_shared<DmDeviceStateManager>(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<DmDeviceStateManager> p = std::make_shared<DmDeviceStateManager>(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<IpcNotifyDeviceStateReq> pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq > (listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceStateReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceStateReq>(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<IpcNotifyDeviceStateReq > pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq >(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceStateReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceStateReq>(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<IpcNotifyDeviceStateReq> pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq >(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceStateReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceStateReq>(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<IpcNotifyDeviceStateReq> pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq >(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceStateReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceStateReq>(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<IpcNotifyDeviceStateReq> pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq >(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceStateReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceStateReq>(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<IpcNotifyDeviceStateReq> pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq >(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceStateReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceStateReq>(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);
}
}
}
}
} // namespace
} // namespace DistributedHardware
} // namespace OHOS
@@ -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
} // namespace DistributedHardware
} // namespace OHOS
#endif
+55 -43
View File
@@ -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<DmDiscoveryManager> discoveryMgr_ = std::make_shared<DmDiscovery
* @tc.type: FUNC
* @tc.require: AR000GHSJK
*/
HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_001, testing::ext::TestSize.Level0) {
HWTEST_F(DmDiscoveryManagerTest, DmDiscoveryManager_001, testing::ext::TestSize.Level0)
{
std::shared_ptr<DmDiscoveryManager> Test = std::make_shared<DmDiscoveryManager>(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<DmDiscoveryManager> Test = std::make_shared<DmDiscoveryManager>(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<IpcNotifyDeviceFoundReq> pReq = std::static_pointer_cast<IpcNotifyDeviceFoundReq>(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDeviceFoundReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceFoundReq>(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<IpcNotifyDeviceFoundReq> pReq = std::static_pointer_cast<IpcNotifyDeviceFoundReq>(listener_->ipcServerListener_.req_);
EXPECT_EQ(ret1, 1);
std::shared_ptr<IpcNotifyDeviceFoundReq> pReq =
std::static_pointer_cast<IpcNotifyDeviceFoundReq>(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<IpcNotifyDiscoverResultReq> pReq = std::static_pointer_cast<IpcNotifyDiscoverResultReq>(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDiscoverResultReq> pReq =
std::static_pointer_cast<IpcNotifyDiscoverResultReq>(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<IpcNotifyDiscoverResultReq> pReq = std::static_pointer_cast<IpcNotifyDiscoverResultReq>(listener_->ipcServerListener_.req_);
EXPECT_EQ(ret1, 0);
std::shared_ptr<IpcNotifyDiscoverResultReq> pReq =
std::static_pointer_cast<IpcNotifyDiscoverResultReq>(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<IpcNotifyDiscoverResultReq> pReq = std::static_pointer_cast<IpcNotifyDiscoverResultReq>(listener_->ipcServerListener_.req_);
std::shared_ptr<IpcNotifyDiscoverResultReq> pReq =
std::static_pointer_cast<IpcNotifyDiscoverResultReq>(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<IpcNotifyDiscoverResultReq> pReq = std::static_pointer_cast<IpcNotifyDiscoverResultReq>(listener_->ipcServerListener_.req_);
EXPECT_EQ(ret1, 1);
std::shared_ptr<IpcNotifyDiscoverResultReq> pReq =
std::static_pointer_cast<IpcNotifyDiscoverResultReq>(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
+4 -5
View File
@@ -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
+57 -57
View File
@@ -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> hichainConnector = std::make_shared<HiChainConnector>();
hichainConnector-> deviceGroupManager_ = nullptr;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<GroupInfo> groupList;
groupList.push_back(aa);
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
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<HiChainConnector> m_HiChainConnector = std::make_shared<HiChainConnector>();
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<HiChainConnector> m_HiChainConnector = std::make_shared<HiChainConnector>();
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<DeviceManagerServiceListener> listener_ = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DmAuthManager> discoveryMgr_ = std::make_shared<DmAuthManager>(softbusConnector, listener_);
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
int ret = hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr<IHiChainConnectorCallback>(discoveryMgr_));
int ret =
hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr<IHiChainConnectorCallback>(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<GroupInfo> groupList ;
GroupInfo groupInfo;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::vector<GroupInfo> groupList;
GroupInfo groupInfo;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<DeviceManagerServiceListener> listener_ = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DmAuthManager> discoveryMgr_ = std::make_shared<DmAuthManager>(softbusConnector, listener_);
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr<IHiChainConnectorCallback>(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<DeviceManagerServiceListener> listener_ = std::make_shared<DeviceManagerServiceListener>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
std::shared_ptr<DmAuthManager> discoveryMgr_ = std::make_shared<DmAuthManager>(softbusConnector, listener_);
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
hichainConnector->RegisterHiChainCallback(pkgName, std::shared_ptr<IHiChainConnectorCallback>(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> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<GroupInfo> groupList;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<GroupInfo> groupList;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<std::string> remoteGroupIdList;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<GroupInfo> groupList;
std::vector<std::string> syncGroupList;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
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<GroupInfo> 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<std::string> syncGroupList;
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
std::shared_ptr<HiChainConnector> hichainConnector = std::make_shared<HiChainConnector>();
int ret = hichainConnector->GetSyncGroupList(groupList, syncGroupList);
EXPECT_EQ(ret, DM_OK);
}
}
}
}
} // namespace
} // namespace DistributedHardware
} // namespace OHOS
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
+1 -29
View File
@@ -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
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
+4 -7
View File
@@ -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<AuthenticateCallback> 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;
}
+1 -1
View File
@@ -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
View File
@@ -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;
+8 -13
View File
@@ -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 <stdbool.h>
#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);
+2 -2
View File
@@ -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<IpcReq>
int32_t IpcServerListener::SendAll(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
{
req_ = req;
std::cout<<req_->GetPkgName()<<"\n";
std::cout << req_->GetPkgName() << "\n";
return 0;
}
} // namespace DistributedHardware
+2 -1
View File
@@ -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<IpcReq> req, std::shared_ptr<IpcRsp> rsp);
int32_t SendAll(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp);
+1 -1
View File
@@ -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,
+15
View File
@@ -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)
+15 -1
View File
@@ -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);
+9 -15
View File
@@ -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
+21 -7
View File
@@ -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)