修改用例名称

Signed-off-by: bWX1145125 <bianjianliang1@huawei.com>
This commit is contained in:
bWX1145125 2024-05-21 15:26:33 +08:00
parent d5ab6dc4cf
commit 4b60699738
16 changed files with 24 additions and 491 deletions

View File

@ -19,11 +19,11 @@ group("distributedhardware") {
deps = [
"distributedaudionewtest:SubDctsdisAudioNewTest",
"distributedaudiotest:SubDctsdisAudioTest",
"distributedcameratest:SubDctsdisCameraTest",
"distributeddevicejstest:SubDctsdisDeviceJsTest",
"distributeddptest:SubDctsDistributedDpTest",
"distributedinputtest:SubDistributedInputTest",
"distributedscreentest:SubDctsdisScreenTest",
"distributedcameratest:DctsSubdisCameraTest",
"distributeddevicejstest:DctsSubdisDeviceJsTest",
"distributeddptest:DctsSubDistributedDpTest",
"distributedinputtest:DctsSubDistributedInputTest",
"distributedscreentest:DctsSubdisScreenTest",
]
}
}

View File

@ -19,7 +19,7 @@ config("dcamera_hdf_demo_config") {
visibility = [ ":*" ]
}
ohos_moduletest_suite("SubDctsdisCameraTest") {
ohos_moduletest_suite("DctsSubdisCameraTest") {
module_out_path = module_output_path
install_enable = true
sources = [
@ -73,7 +73,7 @@ ohos_moduletest_suite("SubDctsdisCameraTest") {
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SubDctsdisCameraTest\"",
"DH_LOG_TAG=\"DctsSubdisCameraTest\"",
"LOG_DOMAIN=0xD004100",
]

View File

@ -1,7 +1,7 @@
{
"description": "Config for disCamera test cases",
"driver": {
"module-name": "SubDctsdisCameraTest",
"module-name": "DctsSubdisCameraTest",
"native-test-timeout": "120000",
"native-test-device-path": "/data/local/tmp",
"runtime-hint": "1s",
@ -13,7 +13,7 @@
"chmod -R 777 /data/local/tmp/*"
],
"push": [
"SubDctsdisCameraTest->/data/local/tmp/SubDctsdisCameraTest"
"DctsSubdisCameraTest->/data/local/tmp/DctsSubdisCameraTest"
],
"type": "PushKit"
}

View File

@ -13,14 +13,14 @@
import("../../../tools/build/suite.gni")
ohos_js_hap_suite("SubDctsdisDeviceJsTest") {
ohos_js_hap_suite("DctsSubdisDeviceJsTest") {
hap_profile = "./src/main/config.json"
deps = [
":distributedjs_assets",
":distributedjs_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "SubDctsdisDeviceJsTest"
hap_name = "DctsSubdisDeviceJsTest"
subsystem_name = "distributedhardware"
part_name = "device_manager"
}

View File

@ -11,7 +11,7 @@
"kits": [
{
"test-file-name": [
"SubDctsdisDeviceJsTest.hap"
"DctsSubdisDeviceJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true

View File

@ -1,77 +0,0 @@
# Copyright (C) 2022-2023 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.
base_root = "../../../../../"
import("//test/xts/tools/build/suite.gni")
module_output_path = "dcts/distributeddeviceprofile"
config("device_info_manager_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"include/authority",
"include/devicemanager",
"include/contentsensor",
"include/dbstorage",
"include/dfx",
"include/subscribemanager",
"${device_profile_path}/common/include",
"${device_profile_innerkits}/core/include",
"${device_profile_service}/core/include",
"//third_party/json/include",
]
}
ohos_moduletest_suite("SubDistributedDeviceProfile") {
module_out_path = module_output_path
sources = [
"disdevprofile_test.cpp",
"distributeddevicesprofiletest.cpp",
]
deps = [
"$base_root/drivers/hdf_core/adapter/uhdf2/utils:libhdf_utils",
"${device_profile_innerkits}/core:distributed_device_profile_client",
"${device_profile_service}/core:distributed_device_profile",
"//third_party/googletest:gtest_main",
]
external_deps = [
"access_token:libaccesstoken",
"access_token:libaccesstoken_sdk",
"access_token:libtoken_setproc",
"c_utils:utils",
"device_manager:devicemanagersdk",
"device_suth:deviceauth_sdk",
"distributed_device_profile_service",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"safwk:system_ability_fwk",
"service_characteristic_profile",
"syscap_codec:syscap_interface_shared",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SubDeviceProfile\"",
"LOG_DOMAIN=0xD004100",
]
install_enable = true
subsystem_name = "DistributedDeviceProfile"
part_name = "device_info_manager"
}

View File

@ -1,21 +0,0 @@
{
"description": "Config for disCamera test cases",
"driver": {
"module-name": "DistributedDeviceProfile",
"native-test-timeout": "120000",
"native-test-device-path": "/data/local/tmp",
"runtime-hint": "1s",
"type": "CppTest"
},
"kits": [
{
"post-push" : [
"chmod -R 777 /data/local/tmp/*"
],
"push": [
"DistributedDeviceProfile->/data/local/tmp/DistributedDeviceProfile"
],
"type": "PushKit"
}
]
}

View File

@ -1,190 +0,0 @@
/*
* Copyright (c) 2021-2023 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 <gtest/gtest.h>
#include <cstdlib>
#include "disdveprofile_test.h"
#include "nlohmann/json.hpp"
#include <system>
#include "json/json.h"
#include <thread>
#include "device_profile_log.h"
#include <string>
#include "distributed_device_profile_client.h"
int32_t dpOk = 0;
int32_t dpError = -1;
int DPTest::InitDevice()
{
DHLOGI("demo test: InitDevice enter");
auto disDPTest = std::make_shared<DistributedDeviceProfileService>();
bool result = disDPTest->Init();
if(!result){
DHLOGI("demo test: InitDevice error");
return dpError;
}
return dpOk;
}
int threadSendF()
{
DHLOGI("demo test: 请插入第一个手机");
int status = system("D:\\DP\\push.bat");
Sleep(40000);
if (status != 0) {
DHLOGI("demo test: send file fail");
return dpError;
}
DHLOGI("demo test: 请插入第二个手机");
int status = system("D:\\DP\\push.bat");
Sleep(40000);
if (status != 0) {
DHLOGI("demo test: send file fail");
return dpError;
}
return dpOk;
}
void DPTest::SendFP()
{
std::thread myThread(threadSendF);
myThread.join();
}
std::string DPTest::GetDevProfileTest()
{
ServiceCharacteristicProfile profile;
std::string testServiceId = profile.GetServiceId();
DistributedDeviceProfileClient::GetInstance().GetDeviceProfile("", testServiceId, profile);
std::string jsonData = profile.GetCharacteristicProfileJson();
if(jsonData.empty()){
DHLOGI("demo test: GetDevProfileTest GetCharacteristicProfileJson error");
return "false";
}
std::string result = result.append("jsonData:" + jsonData + "\n");
return result;
}
std::string DPTest::PutDevProfileTest()
{
// 声明并填充插入数据
ServiceCharacteristicProfile profile;
profile.SetServiceId("test");
profile.SetServiceType("test");
nlohmann::json j;
j["testVersion"] = "3.0.0";
j["testApiLevel"] = API_LEVEL;
profile.SetCharacteristicProfileJson(j.dump());
// 执行插入接口PutDeviceProfile
DistributedDeviceProfileClient::GetInstance().PutDeviceProfile(profile);
std::string jsonData = profile.GetCharacteristicProfileJson();
if (jsonData.empty()) {
DHLOGI("demo test: PutDevProfileTest GetCharacteristicProfileJson error");
return "false";
}
std::string result = result.append("jsonData:" + jsonData + "\n");
return result;
}
/*写入serviceid,servicetype为空*/
std::string DPTest::PutDevProfileSerciceidTest()
{
// 声明并填充插入数据
ServiceCharacteristicProfile profile;
profile.SetServiceId("");
profile.SetServiceType("");
nlohmann::json j;
j["testVersion"] = "3.0.0";
j["testApiLevel"] = API_LEVEL;
profile.SetCharacteristicProfileJson(j.dump());
// 执行插入接口PutDeviceProfile
DistributedDeviceProfileClient::GetInstance().PutDeviceProfile(profile);
std::string jsonData = profile.GetCharacteristicProfileJson();
if (jsonData.empty()) {
DHLOGI("demo test: PutDevProfileTest error");
return "false";
}
std::string result = result.append("jsonData:" + jsonData + "\n");
return result;
}
int DPTest::DeleteDevProfileTest()
{
std::string serviceId = "test";
DistributedDeviceProfileClient::GetInstance().DeleteDeviceProfile(serviceId);
if (ret != 0) {
DHLOGI("demo test: DeleteDevProfileTest error");
return dpError;
}
return dpOk;
}
int DPTest::SyncDveProfileTest(){
ServiceCharacteristicProfile profile;
SyncOptions syncOption;
syncOption.SetSyncMode((OHOS::DeviceProfile::SyncMode)atoi(mode.c_str()));
for (const auto& deviceId : deviceIds) {
syncOption.AddDevice(deviceId);
}
// 执行同步接口
int32_t ret = DistributedDeviceProfileClient::GetInstance().SyncDeviceProfile(syncOption,
std::make_shared<ProfileEventCallback>());
if (ret != ERR_OK) {
DHLOGI("demo test: SyncDveProfileTest error");
return dpError;
}
return dpOk;
}
int DPTest::SubscribeProfileEventsTest(){
auto callback = std::make_shared<ProfileEventCallback>();
std::list<SubscribeInfo> subscribeInfos;
ServiceCharacteristicProfile profile;
std::string deviceId = JSON.stringify(dmDeviceInfo[0]["deviceId"]);
std::string ServiceIds = profile.GetServiceId();
// 订阅EVENT_PROFILE_CHANGED事件
ExtraInfo extraInfo;
extraInfo["deviceId"] = deviceId;
extraInfo["serviceIds"] = ServiceIds;
SubscribeInfo changeEventInfo;
changeEventInfo.profileEvent = ProfileEvent::EVENT_PROFILE_CHANGED;
changeEventInfo.extraInfo = std::move(extraInfo);
subscribeInfos.emplace_back(changeEventInfo);
// 订阅EVENT_SYNC_COMPLETED事件
SubscribeInfo syncEventInfo;
syncEventInfo.profileEvent = ProfileEvent::EVENT_SYNC_COMPLETED;
subscribeInfos.emplace_back(syncEventInfo);
// 执行订阅接口
std::list<ProfileEvent> failedEvents;
DistributedDeviceProfileClient::GetInstance().SubscribeProfileEvents(subscribeInfos,
callback, failedEvents);
if (failedEvents.empty()) {
DHLOGI("demo test: SubscribeProfileEvents error");
return dpError;
}
// 解除订阅
std::list<ProfileEvent> profileEvents;
profileEvents.emplace_back(ProfileEvent::EVENT_PROFILE_CHANGED);
DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(profileEvents,
callback, failedEvents);
if (failedEvents.empty()) {j
DHLOGI("demo test: UnsubscribeProfileEvents error");
return dpError;
}
return dpOk;
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2021-2023 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 JPQDOWN_disdveprofile_test_H
#define JPQDOWN_disdveprofile_test_H
#include <atomic>
#include <string>
#include <thread>
#include "service_characteristic.h"
#include "distributed_device_profile_service.h"
#include "service_characteristic_profile.h"
#include "nocopyable.h"
#include "distributed_hardware_log.h"
#include "distributed_device_profile_client.h"
namespace OHOS {
namespace DeviceProfile {
class DPTest{
public:
DPTest();
~DPTest();
std::string GetDevProfileTest();
std::string PutDevProfileTest();
std::string PutDevProfileSerciceidTest();
int DeleteDevProfileTest();
int SyncDveProfileTest();
int SubscribeProfileEventsTest();
void SendFP();
//private:
};
}
}
#endif //JPQDOWN_disdveprofile_test_H

View File

@ -1,128 +0,0 @@
/*
* Copyright (c) 2021-2023 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 <gtest/gtest.h>
#include <cstdlib>
#include "disdveprofile_test.h"
#include "nlohmann/json.hpp"
#include <system>
#include "json/json.h"
#include <thread>
#include "device_profile_log.h"
#include <string>
#include "distributed_device_profile_client.h"
namespace OHOS {
namespace DeviceProfile {
using namespace testing;
using namespace testing::ext;
auto mainDemo = std::make_shared<DPTest>();
class ServiceProfileTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void ServiceProfileTest::SetUpTestCase()
{
DTEST_LOG << "SetUpTestCase" << std::endl;
}
void ServiceProfileTest::TearDownTestCase()
{
DTEST_LOG << "TearDownTestCase" << std::endl;
}
void ServiceProfileTest::SetUp()
{
DTEST_LOG << "SetUp" << std::endl;
mainDemo->SendFP();
}
void ServiceProfileTest::TearDown()
{
DTEST_LOG << "TearDown" << std::endl;
}
/**
* @tc.number : SUB_DH_DPTSET_Dcts__001
* @tc.name PutDevProfileTest()
* @tc.desc : [SUB_DH_DPTSET_Dcts__001]profile数据
* @tc.desc : Change profile data
* @tc.type : FUNC
* @tc.size : Medium test
*/
HWTEST_F(ServiceProfileTest, SUB_DH_DPTSET_Dcts__001, TestSize.Level3)
{
std::string ret = mainDemo->PutDevProfileTest();
std::string res = mainDemo->GetDevProfileTest();
// if(res != ret){
// DHLOGI("demo test: GetDveProfileTest fail");
// }
EXPECT_EQ(ret, res)<<"PutDevProfileTest PASS";
}
/**
* @tc.number : SUB_DH_DPTSET_Dcts__002
* @tc.name DeleteDevProfileTest
* @tc.desc : [SUB_DH_DPTSET_Dcts__002]profile数据
* @tc.desc : delete profile data
* @tc.type : FUNC
* @tc.size : Medium test
*/
HWTEST_F(ServiceProfileTest, SUB_DH_DPTSET_Dcts__002, TestSize.Level3)
{
// 执行查询接口GetDeviceProfile
int ret = mainDemo->DeleteDevProfileTest();
std::string res = mainDemo->GetDevProfileTest();
EXPECT_EQ("", res)<<"PutDevProfileTest PASS";
}
/**
* @tc.number : SUB_DH_DPTSET_Dcts__003
* @tc.name SyncDveProfileTest
* @tc.desc : [SUB_DH_DPTSET_Dcts__002]profile数据
* @tc.desc : synchronous profile data
* @tc.type : FUNC
* @tc.size : Medium test
*/
HWTEST_F(ServiceProfileTest, SUB_DH_DPTSET_Dcts__003, TestSize.Level3)
{
int ret = mainDemo->SyncDveProfileTest();
EXPECT_EQ(0, ret)<<"SyncDveProfileTest PASS";
}
/**
* @tc.number : SUB_DH_DPTSET_Dcts__004
* @tc.name SyncDveProfileTest
* @tc.desc : [SUB_DH_DPTSET_Dcts__004]profile数据
* @tc.desc : subscribe profile data
* @tc.type : FUNC
* @tc.size : Medium test
*/
HWTEST_F(ServiceProfileTest, SUB_DH_DPTSET_Dcts__004, TestSize.Level3)
{
int ret = mainDemo->SubscribeProfileEventsTest();
EXPECT_EQ(0, res)<<"SubscribeProfileEventsTest PASS";
}
}
}

View File

@ -15,7 +15,7 @@ base_root = "../../../../../"
import("//test/xts/tools/build/suite.gni")
module_out_path = "dcts/distributedhardware"
ohos_moduletest_suite("SubDctsDistributedDpTest") {
ohos_moduletest_suite("DctsSubDistributedDpTest") {
sanitize = {
cfi = true
cfi_cross_dso = true
@ -54,7 +54,7 @@ ohos_moduletest_suite("SubDctsDistributedDpTest") {
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SubDctsDistributedDpTest\"",
"DH_LOG_TAG=\"DctsSubDistributedDpTest\"",
"LOG_DOMAIN=0xD004100",
]

View File

@ -1,7 +1,7 @@
{
"description": "Config for disCamera test cases",
"driver": {
"module-name": "SubDctsDistributedDpTest",
"module-name": "DctsSubDistributedDpTest",
"native-test-timeout": "120000",
"native-test-device-path": "/data/local/tmp",
"runtime-hint": "1s",
@ -13,7 +13,7 @@
"chmod -R 777 /data/local/tmp/*"
],
"push": [
"SubDctsDistributedDpTest->/data/local/tmp/SubDctsDistributedDpTest"
"DctsSubDistributedDpTest->/data/local/tmp/DctsSubDistributedDpTest"
],
"type": "PushKit"
}

View File

@ -16,7 +16,7 @@ import("//test/xts/tools/build/suite.gni")
module_out_path = "dcts/distributedhardware"
ohos_moduletest_suite("SubDistributedInputTest") {
ohos_moduletest_suite("DctsSubDistributedInputTest") {
module_out_path = module_out_path
include_dirs = [
"$base_root/foundation/distributedhardware/distributed_hardware_fwk/av_transport/common/include",
@ -82,7 +82,7 @@ ohos_moduletest_suite("SubDistributedInputTest") {
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SubDistributedInputTest\"",
"DH_LOG_TAG=\"DctsSubDistributedInputTest\"",
"LOG_DOMAIN=0xD004100",
]

View File

@ -1,7 +1,7 @@
{
"description": "Config for disCamera test cases",
"driver": {
"module-name": "SubDistributedInputTest",
"module-name": "DctsSubDistributedInputTest",
"native-test-timeout": "120000",
"native-test-device-path": "/data/local/tmp",
"runtime-hint": "1s",
@ -13,7 +13,7 @@
"chmod -R 777 /data/local/tmp/*"
],
"push": [
"SubDistributedInputTest->/data/local/tmp/SubDistributedInputTest"
"DctsSubDistributedInputTest->/data/local/tmp/DctsSubDistributedInputTest"
],
"type": "PushKit"
}

View File

@ -16,7 +16,7 @@ import("//test/xts/tools/build/suite.gni")
module_output_path = "dcts/distributedhardware"
ohos_moduletest_suite("SubDctsdisScreenTest") {
ohos_moduletest_suite("DctsSubdisScreenTest") {
sanitize = {
cfi = true
cfi_cross_dso = true
@ -49,7 +49,7 @@ ohos_moduletest_suite("SubDctsdisScreenTest") {
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SubDctsdisScreenTest\"",
"DH_LOG_TAG=\"DctsSubdisScreenTest\"",
"LOG_DOMAIN=0xD004100",
]

View File

@ -1,7 +1,7 @@
{
"description": "Config for disSreen test cases",
"driver": {
"module-name": "SubDctsdisScreenTest",
"module-name": "DctsSubdisScreenTest",
"native-test-timeout": "120000",
"native-test-device-path": "/data/local/tmp",
"runtime-hint": "1s",
@ -13,7 +13,7 @@
"chmod -R 777 /data/local/tmp/*"
],
"push": [
"SubDctsdisScreenTest->/data/local/tmp/SubDctsdisScreenTest"
"DctsSubdisScreenTest->/data/local/tmp/DctsSubdisScreenTest"
],
"type": "PushKit"
}