mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-20 21:41:02 -04:00
Description:Sync UT Test Codes
Match-id-9bf485cd303c374aa8275f3a024d608f495248ff
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
"//foundation/distributedhardware/distributed_input/sinkhandler/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/inputcollector/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/transport/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/common/include/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/test:test",
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
size_t StartCollectInputHandler(InputDeviceEvent* buffer, size_t bufferSize);
|
||||
void StopCollectInputEvents();
|
||||
void StopCollectInputHandler();
|
||||
size_t DeviceIsExists(InputDeviceEvent* event, size_t bufferSize);
|
||||
size_t DeviceIsExists(InputDeviceEvent* buffer, size_t bufferSize);
|
||||
std::vector<InputDevice> GetAllInputDevices();
|
||||
// return efftive dhids
|
||||
AffectDhIds SetSupportInputType(bool enabled, const uint32_t &inputTypes);
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 <iostream>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
|
||||
#include "securec.h"
|
||||
#include "session_mock.h"
|
||||
|
||||
constexpr int32_t DH_SUCCESS = 0;
|
||||
constexpr int32_t DH_ERROR = -1;
|
||||
constexpr int32_t MOCK_SESSION_ID = 1;
|
||||
static ISessionListener g_listener;
|
||||
static char g_peerDeviceId[CHAR_ARRAY_SIZE];
|
||||
static char g_peerSessionName[CHAR_ARRAY_SIZE];
|
||||
static char g_mySessionName[CHAR_ARRAY_SIZE];
|
||||
int CreateSessionServer(const char *pkgName, const char *sessionName, const ISessionListener *listener)
|
||||
{
|
||||
std::cout << "CreateSessionServer start sessionName:" << sessionName << std::endl;
|
||||
std::string tmpstr = sessionName;
|
||||
if (tmpstr.size() <= 0) {
|
||||
std::cout << "CreateSessionServer sessionName is empty." << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
if (listener == nullptr) {
|
||||
std::cout << "CreateSessionServer listener is null." << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
if (strcpy_s(g_mySessionName, tmpstr.size(), tmpstr.c_str()) != DH_SUCCESS) {
|
||||
std::cout << "strcpy_s faild" << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
g_listener.onBytesReceived = listener->onBytesReceived;
|
||||
g_listener.onMessageReceived = listener->onMessageReceived;
|
||||
g_listener.onSessionClosed = listener->onSessionClosed;
|
||||
g_listener.onSessionOpened = listener->onSessionOpened;
|
||||
g_listener.onStreamReceived = listener->onStreamReceived;
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int RemoveSessionServer(const char *pkgName, const char *sessionName)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int OpenSession(const char *mySessionName, const char *peerSessionName, const char *peerDeviceId, const char *groupId,
|
||||
const SessionAttribute *attr)
|
||||
{
|
||||
if (strlen(peerSessionName) <= 0) {
|
||||
return DH_ERROR;
|
||||
}
|
||||
if (strlen(peerDeviceId) <= 0) {
|
||||
return DH_ERROR;
|
||||
}
|
||||
if (strncpy_s(g_peerSessionName, sizeof(g_peerSessionName), peerSessionName, CHAR_ARRAY_SIZE) != DH_SUCCESS) {
|
||||
std::cout << "strncpy_s faild" << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
if (strncpy_s(g_peerDeviceId, sizeof(g_peerDeviceId), peerDeviceId, DEVICE_ID_SIZE_MAX) != DH_SUCCESS) {
|
||||
std::cout << "strncpy_s faild" << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
std::thread thd(OpenSessionResult);
|
||||
thd.detach();
|
||||
return MOCK_SESSION_ID;
|
||||
}
|
||||
|
||||
void OpenSessionResult()
|
||||
{
|
||||
g_listener.onSessionOpened(MOCK_SESSION_ID, DH_SUCCESS);
|
||||
}
|
||||
|
||||
void CloseSession(int sessionId) {}
|
||||
|
||||
int SendBytes(int sessionId, const void *data, unsigned int len)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int SendMessage(int sessionId, const void *data, unsigned int len)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int SendStream(int sessionId, const StreamData *data, const StreamData *ext, const FrameInfo *param)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int GetMySessionName(int sessionId, char *sessionName, unsigned int len)
|
||||
{
|
||||
if (strncpy_s(sessionName, sizeof(sessionName), g_mySessionName, CHAR_ARRAY_SIZE) != DH_SUCCESS) {
|
||||
std::cout << "strncpy_s faild" << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int GetPeerSessionName(int sessionId, char *sessionName, unsigned int len)
|
||||
{
|
||||
if (strncpy_s(sessionName, sizeof(sessionName), g_peerSessionName, CHAR_ARRAY_SIZE) != DH_SUCCESS) {
|
||||
std::cout << "strncpy_s faild" << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int GetPeerDeviceId(int sessionId, char *devId, unsigned int len)
|
||||
{
|
||||
if (strncpy_s(devId, sizeof(devId), g_peerDeviceId, DEVICE_ID_SIZE_MAX) != DH_SUCCESS) {
|
||||
std::cout << "strncpy_s faild" << std::endl;
|
||||
return DH_ERROR;
|
||||
}
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int GetSessionSide(int sessionId)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int SetFileReceiveListener(const char *pkgName, const char *sessionName, const IFileReceiveListener *recvListener,
|
||||
const char *rootDir)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int SetFileSendListener(const char *pkgName, const char *sessionName, const IFileSendListener *sendListener)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int SendFile(int sessionId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Softbus
|
||||
* @{
|
||||
*
|
||||
* @brief Provides high-speed, secure communication between devices.
|
||||
*
|
||||
* This module implements unified distributed communication capability management between
|
||||
* nearby devices, and provides link-independent device discovery and transmission interfaces
|
||||
* to support service publishing and data transmission.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file session.h
|
||||
*
|
||||
* @brief Declares unified data transmission interfaces.
|
||||
*
|
||||
* This file provides data transmission capabilities, including creating and removing a session server,
|
||||
* opening and closing sessions, receiving data, and querying basic session information. \n
|
||||
* After multiple nearby devices are discovered and networked, these interfaces can be used to
|
||||
* transmit data across devices. \n
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#ifndef SESSION_MOCK_H
|
||||
#define SESSION_MOCK_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* @brief business type of session
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
TYPE_MESSAGE = 1,
|
||||
TYPE_BYTES,
|
||||
TYPE_FILE,
|
||||
TYPE_STREAM,
|
||||
TYPE_BUTT,
|
||||
} SessionType;
|
||||
|
||||
typedef enum {
|
||||
INVALID = -1,
|
||||
/*
|
||||
* Send any segment of a frame each time.
|
||||
*/
|
||||
RAW_STREAM,
|
||||
/*
|
||||
* Send a whole video frame each time.
|
||||
*/
|
||||
COMMON_VIDEO_STREAM,
|
||||
/*
|
||||
* Send a whole audio frame each time.
|
||||
*/
|
||||
COMMON_AUDIO_STREAM,
|
||||
/*
|
||||
* Slice frame mode.
|
||||
*/
|
||||
VIDEO_SLICE_STREAM,
|
||||
} StreamType;
|
||||
|
||||
typedef enum {
|
||||
LINK_TYPE_WIFI_WLAN_5G = 1,
|
||||
LINK_TYPE_WIFI_WLAN_2G = 2,
|
||||
LINK_TYPE_WIFI_P2P = 3,
|
||||
LINK_TYPE_BR = 4,
|
||||
LINK_TYPE_MAX = 4,
|
||||
} LinkType;
|
||||
|
||||
typedef struct {
|
||||
/* @brief dataType{@link SessionType} */
|
||||
int dataType;
|
||||
int linkTypeNum;
|
||||
LinkType linkType[LINK_TYPE_MAX];
|
||||
union {
|
||||
struct StreamAttr {
|
||||
int streamType;
|
||||
} streamAttr;
|
||||
} attr;
|
||||
} SessionAttribute;
|
||||
|
||||
typedef struct {
|
||||
char *buf;
|
||||
int bufLen;
|
||||
} StreamData;
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
int64_t value;
|
||||
} TV;
|
||||
|
||||
typedef struct {
|
||||
int frameType;
|
||||
int64_t timeStamp;
|
||||
int seqNum;
|
||||
int seqSubNum;
|
||||
int level;
|
||||
int bitMap;
|
||||
int tvCount;
|
||||
TV *tvList;
|
||||
} FrameInfo;
|
||||
|
||||
enum FrameType {
|
||||
NONE,
|
||||
VIDEO_I,
|
||||
VIDEO_P,
|
||||
VIDEO_MAX = 50,
|
||||
RADIO = VIDEO_MAX + 1,
|
||||
RADIO_MAX = 100,
|
||||
};
|
||||
|
||||
// APP should update StreamFrameInfo each time.
|
||||
struct StreamFrameInfo {
|
||||
uint32_t streamId = 0;
|
||||
uint32_t seqNum = 0;
|
||||
uint32_t level = 0;
|
||||
FrameType frameType = NONE;
|
||||
uint32_t timestamp = 0;
|
||||
uint32_t bitrate = 0;
|
||||
};
|
||||
|
||||
constexpr uint32_t DEVICE_ID_SIZE_MAX = 65;
|
||||
constexpr uint32_t CHAR_ARRAY_SIZE = 100;
|
||||
|
||||
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 StreamFrameInfo *param);
|
||||
} ISessionListener;
|
||||
|
||||
typedef struct {
|
||||
int (*onReceiveFileStarted)(int sessionId, const char *files, int fileCnt);
|
||||
int (*onReceiveFileProcess)(int sessionId, const char *firstFile, uint64_t bytesUpload, uint64_t bytesTotal);
|
||||
void (*onReceiveFileFinished)(int sessionId, const char *files, int fileCnt);
|
||||
void (*onFileTransError)(int sessionId);
|
||||
} IFileReceiveListener;
|
||||
|
||||
typedef struct {
|
||||
int (*onSendFileProcess)(int sessionId, uint64_t bytesUpload, uint64_t bytesTotal);
|
||||
int (*onSendFileFinished)(int sessionId, const char *firstFile);
|
||||
void (*onFileTransError)(int sessionId);
|
||||
} IFileSendListener;
|
||||
|
||||
int CreateSessionServer(const char *pkgName, const char *sessionName, const ISessionListener *listener);
|
||||
|
||||
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);
|
||||
void OpenSessionResult(void);
|
||||
|
||||
void CloseSession(int sessionId);
|
||||
|
||||
int SendBytes(int sessionId, const void *data, unsigned int len);
|
||||
|
||||
int SendMessage(int sessionId, const void *data, unsigned int len);
|
||||
|
||||
int SendStream(int sessionId, const StreamData *data, const StreamData *ext, const FrameInfo *param);
|
||||
|
||||
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 SetFileSendListener(const char *pkgName, const char *sessionName, const IFileSendListener *sendListener);
|
||||
|
||||
int SendFile(int sessionId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // SESSION_MOCK_H
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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_bus_center_mock.h"
|
||||
|
||||
constexpr int32_t DH_SUCCESS = 0;
|
||||
int32_t GetLocalNodeDeviceInfo(const char *pkgName, NodeBasicInfo *info)
|
||||
{
|
||||
NodeBasicInfo nodeBasicInfo = {
|
||||
.networkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00",
|
||||
.deviceName = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591",
|
||||
.deviceTypeId = 1};
|
||||
(void)pkgName;
|
||||
*info = nodeBasicInfo;
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 SOFTBUS_BUS_CENTER_MOCK_H
|
||||
#define SOFTBUS_BUS_CENTER_MOCK_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
constexpr uint32_t MOCK_NETWORK_ID_BUF_LEN = 65;
|
||||
constexpr uint32_t MOCK_DEVICE_NAME_BUF_LEN = 65;
|
||||
/**
|
||||
* @brief Defines the basic information about a device.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
char networkId[MOCK_NETWORK_ID_BUF_LEN];
|
||||
char deviceName[MOCK_DEVICE_NAME_BUF_LEN];
|
||||
uint16_t deviceTypeId;
|
||||
} NodeBasicInfo;
|
||||
|
||||
int32_t GetLocalNodeDeviceInfo(const char *pkgName, NodeBasicInfo *info);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // SOFTBUS_BUS_CENTER_MOCK_H
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
group("test") {
|
||||
testonly = true
|
||||
|
||||
deps = [ "sinkcollectorunittest:sinkcollectorunittest" ]
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
import("//build/test.gni")
|
||||
import(
|
||||
"//foundation/distributedhardware/distributed_input/distributedinput.gni")
|
||||
module_out_path = "distributed_input/sink_collector"
|
||||
|
||||
group("sinkcollectorunittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":distributed_input_inner_sinkcollector_test" ]
|
||||
}
|
||||
|
||||
## UnitTest distributed_input_manager_service_test {{{
|
||||
ohos_unittest("distributed_input_inner_sinkcollector_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
include_dirs = [
|
||||
"$services_sink_path/inputcollector/include",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"${common_path}/include",
|
||||
"${frameworks_path}/include",
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
"${fwk_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
"//third_party/json/include",
|
||||
"${fwk_interfaces_path}/include",
|
||||
"${fwk_interfaces_path}/include/ipc",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${common_path}/include/input_hub.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/inputcollector/src/distributed_input_collector.cpp",
|
||||
"distributed_input_collector_test.cpp",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-g3",
|
||||
"-Dprivate=public",
|
||||
"-Dprotected=public",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"distributedinpututtest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/notification/eventhandler/frameworks/eventhandler:libeventhandler",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
}
|
||||
|
||||
## UnitTest distributed_input_manager_service_test }}}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "distributed_input_collector_test.h"
|
||||
#include "event_handler.h"
|
||||
#include "dinput_errcode.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::DistributedHardware::DistributedInput;
|
||||
using namespace std;
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
void DistributedInputCollectorTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedInputCollectorTest::TearDown()
|
||||
{
|
||||
DistributedInputCollector::GetInstance().Release();
|
||||
}
|
||||
|
||||
void DistributedInputCollectorTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedInputCollectorTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
DistributedInputCollectorTest::DInputSinkCollectorEventHandler::DInputSinkCollectorEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner) : AppExecFwk::EventHandler(runner)
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedInputCollectorTest::DInputSinkCollectorEventHandler::ProcessEvent(
|
||||
const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
(void)event;
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputCollectorTest, Init01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ = nullptr;
|
||||
int32_t ret = DistributedInputCollector::GetInstance().Init(eventHandler_);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_COLLECTOR_INIT_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputCollectorTest, Init02, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ =
|
||||
std::make_shared<DistributedInputCollectorTest::DInputSinkCollectorEventHandler>(runner);
|
||||
|
||||
int32_t ret = DistributedInputCollector::GetInstance().Init(eventHandler_);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputCollectorTest, IsAllDevicesStoped, testing::ext::TestSize.Level1)
|
||||
{
|
||||
bool isStop = DistributedInputCollector::GetInstance().IsAllDevicesStoped();
|
||||
EXPECT_EQ(true, isStop);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 DISRIBUTED_INPUT_COLLECTOR_TEST_H
|
||||
#define DISRIBUTED_INPUT_COLLECTOR_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "constants_dinput.h"
|
||||
#include "distributed_input_collector.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
class DistributedInputCollectorTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
class DInputSinkCollectorEventHandler : public AppExecFwk::EventHandler {
|
||||
public:
|
||||
explicit DInputSinkCollectorEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner);
|
||||
~DInputSinkCollectorEventHandler() {}
|
||||
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
|
||||
};
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // DISRIBUTED_INPUT_COLLECTOR_TEST_H
|
||||
@@ -58,6 +58,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
"//drivers/peripheral/display/interfaces/include",
|
||||
"//drivers/peripheral/base",
|
||||
"//foundation/graphic/graphic_2d/utils/buffer_handle/export",
|
||||
"${common_path}/mock",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -70,6 +71,8 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp",
|
||||
"distributed_input_sinkmanager_test.cpp",
|
||||
"${common_path}/mock/session_mock.cpp",
|
||||
"${common_path}/mock/softbus_bus_center_mock.cpp",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -96,7 +99,6 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
"${low_latency_path}:libdinput_low_latency",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//base/notification/eventhandler/frameworks/eventhandler:libeventhandler",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
"${fwk_interfaces_path}:libdhfwk_sdk",
|
||||
"//foundation/window/window_manager/dm:libdm",
|
||||
|
||||
+21
-1
@@ -34,6 +34,10 @@ void DistributedInputSinkManagerTest::SetUp()
|
||||
|
||||
void DistributedInputSinkManagerTest::TearDown()
|
||||
{
|
||||
if (sinkManager_ != nullptr) {
|
||||
delete sinkManager_;
|
||||
sinkManager_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSinkManagerTest::SetUpTestCase()
|
||||
@@ -47,7 +51,23 @@ void DistributedInputSinkManagerTest::TearDownTestCase()
|
||||
HWTEST_F(DistributedInputSinkManagerTest, Init01, testing::ext::TestSize.Level0)
|
||||
{
|
||||
int32_t ret = sinkManager_->Init();
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_MANAGER_INIT_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkManagerTest, GetStartTransFlag, testing::ext::TestSize.Level0)
|
||||
{
|
||||
DInputServerType flag = DInputServerType::SINK_SERVER_TYPE;
|
||||
sinkManager_->SetStartTransFlag(flag);
|
||||
DInputServerType retFlag = sinkManager_->GetStartTransFlag();
|
||||
EXPECT_EQ(flag, retFlag);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkManagerTest, GetInputTypes, testing::ext::TestSize.Level0)
|
||||
{
|
||||
uint32_t inputTypes = static_cast<uint32_t>(DInputDeviceType::MOUSE);
|
||||
sinkManager_->SetInputTypes(inputTypes);
|
||||
uint32_t retType = sinkManager_->GetInputTypes();
|
||||
EXPECT_EQ(inputTypes, retType);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
+3
-3
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#define DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#ifndef DISRIBUTED_INPUT_SINKMANAGER_TEST_H
|
||||
#define DISRIBUTED_INPUT_SINKMANAGER_TEST_H
|
||||
|
||||
|
||||
#include <functional>
|
||||
@@ -44,4 +44,4 @@ private:
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#endif // DISRIBUTED_INPUT_SINKMANAGER_TEST_H
|
||||
|
||||
@@ -37,17 +37,19 @@ ohos_unittest("distributed_input_sinktrans_test") {
|
||||
"${fwk_utils_path}/include",
|
||||
"${service_common}/include",
|
||||
"//third_party/json/include",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/test/sinktransunittest/mock",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
"${low_latency_path}/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"${common_path}/mock",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp",
|
||||
"distributed_input_sinktrans_test.cpp",
|
||||
"${common_path}/mock/session_mock.cpp",
|
||||
"${common_path}/mock/softbus_bus_center_mock.cpp",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -69,7 +71,6 @@ ohos_unittest("distributed_input_sinktrans_test") {
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//base/notification/eventhandler/frameworks/eventhandler:libeventhandler",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
+40
-1
@@ -41,7 +41,14 @@ void DistributedInputSinkTransTest::TearDownTestCase()
|
||||
HWTEST_F(DistributedInputSinkTransTest, Init, testing::ext::TestSize.Level0)
|
||||
{
|
||||
int32_t ret = DistributedInputSinkTransport::GetInstance().Init();
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_TRANSPORT_INIT_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, GetSessionIdByNetId, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "";
|
||||
int32_t ret = DistributedInputSinkTransport::GetInstance().GetSessionIdByNetId(srcId);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_TRANSPORT_GET_SESSIONID_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespPrepareRemoteInput01, testing::ext::TestSize.Level1)
|
||||
@@ -60,6 +67,14 @@ HWTEST_F(DistributedInputSinkTransTest, RespPrepareRemoteInput02, testing::ext::
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_TRANSPORT_RESPPREPARE_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespPrepareRemoteInput03, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t sessionId = 1;
|
||||
std::string smsg = "";
|
||||
int32_t ret = DistributedInputSinkTransport::GetInstance().RespPrepareRemoteInput(sessionId, smsg);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespUnprepareRemoteInput01, testing::ext::TestSize.Level0)
|
||||
{
|
||||
int32_t sessionId = -1;
|
||||
@@ -76,6 +91,14 @@ HWTEST_F(DistributedInputSinkTransTest, RespUnprepareRemoteInput02, testing::ext
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_TRANSPORT_RESPUNPREPARE_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespUnprepareRemoteInput03, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t sessionId = 1;
|
||||
std::string smsg = "";
|
||||
int32_t ret = DistributedInputSinkTransport::GetInstance().RespUnprepareRemoteInput(sessionId, smsg);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespStartRemoteInput01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t sessionId = -1;
|
||||
@@ -92,6 +115,14 @@ HWTEST_F(DistributedInputSinkTransTest, RespStartRemoteInput02, testing::ext::Te
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_TRANSPORT_RESPSTART_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespStartRemoteInput03, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t sessionId = 1;
|
||||
std::string smsg = "";
|
||||
int32_t ret = DistributedInputSinkTransport::GetInstance().RespStartRemoteInput(sessionId, smsg);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespStopRemoteInput01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t sessionId = -1;
|
||||
@@ -108,6 +139,14 @@ HWTEST_F(DistributedInputSinkTransTest, RespStopRemoteInput02, testing::ext::Tes
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SINK_TRANSPORT_RESPSTOP_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, RespStopRemoteInput03, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t sessionId = 1;
|
||||
std::string smsg = "";
|
||||
int32_t ret = DistributedInputSinkTransport::GetInstance().RespStopRemoteInput(sessionId, smsg);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSinkTransTest, GetEventHandler, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHd =
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#define DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#ifndef DISRIBUTED_INPUT_SINKTRANS_TEST_H
|
||||
#define DISRIBUTED_INPUT_SINKTRANS_TEST_H
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -40,4 +40,4 @@ public:
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#endif // DISRIBUTED_INPUT_SINKTRANS_TEST_H
|
||||
|
||||
@@ -36,6 +36,7 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"${common_path}/include",
|
||||
"${frameworks_path}/include",
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
@@ -50,10 +51,13 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
|
||||
"${distributedinput_path}/inputdevicehandler/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//base/notification/eventhandler/interfaces/inner_api",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${common_path}/include/input_hub.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/inputdevicehandler/src/distributed_input_handler.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/src/distributed_input_inject.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/src/distributed_input_node_manager.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/src/virtual_device.cpp",
|
||||
@@ -82,12 +86,14 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
"${distributedinput_path}/interfaces/inner_kits:libdinput_sdk",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"ipc:ipc_core",
|
||||
"dsoftbus:softbus_client",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
+31
@@ -51,6 +51,23 @@ void DistributedInputSourceInjectTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedInputSourceInjectTest::TestInputNodeListener::OnNodeOnLine(const std::string srcDevId,
|
||||
const std::string sinkDevId, const std::string sinkNodeId, const std::string sinkNodeDesc)
|
||||
{
|
||||
(void)srcDevId;
|
||||
(void)sinkDevId;
|
||||
(void)sinkNodeId;
|
||||
(void)sinkNodeDesc;
|
||||
}
|
||||
|
||||
void DistributedInputSourceInjectTest::TestInputNodeListener::OnNodeOffLine(const std::string srcDevId,
|
||||
const std::string sinkDevId, const std::string sinkNodeId)
|
||||
{
|
||||
(void)srcDevId;
|
||||
(void)sinkDevId;
|
||||
(void)sinkNodeId;
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedHardware01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
InputDevice pBuffer;
|
||||
@@ -230,6 +247,20 @@ HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedEvent03, testing::
|
||||
int32_t ret = DistributedInputInject::GetInstance().RegisterDistributedEvent(writeBuffer, count);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, RegisterInputNodeListener, testing::ext::TestSize.Level1)
|
||||
{
|
||||
inputNodelistener_ = (std::make_unique<TestInputNodeListener>()).release();
|
||||
int32_t ret = DistributedInputInject::GetInstance().RegisterInputNodeListener(inputNodelistener_);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, UnRegisterInputNodeListener, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t ret = DistributedInputInject::GetInstance().UnregisterInputNodeListener(inputNodelistener_);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
+14
-3
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#define DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#ifndef DISRIBUTED_INPUT_SOURCEINJECT_TEST_H
|
||||
#define DISRIBUTED_INPUT_SOURCEINJECT_TEST_H
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "constants_dinput.h"
|
||||
#include "distributed_input_inject.h"
|
||||
#include "input_node_listener_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -35,9 +36,19 @@ public:
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
class TestInputNodeListener : public OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub {
|
||||
public:
|
||||
TestInputNodeListener() = default;
|
||||
virtual ~TestInputNodeListener() = default;
|
||||
void OnNodeOnLine(const std::string srcDevId, const std::string sinkDevId, const std::string sinkNodeId,
|
||||
const std::string sinkNodeDesc);
|
||||
void OnNodeOffLine(const std::string srcDevId, const std::string sinkDevId, const std::string sinkNodeId);
|
||||
};
|
||||
private:
|
||||
sptr<TestInputNodeListener> inputNodelistener_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#endif // DISRIBUTED_INPUT_SOURCEINJECT_TEST_H
|
||||
|
||||
@@ -1193,6 +1193,10 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_START_USE, sinkId, "dinput start use call");
|
||||
DHLOGI("StartRemoteInput called, srcId: %s, sinkId: %s, inputTypes: %d", GetAnonyString(srcId).c_str(),
|
||||
GetAnonyString(sinkId).c_str(), inputTypes);
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("StartRemoteInput called, callback is null.");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
|
||||
}
|
||||
std::string localNetworkId = GetLocalNetworkId();
|
||||
if (localNetworkId.empty()) {
|
||||
DHLOGE("StartRemoteInput called, Could not get local device id.");
|
||||
@@ -1209,8 +1213,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId
|
||||
|
||||
for (auto iter : staCallbacks_) {
|
||||
if (iter.devId == sinkId && iter.inputTypes == inputTypes) {
|
||||
DHLOGE("StartRemoteInput called, srcId: %s, sinkId: %s repeat call.",
|
||||
GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str());
|
||||
DHLOGE("StartRemoteInput called, repeat call.");
|
||||
HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId,
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "dinput start use failed in already started");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK);
|
||||
@@ -1228,7 +1231,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "dinput start use failed in transport start");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK);
|
||||
DHLOGE("StartRemoteInput called, start fail.");
|
||||
for (std::vector<DInputClientStartInfo>::iterator it = staCallbacks_.begin(); it != staCallbacks_.end(); it++) {
|
||||
for (auto it = staCallbacks_.begin(); it != staCallbacks_.end(); it++) {
|
||||
if (it->devId == sinkId && it->inputTypes == inputTypes) {
|
||||
staCallbacks_.erase(it);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
|
||||
@@ -1246,6 +1249,10 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId,
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_STOP_USE, sinkId, "dinput stop use call");
|
||||
DHLOGI("StopRemoteInput called, srcId: %s, sinkId: %s, inputTypes: %d", GetAnonyString(srcId).c_str(),
|
||||
GetAnonyString(sinkId).c_str(), inputTypes);
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("StopRemoteInput called, callback is null.");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
|
||||
}
|
||||
std::string localNetworkId = GetLocalNetworkId();
|
||||
if (localNetworkId.empty()) {
|
||||
DHLOGE("StopRemoteInput called, Could not get local device id.");
|
||||
@@ -1278,7 +1285,7 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId,
|
||||
HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId,
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "dinput stop use failed in transport stop");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK);
|
||||
for (std::vector<DInputClientStopInfo>::iterator it = stpCallbacks_.begin(); it != stpCallbacks_.end(); it++) {
|
||||
for (auto it = stpCallbacks_.begin(); it != stpCallbacks_.end(); it++) {
|
||||
if (it->devId == sinkId && it->inputTypes == inputTypes) {
|
||||
stpCallbacks_.erase(it);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
|
||||
@@ -1469,6 +1476,10 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &sinkI
|
||||
StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK);
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_START_USE, sinkId, "dinput start use call");
|
||||
DHLOGI("sinkId: %s, vector.string.size: %d", GetAnonyString(sinkId).c_str(), dhIds.size());
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("StartRemoteInput called, callback is null.");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
|
||||
}
|
||||
std::string localNetworkId = GetLocalNetworkId();
|
||||
if (localNetworkId.empty()) {
|
||||
DHLOGE("Could not get local device id.");
|
||||
@@ -1505,8 +1516,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &sinkI
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "dinput start use failed in transport start");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK);
|
||||
DHLOGE("StartRemoteInput start fail.");
|
||||
for (std::vector<DInputClientStartDhidInfo>::iterator iter = staStringCallbacks_.begin();
|
||||
iter != staStringCallbacks_.end(); iter++) {
|
||||
for (auto iter = staStringCallbacks_.begin(); iter != staStringCallbacks_.end(); iter++) {
|
||||
if (iter->sinkId == sinkId && IsStringDataSame(iter->dhIds, dhIds)) {
|
||||
staStringCallbacks_.erase(iter);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
|
||||
@@ -1523,6 +1533,10 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &sinkId
|
||||
StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK);
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_STOP_USE, sinkId, "dinput stop use call");
|
||||
DHLOGI("sinkId: %s, vector.string.size: %d", GetAnonyString(sinkId).c_str(), dhIds.size());
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("StopRemoteInput called, callback is null.");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
|
||||
}
|
||||
std::string localNetworkId = GetLocalNetworkId();
|
||||
if (localNetworkId.empty()) {
|
||||
DHLOGE("Could not get local device id.");
|
||||
@@ -1555,8 +1569,7 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &sinkId
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "dinput stop use failed in transport stop");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK);
|
||||
DHLOGE("StopRemoteInput stop fail.");
|
||||
for (std::vector<DInputClientStopDhidInfo>::iterator iter = stpStringCallbacks_.begin();
|
||||
iter != stpStringCallbacks_.end(); iter++) {
|
||||
for (auto iter = stpStringCallbacks_.begin(); iter != stpStringCallbacks_.end(); iter++) {
|
||||
if (iter->sinkId == sinkId && IsStringDataSame(iter->dhIds, dhIds)) {
|
||||
stpStringCallbacks_.erase(iter);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
|
||||
@@ -1574,6 +1587,10 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_START_USE, sinkId, "dinput start use call");
|
||||
DHLOGI("srcId: %s, sinkId: %s, dhids size: %d",
|
||||
GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str(), dhIds.size());
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("StartRemoteInput called, callback is null.");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
|
||||
}
|
||||
std::string localNetworkId = GetLocalNetworkId();
|
||||
if (localNetworkId.empty()) {
|
||||
DHLOGE("Could not get local device id.");
|
||||
@@ -1610,8 +1627,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "dinput start use failed in transport start");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK);
|
||||
DHLOGE("StartRemoteInput start fail.");
|
||||
for (std::vector<DInputClientStartDhidInfo>::iterator iter = staStringCallbacks_.begin();
|
||||
iter != staStringCallbacks_.end(); iter++) {
|
||||
for (auto iter = staStringCallbacks_.begin(); iter != staStringCallbacks_.end(); iter++) {
|
||||
if (iter->srcId == srcId && iter->sinkId == sinkId && IsStringDataSame(iter->dhIds, dhIds)) {
|
||||
staStringCallbacks_.erase(iter);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
|
||||
@@ -1629,6 +1645,10 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId,
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_STOP_USE, sinkId, "dinput stop use call");
|
||||
DHLOGI("srcId: %s, sinkId: %s, vector.string.size: %d",
|
||||
GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str(), dhIds.size());
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("StopRemoteInput called, callback is null.");
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
|
||||
}
|
||||
std::string localNetworkId = GetLocalNetworkId();
|
||||
if (localNetworkId.empty()) {
|
||||
DHLOGE("Could not get local device id.");
|
||||
@@ -1653,21 +1673,15 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId,
|
||||
}
|
||||
}
|
||||
|
||||
DInputClientStopDhidInfo info;
|
||||
info.srcId = srcId;
|
||||
info.sinkId = sinkId;
|
||||
info.dhIds = dhIds;
|
||||
info.callback = callback;
|
||||
DInputClientStopDhidInfo info{srcId, sinkId, dhIds, callback};
|
||||
stpStringCallbacks_.push_back(info);
|
||||
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(sinkId, dhIds);
|
||||
if (ret != DH_SUCCESS) {
|
||||
HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, sinkId,
|
||||
ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "dinput stop use failed in transport stop");
|
||||
FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK);
|
||||
DHLOGE("StopRemoteInput stop fail.");
|
||||
for (std::vector<DInputClientStopDhidInfo>::iterator iter = stpStringCallbacks_.begin();
|
||||
iter != stpStringCallbacks_.end(); iter++) {
|
||||
for (auto iter = stpStringCallbacks_.begin(); iter != stpStringCallbacks_.end(); iter++) {
|
||||
if (iter->srcId == srcId && iter->sinkId == sinkId && IsStringDataSame(iter->dhIds, dhIds)) {
|
||||
stpStringCallbacks_.erase(iter);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
|
||||
|
||||
@@ -55,6 +55,7 @@ ohos_unittest("distributed_input_sourcemanager_test") {
|
||||
"${fwk_interfaces_path}/include",
|
||||
"${fwk_interfaces_path}/include/ipc",
|
||||
"//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include",
|
||||
"${common_path}/mock",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -94,6 +95,8 @@ ohos_unittest("distributed_input_sourcemanager_test") {
|
||||
"//foundation/distributedhardware/distributed_input/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/transport/src/distributed_input_source_transport.cpp",
|
||||
"distributed_input_sourcemanager_test.cpp",
|
||||
"${common_path}/mock/session_mock.cpp",
|
||||
"${common_path}/mock/softbus_bus_center_mock.cpp",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -120,7 +123,6 @@ ohos_unittest("distributed_input_sourcemanager_test") {
|
||||
"${low_latency_path}:libdinput_low_latency",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//base/notification/eventhandler/frameworks/eventhandler:libeventhandler",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
"${fwk_interfaces_path}:libdhfwk_sdk",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
|
||||
+63
-46
@@ -165,6 +165,15 @@ void DistributedInputSourceManagerTest::TestInputNodeListenerCb::OnNodeOffLine(c
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceManagerTest::TestSimulationEventCb::OnSimulationEvent(uint32_t type, uint32_t code,
|
||||
int32_t value)
|
||||
{
|
||||
(void)type;
|
||||
(void)code;
|
||||
(void)value;
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceManagerTest::StructTransJson(const InputDevice& pBuf, std::string& strDescriptor) const
|
||||
{
|
||||
nlohmann::json tmpJson;
|
||||
@@ -187,7 +196,7 @@ int32_t DistributedInputSourceManagerTest::StructTransJson(const InputDevice& pB
|
||||
HWTEST_F(DistributedInputSourceManagerTest, Init01, testing::ext::TestSize.Level0)
|
||||
{
|
||||
int32_t ret = sourceManager_->Init();
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INIT_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware01, testing::ext::TestSize.Level0)
|
||||
@@ -263,7 +272,7 @@ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput01, testing::ext::
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestPrepareDInputCallback> callback = new TestPrepareDInputCallback();
|
||||
int32_t ret = sourceManager_->PrepareRemoteInput(devId, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput02, testing::ext::TestSize.Level0)
|
||||
@@ -290,11 +299,11 @@ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput03, testing::ext::
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestPrepareDInputCallback> callback = new TestPrepareDInputCallback();
|
||||
int32_t ret = sourceManager_->PrepareRemoteInput(srcId, sinkId, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,7 +314,7 @@ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput04, testing::ext::
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput05, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestPrepareDInputCallback> callback;
|
||||
int32_t ret = sourceManager_->PrepareRemoteInput(srcId, sinkId, callback);
|
||||
@@ -332,7 +341,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput01, testing::ext::Te
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestStartDInputCallback> callback = new TestStartDInputCallback();
|
||||
int32_t ret = sourceManager_->StartRemoteInput(devId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput02, testing::ext::TestSize.Level0)
|
||||
@@ -352,30 +361,30 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput03, testing::ext::Te
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteInput06
|
||||
* @tc.name: StartRemoteInput04
|
||||
* @tc.desc: verify the function of starting distributed input on InputDeviceType.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J75
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestStartDInputCallback> callback = new TestStartDInputCallback();
|
||||
int32_t ret =
|
||||
sourceManager_->StartRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteInput06
|
||||
* @tc.name: StartRemoteInput05
|
||||
* @tc.desc: verify the function of starting distributed input on InputDeviceType.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J75
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput05, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestStartDInputCallback> callback;
|
||||
int32_t ret =
|
||||
@@ -405,26 +414,26 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput06, testing::ext::Te
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J76
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput10, testing::ext::TestSize.Level0)
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput07, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::vector<std::string> dhIds;
|
||||
dhIds.push_back("Input_slkdiek3kddkeojfe");
|
||||
sptr<TestStartStopVectorCallbackStub> callback = new TestStartStopVectorCallbackStub();
|
||||
int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteInput10
|
||||
* @tc.name: StartRemoteInput08
|
||||
* @tc.desc: verify the function of transferring mouse button status.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J76
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput11, testing::ext::TestSize.Level0)
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput08, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::vector<std::string> dhIds;
|
||||
sptr<TestStartStopVectorCallbackStub> callback;
|
||||
@@ -433,12 +442,12 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput11, testing::ext::Te
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteInput12
|
||||
* @tc.name: StartRemoteInput09
|
||||
* @tc.desc: verify the low-latency transmission capability of distributed input
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J78
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput12, testing::ext::TestSize.Level0)
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput09, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "";
|
||||
std::string sinkId = "";
|
||||
@@ -454,7 +463,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput01, testing::ext::Tes
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestStopDInputCallback> callback = new TestStopDInputCallback();
|
||||
int32_t ret = sourceManager_->StopRemoteInput(devId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput02, testing::ext::TestSize.Level0)
|
||||
@@ -481,12 +490,12 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput03, testing::ext::Tes
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestStopDInputCallback> callback = new TestStopDInputCallback();
|
||||
int32_t ret =
|
||||
sourceManager_->StopRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -513,7 +522,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput05, testing::ext::Tes
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput06, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestStopDInputCallback> callback;
|
||||
int32_t ret =
|
||||
@@ -522,31 +531,31 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput06, testing::ext::Tes
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopRemoteInput10
|
||||
* @tc.name: StopRemoteInput07
|
||||
* @tc.desc: verify the function of stoping distributed input with dhid.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J74
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput10, testing::ext::TestSize.Level0)
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput07, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::vector<std::string> dhIds;
|
||||
dhIds.push_back("Input_slkdiek3kddkeojfe");
|
||||
sptr<TestStartStopVectorCallbackStub> callback = new TestStartStopVectorCallbackStub();
|
||||
int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopRemoteInput11
|
||||
* @tc.name: StopRemoteInput08
|
||||
* @tc.desc: verify the function of stoping distributed input with dhid.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J74
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput11, testing::ext::TestSize.Level0)
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput08, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::vector<std::string> dhIds;
|
||||
sptr<TestStartStopVectorCallbackStub> callback;
|
||||
@@ -555,12 +564,12 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput11, testing::ext::Tes
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StopRemoteInput12
|
||||
* @tc.name: StopRemoteInput09
|
||||
* @tc.desc: verify the function of stoping distributed input with dhid.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J74
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput12, testing::ext::TestSize.Level0)
|
||||
HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput09, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "";
|
||||
std::string sinkId = "";
|
||||
@@ -576,7 +585,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput01, testing::ext
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestUnprepareDInputCallback> callback = new TestUnprepareDInputCallback();
|
||||
int32_t ret = sourceManager_->UnprepareRemoteInput(devId, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput02, testing::ext::TestSize.Level0)
|
||||
@@ -603,11 +612,11 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput03, testing::ext
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestUnprepareDInputCallback> callback = new TestUnprepareDInputCallback();
|
||||
int32_t ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -633,7 +642,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput05, testing::ext
|
||||
*/
|
||||
HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput06, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string srcId = "umkyu1b165e1be98151891erbe8r91eb";
|
||||
std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
sptr<TestUnprepareDInputCallback> callback;
|
||||
int32_t ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
|
||||
@@ -641,7 +650,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput06, testing::ext
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnprepareRemoteInput06
|
||||
* @tc.name: UnprepareRemoteInput01
|
||||
* @tc.desc: verify the function of disabling a peripheral device.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J77
|
||||
@@ -656,7 +665,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware01, tes
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnprepareRemoteInput06
|
||||
* @tc.name: UnprepareRemoteInput02
|
||||
* @tc.desc: verify the function of disabling a peripheral device.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H9J77
|
||||
@@ -665,7 +674,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware02, tes
|
||||
{
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string dhId = "rt12r1nr81n521be8rb1erbe1w8bg1erb18";
|
||||
sptr<TestUnregisterDInputCb> callback = new TestUnregisterDInputCb();
|
||||
sptr<TestUnregisterDInputCb> callback;
|
||||
int32_t ret = sourceManager_->UnregisterDistributedHardware(devId, dhId, callback);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL, ret);
|
||||
}
|
||||
@@ -707,19 +716,27 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback02, test
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RegisterInputNodeListener01, testing::ext::TestSize.Level0)
|
||||
{
|
||||
sptr<TestInputNodeListenerCb> callback = new TestInputNodeListenerCb();
|
||||
int32_t ret = sourceManager_->RegisterInputNodeListener(callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, UnRegisterInputNodeListener01, testing::ext::TestSize.Level0)
|
||||
{
|
||||
sptr<TestInputNodeListenerCb> callback = new TestInputNodeListenerCb();
|
||||
int32_t ret = sourceManager_->UnregisterInputNodeListener(callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, RegisterSimulationEventListener, testing::ext::TestSize.Level0)
|
||||
{
|
||||
sptr<TestSimulationEventCb> callback = new TestSimulationEventCb();
|
||||
int32_t ret = sourceManager_->RegisterSimulationEventListener(callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceManagerTest, UnregisterSimulationEventListener, testing::ext::TestSize.Level0)
|
||||
{
|
||||
sptr<TestSimulationEventCb> callback = new TestSimulationEventCb();
|
||||
int32_t ret = sourceManager_->UnregisterSimulationEventListener(callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
sourceManager_->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#define DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#ifndef DISRIBUTED_INPUT_SOURCEMANAGER_TEST_H
|
||||
#define DISRIBUTED_INPUT_SOURCEMANAGER_TEST_H
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "start_stop_d_inputs_call_back_stub.h"
|
||||
#include "start_stop_result_call_back_stub.h"
|
||||
#include "input_node_listener_stub.h"
|
||||
#include "simulation_event_listener_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -134,6 +135,13 @@ public:
|
||||
const std::string sinkNodeId);
|
||||
};
|
||||
|
||||
class TestSimulationEventCb : public OHOS::DistributedHardware::DistributedInput::SimulationEventListenerStub {
|
||||
public:
|
||||
TestSimulationEventCb() = default;
|
||||
virtual ~TestSimulationEventCb() = default;
|
||||
int32_t OnSimulationEvent(uint32_t type, uint32_t code, int32_t value);
|
||||
};
|
||||
|
||||
private:
|
||||
int32_t StructTransJson(const InputDevice& pBuf, std::string& strDescriptor) const;
|
||||
DistributedInputSourceManager* sourceManager_;
|
||||
@@ -142,4 +150,4 @@ private:
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#endif // DISRIBUTED_INPUT_SOURCEMANAGER_TEST_H
|
||||
|
||||
@@ -47,11 +47,14 @@ ohos_unittest("distributed_input_sourcetrans_test") {
|
||||
"${distributedinput_path}/inputdevicehandler/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//base/notification/eventhandler/interfaces/inner_api",
|
||||
"${common_path}/mock",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"//foundation/distributedhardware/distributed_input/services/source/transport/src/distributed_input_source_transport.cpp",
|
||||
"distributed_input_sourcetrans_test.cpp",
|
||||
"${common_path}/mock/session_mock.cpp",
|
||||
"${common_path}/mock/softbus_bus_center_mock.cpp",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -72,7 +75,6 @@ ohos_unittest("distributed_input_sourcetrans_test") {
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject:libdinput_inject",
|
||||
]
|
||||
|
||||
|
||||
+23
-5
@@ -38,10 +38,28 @@ void DistributedInputSourceTransTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, OpenInputSoftbus01, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string remoteDevId = "";
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().OpenInputSoftbus(remoteDevId);
|
||||
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_OPEN_SESSION_FAIL, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, OpenInputSoftbus02, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string remoteDevId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591";
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().Init();
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
ret = DistributedInputSourceTransport::GetInstance().OpenInputSoftbus(remoteDevId);
|
||||
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, Init, testing::ext::TestSize.Level0)
|
||||
{
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().Init();
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_INIT_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, PrepareRemoteInput01, testing::ext::TestSize.Level0)
|
||||
@@ -62,7 +80,7 @@ HWTEST_F(DistributedInputSourceTransTest, PrepareRemoteInput03, testing::ext::Te
|
||||
{
|
||||
std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591";
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().PrepareRemoteInput(deviceId);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_PREPARE_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, UnprepareRemoteInput01, testing::ext::TestSize.Level0)
|
||||
@@ -83,7 +101,7 @@ HWTEST_F(DistributedInputSourceTransTest, UnprepareRemoteInput03, testing::ext::
|
||||
{
|
||||
std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591";
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().UnprepareRemoteInput(deviceId);
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_UNPREPARE_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, StartRemoteInput01, testing::ext::TestSize.Level0)
|
||||
@@ -99,7 +117,7 @@ HWTEST_F(DistributedInputSourceTransTest, StartRemoteInput02, testing::ext::Test
|
||||
std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591";
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput(
|
||||
deviceId, static_cast<uint32_t>(DInputDeviceType::ALL));
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceTransTest, StopRemoteInput01, testing::ext::TestSize.Level0)
|
||||
@@ -115,7 +133,7 @@ HWTEST_F(DistributedInputSourceTransTest, StopRemoteInput02, testing::ext::TestS
|
||||
std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591";
|
||||
int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(
|
||||
deviceId, static_cast<uint32_t>(DInputDeviceType::ALL));
|
||||
EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL, ret);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
DistributedInputSourceTransport::GetInstance().CloseInputSoftbus(deviceId);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
|
||||
+3
-3
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#define DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#ifndef DISRIBUTED_INPUT_SOURCETRANS_TEST_H
|
||||
#define DISRIBUTED_INPUT_SOURCETRANS_TEST_H
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -40,4 +40,4 @@ public:
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISRIBUTED_INPUT_INNER_TEST_H
|
||||
#endif // DISRIBUTED_INPUT_SOURCETRANS_TEST_H
|
||||
|
||||
Reference in New Issue
Block a user