1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #define BUFF_SIZE 100
17 #include "intention_service_test.h"
18
19 #include "ddm_adapter.h"
20 #include "drag_data_manager.h"
21 #include "drag_params.h"
22 #include "drag_server.h"
23 #include "dsoftbus_adapter.h"
24 #include "fi_log.h"
25 #include "input_adapter.h"
26 #include "intention_service.h"
27 #include "interaction_manager.h"
28 #include "ipc_skeleton.h"
29 #include "plugin_manager.h"
30
31 #undef LOG_TAG
32 #define LOG_TAG "IntentionServiceTest"
33
34 namespace OHOS {
35 namespace Msdp {
36 namespace DeviceStatus {
37 using namespace testing::ext;
38 namespace {
39 constexpr int32_t TIME_WAIT_FOR_OP_MS { 20 };
40 constexpr int32_t POINTER_ID { 0 };
41 constexpr int32_t DRAG_NUM_ONE { 1 };
42 constexpr int32_t SHADOW_NUM_ONE { 1 };
43 constexpr int32_t PIXEL_MAP_WIDTH { 3 };
44 constexpr int32_t PIXEL_MAP_HEIGHT { 3 };
45 constexpr int32_t WINDOW_ID { -1 };
46 constexpr int32_t READ_OK { 1 };
47 constexpr uint32_t DEFAULT_ICON_COLOR { 0xFF };
48 const std::string FILTER_INFO { "Undefined filter info" };
49 const std::string UD_KEY { "Unified data key" };
50 const std::string EXTRA_INFO { "Undefined extra info" };
51 const std::string CURVE_NAME { "cubic-bezier" };
52 constexpr int32_t FOREGROUND_COLOR_IN { 0x33FF0000 };
53 constexpr int32_t DISPLAY_ID { 0 };
54 constexpr int32_t DISPLAY_X { 50 };
55 constexpr int32_t DISPLAY_Y { 50 };
56 constexpr int32_t INT32_BYTE { 4 };
57 int32_t g_shadowinfoX { 0 };
58 int32_t g_shadowinfoY { 0 };
59 constexpr int32_t ANIMATION_DURATION { 500 };
60 constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
61 constexpr int32_t MAX_PIXEL_MAP_HEIGHT { 600 };
62 constexpr bool HAS_CANCELED_ANIMATION { true };
63 constexpr bool HAS_CUSTOM_ANIMATION { true };
64 Intention g_intention { Intention::DRAG };
65 std::shared_ptr<ContextService> g_context { nullptr };
66 std::shared_ptr<IntentionService> g_intentionService { nullptr };
67 std::shared_ptr<IntentionService> g_intentionServiceNullptr { nullptr };
68 IContext *g_contextNullptr { nullptr };
69 } // namespace
70
PostSyncTask(DTaskCallback callback)71 int32_t MockDelegateTasks::PostSyncTask(DTaskCallback callback)
72 {
73 return callback();
74 }
75
PostAsyncTask(DTaskCallback callback)76 int32_t MockDelegateTasks::PostAsyncTask(DTaskCallback callback)
77 {
78 return callback();
79 }
80
GetInstance()81 ContextService* ContextService::GetInstance()
82 {
83 static std::once_flag flag;
84 std::call_once(flag, [&]() {
85 g_context = std::make_shared<ContextService>();
86 });
87 return g_context.get();
88 }
89
ContextService()90 ContextService::ContextService()
91 {
92 ddm_ = std::make_unique<DDMAdapter>();
93 input_ = std::make_unique<InputAdapter>();
94 pluginMgr_ = std::make_unique<PluginManager>(this);
95 dsoftbus_ = std::make_unique<DSoftbusAdapter>();
96 }
97
GetDelegateTasks()98 IDelegateTasks& ContextService::GetDelegateTasks()
99 {
100 return delegateTasks_;
101 }
102
GetDeviceManager()103 IDeviceManager& ContextService::GetDeviceManager()
104 {
105 return devMgr_;
106 }
107
GetTimerManager()108 ITimerManager& ContextService::GetTimerManager()
109 {
110 return timerMgr_;
111 }
112
GetDragManager()113 IDragManager& ContextService::GetDragManager()
114 {
115 return dragMgr_;
116 }
117
GetSocketSessionManager()118 ISocketSessionManager& ContextService::GetSocketSessionManager()
119 {
120 return socketSessionMgr_;
121 }
122
GetDDM()123 IDDMAdapter& ContextService::GetDDM()
124 {
125 return *ddm_;
126 }
127
GetPluginManager()128 IPluginManager& ContextService::GetPluginManager()
129 {
130 return *pluginMgr_;
131 }
132
GetInput()133 IInputAdapter& ContextService::GetInput()
134 {
135 return *input_;
136 }
137
GetDSoftbus()138 IDSoftbusAdapter& ContextService::GetDSoftbus()
139 {
140 return *dsoftbus_;
141 }
142
SetUpTestCase()143 void IntentionServiceTest::SetUpTestCase()
144 {
145 g_intentionService = std::make_shared<IntentionService>(ContextService::GetInstance());
146 g_intentionServiceNullptr = std::make_shared<IntentionService>(g_contextNullptr);
147 }
148
TearDownTestCase()149 void IntentionServiceTest::TearDownTestCase()
150 {
151 std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP_MS));
152 g_intentionServiceNullptr = nullptr;
153 }
154
SetUp()155 void IntentionServiceTest::SetUp() {}
156
TearDown()157 void IntentionServiceTest::TearDown() {}
158
CreatePixelMap(int32_t width, int32_t height)159 std::shared_ptr<Media::PixelMap> IntentionServiceTest::CreatePixelMap(int32_t width, int32_t height)
160 {
161 CALL_DEBUG_ENTER;
162 if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
163 FI_HILOGE("invalid, height:%{public}d, width:%{public}d", height, width);
164 return nullptr;
165 }
166 Media::InitializationOptions opts;
167 opts.size.width = width;
168 opts.size.height = height;
169 opts.pixelFormat = Media::PixelFormat::BGRA_8888;
170 opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
171 opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
172
173 int32_t colorLen = width * height;
174 uint32_t *pixelColors = new (std::nothrow) uint32_t[BUFF_SIZE];
175 CHKPP(pixelColors);
176 int32_t colorByteCount = colorLen * INT32_BYTE;
177 errno_t ret = memset_s(pixelColors, BUFF_SIZE, DEFAULT_ICON_COLOR, colorByteCount);
178 if (ret != EOK) {
179 FI_HILOGE("memset_s failed");
180 delete[] pixelColors;
181 return nullptr;
182 }
183 std::shared_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(pixelColors, colorLen, opts);
184 if (pixelMap == nullptr) {
185 FI_HILOGE("Create pixelMap failed");
186 delete[] pixelColors;
187 return nullptr;
188 }
189 delete[] pixelColors;
190 return pixelMap;
191 }
192
CreateDragData(int32_t sourceType, int32_t pointerId, int32_t dragNum, bool hasCoordinateCorrected, int32_t shadowNum)193 std::optional<DragData> IntentionServiceTest::CreateDragData(int32_t sourceType,
194 int32_t pointerId, int32_t dragNum, bool hasCoordinateCorrected, int32_t shadowNum)
195 {
196 CALL_DEBUG_ENTER;
197 DragData dragData;
198 for (int32_t i = 0; i < shadowNum; i++) {
199 std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(PIXEL_MAP_WIDTH, PIXEL_MAP_HEIGHT);
200 if (pixelMap == nullptr) {
201 FI_HILOGE("pixelMap nullptr");
202 return std::nullopt;
203 }
204 dragData.shadowInfos.push_back({ pixelMap, g_shadowinfoX, g_shadowinfoY });
205 }
206 dragData.buffer = std::vector<uint8_t>(MAX_BUFFER_SIZE, 0);
207 dragData.extraInfo = FILTER_INFO;
208 dragData.udKey = UD_KEY;
209 dragData.sourceType = sourceType;
210 dragData.extraInfo = EXTRA_INFO;
211 dragData.displayId = DISPLAY_ID;
212 dragData.pointerId = pointerId;
213 dragData.dragNum = dragNum;
214 dragData.displayX = DISPLAY_X;
215 dragData.displayY = DISPLAY_Y;
216 dragData.hasCoordinateCorrected = hasCoordinateCorrected;
217 dragData.hasCanceledAnimation = HAS_CANCELED_ANIMATION;
218 return dragData;
219 }
220
221 class TestStartDragListener : public IStartDragListener {
222 public:
TestStartDragListener(std::function<void(const DragNotifyMsg&)> function)223 explicit TestStartDragListener(std::function<void(const DragNotifyMsg&)> function) : function_(function) { }
224 void OnDragEndMessage(const DragNotifyMsg &msg) override
225 {
226 FI_HILOGD("DisplayX:%{public}d, displayY:%{public}d, targetPid:%{public}d, result:%{public}d",
227 msg.displayX, msg.displayY, msg.targetPid, static_cast<int32_t>(msg.result));
228 if (function_ != nullptr) {
229 function_(msg);
230 }
231 FI_HILOGD("Test OnDragEndMessage");
232 }
233
234 void OnHideIconMessage() override
235 {
236 FI_HILOGD("Test OnHideIconMessage");
237 }
238 private:
239 std::function<void(const DragNotifyMsg&)> function_;
240 };
241
242 class DragListenerTest : public IDragListener {
243 public:
DragListenerTest()244 DragListenerTest() {}
DragListenerTest(const std::string& name)245 explicit DragListenerTest(const std::string& name) : moduleName_(name) {}
246 void OnDragMessage(DragState state) override
247 {
248 if (moduleName_.empty()) {
249 moduleName_ = std::string("DragListenerTest");
250 }
251 FI_HILOGD("%{public}s, state:%{public}s", moduleName_.c_str(), PrintDragMessage(state).c_str());
252 }
253 private:
PrintDragMessage(DragState state)254 std::string PrintDragMessage(DragState state)
255 {
256 std::string type = "unknow";
257 const std::map<DragState, std::string> stateType = {
258 { DragState::ERROR, "error"},
259 { DragState::START, "start"},
260 { DragState::STOP, "stop"},
261 { DragState::CANCEL, "cancel"}
262 };
263 auto item = stateType.find(state);
264 if (item != stateType.end()) {
265 type = item->second;
266 }
267 return type;
268 }
269 private:
270 std::string moduleName_;
271 };
272
AssignToAnimation(PreviewAnimation &animation)273 void IntentionServiceTest::AssignToAnimation(PreviewAnimation &animation)
274 {
275 animation.duration = ANIMATION_DURATION;
276 animation.curveName = CURVE_NAME;
277 animation.curve = { 0.33, 0, 0.67, 1 };
278 }
279
280 /**
281 * @tc.name: IntentionServiceTest_1
282 * @tc.desc: Test Enable
283 * @tc.type: FUNC
284 * @tc.require:
285 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Enable001, TestSize.Level0)286 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Enable001, TestSize.Level0)
287 {
288 CALL_TEST_DEBUG;
289 MessageParcel dataParcel;
290 MessageParcel replyParcel;
291 int32_t ret = g_intentionService->Enable(g_intention, dataParcel, replyParcel);
292 EXPECT_EQ(ret, RET_ERR);
293 }
294
295 /**
296 * @tc.name: IntentionServiceTest2
297 * @tc.desc: Test Disable
298 * @tc.type: FUNC
299 * @tc.require:
300 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Disable001, TestSize.Level0)301 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Disable001, TestSize.Level0)
302 {
303 CALL_TEST_DEBUG;
304 MessageParcel replyParcel;
305 MessageParcel dataParcel;
306 int32_t ret = g_intentionService->Disable(g_intention, dataParcel, replyParcel);
307 EXPECT_EQ(ret, RET_ERR);
308 }
309
310 /**
311 * @tc.name: IntentionServiceTest3
312 * @tc.desc: Test Start
313 * @tc.type: FUNC
314 * @tc.require:
315 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Start001, TestSize.Level0)316 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Start001, TestSize.Level0)
317 {
318 CALL_TEST_DEBUG;
319 std::optional<DragData> dragData = CreateDragData(
320 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
321 MessageParcel replyParcel;
322 MessageParcel dataParcel;
323
324 int32_t ret = g_intentionService->Start(g_intention, dataParcel, replyParcel);
325 EXPECT_EQ(ret, RET_ERR);
326 }
327
328 /**
329 * @tc.name: IntentionServiceTest_Stop001
330 * @tc.desc: Test Stop
331 * @tc.type: FUNC
332 * @tc.require:
333 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Stop001, TestSize.Level0)334 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Stop001, TestSize.Level0)
335 {
336 CALL_TEST_DEBUG;
337 MessageParcel replyParcel;
338 MessageParcel dataParcel;
339 int32_t ret = g_intentionService->Stop(g_intention, dataParcel, replyParcel);
340 EXPECT_EQ(ret, RET_ERR);
341 }
342
343 /**
344 * @tc.name: IntentionServiceTest_Stop002
345 * @tc.desc: Test Stop
346 * @tc.type: FUNC
347 * @tc.require:
348 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Stop002, TestSize.Level0)349 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Stop002, TestSize.Level0)
350 {
351 CALL_TEST_DEBUG;
352 auto env = ContextService::GetInstance();
353 ASSERT_NE(env, nullptr);
354 MessageParcel replyParcel;
355 MessageParcel dataParcel;
356 DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
357 env->dragMgr_.dragState_ = DragState::START;
358 StopDragParam param { dropResult };
359
360 int32_t ret = param.Marshalling(dataParcel);
361 EXPECT_EQ(ret, READ_OK);
362 ret = g_intentionService->Stop(g_intention, dataParcel, replyParcel);
363 EXPECT_EQ(ret, RET_OK);
364 env->dragMgr_.dragState_ = DragState::STOP;
365 }
366
367 /**
368 * @tc.name: IntentionServiceTest_Stop003
369 * @tc.desc: Test Stop
370 * @tc.type: FUNC
371 * @tc.require:
372 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Stop003, TestSize.Level0)373 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Stop003, TestSize.Level0)
374 {
375 CALL_TEST_DEBUG;
376 auto env = ContextService::GetInstance();
377 ASSERT_NE(env, nullptr);
378 MessageParcel dataParcel;
379 MessageParcel replyParcel;
380 DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
381 env->dragMgr_.dragState_ = DragState::START;
382 StopDragParam param { dropResult };
383
384 int32_t ret = param.Marshalling(dataParcel);
385 EXPECT_EQ(ret, READ_OK);
386 ret = g_intentionServiceNullptr->Stop(g_intention, dataParcel, replyParcel);
387 EXPECT_EQ(ret, RET_ERR);
388 env->dragMgr_.dragState_ = DragState::STOP;
389 }
390
391 /**
392 * @tc.name: IntentionServiceTest5
393 * @tc.desc: Test AddWatch
394 * @tc.type: FUNC
395 * @tc.require:
396 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_AddWatch001, TestSize.Level0)397 HWTEST_F(IntentionServiceTest, IntentionServiceTest_AddWatch001, TestSize.Level0)
398 {
399 CALL_TEST_DEBUG;
400 int32_t ret = RET_ERR;
401 MessageParcel replyParcel;
402 MessageParcel dataParcel;
403 std::vector<DragRequestID> dragRequestIDs = {DragRequestID::UNKNOWN_DRAG_ACTION,
404 DragRequestID::ADD_DRAG_LISTENER, DragRequestID::ADD_SUBSCRIPT_LISTENER};
405 for (const auto& dragRequestID : dragRequestIDs) {
406 ret = g_intentionService->AddWatch(g_intention, dragRequestID, dataParcel, replyParcel);
407 EXPECT_EQ(ret, RET_ERR);
408 }
409 }
410
411 /**
412 * @tc.name: IntentionServiceTest6
413 * @tc.desc: Test RemoveWatch
414 * @tc.type: FUNC
415 * @tc.require:
416 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_RemoveWatch001, TestSize.Level0)417 HWTEST_F(IntentionServiceTest, IntentionServiceTest_RemoveWatch001, TestSize.Level0)
418 {
419 CALL_TEST_DEBUG;
420 MessageParcel replyParcel;
421 MessageParcel dataParcel;
422 int32_t ret = RET_ERR;
423 std::vector<DragRequestID> dragRequestIDs = {DragRequestID::UNKNOWN_DRAG_ACTION,
424 DragRequestID::ADD_DRAG_LISTENER, DragRequestID::ADD_SUBSCRIPT_LISTENER};
425 for (const auto& dragRequestID : dragRequestIDs) {
426 ret = g_intentionService->RemoveWatch(g_intention, dragRequestID, dataParcel, replyParcel);
427 EXPECT_EQ(ret, RET_ERR);
428 }
429 }
430
431 /**
432 * @tc.name: IntentionServiceTest_Control001
433 * @tc.desc: Test Control
434 * @tc.type: FUNC
435 * @tc.require:
436 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_Control001, TestSize.Level0)437 HWTEST_F(IntentionServiceTest, IntentionServiceTest_Control001, TestSize.Level0)
438 {
439 CALL_TEST_DEBUG;
440 int32_t ret = RET_ERR;
441 MessageParcel dataParcel;
442 MessageParcel replyParcel;
443 std::vector<DragRequestID> dragRequestIDs = {DragRequestID::UNKNOWN_DRAG_ACTION,
444 DragRequestID::ADD_PRIVILEGE, DragRequestID::ENTER_TEXT_EDITOR_AREA};
445 for (const auto& dragRequestID : dragRequestIDs) {
446 ret = g_intentionService->Control(g_intention, dragRequestID, dataParcel, replyParcel);
447 EXPECT_EQ(ret, RET_ERR);
448 }
449 }
450
451 /**
452 * @tc.name: IntentionServiceTest_SetParam001
453 * @tc.desc: Test SetParam
454 * @tc.type: FUNC
455 * @tc.require:
456 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam001, TestSize.Level0)457 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam001, TestSize.Level0)
458 {
459 CALL_TEST_DEBUG;
460 MessageParcel replyParcel;
461 MessageParcel dataParcel;
462 int32_t ret = RET_ERR;
463 std::vector<DragRequestID> dragRequestIDs = {DragRequestID::UNKNOWN_DRAG_ACTION,
464 DragRequestID::SET_DRAG_WINDOW_VISIBLE, DragRequestID::UPDATE_DRAG_STYLE,
465 DragRequestID::UPDATE_SHADOW_PIC, DragRequestID::UPDATE_PREVIEW_STYLE,
466 DragRequestID::UPDATE_PREVIEW_STYLE_WITH_ANIMATION};
467 for (const auto& dragRequestID : dragRequestIDs) {
468 ret = g_intentionService->SetParam(g_intention, dragRequestID, dataParcel, replyParcel);
469 EXPECT_EQ(ret, RET_ERR);
470 }
471 }
472
473 /**
474 * @tc.name: IntentionServiceTest_SetParam002
475 * @tc.desc: Test SetParam
476 * @tc.type: FUNC
477 * @tc.require:
478 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam002, TestSize.Level0)479 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam002, TestSize.Level0)
480 {
481 CALL_TEST_DEBUG;
482 MessageParcel replyParcel;
483 MessageParcel dataParcel;
484 int32_t ret = g_intentionService->SetParam(g_intention, DragRequestID::SET_DRAG_WINDOW_VISIBLE,
485 dataParcel, replyParcel);
486 EXPECT_EQ(ret, RET_ERR);
487 }
488
489 /**
490 * @tc.name: IntentionServiceTest_SetParam003
491 * @tc.desc: Test SetParam
492 * @tc.type: FUNC
493 * @tc.require:
494 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam003, TestSize.Level0)495 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam003, TestSize.Level0)
496 {
497 CALL_TEST_DEBUG;
498 MessageParcel replyParcel;
499 MessageParcel dataParcel;
500 int32_t ret = g_intentionService->SetParam(g_intention, DragRequestID::UPDATE_DRAG_STYLE,
501 dataParcel, replyParcel);
502 EXPECT_EQ(ret, RET_ERR);
503 }
504
505 /**
506 * @tc.name: IntentionServiceTest_SetParam004
507 * @tc.desc: Test SetParam
508 * @tc.type: FUNC
509 * @tc.require:
510 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam004, TestSize.Level0)511 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam004, TestSize.Level0)
512 {
513 CALL_TEST_DEBUG;
514 MessageParcel replyParcel;
515 MessageParcel dataParcel;
516 int32_t ret = g_intentionService->SetParam(g_intention, DragRequestID::UPDATE_SHADOW_PIC,
517 dataParcel, replyParcel);
518 EXPECT_EQ(ret, RET_ERR);
519 }
520
521 /**
522 * @tc.name: IntentionServiceTest_SetParam005
523 * @tc.desc: Test SetParam
524 * @tc.type: FUNC
525 * @tc.require:
526 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam005, TestSize.Level0)527 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam005, TestSize.Level0)
528 {
529 CALL_TEST_DEBUG;
530 MessageParcel replyParcel;
531 MessageParcel dataParcel;
532 int32_t ret = g_intentionService->SetParam(g_intention, DragRequestID::UPDATE_PREVIEW_STYLE,
533 dataParcel, replyParcel);
534 EXPECT_EQ(ret, RET_ERR);
535 }
536
537 /**
538 * @tc.name: IntentionServiceTest_SetParam006
539 * @tc.desc: Test SetParam
540 * @tc.type: FUNC
541 * @tc.require:
542 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam006, TestSize.Level0)543 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam006, TestSize.Level0)
544 {
545 CALL_TEST_DEBUG;
546 MessageParcel replyParcel;
547 MessageParcel dataParcel;
548 int32_t ret = g_intentionService->SetParam(g_intention, DragRequestID::UPDATE_PREVIEW_STYLE_WITH_ANIMATION,
549 dataParcel, replyParcel);
550 EXPECT_EQ(ret, RET_ERR);
551 }
552
553 /**
554 * @tc.name: IntentionServiceTest_SetParam007
555 * @tc.desc: Test SetParam
556 * @tc.type: FUNC
557 * @tc.require:
558 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam007, TestSize.Level0)559 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam007, TestSize.Level0)
560 {
561 CALL_TEST_DEBUG;
562 MessageParcel replyParcel;
563 MessageParcel dataParcel;
564 int32_t ret = g_intentionService->SetParam(g_intention, DragRequestID::ENTER_TEXT_EDITOR_AREA,
565 dataParcel, replyParcel);
566 EXPECT_EQ(ret, RET_ERR);
567 }
568
569 /**
570 * @tc.name: IntentionServiceTest_SetParam008
571 * @tc.desc: Test SetParam
572 * @tc.type: FUNC
573 * @tc.require:
574 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam008, TestSize.Level0)575 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam008, TestSize.Level0)
576 {
577 CALL_TEST_DEBUG;
578 auto env = ContextService::GetInstance();
579 ASSERT_NE(env, nullptr);
580 std::optional<DragData> dragData = CreateDragData(
581 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
582 MessageParcel replyParcel;
583 MessageParcel dataParcel;
584 env->dragMgr_.dragState_ = DragState::START;
585 SetDragWindowVisibleParam param { true, true };
586 int32_t ret = param.Marshalling(dataParcel);
587 EXPECT_EQ(ret, READ_OK);
588 ret = g_intentionService->SetParam(Intention::DRAG, DragRequestID::SET_DRAG_WINDOW_VISIBLE,
589 dataParcel, replyParcel);
590 EXPECT_EQ(ret, RET_OK);
591 env->dragMgr_.dragState_ = DragState::STOP;
592 DRAG_DATA_MGR.dragData_ = {};
593 }
594
595 /**
596 * @tc.name: IntentionServiceTest_SetParam009
597 * @tc.desc: Test SetParam
598 * @tc.type: FUNC
599 * @tc.require:
600 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam009, TestSize.Level0)601 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam009, TestSize.Level0)
602 {
603 CALL_TEST_DEBUG;
604 auto env = ContextService::GetInstance();
605 ASSERT_NE(env, nullptr);
606 MessageParcel dataParcel;
607 MessageParcel replyParcel;
608 env->dragMgr_.dragState_ = DragState::START;
609 std::shared_ptr<Media::PixelMap> pixelMap = CreatePixelMap(PIXEL_MAP_WIDTH, PIXEL_MAP_HEIGHT);
610 ASSERT_NE(pixelMap, nullptr);
611 ShadowInfo shadowInfo = { pixelMap, 0, 0 };
612 std::string extraInfo;
613 UpdateShadowPicParam param { shadowInfo };
614 bool ret = param.Marshalling(dataParcel);;
615 EXPECT_EQ(ret, READ_OK);
616 ret = g_intentionService->SetParam(g_intention, DragRequestID::UPDATE_SHADOW_PIC,
617 dataParcel, replyParcel);
618 EXPECT_TRUE(ret);
619 env->dragMgr_.dragState_ = DragState::STOP;
620 }
621
622 /**
623 * @tc.name: IntentionServiceTest_SetParam010
624 * @tc.desc: Test SetParam
625 * @tc.type: FUNC
626 * @tc.require:
627 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam010, TestSize.Level0)628 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam010, TestSize.Level0)
629 {
630 CALL_TEST_DEBUG;
631 auto env = ContextService::GetInstance();
632 ASSERT_NE(env, nullptr);
633 MessageParcel dataParcel;
634 MessageParcel replyParcel;
635 env->dragMgr_.dragState_ = DragState::START;
636 PreviewStyle previewStyleIn;
637 previewStyleIn.types = { PreviewType::FOREGROUND_COLOR };
638 previewStyleIn.foregroundColor = FOREGROUND_COLOR_IN;
639 UpdatePreviewStyleParam param { previewStyleIn };
640 bool ret = param.Marshalling(dataParcel);;
641 EXPECT_EQ(ret, READ_OK);
642 ret = g_intentionService->SetParam(g_intention, DragRequestID::UPDATE_PREVIEW_STYLE,
643 dataParcel, replyParcel);
644 EXPECT_TRUE(ret);
645 env->dragMgr_.dragState_ = DragState::STOP;
646 }
647
648 /**
649 * @tc.name: IntentionServiceTest_SetParam011
650 * @tc.desc: Test SetParam
651 * @tc.type: FUNC
652 * @tc.require:
653 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam011, TestSize.Level0)654 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam011, TestSize.Level0)
655 {
656 CALL_TEST_DEBUG;
657 auto env = ContextService::GetInstance();
658 ASSERT_NE(env, nullptr);
659 MessageParcel dataParcel;
660 MessageParcel replyParcel;
661 env->dragMgr_.dragState_ = DragState::START;
662 PreviewStyle previewStyleIn;
663 previewStyleIn.types = { PreviewType::FOREGROUND_COLOR };
664 previewStyleIn.foregroundColor = FOREGROUND_COLOR_IN;
665 PreviewAnimation animationOut;
666 AssignToAnimation(animationOut);
667 UpdatePreviewAnimationParam param { previewStyleIn, animationOut };
668 bool ret = param.Marshalling(dataParcel);;
669 EXPECT_EQ(ret, READ_OK);
670 ret = g_intentionService->SetParam(Intention::DRAG, DragRequestID::UPDATE_PREVIEW_STYLE_WITH_ANIMATION,
671 dataParcel, replyParcel);
672 EXPECT_FALSE(ret);
673 env->dragMgr_.dragState_ = DragState::STOP;
674 }
675
676 /**
677 * @tc.name: IntentionServiceTest_SetParam012
678 * @tc.desc: Test SetParam
679 * @tc.type: FUNC
680 * @tc.require:
681 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam012, TestSize.Level0)682 HWTEST_F(IntentionServiceTest, IntentionServiceTest_SetParam012, TestSize.Level0)
683 {
684 CALL_TEST_DEBUG;
685 MessageParcel replyParcel;
686 MessageParcel dataParcel;
687 EnterTextEditorAreaParam param { true };
688 bool ret = param.Marshalling(dataParcel);;
689 EXPECT_EQ(ret, READ_OK);
690 ret = g_intentionService->SetParam(g_intention, DragRequestID::ENTER_TEXT_EDITOR_AREA, dataParcel, replyParcel);
691 EXPECT_EQ(ret, READ_OK);
692 }
693
694 /**
695 * @tc.name: IntentionServiceTest_GetParam001
696 * @tc.desc: Test GetParam
697 * @tc.type: FUNC
698 * @tc.require:
699 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam001, TestSize.Level0)700 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam001, TestSize.Level0)
701 {
702 CALL_TEST_DEBUG;
703 int32_t ret = RET_ERR;
704 MessageParcel replyParcel;
705 MessageParcel dataParcel;
706 std::vector<DragRequestID> dragRequestIDs = {DragRequestID::UNKNOWN_DRAG_ACTION,
707 DragRequestID::GET_DRAG_TARGET_PID, DragRequestID::GET_UDKEY,
708 DragRequestID::GET_SHADOW_OFFSET, DragRequestID::GET_DRAG_DATA,
709 DragRequestID::GET_DRAG_STATE, DragRequestID::GET_DRAG_SUMMARY,
710 DragRequestID::GET_DRAG_ACTION, DragRequestID::GET_EXTRA_INFO};
711 for (const auto& dragRequestID : dragRequestIDs) {
712 if (dragRequestID == DragRequestID::UNKNOWN_DRAG_ACTION ||
713 dragRequestID == DragRequestID::GET_UDKEY ||
714 dragRequestID == DragRequestID::GET_DRAG_DATA ||
715 dragRequestID == DragRequestID::GET_DRAG_SUMMARY ||
716 dragRequestID == DragRequestID::GET_DRAG_ACTION||
717 dragRequestID == DragRequestID::GET_EXTRA_INFO) {
718 ret = g_intentionService->GetParam(Intention::DRAG, dragRequestID, dataParcel, replyParcel);
719 if (ret == RET_OK) {
720 GTEST_LOG_(INFO) << "dragRequestID: " << dragRequestID;
721 }
722 EXPECT_EQ(ret, RET_ERR);
723 } else {
724 ret = g_intentionService->GetParam(Intention::DRAG, dragRequestID, dataParcel, replyParcel);
725 EXPECT_EQ(ret, RET_OK);
726 }
727 }
728 }
729
730 /**
731 * @tc.name: IntentionServiceTest_GetParam002
732 * @tc.desc: Test GetParam
733 * @tc.type: FUNC
734 * @tc.require:
735 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam002, TestSize.Level0)736 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam002, TestSize.Level0)
737 {
738 CALL_TEST_DEBUG;
739 MessageParcel replyParcel;
740 MessageParcel dataParcel;
741 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_TARGET_PID,
742 dataParcel, replyParcel);
743 EXPECT_EQ(ret, RET_OK);
744 }
745
746 /**
747 * @tc.name: IntentionServiceTest_GetParam003
748 * @tc.desc: Test GetParam
749 * @tc.type: FUNC
750 * @tc.require:
751 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam003, TestSize.Level0)752 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam003, TestSize.Level0)
753 {
754 CALL_TEST_DEBUG;
755 std::optional<DragData> dragData = CreateDragData(
756 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
757 DRAG_DATA_MGR.Init(dragData.value());
758 MessageParcel replyParcel;
759 MessageParcel dataParcel;
760 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_UDKEY,
761 dataParcel, replyParcel);
762 EXPECT_EQ(ret, RET_OK);
763 DRAG_DATA_MGR.dragData_ = {};
764 }
765
766 /**
767 * @tc.name: IntentionServiceTest_GetParam004
768 * @tc.desc: Test GetParam
769 * @tc.type: FUNC
770 * @tc.require:
771 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam004, TestSize.Level0)772 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam004, TestSize.Level0)
773 {
774 CALL_TEST_DEBUG;
775 MessageParcel replyParcel;
776 MessageParcel dataParcel;
777 int32_t ret = g_intentionService->GetParam(g_intention, DragRequestID::GET_SHADOW_OFFSET,
778 dataParcel, replyParcel);
779 EXPECT_EQ(ret, RET_ERR);
780 }
781
782 /**
783 * @tc.name: IntentionServiceTest_GetParam005
784 * @tc.desc: Test GetParam
785 * @tc.type: FUNC
786 * @tc.require:
787 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam005, TestSize.Level0)788 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam005, TestSize.Level0)
789 {
790 CALL_TEST_DEBUG;
791 MessageParcel replyParcel;
792 MessageParcel dataParcel;
793 int32_t ret = g_intentionService->GetParam(g_intention, DragRequestID::GET_DRAG_DATA,
794 dataParcel, replyParcel);
795 EXPECT_EQ(ret, RET_ERR);
796 }
797
798 /**
799 * @tc.name: IntentionServiceTest_GetParam006
800 * @tc.desc: Test GetParam
801 * @tc.type: FUNC
802 * @tc.require:
803 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam006, TestSize.Level0)804 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam006, TestSize.Level0)
805 {
806 CALL_TEST_DEBUG;
807 MessageParcel replyParcel;
808 MessageParcel dataParcel;
809 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_STATE,
810 dataParcel, replyParcel);
811 EXPECT_EQ(ret, RET_OK);
812 }
813
814 /**
815 * @tc.name: IntentionServiceTest_GetParam007
816 * @tc.desc: Test GetParam
817 * @tc.type: FUNC
818 * @tc.require:
819 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam007, TestSize.Level0)820 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam007, TestSize.Level0)
821 {
822 CALL_TEST_DEBUG;
823 MessageParcel replyParcel;
824 MessageParcel dataParcel;
825 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_SUMMARY,
826 dataParcel, replyParcel);
827 EXPECT_EQ(ret, RET_ERR);
828 }
829
830 /**
831 * @tc.name: IntentionServiceTest_GetParam008
832 * @tc.desc: Test GetParam
833 * @tc.type: FUNC
834 * @tc.require:
835 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam008, TestSize.Level0)836 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam008, TestSize.Level0)
837 {
838 CALL_TEST_DEBUG;
839 MessageParcel replyParcel;
840 MessageParcel dataParcel;
841 int32_t ret = g_intentionService->GetParam(g_intention, DragRequestID::GET_DRAG_ACTION,
842 dataParcel, replyParcel);
843 EXPECT_EQ(ret, RET_ERR);
844 }
845
846 /**
847 * @tc.name: IntentionServiceTest_GetParam009
848 * @tc.desc: Test GetParam
849 * @tc.type: FUNC
850 * @tc.require:
851 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam009, TestSize.Level0)852 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam009, TestSize.Level0)
853 {
854 CALL_TEST_DEBUG;
855 MessageParcel replyParcel;
856 MessageParcel dataParcel;
857 int32_t ret = g_intentionService->GetParam(g_intention, DragRequestID::GET_EXTRA_INFO, dataParcel, replyParcel);
858 EXPECT_EQ(ret, RET_ERR);
859 }
860
861 /**
862 * @tc.name: IntentionServiceTest_GetParam010
863 * @tc.desc: Test GetParam
864 * @tc.type: FUNC
865 * @tc.require:
866 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam010, TestSize.Level0)867 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam010, TestSize.Level0)
868 {
869 CALL_TEST_DEBUG;
870 MessageParcel replyParcel;
871 MessageParcel dataParcel;
872 int32_t ret = g_intentionService->GetParam(g_intention, DragRequestID::GET_UDKEY, dataParcel, replyParcel);
873 EXPECT_EQ(ret, RET_ERR);
874 }
875
876 /**
877 * @tc.name: IntentionServiceTest_GetParam011
878 * @tc.desc: Test GetParam
879 * @tc.type: FUNC
880 * @tc.require:
881 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam011, TestSize.Level0)882 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam011, TestSize.Level0)
883 {
884 CALL_TEST_DEBUG;
885 std::optional<DragData> dragData = CreateDragData(
886 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
887 DRAG_DATA_MGR.Init(dragData.value());
888 MessageParcel replyParcel;
889 MessageParcel dataParcel;
890 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_SHADOW_OFFSET,
891 dataParcel, replyParcel);
892 EXPECT_EQ(ret, RET_OK);
893 DRAG_DATA_MGR.dragData_ = {};
894 }
895
896 /**
897 * @tc.name: IntentionServiceTest_GetParam012
898 * @tc.desc: Test GetParam
899 * @tc.type: FUNC
900 * @tc.require:
901 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam012, TestSize.Level0)902 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam012, TestSize.Level0)
903 {
904 CALL_TEST_DEBUG;
905 std::optional<DragData> dragData = CreateDragData(
906 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
907 DRAG_DATA_MGR.Init(dragData.value());
908 MessageParcel replyParcel;
909 MessageParcel dataParcel;
910 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_EXTRA_INFO,
911 dataParcel, replyParcel);
912 EXPECT_EQ(ret, RET_OK);
913 DRAG_DATA_MGR.dragData_ = {};
914 }
915
916 /**
917 * @tc.name: IntentionServiceTest_GetParam013
918 * @tc.desc: Test GetParam
919 * @tc.type: FUNC
920 * @tc.require:
921 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam013, TestSize.Level0)922 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam013, TestSize.Level0)
923 {
924 CALL_TEST_DEBUG;
925 auto env = ContextService::GetInstance();
926 ASSERT_NE(env, nullptr);
927 MessageParcel dataParcel;
928 MessageParcel replyParcel;
929 env->dragMgr_.dragState_ = DragState::START;
930 UpdateDragStyleParam param { DragCursorStyle::COPY, -1 };
931 bool ret = param.Marshalling(dataParcel);
932 EXPECT_EQ(ret, READ_OK);
933 ret = g_intentionService->GetParam(g_intention, DragRequestID::UPDATE_DRAG_STYLE, dataParcel, replyParcel);
934 EXPECT_TRUE(ret);
935 env->dragMgr_.dragState_ = DragState::STOP;
936 }
937
938 /**
939 * @tc.name: IntentionServiceTest_GetParam014
940 * @tc.desc: Test GetParam
941 * @tc.type: FUNC
942 * @tc.require:
943 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam014, TestSize.Level0)944 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam014, TestSize.Level0)
945 {
946 CALL_TEST_DEBUG;
947 auto env = ContextService::GetInstance();
948 ASSERT_NE(env, nullptr);
949 MessageParcel dataParcel;
950 MessageParcel replyParcel;
951 env->dragMgr_.dragState_ = DragState::START;
952 GetDragTargetPidReply targetPidReply { IPCSkeleton::GetCallingPid() };
953 bool ret = targetPidReply.Marshalling(dataParcel);
954 EXPECT_EQ(ret, READ_OK);
955 ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_TARGET_PID, dataParcel, replyParcel);
956 EXPECT_FALSE(ret);
957 env->dragMgr_.dragState_ = DragState::STOP;
958 }
959
960 /**
961 * @tc.name: IntentionServiceTest_GetParam015
962 * @tc.desc: Test GetParam
963 * @tc.type: FUNC
964 * @tc.require:
965 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam015, TestSize.Level0)966 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam015, TestSize.Level0)
967 {
968 CALL_TEST_DEBUG;
969 auto env = ContextService::GetInstance();
970 ASSERT_NE(env, nullptr);
971 std::optional<DragData> dragData = CreateDragData(
972 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
973 env->dragMgr_.dragState_ = DragState::START;
974 MessageParcel replyParcel;
975 MessageParcel dataParcel;
976 DRAG_DATA_MGR.Init(dragData.value());
977 int32_t ret = g_intentionService->GetParam(g_intention, DragRequestID::GET_DRAG_DATA, dataParcel, replyParcel);
978 EXPECT_EQ(ret, RET_OK);
979 DRAG_DATA_MGR.dragData_ = {};
980 ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_DATA, dataParcel, replyParcel);
981 EXPECT_EQ(ret, RET_ERR);
982 env->dragMgr_.dragState_ = DragState::STOP;
983 }
984
985 /**
986 * @tc.name: IntentionServiceTest_GetParam016
987 * @tc.desc: Test GetParam
988 * @tc.type: FUNC
989 * @tc.require:
990 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam016, TestSize.Level0)991 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam016, TestSize.Level0)
992 {
993 CALL_TEST_DEBUG;
994 auto env = ContextService::GetInstance();
995 ASSERT_NE(env, nullptr);
996 env->dragMgr_.dragState_ = DragState::ERROR;
997 MessageParcel replyParcel;
998 MessageParcel dataParcel;
999 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_STATE,
1000 dataParcel, replyParcel);
1001 EXPECT_EQ(ret, RET_ERR);
1002 env->dragMgr_.dragState_ = DragState::START;
1003 ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_STATE, dataParcel, replyParcel);
1004 EXPECT_EQ(ret, RET_OK);
1005 env->dragMgr_.dragState_ = DragState::STOP;
1006 }
1007
1008 /**
1009 * @tc.name: IntentionServiceTest_GetParam017
1010 * @tc.desc: Test GetParam
1011 * @tc.type: FUNC
1012 * @tc.require:
1013 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam017, TestSize.Level0)1014 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam017, TestSize.Level0)
1015 {
1016 CALL_TEST_DEBUG;
1017 auto env = ContextService::GetInstance();
1018 ASSERT_NE(env, nullptr);
1019 env->dragMgr_.dragState_ = DragState::ERROR;
1020 MessageParcel replyParcel;
1021 MessageParcel dataParcel;
1022 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_ACTION,
1023 dataParcel, replyParcel);
1024 EXPECT_EQ(ret, RET_ERR);
1025 env->dragMgr_.dragState_ = DragState::START;
1026 ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_DRAG_ACTION, dataParcel, replyParcel);
1027 EXPECT_EQ(ret, RET_OK);
1028 env->dragMgr_.dragState_ = DragState::STOP;
1029 }
1030
1031 /**
1032 * @tc.name: IntentionServiceTest_GetParam018
1033 * @tc.desc: Test GetParam
1034 * @tc.type: FUNC
1035 * @tc.require:
1036 */
HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam018, TestSize.Level0)1037 HWTEST_F(IntentionServiceTest, IntentionServiceTest_GetParam018, TestSize.Level0)
1038 {
1039 CALL_TEST_DEBUG;
1040 auto env = ContextService::GetInstance();
1041 ASSERT_NE(env, nullptr);
1042 std::optional<DragData> dragData = CreateDragData(
1043 MMI::PointerEvent::SOURCE_TYPE_MOUSE, POINTER_ID, DRAG_NUM_ONE, false, SHADOW_NUM_ONE);
1044 MessageParcel replyParcel;
1045 MessageParcel dataParcel;
1046 DRAG_DATA_MGR.Init(dragData.value());
1047 int32_t ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_EXTRA_INFO,
1048 dataParcel, replyParcel);
1049 EXPECT_EQ(ret, RET_OK);
1050 DRAG_DATA_MGR.dragData_ = {};
1051 ret = g_intentionService->GetParam(Intention::DRAG, DragRequestID::GET_EXTRA_INFO, dataParcel, replyParcel);
1052 EXPECT_EQ(ret, RET_ERR);
1053 }
1054 } // namespace DeviceStatus
1055 } // namespace Msdp
1056 } // namespace OHOS