1 /*
2 * Copyright (c) 2023 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 #include <gtest/gtest.h>
17
18 #include "accesstoken_kit.h"
19 #include "bool_wrapper.h"
20 #include "nativetoken_kit.h"
21 #include "token_setproc.h"
22 #include "want_agent.h"
23 #include "avcast_control_command.h"
24 #include "avcast_controller_item.h"
25 #include "avmedia_description.h"
26 #include "avmeta_data.h"
27 #include "avplayback_state.h"
28 #include "avqueue_item.h"
29 #include "avsession_manager.h"
30 #include "avsession_errors.h"
31 #include "avsession_log.h"
32 #include "hw_cast_stream_player.h"
33 #include "iavcast_controller.h"
34 #include "iservice_registry.h"
35 #include "system_ability_definition.h"
36
37 #define private public
38 #include "hw_cast_provider.h"
39 #undef private
40
41 using namespace testing::ext;
42 using namespace OHOS::Security::AccessToken;
43
44 namespace OHOS {
45 namespace AVSession {
46 static int32_t g_onCall = AVSESSION_ERROR;
47 static int32_t g_sessionId = AVSESSION_ERROR;
48 static AVMetaData g_metaData;
49 static AVPlaybackState g_playbackState;
50 static char g_testSessionTag[] = "test";
51 static char g_testBundleName[] = "test.ohos.avsession";
52 static char g_testAbilityName[] = "test.ability";
53 static uint64_t g_selfTokenId = 0;
54 static std::string g_errLog;
55 sptr<AVCastControllerCallbackProxy> g_AVCastControllerCallbackProxy {nullptr};
56
MyLogCallback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)57 void MyLogCallback(const LogType type, const LogLevel level,
58 const unsigned int domain, const char *tag, const char *msg)
59 {
60 g_errLog = msg;
61 }
62
63 static HapInfoParams g_info = {
64 .userID = 100,
65 .bundleName = "ohos.permission_test.demo",
66 .instIndex = 0,
67 .appIDDesc = "ohos.permission_test.demo",
68 .isSystemApp = true
69 };
70
71 static HapPolicyParams g_policy = {
72 .apl = APL_NORMAL,
73 .domain = "test.domain",
74 .permList = {
75 {
76 .permissionName = "ohos.permission.MANAGE_MEDIA_RESOURCES",
77 .bundleName = "ohos.permission_test.demo",
78 .grantMode = 1,
79 .availableLevel = APL_NORMAL,
80 .label = "label",
81 .labelId = 1,
82 .description = "test",
83 .descriptionId = 1
84 }
85 },
86 .permStateList = {
87 {
88 .permissionName = "ohos.permission.MANAGE_MEDIA_RESOURCES",
89 .isGeneral = true,
90 .resDeviceID = { "local" },
91 .grantStatus = { PermissionState::PERMISSION_GRANTED },
92 .grantFlags = { 1 }
93 }
94 }
95 };
96
97 class AVCastControllerTest : public testing::Test {
98 public:
99 static void SetUpTestCase();
100 static void TearDownTestCase();
101 void SetUp() override;
102 void TearDown() override;
103
104 std::shared_ptr<AVSession> avsession_ = nullptr;
105 std::shared_ptr<AVSessionController> controller_ = nullptr;
106 std::shared_ptr<AVCastControllerItem> castController_ = std::make_shared<AVCastControllerItem>();
107 std::vector<int32_t> supportedCastCmd_;
108
109 static constexpr int SESSION_LEN = 64;
110 };
111
SetUpTestCase()112 void AVCastControllerTest::SetUpTestCase()
113 {
114 g_selfTokenId = GetSelfTokenID();
115 AccessTokenKit::AllocHapToken(g_info, g_policy);
116 AccessTokenIDEx tokenID = AccessTokenKit::GetHapTokenIDEx(g_info.userID, g_info.bundleName, g_info.instIndex);
117 SetSelfTokenID(tokenID.tokenIDEx);
118
119 auto mgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
120 if (mgr == nullptr) {
121 SLOGI("failed to get sa mgr");
122 return;
123 }
124 auto object = mgr->GetSystemAbility(OHOS::AVSESSION_SERVICE_ID);
125 if (object == nullptr) {
126 SLOGI("failed to get service");
127 return;
128 }
129 g_AVCastControllerCallbackProxy = iface_cast<AVCastControllerCallbackProxy>(object);
130 ASSERT_TRUE(g_AVCastControllerCallbackProxy != nullptr);
131 }
132
TearDownTestCase()133 void AVCastControllerTest::TearDownTestCase()
134 {
135 SetSelfTokenID(g_selfTokenId);
136 auto tokenId = AccessTokenKit::GetHapTokenID(g_info.userID, g_info.bundleName, g_info.instIndex);
137 AccessTokenKit::DeleteToken(tokenId);
138 }
139
SetUp()140 void AVCastControllerTest::SetUp()
141 {
142 OHOS::AppExecFwk::ElementName elementName;
143 elementName.SetBundleName(g_testBundleName);
144 elementName.SetAbilityName(g_testAbilityName);
145 avsession_ = AVSessionManager::GetInstance().CreateSession(g_testSessionTag, AVSession::SESSION_TYPE_AUDIO,
146 elementName);
147 ASSERT_NE(avsession_, nullptr);
148 g_sessionId++;
149 auto ret = AVSessionManager::GetInstance().CreateController(avsession_->GetSessionId(), controller_);
150 ASSERT_EQ(ret, AVSESSION_SUCCESS);
151 ASSERT_NE(controller_, nullptr);
152
153 std::shared_ptr<HwCastStreamPlayer> HwCastStreamPlayer_ = std::make_shared<HwCastStreamPlayer>(nullptr);
154 auto validCallback = [this](int32_t cmd, std::vector<int32_t>& supportedCastCmds) {
155 SLOGI("add cast valid command %{public}d", cmd);
156 supportedCastCmds = supportedCastCmd_;
157 return;
158 };
159 auto preparecallback = []() {
160 SLOGI("prepare callback");
161 };
162 castController_->Init(HwCastStreamPlayer_, validCallback, preparecallback);
163 }
164
TearDown()165 void AVCastControllerTest::TearDown()
166 {
167 [[maybe_unused]] int32_t ret = AVSESSION_ERROR;
168 if (avsession_ != nullptr) {
169 ret = avsession_->Destroy();
170 avsession_ = nullptr;
171 }
172 if (controller_ != nullptr) {
173 ret = controller_->Destroy();
174 controller_ = nullptr;
175 }
176 g_onCall = AVSESSION_ERROR;
177 }
178
179 class AVCastControllerCallbackImpl : public AVCastControllerCallback {
180 public:
181 void OnCastPlaybackStateChange(const AVPlaybackState& state) override;
182
183 void OnMediaItemChange(const AVQueueItem& avQueueItem) override;
184
185 void OnPlayNext() override;
186
187 void OnPlayPrevious() override;
188
189 void OnSeekDone(const int32_t seekNumber) override;
190
191 void OnVideoSizeChange(const int32_t width, const int32_t height) override;
192
193 void OnPlayerError(const int32_t errorCode, const std::string& errorMsg) override;
194
195 void OnCastValidCommandChanged(const std::vector<int32_t> &cmds) override;
196
197 ~AVCastControllerCallbackImpl() override;
198
199 AVPlaybackState state_;
200 AVQueueItem avQueueItem_;
201 int32_t seekNumber_;
202 int32_t width_;
203 int32_t height_;
204 int32_t errorCode_;
205 std::string errorMsg_;
206 };
207
~AVCastControllerCallbackImpl()208 AVCastControllerCallbackImpl::~AVCastControllerCallbackImpl()
209 {
210 }
211
OnCastPlaybackStateChange(const AVPlaybackState & state)212 void AVCastControllerCallbackImpl::OnCastPlaybackStateChange(const AVPlaybackState& state)
213 {
214 state_ = state;
215 }
216
OnMediaItemChange(const AVQueueItem & avQueueItem)217 void AVCastControllerCallbackImpl::OnMediaItemChange(const AVQueueItem& avQueueItem)
218 {
219 avQueueItem_ = avQueueItem;
220 }
221
OnPlayNext()222 void AVCastControllerCallbackImpl::OnPlayNext()
223 {
224 }
225
OnPlayPrevious()226 void AVCastControllerCallbackImpl::OnPlayPrevious()
227 {
228 }
229
OnSeekDone(const int32_t seekNumber)230 void AVCastControllerCallbackImpl::OnSeekDone(const int32_t seekNumber)
231 {
232 seekNumber_ = seekNumber;
233 }
234
OnVideoSizeChange(const int32_t width,const int32_t height)235 void AVCastControllerCallbackImpl::OnVideoSizeChange(const int32_t width, const int32_t height)
236 {
237 width_ = width;
238 height_ = height;
239 }
240
OnPlayerError(const int32_t errorCode,const std::string & errorMsg)241 void AVCastControllerCallbackImpl::OnPlayerError(const int32_t errorCode, const std::string& errorMsg)
242 {
243 errorCode_ = errorCode;
244 errorMsg_ = errorMsg;
245 }
246
OnCastValidCommandChanged(const std::vector<int32_t> & cmds)247 void AVCastControllerCallbackImpl::OnCastValidCommandChanged(const std::vector<int32_t> &cmds)
248 {
249 }
250
251 class AVCastControllerProxyMock : public IAVCastControllerProxy {
252 public:
Release()253 void Release() {};
RegisterControllerListener(const std::shared_ptr<IAVCastControllerProxyListener> iAVCastControllerProxyListener)254 int32_t RegisterControllerListener(const std::shared_ptr<IAVCastControllerProxyListener>
255 iAVCastControllerProxyListener) {return 0;}
UnRegisterControllerListener(const std::shared_ptr<IAVCastControllerProxyListener> iAVCastControllerProxyListener)256 int32_t UnRegisterControllerListener(const std::shared_ptr<IAVCastControllerProxyListener>
257 iAVCastControllerProxyListener) {return 0;}
GetCurrentItem()258 AVQueueItem GetCurrentItem() {return AVQueueItem();}
Start(const AVQueueItem & avQueueItem)259 int32_t Start(const AVQueueItem& avQueueItem) {return 0;}
Prepare(const AVQueueItem & avQueueItem)260 int32_t Prepare(const AVQueueItem& avQueueItem) {return 0;}
SendControlCommand(const AVCastControlCommand cmd)261 void SendControlCommand(const AVCastControlCommand cmd) {}
GetDuration(int32_t & duration)262 int32_t GetDuration(int32_t& duration) {return 0;}
GetCastAVPlaybackState(AVPlaybackState & avPlaybackState)263 int32_t GetCastAVPlaybackState(AVPlaybackState& avPlaybackState) {return 0;}
SetValidAbility(const std::vector<int32_t> & validAbilityList)264 int32_t SetValidAbility(const std::vector<int32_t>& validAbilityList) {return 0;}
GetValidAbility(std::vector<int32_t> & validAbilityList)265 int32_t GetValidAbility(std::vector<int32_t> &validAbilityList) {return 0;}
SetDisplaySurface(std::string & surfaceId)266 int32_t SetDisplaySurface(std::string& surfaceId) {return 0;}
ProcessMediaKeyResponse(const std::string & assetId,const std::vector<uint8_t> & response)267 int32_t ProcessMediaKeyResponse(const std::string& assetId, const std::vector<uint8_t>& response) {return 0;}
GetSupportedDecoders(std::vector<std::string> & decoderTypes)268 int32_t GetSupportedDecoders(std::vector<std::string>& decoderTypes) {return 0;}
GetRecommendedResolutionLevel(std::string & decoderType,ResolutionLevel & resolutionLevel)269 int32_t GetRecommendedResolutionLevel(std::string& decoderType, ResolutionLevel& resolutionLevel) {return 0;}
GetSupportedHdrCapabilities(std::vector<HDRFormat> & hdrFormats)270 int32_t GetSupportedHdrCapabilities(std::vector<HDRFormat>& hdrFormats) {return 0;}
GetSupportedPlaySpeeds(std::vector<float> & playSpeeds)271 int32_t GetSupportedPlaySpeeds(std::vector<float>& playSpeeds) {return 0;}
RefreshCurrentAVQueueItem(const AVQueueItem & avQueueItem)272 int32_t RefreshCurrentAVQueueItem(const AVQueueItem& avQueueItem) {return 0;}
273 };
274
275 /**
276 * @tc.name: SendControlCommand001
277 * @tc.desc: send command, check if AVCastControlCommand is invalid
278 * @tc.type: FUNC
279 * @tc.require:
280 */
281 HWTEST_F(AVCastControllerTest, SendControlCommand001, TestSize.Level1)
282 {
283 AVCastControlCommand command;
284 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_INVALID), ERR_INVALID_PARAM);
285 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_MAX), ERR_INVALID_PARAM);
286 EXPECT_EQ(command.SetForwardTime(0), ERR_INVALID_PARAM);
287 EXPECT_EQ(command.SetRewindTime(-1), ERR_INVALID_PARAM);
288 EXPECT_EQ(command.SetSeekTime(-1), ERR_INVALID_PARAM);
289 EXPECT_EQ(command.SetSpeed(-1), ERR_INVALID_PARAM);
290 EXPECT_EQ(command.SetLoopMode(-1), ERR_INVALID_PARAM);
291 }
292
293 /**
294 * @tc.name: SendControlCommand002
295 * @tc.desc: send command, check if AVCastControlCommand is invalid
296 * @tc.type: FUNC
297 * @tc.require:
298 */
299 HWTEST_F(AVCastControllerTest, SendControlCommand002, TestSize.Level1)
300 {
301 AVCastControlCommand command;
302 int32_t mode = -1;
303 OHOS::Parcel parcel;
304 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_SET_LOOP_MODE), AVSESSION_SUCCESS);
305 EXPECT_EQ(command.SetLoopMode(AVPlaybackState::LOOP_MODE_SEQUENCE), AVSESSION_SUCCESS);
306 EXPECT_EQ(command.Marshalling(parcel), true);
307 AVCastControlCommand *ret = AVCastControlCommand::Unmarshalling(parcel);
308 EXPECT_NE(ret, nullptr);
309 EXPECT_EQ(ret->GetCommand(), AVCastControlCommand::CAST_CONTROL_CMD_SET_LOOP_MODE);
310 EXPECT_EQ(ret->GetLoopMode(mode), AVSESSION_SUCCESS);
311 EXPECT_EQ(mode, AVPlaybackState::LOOP_MODE_SEQUENCE);
312 delete ret;
313 ret = nullptr;
314 }
315
316 /**
317 * @tc.name: SendControlCommand003
318 * @tc.desc: send command, check if AVCastControlCommand is invalid
319 * @tc.type: FUNC
320 * @tc.require:
321 */
322 HWTEST_F(AVCastControllerTest, SendControlCommand003, TestSize.Level1)
323 {
324 AVCastControlCommand command;
325 int32_t speed = -1;
326 OHOS::Parcel parcel;
327 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_SET_SPEED), AVSESSION_SUCCESS);
328 EXPECT_EQ(command.SetSpeed(1), AVSESSION_SUCCESS);
329 EXPECT_EQ(command.Marshalling(parcel), true);
330 AVCastControlCommand *ret = AVCastControlCommand::Unmarshalling(parcel);
331 EXPECT_NE(ret, nullptr);
332 EXPECT_EQ(ret->GetCommand(), AVCastControlCommand::CAST_CONTROL_CMD_SET_SPEED);
333 EXPECT_EQ(ret->GetSpeed(speed), AVSESSION_SUCCESS);
334 EXPECT_EQ(speed, 1);
335 delete ret;
336 ret = nullptr;
337 }
338
339 /**
340 * @tc.name: SendControlCommand004
341 * @tc.desc: send command, check if AVCastControlCommand is invalid
342 * @tc.type: FUNC
343 * @tc.require:
344 */
345 HWTEST_F(AVCastControllerTest, SendControlCommand004, TestSize.Level1)
346 {
347 AVCastControlCommand command;
348 int32_t volumn = -1;
349 OHOS::Parcel parcel;
350 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_SET_VOLUME), AVSESSION_SUCCESS);
351 EXPECT_EQ(command.SetVolume(1), AVSESSION_SUCCESS);
352 EXPECT_EQ(command.Marshalling(parcel), true);
353 AVCastControlCommand *ret = AVCastControlCommand::Unmarshalling(parcel);
354 EXPECT_NE(ret, nullptr);
355 EXPECT_EQ(ret->GetCommand(), AVCastControlCommand::CAST_CONTROL_CMD_SET_VOLUME);
356 EXPECT_EQ(ret->GetVolume(volumn), AVSESSION_SUCCESS);
357 EXPECT_EQ(volumn, 1);
358 delete ret;
359 ret = nullptr;
360 }
361
362 /**
363 * @tc.name: SendControlCommand005
364 * @tc.desc: send command, check if AVCastControlCommand is invalid
365 * @tc.type: FUNC
366 * @tc.require:
367 */
368 HWTEST_F(AVCastControllerTest, SendControlCommand005, TestSize.Level1)
369 {
370 AVCastControlCommand command;
371 int32_t seek = -1;
372 OHOS::Parcel parcel;
373 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_SEEK), AVSESSION_SUCCESS);
374 EXPECT_EQ(command.SetSeekTime(1), AVSESSION_SUCCESS);
375 EXPECT_EQ(command.Marshalling(parcel), true);
376 AVCastControlCommand *ret = AVCastControlCommand::Unmarshalling(parcel);
377 EXPECT_NE(ret, nullptr);
378 EXPECT_EQ(ret->GetCommand(), AVCastControlCommand::CAST_CONTROL_CMD_SEEK);
379 EXPECT_EQ(ret->GetSeekTime(seek), AVSESSION_SUCCESS);
380 EXPECT_EQ(seek, 1);
381 delete ret;
382 ret = nullptr;
383 }
384
385 /**
386 * @tc.name: SendControlCommand006
387 * @tc.desc: send command, check if AVCastControlCommand is invalid
388 * @tc.type: FUNC
389 * @tc.require:
390 */
391 HWTEST_F(AVCastControllerTest, SendControlCommand006, TestSize.Level1)
392 {
393 AVCastControlCommand command;
394 int32_t rewind = -1;
395 OHOS::Parcel parcel;
396 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_REWIND), AVSESSION_SUCCESS);
397 EXPECT_EQ(command.SetRewindTime(1), AVSESSION_SUCCESS);
398 EXPECT_EQ(command.Marshalling(parcel), true);
399 AVCastControlCommand *ret = AVCastControlCommand::Unmarshalling(parcel);
400 EXPECT_NE(ret, nullptr);
401 EXPECT_EQ(ret->GetCommand(), AVCastControlCommand::CAST_CONTROL_CMD_REWIND);
402 EXPECT_EQ(ret->GetRewindTime(rewind), AVSESSION_SUCCESS);
403 EXPECT_EQ(rewind, 1);
404 delete ret;
405 ret = nullptr;
406 }
407
408 /**
409 * @tc.name: SendControlCommand007
410 * @tc.desc: send command, check if AVCastControlCommand is invalid
411 * @tc.type: FUNC
412 * @tc.require:
413 */
414 HWTEST_F(AVCastControllerTest, SendControlCommand007, TestSize.Level1)
415 {
416 AVCastControlCommand command;
417 int32_t forward = -1;
418 OHOS::Parcel parcel;
419 EXPECT_EQ(command.SetCommand(AVCastControlCommand::CAST_CONTROL_CMD_FAST_FORWARD), AVSESSION_SUCCESS);
420 EXPECT_EQ(command.SetForwardTime(1), AVSESSION_SUCCESS);
421 EXPECT_EQ(command.Marshalling(parcel), true);
422 AVCastControlCommand *ret = AVCastControlCommand::Unmarshalling(parcel);
423 EXPECT_NE(ret, nullptr);
424 EXPECT_EQ(ret->GetCommand(), AVCastControlCommand::CAST_CONTROL_CMD_FAST_FORWARD);
425 EXPECT_EQ(ret->GetForwardTime(forward), AVSESSION_SUCCESS);
426 EXPECT_EQ(forward, 1);
427 delete ret;
428 ret = nullptr;
429 }
430
431 /**
432 * @tc.name: SendControlCommand008
433 * @tc.desc: send command, check if AVCastControlCommand is invalid
434 * @tc.type: FUNC
435 * @tc.require:
436 */
437 HWTEST_F(AVCastControllerTest, SendControlCommand008, TestSize.Level1)
438 {
439 AVCastControlCommand command;
440 EXPECT_EQ(castController_->SendControlCommand(command), AVSESSION_SUCCESS);
441 }
442
443 /**
444 * @tc.name: Start001
445 * @tc.desc: Start
446 * @tc.type: FUNC
447 * @tc.require:
448 */
449 HWTEST_F(AVCastControllerTest, Start001, TestSize.Level1)
450 {
451 AVQueueItem avQueueItem;
452 std::shared_ptr<AVMediaDescription> description = std::make_shared<AVMediaDescription>();
453 description->SetMediaId("123");
454 description->SetTitle("Title");
455 description->SetSubtitle("Subtitle");
456 description->SetDescription("This is music description");
457 description->SetIcon(nullptr);
458 description->SetIconUri("xxxxx");
459 description->SetExtras(nullptr);
460 description->SetMediaUri("Media url");
461 avQueueItem.SetDescription(description);
462 EXPECT_EQ(castController_->Start(avQueueItem), AVSESSION_SUCCESS);
463 }
464
465 /**
466 * @tc.name: Prepare001
467 * @tc.desc: Prepare
468 * @tc.type: FUNC
469 * @tc.require:
470 */
471 HWTEST_F(AVCastControllerTest, Prepare001, TestSize.Level1)
472 {
473 AVQueueItem avQueueItem;
474 std::shared_ptr<AVMediaDescription> description = std::make_shared<AVMediaDescription>();
475 description->SetMediaId("123");
476 description->SetTitle("Title");
477 description->SetSubtitle("Subtitle");
478 description->SetDescription("This is music description");
479 description->SetIcon(nullptr);
480 description->SetIconUri("xxxxx");
481 description->SetExtras(nullptr);
482 description->SetMediaUri("Media url");
483 avQueueItem.SetDescription(description);
484 EXPECT_EQ(castController_->Prepare(avQueueItem), AVSESSION_SUCCESS);
485 }
486
487 /**
488 * @tc.name: GetDuration001
489 * @tc.desc: GetDuration
490 * @tc.type: FUNC
491 * @tc.require:
492 */
493 HWTEST_F(AVCastControllerTest, GetDuration001, TestSize.Level1)
494 {
495 int32_t duration;
496 EXPECT_EQ(castController_->GetDuration(duration), AVSESSION_ERROR);
497 }
498
499 /**
500 * @tc.name: GetCastAVPlaybackState001
501 * @tc.desc: GetCastAVPlaybackState
502 * @tc.type: FUNC
503 * @tc.require:
504 */
505 HWTEST_F(AVCastControllerTest, GetCastAVPlaybackState001, TestSize.Level1)
506 {
507 AVPlaybackState avPlaybackState;
508 EXPECT_EQ(castController_->GetCastAVPlaybackState(avPlaybackState), AVSESSION_ERROR);
509 }
510
511 /**
512 * @tc.name: GetCurrentItem001
513 * @tc.desc: GetCurrentItem
514 * @tc.type: FUNC
515 * @tc.require:
516 */
517 HWTEST_F(AVCastControllerTest, GetCurrentItem001, TestSize.Level1)
518 {
519 AVQueueItem currentItem;
520 EXPECT_EQ(castController_->GetCurrentItem(currentItem), AVSESSION_SUCCESS);
521 }
522
523 /**
524 * @tc.name: GetValidCommands001
525 * @tc.desc: GetValidCommands
526 * @tc.type: FUNC
527 * @tc.require:
528 */
529 HWTEST_F(AVCastControllerTest, GetValidCommands001, TestSize.Level1)
530 {
531 std::vector<int32_t> cmds;
532 EXPECT_EQ(castController_->GetValidCommands(cmds), AVSESSION_SUCCESS);
533 }
534
535 /**
536 * @tc.name: SetDisplaySurface001
537 * @tc.desc: SetDisplaySurface
538 * @tc.type: FUNC
539 * @tc.require:
540 */
541 HWTEST_F(AVCastControllerTest, SetDisplaySurface001, TestSize.Level1)
542 {
543 std::string surfaceId = "surfaceId";
544 EXPECT_EQ(castController_->SetDisplaySurface(surfaceId), AVSESSION_ERROR);
545 }
546
547 /**
548 * @tc.name: ProcessMediaKeyResponse001
549 * @tc.desc: ProcessMediaKeyResponse
550 * @tc.type: FUNC
551 * @tc.require:
552 */
553 HWTEST_F(AVCastControllerTest, ProcessMediaKeyResponse001, TestSize.Level1)
554 {
555 std::string assetId = "assetId";
556 std::vector<uint8_t> response;
557 EXPECT_EQ(castController_->ProcessMediaKeyResponse(assetId, response), AVSESSION_ERROR);
558 }
559
560 /**
561 * @tc.name: SetCastPlaybackFilter001
562 * @tc.desc: SetCastPlaybackFilter
563 * @tc.type: FUNC
564 * @tc.require:
565 */
566 HWTEST_F(AVCastControllerTest, SetCastPlaybackFilter001, TestSize.Level1)
567 {
568 AVPlaybackState::PlaybackStateMaskType filter;
569 EXPECT_EQ(castController_->SetCastPlaybackFilter(filter), AVSESSION_SUCCESS);
570 }
571
572 /**
573 * @tc.name: AddAvailableCommand001
574 * @tc.desc: AddAvailableCommand
575 * @tc.type: FUNC
576 * @tc.require:
577 */
578 HWTEST_F(AVCastControllerTest, AddAvailableCommand001, TestSize.Level1)
579 {
580 EXPECT_EQ(castController_->AddAvailableCommand(0), AVSESSION_SUCCESS);
581 }
582
583 /**
584 * @tc.name: RemoveAvailableCommand001
585 * @tc.desc: RemoveAvailableCommand
586 * @tc.type: FUNC
587 * @tc.require:
588 */
589 HWTEST_F(AVCastControllerTest, RemoveAvailableCommand001, TestSize.Level1)
590 {
591 EXPECT_EQ(castController_->AddAvailableCommand(0), AVSESSION_SUCCESS);
592 EXPECT_EQ(castController_->RemoveAvailableCommand(0), AVSESSION_SUCCESS);
593 }
594
595 /**
596 * @tc.name: RegisterControllerListener001
597 * @tc.desc: RegisterControllerListener
598 * @tc.type: FUNC
599 * @tc.require:
600 */
601 HWTEST_F(AVCastControllerTest, RegisterControllerListener001, TestSize.Level1)
602 {
603 std::shared_ptr<IAVCastControllerProxy> castControllerProxy = nullptr;
604 EXPECT_EQ(castController_->RegisterControllerListener(castControllerProxy), true);
605 }
606
607 /**
608 * @tc.name: Destroy001
609 * @tc.desc: Destroy
610 * @tc.type: FUNC
611 * @tc.require:
612 */
613 HWTEST_F(AVCastControllerTest, Destroy001, TestSize.Level1)
614 {
615 EXPECT_EQ(castController_->Destroy(), AVSESSION_SUCCESS);
616 }
617
618 /**
619 * @tc.name: OnCastPlaybackStateChange001
620 * @tc.desc: OnCastPlaybackStateChange, no callback
621 * @tc.type: FUNC
622 * @tc.require:
623 */
624 HWTEST_F(AVCastControllerTest, OnCastPlaybackStateChange001, TestSize.Level1)
625 {
626 LOG_SetCallback(MyLogCallback);
627 AVPlaybackState state;
628 castController_->OnCastPlaybackStateChange(state);
629 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
630 }
631
632 /**
633 * @tc.name: OnMediaItemChange001
634 * @tc.desc: OnMediaItemChange, no callback
635 * @tc.type: FUNC
636 * @tc.require:
637 */
638 HWTEST_F(AVCastControllerTest, OnMediaItemChange001, TestSize.Level1)
639 {
640 LOG_SetCallback(MyLogCallback);
641 AVQueueItem avQueueItem;
642 castController_->OnMediaItemChange(avQueueItem);
643 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
644 }
645
646 /**
647 * @tc.name: OnPlayNext001
648 * @tc.desc: OnPlayNext, no callback
649 * @tc.type: FUNC
650 * @tc.require:
651 */
652 HWTEST_F(AVCastControllerTest, OnPlayNext001, TestSize.Level1)
653 {
654 LOG_SetCallback(MyLogCallback);
655 castController_->OnPlayNext();
656 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
657 }
658
659 /**
660 * @tc.name: OnPlayPrevious001
661 * @tc.desc: OnPlayPrevious, no callback
662 * @tc.type: FUNC
663 * @tc.require:
664 */
665 HWTEST_F(AVCastControllerTest, OnPlayPrevious001, TestSize.Level1)
666 {
667 LOG_SetCallback(MyLogCallback);
668 castController_->OnPlayPrevious();
669 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
670 }
671
672 /**
673 * @tc.name: OnSeekDone001
674 * @tc.desc: OnSeekDone, no callback
675 * @tc.type: FUNC
676 * @tc.require:
677 */
678 HWTEST_F(AVCastControllerTest, OnSeekDone001, TestSize.Level1)
679 {
680 LOG_SetCallback(MyLogCallback);
681 int32_t seekNumber = 0;
682 castController_->OnSeekDone(seekNumber);
683 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
684 }
685
686 /**
687 * @tc.name: OnVideoSizeChange001
688 * @tc.desc: OnVideoSizeChange, no callback
689 * @tc.type: FUNC
690 * @tc.require:
691 */
692 HWTEST_F(AVCastControllerTest, OnVideoSizeChange001, TestSize.Level1)
693 {
694 LOG_SetCallback(MyLogCallback);
695 int32_t width = 0;
696 int32_t height = 0;
697 castController_->OnVideoSizeChange(width, height);
698 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
699 }
700
701 /**
702 * @tc.name: OnPlayerError001
703 * @tc.desc: OnPlayerError, no callback
704 * @tc.type: FUNC
705 * @tc.require:
706 */
707 HWTEST_F(AVCastControllerTest, OnPlayerError001, TestSize.Level1)
708 {
709 LOG_SetCallback(MyLogCallback);
710 int32_t errorCode = 0;
711 std::string errorMsg = "errorMsg";
712 castController_->OnPlayerError(errorCode, errorMsg);
713 EXPECT_TRUE(g_errLog.find("xxx") == std::string::npos);
714 }
715
716 /**
717 * @tc.name: StartCastDiscovery001
718 * @tc.desc: StartCastDiscovery
719 * @tc.type: FUNC
720 * @tc.require:
721 */
722 HWTEST_F(AVCastControllerTest, StartCastDiscovery001, TestSize.Level1)
723 {
724 EXPECT_EQ(AVSessionManager::GetInstance().StartCastDiscovery(1, {}), AVSESSION_SUCCESS);
725 }
726
727 /**
728 * @tc.name: StopCastDiscovery001
729 * @tc.desc: StopCastDiscovery
730 * @tc.type: FUNC
731 * @tc.require:
732 */
733 HWTEST_F(AVCastControllerTest, StopCastDiscovery001, TestSize.Level1)
734 {
735 EXPECT_EQ(AVSessionManager::GetInstance().StopCastDiscovery(), AVSESSION_SUCCESS);
736 }
737
738 /**
739 * @tc.name: SetDiscoverable001
740 * @tc.desc: SetDiscoverable
741 * @tc.type: FUNC
742 * @tc.require:
743 */
744 HWTEST_F(AVCastControllerTest, SetDiscoverable001, TestSize.Level1)
745 {
746 EXPECT_EQ(AVSessionManager::GetInstance().SetDiscoverable(true), AVSESSION_SUCCESS);
747 }
748
749 /**
750 * @tc.name: StartCast001
751 * @tc.desc: StartCast
752 * @tc.type: FUNC
753 * @tc.require:
754 */
755 HWTEST_F(AVCastControllerTest, StartCast001, TestSize.Level1)
756 {
757 SessionToken sessionToken;
758 sessionToken.sessionId = avsession_->GetSessionId();
759 OutputDeviceInfo outputDeviceInfo;
760 DeviceInfo deviceInfo;
761 deviceInfo.castCategory_ = 1;
762 deviceInfo.deviceId_ = "deviceId";
763 outputDeviceInfo.deviceInfos_.push_back(deviceInfo);
764 EXPECT_EQ(AVSessionManager::GetInstance().StartCast(sessionToken, outputDeviceInfo), -1007);
765 }
766
767 /**
768 * @tc.name: StopCast001
769 * @tc.desc: StopCast
770 * @tc.type: FUNC
771 * @tc.require:
772 */
773 HWTEST_F(AVCastControllerTest, StopCast001, TestSize.Level1)
774 {
775 SessionToken sessionToken;
776 sessionToken.sessionId = avsession_->GetSessionId();
777 EXPECT_EQ(AVSessionManager::GetInstance().StopCast(sessionToken), AVSESSION_SUCCESS);
778 }
779
780 HWTEST_F(AVCastControllerTest, StartDiscovery001, TestSize.Level1)
781 {
782 HwCastProvider hwCastProvider;
783 std::vector<std::string> drmSchemes;
784 EXPECT_EQ(hwCastProvider.StartDiscovery(2, drmSchemes), true);
785 }
786
787 HWTEST_F(AVCastControllerTest, StopDiscovery001, TestSize.Level1)
788 {
789 HwCastProvider hwCastProvider;
790 hwCastProvider.StopDiscovery();
791 EXPECT_TRUE(true);
792 }
793
794 HWTEST_F(AVCastControllerTest, Release001, TestSize.Level1)
795 {
796 HwCastProvider hwCastProvider;
797 hwCastProvider.Release();
798 EXPECT_TRUE(true);
799 }
800
801 HWTEST_F(AVCastControllerTest, StartCastSession001, TestSize.Level1)
802 {
803 HwCastProvider hwCastProvider;
804 // StartCastSession may fail with -1003
805 int32_t ret = hwCastProvider.StartCastSession();
806 SLOGI("StartCastSession001 with ret %{public}d", ret);
807 EXPECT_TRUE(ret != AVSESSION_SUCCESS);
808 }
809
810 HWTEST_F(AVCastControllerTest, StopCastSession001, TestSize.Level1)
811 {
812 HwCastProvider hwCastProvider;
813 hwCastProvider.StopCastSession(2);
814 EXPECT_TRUE(true);
815 }
816
817 HWTEST_F(AVCastControllerTest, AddCastDevice001, TestSize.Level1)
818 {
819 HwCastProvider hwCastProvider;
820
821 DeviceInfo deviceInfo1;
822 deviceInfo1.castCategory_ = 1;
823 deviceInfo1.deviceId_ = "deviceid1";
824 deviceInfo1.deviceName_ = "devicename1";
825 deviceInfo1.deviceType_ = 1;
826 deviceInfo1.ipAddress_ = "ipAddress1";
827 deviceInfo1.providerId_ = 1;
828 deviceInfo1.supportedProtocols_ = 3;
829 deviceInfo1.authenticationStatus_ = 1;
830 std::vector<std::string> supportedDrmCapabilities;
831 supportedDrmCapabilities.emplace_back("");
832 deviceInfo1.supportedDrmCapabilities_ = supportedDrmCapabilities;
833 deviceInfo1.isLegacy_ = false;
834 deviceInfo1.mediumTypes_ = 2;
835
836 EXPECT_EQ(hwCastProvider.AddCastDevice(1, deviceInfo1), false);
837 }
838
839 HWTEST_F(AVCastControllerTest, RemoveCastDevice001, TestSize.Level1)
840 {
841 HwCastProvider hwCastProvider;
842
843 DeviceInfo deviceInfo1;
844 deviceInfo1.castCategory_ = 1;
845 deviceInfo1.deviceId_ = "deviceid1";
846 deviceInfo1.deviceName_ = "devicename1";
847 deviceInfo1.deviceType_ = 1;
848 deviceInfo1.ipAddress_ = "ipAddress1";
849 deviceInfo1.providerId_ = 1;
850 deviceInfo1.supportedProtocols_ = 1;
851 deviceInfo1.authenticationStatus_ = 0;
852 std::vector<std::string> supportedDrmCapabilities;
853 supportedDrmCapabilities.emplace_back("");
854 deviceInfo1.supportedDrmCapabilities_ = supportedDrmCapabilities;
855 deviceInfo1.isLegacy_ = false;
856 deviceInfo1.mediumTypes_ = 2;
857
858 EXPECT_EQ(hwCastProvider.RemoveCastDevice(1, deviceInfo1), false);
859 }
860
861 HWTEST_F(AVCastControllerTest, RegisterCastStateListener001, TestSize.Level1)
862 {
863 HwCastProvider hwCastProvider;
864
865 EXPECT_EQ(hwCastProvider.RegisterCastStateListener(nullptr), false);
866 }
867
868 HWTEST_F(AVCastControllerTest, UnRegisterCastStateListener001, TestSize.Level1)
869 {
870 HwCastProvider hwCastProvider;
871
872 EXPECT_EQ(hwCastProvider.UnRegisterCastStateListener(nullptr), false);
873 }
874
875 HWTEST_F(AVCastControllerTest, RegisterCastSessionStateListener001, TestSize.Level1)
876 {
877 HwCastProvider hwCastProvider;
878
879 EXPECT_EQ(hwCastProvider.RegisterCastSessionStateListener(2, nullptr), false);
880 }
881
882 HWTEST_F(AVCastControllerTest, UnRegisterCastSessionStateListener001, TestSize.Level1)
883 {
884 HwCastProvider hwCastProvider;
885
886 EXPECT_EQ(hwCastProvider.UnRegisterCastSessionStateListener(2, nullptr), false);
887 }
888
889 /**
890 * @tc.name: OnCastPlaybackStateChange002
891 * @tc.desc: OnCastPlaybackStateChange, no callback
892 * @tc.type: FUNC
893 * @tc.require:
894 */
895 HWTEST_F(AVCastControllerTest, OnCastPlaybackStateChange002, TestSize.Level1)
896 {
897 LOG_SetCallback(MyLogCallback);
898 AVPlaybackState state;
899 state.SetState(AVPlaybackState::PLAYBACK_STATE_PREPARE);
900 castController_->OnCastPlaybackStateChange(state);
901 auto ret = state.GetState();
902 EXPECT_EQ(ret, AVPlaybackState::PLAYBACK_STATE_PREPARE);
903 }
904
905 /**
906 * @tc.name: OnCastPlaybackStateChange003
907 * @tc.desc: OnCastPlaybackStateChange, have reigstered callback
908 * @tc.type: FUNC
909 * @tc.require:
910 */
911 HWTEST_F(AVCastControllerTest, OnCastPlaybackStateChange003, TestSize.Level1)
912 {
913 LOG_SetCallback(MyLogCallback);
914 castController_->callback_ = g_AVCastControllerCallbackProxy;
915 castController_->castControllerProxy_ = std::make_shared<AVCastControllerProxyMock>();
916
917 AVPlaybackState state;
918 state.SetState(AVPlaybackState::PLAYBACK_STATE_PLAY);
919 castController_->OnCastPlaybackStateChange(state);
920 auto ret = state.GetState();
921 EXPECT_EQ(ret, AVPlaybackState::PLAYBACK_STATE_PLAY);
922 }
923
924 /**
925 * @tc.name: OnCastPlaybackStateChange003
926 * @tc.desc: OnCastPlaybackStateChange, have reigstered callback and session callback
927 * @tc.type: FUNC
928 * @tc.require:
929 */
930 HWTEST_F(AVCastControllerTest, OnCastPlaybackStateChange004, TestSize.Level1)
931 {
932 LOG_SetCallback(MyLogCallback);
933 castController_->callback_ = g_AVCastControllerCallbackProxy;
934 castController_->castControllerProxy_ = std::make_shared<AVCastControllerProxyMock>();
__anon3194669e0302(std::string&, bool, bool)935 castController_->sessionCallbackForCastNtf_ = [](std::string&, bool, bool)->void {};
936 AVPlaybackState state;
937 state.SetState(AVPlaybackState::PLAYBACK_STATE_PLAY);
938 castController_->OnCastPlaybackStateChange(state);
939 auto ret = state.GetState();
940 EXPECT_EQ(ret, AVPlaybackState::PLAYBACK_STATE_PLAY);
941 }
942
943 /**
944 * @tc.name: OnMediaItemChange002
945 * @tc.desc: OnMediaItemChange, have reigstered callback
946 * @tc.type: FUNC
947 * @tc.require:
948 */
949 HWTEST_F(AVCastControllerTest, OnMediaItemChange002, TestSize.Level1)
950 {
951 LOG_SetCallback(MyLogCallback);
952 castController_->callback_ = g_AVCastControllerCallbackProxy;
953 AVQueueItem avQueueItem;
954 castController_->OnMediaItemChange(avQueueItem);
955 EXPECT_TRUE(castController_->callback_ != nullptr);
956 }
957
958 /**
959 * @tc.name: OnPlayNext002
960 * @tc.desc: OnPlayNext, have reigstered callback
961 * @tc.type: FUNC
962 * @tc.require:
963 */
964 HWTEST_F(AVCastControllerTest, OnPlayNext002, TestSize.Level1)
965 {
966 LOG_SetCallback(MyLogCallback);
967 castController_->callback_ = g_AVCastControllerCallbackProxy;
968 castController_->OnPlayNext();
969 EXPECT_TRUE(castController_->callback_ != nullptr);
970 }
971
972 /**
973 * @tc.name: OnPlayPrevious002
974 * @tc.desc: OnPlayPrevious, have reigstered callback
975 * @tc.type: FUNC
976 * @tc.require:
977 */
978 HWTEST_F(AVCastControllerTest, OnPlayPrevious002, TestSize.Level1)
979 {
980 LOG_SetCallback(MyLogCallback);
981 castController_->callback_ = g_AVCastControllerCallbackProxy;
982 castController_->OnPlayPrevious();
983 EXPECT_TRUE(castController_->callback_ != nullptr);
984 }
985
986 /**
987 * @tc.name: OnSeekDone002
988 * @tc.desc: OnSeekDone, no callback
989 * @tc.type: FUNC
990 * @tc.require:
991 */
992 HWTEST_F(AVCastControllerTest, OnSeekDone002, TestSize.Level1)
993 {
994 LOG_SetCallback(MyLogCallback);
995 castController_->callback_ = g_AVCastControllerCallbackProxy;
996 int32_t seekNumber = 0;
997 castController_->OnSeekDone(seekNumber);
998 EXPECT_TRUE(castController_->callback_ != nullptr);
999 }
1000
1001 /**
1002 * @tc.name: OnVideoSizeChange002
1003 * @tc.desc: OnVideoSizeChange, have reigstered callback
1004 * @tc.type: FUNC
1005 * @tc.require:
1006 */
1007 HWTEST_F(AVCastControllerTest, OnVideoSizeChange002, TestSize.Level1)
1008 {
1009 LOG_SetCallback(MyLogCallback);
1010 castController_->callback_ = g_AVCastControllerCallbackProxy;
1011 int32_t width = 0;
1012 int32_t height = 0;
1013 castController_->OnVideoSizeChange(width, height);
1014 EXPECT_TRUE(castController_->callback_ != nullptr);
1015 }
1016
1017 /**
1018 * @tc.name: OnPlayerError002
1019 * @tc.desc: OnPlayerError, have reigstered callback
1020 * @tc.type: FUNC
1021 * @tc.require:
1022 */
1023 HWTEST_F(AVCastControllerTest, OnPlayerError002, TestSize.Level1)
1024 {
1025 LOG_SetCallback(MyLogCallback);
1026 castController_->callback_ = g_AVCastControllerCallbackProxy;
1027 int32_t errorCode = 0;
1028 std::string errorMsg = "errorMsg";
1029 castController_->OnPlayerError(errorCode, errorMsg);
1030 EXPECT_TRUE(castController_->callback_ != nullptr);
1031 }
1032
1033 /**
1034 * @tc.name: OnEndOfStream001
1035 * @tc.desc: OnEndOfStream, no callback
1036 * @tc.type: FUNC
1037 * @tc.require:
1038 */
1039 HWTEST_F(AVCastControllerTest, OnEndOfStream001, TestSize.Level1)
1040 {
1041 LOG_SetCallback(MyLogCallback);
1042 castController_->callback_ = nullptr;
1043 int32_t isLooping = true;
1044 castController_->OnEndOfStream(isLooping);
1045 EXPECT_TRUE(castController_->callback_ == nullptr);
1046 }
1047
1048 /**
1049 * @tc.name: OnEndOfStream002
1050 * @tc.desc: OnEndOfStream, have reigstered callback
1051 * @tc.type: FUNC
1052 * @tc.require:
1053 */
1054 HWTEST_F(AVCastControllerTest, OnEndOfStream002, TestSize.Level1)
1055 {
1056 LOG_SetCallback(MyLogCallback);
1057 castController_->callback_ = g_AVCastControllerCallbackProxy;
1058 int32_t isLooping = true;
1059 castController_->OnEndOfStream(isLooping);
1060 EXPECT_TRUE(castController_->callback_ != nullptr);
1061 }
1062
1063 /**
1064 * @tc.name: OnPlayRequest001
1065 * @tc.desc: OnPlayRequest, no callback
1066 * @tc.type: FUNC
1067 * @tc.require:
1068 */
1069 HWTEST_F(AVCastControllerTest, OnPlayRequest001, TestSize.Level1)
1070 {
1071 LOG_SetCallback(MyLogCallback);
1072 castController_->callback_ = nullptr;
1073 AVQueueItem avQueueItem;
1074 castController_->OnPlayRequest(avQueueItem);
1075 EXPECT_TRUE(castController_->callback_ == nullptr);
1076 }
1077
1078 /**
1079 * @tc.name: OnPlayRequest002
1080 * @tc.desc: OnPlayRequest, have reigstered callback
1081 * @tc.type: FUNC
1082 * @tc.require:
1083 */
1084 HWTEST_F(AVCastControllerTest, OnPlayRequest002, TestSize.Level1)
1085 {
1086 LOG_SetCallback(MyLogCallback);
1087 castController_->callback_ = g_AVCastControllerCallbackProxy;
1088 AVQueueItem avQueueItem;
1089 castController_->OnPlayRequest(avQueueItem);
1090 EXPECT_TRUE(castController_->callback_ != nullptr);
1091 }
1092
1093 /**
1094 * @tc.name: OnKeyRequest001
1095 * @tc.desc: OnKeyRequest, no callback
1096 * @tc.type: FUNC
1097 * @tc.require:
1098 */
1099 HWTEST_F(AVCastControllerTest, OnKeyRequest001, TestSize.Level1)
1100 {
1101 LOG_SetCallback(MyLogCallback);
1102 castController_->callback_ = nullptr;
1103 std::string assetId = "test";
1104 std::vector<uint8_t> keyRequestData {};
1105 castController_->OnKeyRequest(assetId, keyRequestData);
1106 EXPECT_TRUE(castController_->callback_ == nullptr);
1107 }
1108
1109 /**
1110 * @tc.name: OnKeyRequest002
1111 * @tc.desc: OnKeyRequest, have reigstered callback
1112 * @tc.type: FUNC
1113 * @tc.require:
1114 */
1115 HWTEST_F(AVCastControllerTest, OnKeyRequest002, TestSize.Level1)
1116 {
1117 LOG_SetCallback(MyLogCallback);
1118 castController_->callback_ = g_AVCastControllerCallbackProxy;
1119 std::string assetId = "test";
1120 std::vector<uint8_t> keyRequestData {};
1121 castController_->OnKeyRequest(assetId, keyRequestData);
1122 EXPECT_TRUE(castController_->callback_ != nullptr);
1123 }
1124
1125 /**
1126 * @tc.name: onDataSrcRead001
1127 * @tc.desc: onDataSrcRead, no callback
1128 * @tc.type: FUNC
1129 * @tc.require:
1130 */
1131 HWTEST_F(AVCastControllerTest, onDataSrcRead001, TestSize.Level1)
1132 {
1133 LOG_SetCallback(MyLogCallback);
1134 castController_->callback_ = nullptr;
1135 std::shared_ptr<AVSharedMemory> mem = nullptr;
1136 uint32_t length = 0;
1137 int64_t pos = 0;
1138 castController_->onDataSrcRead(mem, length, pos);
1139 EXPECT_TRUE(castController_->callback_ == nullptr);
1140 }
1141
1142 /**
1143 * @tc.name: onDataSrcRead002
1144 * @tc.desc: onDataSrcRead, have reigstered callback
1145 * @tc.type: FUNC
1146 * @tc.require:
1147 */
1148 HWTEST_F(AVCastControllerTest, onDataSrcRead002, TestSize.Level1)
1149 {
1150 LOG_SetCallback(MyLogCallback);
1151 castController_->callback_ = g_AVCastControllerCallbackProxy;
1152 std::shared_ptr<AVSharedMemory> mem = nullptr;
1153 uint32_t length = 0;
1154 int64_t pos = 0;
1155 castController_->onDataSrcRead(mem, length, pos);
1156 EXPECT_TRUE(castController_->callback_ != nullptr);
1157 }
1158
1159 } // namespace AVSession
1160 } // namespace OHOS