Merge pull request !1537 from HYH/429
This commit is contained in:
openharmony_ci 2024-04-30 13:32:25 +00:00 committed by Gitee
commit 34c2d57391
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 880 additions and 49 deletions

View File

@ -21,6 +21,7 @@ group("device_status_unittest") {
"intention/common:unittest",
"intention/scheduler:unittest",
"intentiontest:DragManagerTest",
"intentiontest:SocketSessionTest",
"utils:UtilityTest",
]
}

View File

@ -56,7 +56,50 @@ ohos_unittest("DragManagerTest") {
]
}
ohos_unittest("SocketSessionTest") {
sanitize = {
integer_overflow = true
ubsan = true
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
}
branch_protector_ret = "pac_ret"
module_out_path = module_output_path
include_dirs = [ "include" ]
defines = []
sources = [ "src/socket_session_test.cpp" ]
deps = [
"${device_status_interfaces_path}/innerkits:devicestatus_client",
"${device_status_root_path}/intention/cooperate/client:intention_cooperate_client",
"${device_status_root_path}/intention/drag/client:intention_drag_client",
"${device_status_root_path}/intention/ipc/socket:intention_socket_connection",
"${device_status_root_path}/intention/ipc/socket:intention_socket_session_manager",
"${device_status_root_path}/intention/ipc/tunnel:intention_tunnel_client",
"${device_status_root_path}/services:devicestatus_static_service",
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
"${device_status_utils_path}:devicestatus_util",
]
external_deps = [
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",
"image_framework:image_native",
"input:libmmi-client",
"samgr:samgr_proxy",
"window_manager:libdm",
]
}
group("unittest") {
testonly = true
deps = [ ":DragManagerTest" ]
deps = [
":DragManagerTest",
":SocketSessionTest",
]
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 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 DRAG_MANAGER_TEST_H
#define DRAG_MANAGER_TEST_H
#include <gtest/gtest.h>
#include "socket_session.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
class SocketSessionTest : public testing::Test {
public:
static void SetUpTestCase();
void SetUp();
void TearDown();
};
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS
#endif // DRAG_MANAGER_TEST_H

View File

@ -45,6 +45,7 @@ constexpr int32_t FOREGROUND_COLOR_IN { 0x33FF0000 };
constexpr int32_t FOREGROUND_COLOR_OUT { 0x00000000 };
int32_t g_shadowinfo_x { 0 };
int32_t g_shadowinfo_y { 0 };
constexpr int32_t WINDOW_ID { -1 };
constexpr int32_t ANIMATION_DURATION { 500 };
const std::string CURVE_NAME { "cubic-bezier" };
constexpr bool HAS_CUSTOM_ANIMATION { true };
@ -244,7 +245,7 @@ HWTEST_F(DragManagerTest, DragManagerTest1, TestSize.Level0)
CALL_TEST_DEBUG;
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), nullptr);
ASSERT_EQ(ret, RET_ERR);
}
@ -266,7 +267,7 @@ HWTEST_F(DragManagerTest, DragManagerTest2, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, 0);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, ERR_INVALID_VALUE);
@ -290,7 +291,7 @@ HWTEST_F(DragManagerTest, DragManagerTest3, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_ERR);
@ -314,7 +315,7 @@ HWTEST_F(DragManagerTest, DragManagerTest4, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, -1, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_ERR);
@ -459,7 +460,7 @@ HWTEST_F(DragManagerTest, DragManagerTest14, TestSize.Level0)
CALL_TEST_DEBUG;
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
std::promise<bool> promiseFlag;
std::future<bool> futureFlag = promiseFlag.get_future();
auto callback = [&promiseFlag](const DragNotifyMsg &notifyMessage) {
@ -481,7 +482,7 @@ HWTEST_F(DragManagerTest, DragManagerTest14, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);}
/**
@ -502,7 +503,7 @@ HWTEST_F(DragManagerTest, DragManagerTest15, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -511,7 +512,7 @@ HWTEST_F(DragManagerTest, DragManagerTest15, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);}
/**
@ -532,7 +533,7 @@ HWTEST_F(DragManagerTest, DragManagerTest16, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -543,7 +544,7 @@ HWTEST_F(DragManagerTest, DragManagerTest16, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);}
/**
@ -564,7 +565,7 @@ HWTEST_F(DragManagerTest, DragManagerTest17, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -579,7 +580,7 @@ HWTEST_F(DragManagerTest, DragManagerTest17, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -605,7 +606,7 @@ HWTEST_F(DragManagerTest, DragManagerTest18, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -617,7 +618,7 @@ HWTEST_F(DragManagerTest, DragManagerTest18, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -639,7 +640,7 @@ HWTEST_F(DragManagerTest, DragManagerTest19, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -654,7 +655,7 @@ HWTEST_F(DragManagerTest, DragManagerTest19, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -676,7 +677,7 @@ HWTEST_F(DragManagerTest, DragManagerTest20, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -689,7 +690,7 @@ HWTEST_F(DragManagerTest, DragManagerTest20, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -711,7 +712,7 @@ HWTEST_F(DragManagerTest, DragManagerTest21, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -724,7 +725,7 @@ HWTEST_F(DragManagerTest, DragManagerTest21, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -746,7 +747,7 @@ HWTEST_F(DragManagerTest, DragManagerTest22, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -759,7 +760,7 @@ HWTEST_F(DragManagerTest, DragManagerTest22, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -781,7 +782,7 @@ HWTEST_F(DragManagerTest, DragManagerTest23, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -794,7 +795,7 @@ HWTEST_F(DragManagerTest, DragManagerTest23, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -816,7 +817,7 @@ HWTEST_F(DragManagerTest, DragManagerTest24, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -837,7 +838,7 @@ HWTEST_F(DragManagerTest, DragManagerTest24, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -859,7 +860,7 @@ HWTEST_F(DragManagerTest, DragManagerTest25, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -883,7 +884,7 @@ HWTEST_F(DragManagerTest, DragManagerTest25, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -905,7 +906,7 @@ HWTEST_F(DragManagerTest, DragManagerTest26, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
const std::string udType = "general.message";
constexpr int64_t recordSize = 20;
std::map<std::string, int64_t> summarys = { { udType, recordSize } };
@ -922,7 +923,7 @@ HWTEST_F(DragManagerTest, DragManagerTest26, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -944,7 +945,7 @@ HWTEST_F(DragManagerTest, DragManagerTest27, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -959,7 +960,7 @@ HWTEST_F(DragManagerTest, DragManagerTest27, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -981,7 +982,7 @@ HWTEST_F(DragManagerTest, DragManagerTest28, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -993,7 +994,7 @@ HWTEST_F(DragManagerTest, DragManagerTest28, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -1015,7 +1016,7 @@ HWTEST_F(DragManagerTest, DragManagerTest29, TestSize.Level0)
};
std::optional<DragData> dragData = CreateDragData(
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
ASSERT_TRUE(dragData);
EXPECT_TRUE(dragData);
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<TestStartDragListener>(callback));
ASSERT_EQ(ret, RET_OK);
@ -1027,7 +1028,7 @@ HWTEST_F(DragManagerTest, DragManagerTest29, TestSize.Level0)
HAS_CUSTOM_ANIMATION, TARGET_MAIN_WINDOW };
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
ASSERT_EQ(ret, RET_OK);
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
EXPECT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
std::future_status::timeout);
}
@ -1106,7 +1107,7 @@ HWTEST_F(DragManagerTest, DragManagerTest34, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t pid = InteractionManager::GetInstance()->GetDragTargetPid();
ASSERT_TRUE(pid > 0);
EXPECT_GT(pid, 0);
}
/**
@ -1268,7 +1269,7 @@ HWTEST_F(DragManagerTest, DragManagerTest44, TestSize.Level0)
MessageParcel data;
StopDragParam param {};
bool ret = param.Unmarshalling(data);
ASSERT_EQ(ret, false);
EXPECT_FALSE(ret);
}
/**
@ -1283,7 +1284,7 @@ HWTEST_F(DragManagerTest, DragManagerTest45, TestSize.Level0)
MessageParcel data;
SetDragWindowVisibleParam param {};
bool ret = param.Unmarshalling(data);
ASSERT_EQ(ret, false);
EXPECT_FALSE(ret);
}
/**
@ -1299,7 +1300,7 @@ HWTEST_F(DragManagerTest, DragManagerTest46, TestSize.Level0)
MessageParcel data;
GetDragTargetPidReply targetPidReply { pid };
bool ret = targetPidReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1315,7 +1316,7 @@ HWTEST_F(DragManagerTest, DragManagerTest47, TestSize.Level0)
MessageParcel data;
GetDragTargetPidReply targetPidReply { pid };
bool ret = targetPidReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1331,7 +1332,7 @@ HWTEST_F(DragManagerTest, DragManagerTest48, TestSize.Level0)
MessageParcel data;
GetUdKeyReply udKeyReply { std::move(udKey) };
bool ret = udKeyReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1347,7 +1348,7 @@ HWTEST_F(DragManagerTest, DragManagerTest49, TestSize.Level0)
MessageParcel data;
GetShadowOffsetReply shadowOffsetReply { shadowOffset };
bool ret = shadowOffsetReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1362,7 +1363,7 @@ HWTEST_F(DragManagerTest, DragManagerTest50, TestSize.Level0)
UpdatePreviewAnimationParam param {};
MessageParcel data;
bool ret = param.Unmarshalling(data);
ASSERT_EQ(ret, false);
EXPECT_FALSE(ret);
}
/**
@ -1378,7 +1379,7 @@ HWTEST_F(DragManagerTest, DragManagerTest51, TestSize.Level0)
GetDragSummaryReply summaryReply { std::move(summaries) };
MessageParcel data;
bool ret = summaryReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1394,7 +1395,7 @@ HWTEST_F(DragManagerTest, DragManagerTest52, TestSize.Level0)
GetDragStateReply dragStateReply { dragState };
MessageParcel data;
bool ret = dragStateReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1410,7 +1411,7 @@ HWTEST_F(DragManagerTest, DragManagerTest53, TestSize.Level0)
GetDragActionReply dragActionReply { dragAction };
MessageParcel data;
bool ret = dragActionReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
@ -1426,7 +1427,211 @@ HWTEST_F(DragManagerTest, DragManagerTest54, TestSize.Level0)
GetExtraInfoReply extraInfoReply { std::move(extraInfo) };
MessageParcel data;
bool ret = extraInfoReply.Marshalling(data);
ASSERT_EQ(ret, true);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest55
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest55, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
GetExtraInfoReply extraInfoReply { std::move(extraInfo) };
MessageParcel data;
bool ret = extraInfoReply.Marshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest56
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest56, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
UpdateDragStyleParam param;
MessageParcel data;
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest57
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest57, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
UpdateDragStyleParam param;
MessageParcel data;
bool ret = param.Unmarshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: DragManagerTest58
* @tc.desc: Drag Drawing
* @tc.type: FUNCdSession
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest58, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
UpdateShadowPicParam param;
MessageParcel data;
bool ret = param.Unmarshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: DragManagerTest59
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest59, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
UpdateShadowPicParam param;
MessageParcel data;
bool ret = param.Marshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: DragManagerTest60
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest60, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
UpdatePreviewStyleParam param;
MessageParcel data;
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest61
* @tc.desc: Drag Drawingx`
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest61, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::string extraInfo;
UpdatePreviewStyleParam param;
MessageParcel data;
bool ret = param.Unmarshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: DragManagerTest62
* @tc.desc: Drag Drawingx`
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest62, TestSize.Level0)
{
CALL_TEST_DEBUG;
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
StopDragParam param { dropResult };
MessageParcel data;
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
ret = param.Unmarshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest63
* @tc.desc: Drag Drawingx`
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest63, TestSize.Level0)
{
CALL_TEST_DEBUG;
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION,
WINDOW_ID, static_cast<DragBehavior>(-2)};
StopDragParam param { dropResult };
MessageParcel data;
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
ret = param.Unmarshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: DragManagerTest64
* @tc.desc: Drag Drawingx`
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest64, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageParcel data;
SetDragWindowVisibleParam param { true, true };
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
ret = param.Unmarshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest65
* @tc.desc: Drag Drawingx`
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest65, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageParcel data;
UpdateDragStyleParam param { DragCursorStyle::DEFAULT };
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
ret = param.Unmarshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: DragManagerTest66
* @tc.desc: Drag Drawingx`
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(DragManagerTest, DragManagerTest66, TestSize.Level0)
{
CALL_TEST_DEBUG;
std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(PIXEL_MAP_WIDTH, PIXEL_MAP_HEIGHT);
ASSERT_NE(pixelMap, nullptr);
ShadowInfo shadowInfo = { pixelMap, 0, 0 };
std::string extraInfo;
UpdateShadowPicParam param { shadowInfo };
MessageParcel data;
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
ret = param.Unmarshalling(data);
EXPECT_TRUE(ret);
}
} // namespace DeviceStatus
} // namespace Msdp

View File

@ -0,0 +1,547 @@
/*
* Copyright (c) 2024 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.
*/
#define private public
#include "socket_session_test.h"
#include "ipc_skeleton.h"
#include "message_parcel.h"
#include "i_context.h"
#include "i_plugin.h"
#include "socket_client.h"
#include "socket_params.h"
#include "socket_session_manager.h"
#include "socket_server.h"
#include "tunnel_client.h"
namespace OHOS {
namespace Msdp {
namespace DeviceStatus {
using namespace testing::ext;
namespace {
constexpr size_t BUF_CMD_SIZE { 512 };
std::shared_ptr<TunnelClient> g_tunnel {nullptr};
std::unique_ptr<SocketClient> g_client {nullptr};
std::shared_ptr<SocketConnection> g_socket { nullptr };
std::shared_ptr<SocketServer> g_socketServer { nullptr };
std::shared_ptr<SocketSession> g_session { nullptr };
std::shared_ptr<SocketSessionManager> g_socketSessionManager { nullptr };
IContext *g_context { nullptr };
Intention g_intention { Intention::UNKNOWN_INTENTION };
constexpr int32_t TIME_WAIT_FOR_OP_MS { 20 };
} // namespace
void SocketSessionTest::SetUpTestCase() {}
void SocketSessionTest::SetUp()
{
g_tunnel = std::make_shared<TunnelClient>();
g_client = std::make_unique<SocketClient>(g_tunnel);
g_socketServer = std::make_unique<SocketServer>(g_context);
g_socketSessionManager = std::make_shared<SocketSessionManager>();
int32_t moduleType = 1;
int32_t tokenType = 1;
int32_t uid = 1;
int32_t pid = 1;
int32_t sockFds[2] { -1, -1 };
g_session = std::make_shared<SocketSession>("", moduleType, tokenType, sockFds[0], uid, pid);
}
void SocketSessionTest::TearDown()
{
g_tunnel = nullptr;
g_client = nullptr;
g_socket = nullptr;
g_socketSessionManager = nullptr;
g_session = nullptr;
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP_MS));
}
/**
* @tc.name: SocketSessionTest1
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest1, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t ret = g_client->Connect();
EXPECT_TRUE(ret);
ret = g_client->Connect();
EXPECT_TRUE(ret);
g_client->Stop();
g_client->OnDisconnected();
}
/**
* @tc.name: SocketSessionTest2
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest2, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t ret = g_client->Socket();
MessageId msgId { MessageId::INVALID };
NetPacket pkt(msgId);
g_client->OnPacket(pkt);
EXPECT_GT(ret, -1);
}
/**
* @tc.name: SocketSessionTest3
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest3, TestSize.Level0)
{
CALL_TEST_DEBUG;
g_client->Reconnect();
int32_t ret = g_client->Connect();
EXPECT_TRUE(ret);
g_client->Reconnect();
g_client->OnDisconnected();
}
/**
* @tc.name: SocketSessionTest4
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest4, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageParcel data;
AllocSocketPairParam param;
bool ret = param.Unmarshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: SocketSessionTest5
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest5, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageParcel data;
AllocSocketPairParam param;
bool ret = param.Marshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: SocketSessionTest6
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest6, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageParcel data;
AllocSocketPairReply replyData(1, 1);
bool ret = replyData.Marshalling(data);
EXPECT_TRUE(ret);
}
/**
* @tc.name: SocketSessionTest7
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest7, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageParcel data;
AllocSocketPairReply replyData(1, 1);
bool ret = replyData.Unmarshalling(data);
EXPECT_FALSE(ret);
}
/**
* @tc.name: SocketSessionTest8
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest8, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel datas;
MessageParcel reply;
int32_t ret = g_socketServer->Enable(context, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest9
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest9, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->Disable(context, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest10
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest10, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->Start(context, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest11
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest11, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->Stop(context, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest12
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest12, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->AddWatch(context, 1, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest13
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest13, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->RemoveWatch(context, 1, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest14
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest14, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->SetParam(context, 1, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest15
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest15, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->GetParam(context, 1, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest16
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest16, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->Control(context, 1, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest17
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest17, TestSize.Level0)
{
CALL_TEST_DEBUG;
CallingContext context {
.intention = g_intention,
.tokenId = IPCSkeleton::GetCallingTokenID(),
.uid = IPCSkeleton::GetCallingUid(),
.pid = IPCSkeleton::GetCallingPid(),
};
MessageParcel reply;
MessageParcel datas;
int32_t ret = g_socketServer->Control(context, -1, datas, reply);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest18
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest18, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t ret = g_socketSessionManager->Init();
EXPECT_EQ(ret, RET_OK);
}
/**
* @tc.name: SocketSessionTest19
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest19, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t clientFd { -1 };
int32_t ret = g_socketSessionManager->AllocSocketFd("", 1, 1, 1, 1, clientFd);
EXPECT_EQ(ret, RET_ERR);
}
/**
* @tc.name: SocketSessionTest20
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest20, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t pid { 1 };
g_socketSessionManager->FindSessionByPid(pid);
g_socketSessionManager->DispatchOne();
int32_t fd { 1 };
g_socketSessionManager->ReleaseSession(fd);
g_socketSessionManager->FindSession(fd);
g_socketSessionManager->DumpSession("");
g_socketSessionManager->RemoveSessionDeletedCallback(pid);
int32_t sockFd { -1 };
int32_t bufSize { -1 };
int32_t ret = g_socketSessionManager->SetBufferSize(sockFd, bufSize);
EXPECT_EQ(ret, RET_OK);
}
/**
* @tc.name: SocketSessionTest21
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest21, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t fd { 1 };
bool ret = g_socketSessionManager->AddSession(g_session);
g_socketSessionManager->NotifySessionDeleted(g_session);
EXPECT_TRUE(ret);
g_socketSessionManager->ReleaseSession(fd);
}
/**
* @tc.name: SocketSessionTest22
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest22, TestSize.Level0)
{
CALL_TEST_DEBUG;
MessageId msgId { MessageId::INVALID };
NetPacket pkt(msgId);
bool ret = g_session->SendMsg(pkt);
EXPECT_FALSE(ret);
}
/**
* @tc.name: SocketSessionTest23
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest23, TestSize.Level0)
{
CALL_TEST_DEBUG;
char buf[BUF_CMD_SIZE] = { 0 };
size_t size = 1;
bool ret = g_session->SendMsg(buf, size);
EXPECT_FALSE(ret);
}
/**
* @tc.name: SocketSessionTest24
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest24, TestSize.Level0)
{
CALL_TEST_DEBUG;
char buf[BUF_CMD_SIZE] = { 0 };
size_t size = 1;
struct epoll_event ev {};
ev.events = 0;
ev.events |= EPOLLIN;
g_session->Dispatch(ev);
ev.events = 0;
ev.events |= EPOLLHUP;
g_session->Dispatch(ev);
bool ret = g_session->SendMsg(buf, size);
g_session->ToString();
EXPECT_FALSE(ret);
}
/**
* @tc.name: SocketSessionTest25
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest25, TestSize.Level0)
{
CALL_TEST_DEBUG;
g_socketSessionManager->AddSessionDeletedCallback(1, nullptr);
g_socketSessionManager->AddSessionDeletedCallback(1, [](SocketSessionPtr ptr){});
bool ret = g_socketSessionManager->AddSession(nullptr);
EXPECT_FALSE(ret);
}
/**
* @tc.name: SocketSessionTest26
* @tc.desc: Drag Drawing
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(SocketSessionTest, SocketSessionTest26, TestSize.Level0)
{
CALL_TEST_DEBUG;
int32_t fd = 12;
int32_t ret = g_client->Connect();
EXPECT_TRUE(ret);
g_client->socket_->OnReadable(fd);
fd = 1;
g_client->socket_->OnReadable(fd);
g_client->socket_->OnException(fd);
g_client->OnDisconnected();
}
} // namespace DeviceStatus
} // namespace Msdp
} // namespace OHOS