• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "nativetoken_kit.h"
20 #include "token_setproc.h"
21 #include "cast_session_manager.h"
22 #include "avcast_controller_item.h"
23 #include "avsession_errors.h"
24 #include "avsession_log.h"
25 #include "hw_cast_provider.h"
26 #include "hw_cast_stream_player.h"
27 
28 using namespace testing::ext;
29 using namespace OHOS::CastEngine::CastEngineClient;
30 using namespace OHOS::CastEngine;
31 
32 namespace OHOS {
33 namespace AVSession {
34 class HwCastStreamPlayerTest : public testing::TestWithParam<int> {
35 public:
36     static void SetUpTestCase();
37     static void TearDownTestCase();
38     void SetUp() override;
39     void TearDown() override;
40     std::shared_ptr<HwCastProviderSession> hwCastProviderSession = nullptr;
41     std::shared_ptr<HwCastStreamPlayer> hwCastStreamPlayer = nullptr;
42 };
43 
44 class TestCastSessionManagerListener : public ICastSessionManagerListener {
45 public:
OnDeviceFound(const std::vector<CastRemoteDevice> & deviceList)46     void OnDeviceFound(const std::vector<CastRemoteDevice> &deviceList) override
47     {
48         static_cast<void>(deviceList);
49     }
OnSessionCreated(const std::shared_ptr<ICastSession> & castSession)50     void OnSessionCreated(const std::shared_ptr<ICastSession> &castSession) override
51     {
52         static_cast<void>(castSession);
53     }
OnServiceDied()54     void OnServiceDied() override {}
OnDeviceOffline(const std::string & deviceId)55     void OnDeviceOffline(const std::string &deviceId) override
56     {
57         static_cast<void>(deviceId);
58     }
59 };
60 
CreateSession()61 std::shared_ptr<ICastSession> CreateSession()
62 {
63     std::shared_ptr<ICastSession> session;
64     auto listener = std::make_shared<TestCastSessionManagerListener>();
65     CastSessionManager::GetInstance().RegisterListener(listener);
66     CastSessionProperty property = {CastEngine::ProtocolType::CAST_PLUS_STREAM, CastEngine::EndType::CAST_SOURCE};
67     CastSessionManager::GetInstance().CreateCastSession(property, session);
68     return session;
69 }
70 
CreateAVMediaDescription()71 std::shared_ptr<AVMediaDescription> CreateAVMediaDescription()
72 {
73     std::shared_ptr<AVMediaDescription> description = std::make_shared<AVMediaDescription>();
74     description->Reset();
75     description->SetMediaId("123");
76     description->SetTitle("Title");
77     description->SetSubtitle("SubTitle");
78     description->SetDescription("This is music description");
79     description->SetIcon(nullptr);
80     description->SetIconUri("xxxxx");
81     description->SetExtras(nullptr);
82     return description;
83 }
84 
SetUpTestCase()85 void HwCastStreamPlayerTest::SetUpTestCase()
86 {}
87 
TearDownTestCase()88 void HwCastStreamPlayerTest::TearDownTestCase()
89 {}
90 
SetUp()91 void HwCastStreamPlayerTest::SetUp()
92 {
93     constexpr int castPermissionNum = 2;
94     const char *perms[castPermissionNum] = {
95         "ohos.permission.ACCESS_CAST_ENGINE_MIRROR",
96         "ohos.permission.ACCESS_CAST_ENGINE_STREAM",
97     };
98     NativeTokenInfoParams infoInstance = {
99         .dcapsNum = 0,  // Indicates the capsbility list of the sa.
100         .permsNum = castPermissionNum,
101         .aclsNum = 0,   // acls is the list of rights that can be escalated.
102         .dcaps = nullptr,
103         .perms = perms,
104         .acls = nullptr,
105         .processName = "hw_cast_stream_player_test",
106         .aplStr = "system_basic",
107     };
108     uint64_t tokenId = GetAccessTokenId(&infoInstance);
109     SetSelfTokenID(tokenId);
110     Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
111     std::shared_ptr<ICastSession> castSession = CreateSession();
112     hwCastProviderSession = std::make_shared<HwCastProviderSession>(castSession);
113     if (hwCastProviderSession) {
114         hwCastProviderSession->Init();
115     }
116     std::shared_ptr<IStreamPlayer> streamPlayer = hwCastProviderSession->CreateStreamPlayer();
117     hwCastStreamPlayer = std::make_shared<HwCastStreamPlayer>(streamPlayer);
118     if (hwCastStreamPlayer) {
119         hwCastStreamPlayer->Init();
120     }
121 }
122 
TearDown()123 void HwCastStreamPlayerTest::TearDown()
124 {
125     if (hwCastProviderSession) {
126         hwCastProviderSession->Release();
127     }
128     if (hwCastStreamPlayer) {
129         hwCastStreamPlayer->Release();
130     }
131 }
132 
133 INSTANTIATE_TEST_CASE_P(SendControlCommand, HwCastStreamPlayerTest, testing::Values(
134     AVCastControlCommand::CAST_CONTROL_CMD_INVALID,
135     AVCastControlCommand::CAST_CONTROL_CMD_PLAY,
136     AVCastControlCommand::CAST_CONTROL_CMD_PAUSE,
137     AVCastControlCommand::CAST_CONTROL_CMD_STOP,
138     AVCastControlCommand::CAST_CONTROL_CMD_PLAY_NEXT,
139     AVCastControlCommand::CAST_CONTROL_CMD_PLAY_PREVIOUS,
140     AVCastControlCommand::CAST_CONTROL_CMD_FAST_FORWARD,
141     AVCastControlCommand::CAST_CONTROL_CMD_REWIND,
142     AVCastControlCommand::CAST_CONTROL_CMD_SEEK,
143     AVCastControlCommand::CAST_CONTROL_CMD_SET_VOLUME,
144     AVCastControlCommand::CAST_CONTROL_CMD_SET_SPEED,
145     AVCastControlCommand::CAST_CONTROL_CMD_SET_LOOP_MODE,
146     AVCastControlCommand::CAST_CONTROL_CMD_TOGGLE_FAVORITE,
147     AVCastControlCommand::CAST_CONTROL_CMD_MAX
148 ));
149 
150 /**
151  * @tc.name: SendControlCommand001
152  * @tc.desc: SendControlCommand all test
153  * @tc.type: FUNC
154  * @tc.require: NA
155  */
156 HWTEST_P(HwCastStreamPlayerTest, SendControlCommand001, TestSize.Level1)
157 {
158     SLOGI("SendControlCommand001 begin!");
159     AVCastControlCommand command;
160     int32_t cmd = GetParam();
161     if (cmd == AVCastControlCommand::CAST_CONTROL_CMD_INVALID || cmd == AVCastControlCommand::CAST_CONTROL_CMD_MAX) {
162         ASSERT_EQ(command.SetCommand(cmd), ERR_INVALID_PARAM);
163     } else {
164         ASSERT_EQ(command.SetCommand(cmd), AVSESSION_SUCCESS);
165     }
166     hwCastStreamPlayer->SendControlCommand(command);
167     SLOGI("SendControlCommand001 end!");
168 }
169 
170 /**
171  * @tc.name: Start001
172  * @tc.desc: start no media id and fd src
173  * @tc.type: FUNC
174  * @tc.require: NA
175  */
176 HWTEST_F(HwCastStreamPlayerTest, Start001, TestSize.Level1)
177 {
178     SLOGI("Start001 begin!");
179     std::shared_ptr<AVMediaDescription> description = CreateAVMediaDescription();
180     description->SetMediaUri("");
181     AVQueueItem avQueueItem;
182     avQueueItem.SetDescription(description);
183     auto ret = hwCastStreamPlayer->Start(avQueueItem);
184     ASSERT_EQ(ret, AVSESSION_SUCCESS);
185     SLOGI("Start001 end!");
186 }
187 
188 /**
189  * @tc.name: Start002
190  * @tc.desc: start with fd src
191  * @tc.type: FUNC
192  * @tc.require: NA
193  */
194 HWTEST_F(HwCastStreamPlayerTest, Start002, TestSize.Level1)
195 {
196     SLOGI("Start002 begin!");
197     std::shared_ptr<AVMediaDescription> description = CreateAVMediaDescription();
198     description->SetMediaUri("");
199     AVFileDescriptor avFileDescriptor;
200     avFileDescriptor.fd_ = 100;
201     description->SetFdSrc(avFileDescriptor);
202     AVQueueItem avQueueItem;
203     avQueueItem.SetDescription(description);
204     auto ret = hwCastStreamPlayer->Start(avQueueItem);
205     ASSERT_EQ(ret, AVSESSION_ERROR);
206     SLOGI("Start002 end!");
207 }
208 
209 /**
210  * @tc.name: Start003
211  * @tc.desc: start same media
212  * @tc.type: FUNC
213  * @tc.require: NA
214  */
215 HWTEST_F(HwCastStreamPlayerTest, Start003, TestSize.Level1)
216 {
217     SLOGI("Start003 begin!");
218     std::shared_ptr<AVMediaDescription> description = CreateAVMediaDescription();
219     description->SetMediaUri("Media url");
220     AVQueueItem avQueueItem;
221     avQueueItem.SetDescription(description);
222     auto ret = hwCastStreamPlayer->Start(avQueueItem);
223     ASSERT_EQ(ret, AVSESSION_SUCCESS);
224     hwCastStreamPlayer->Start(avQueueItem);
225     SLOGI("Start003 end!");
226 }
227 
228 /**
229  * @tc.name: Prepare001
230  * @tc.desc: prepare no media id and fd src
231  * @tc.type: FUNC
232  * @tc.require: NA
233  */
234 HWTEST_F(HwCastStreamPlayerTest, Prepare001, TestSize.Level1)
235 {
236     SLOGI("Prepare001 begin!");
237     std::shared_ptr<AVMediaDescription> description = CreateAVMediaDescription();
238     description->SetMediaUri("");
239     AVQueueItem avQueueItem;
240     avQueueItem.SetDescription(description);
241     auto ret = hwCastStreamPlayer->Start(avQueueItem);
242     ASSERT_EQ(ret, AVSESSION_SUCCESS);
243     ret = hwCastStreamPlayer->Prepare(avQueueItem);
244     ASSERT_EQ(ret, AVSESSION_SUCCESS);
245     SLOGI("Prepare001 end!");
246 }
247 
248 /**
249  * @tc.name: Prepare002
250  * @tc.desc: prepare with fd src
251  * @tc.type: FUNC
252  * @tc.require: NA
253  */
254 HWTEST_F(HwCastStreamPlayerTest, Prepare002, TestSize.Level1)
255 {
256     SLOGI("Prepare002 begin!");
257     std::shared_ptr<AVMediaDescription> description = CreateAVMediaDescription();
258     description->SetMediaUri("");
259     AVFileDescriptor avFileDescriptor;
260     avFileDescriptor.fd_ = 100;
261     description->SetFdSrc(avFileDescriptor);
262     AVQueueItem avQueueItem;
263     avQueueItem.SetDescription(description);
264     auto ret = hwCastStreamPlayer->Start(avQueueItem);
265     ASSERT_EQ(ret, AVSESSION_ERROR);
266     ret = hwCastStreamPlayer->Prepare(avQueueItem);
267     ASSERT_EQ(ret, AVSESSION_ERROR);
268     SLOGI("Prepare002 end!");
269 }
270 
271 /**
272  * @tc.name: GetDuration001
273  * @tc.desc: GetDuration
274  * @tc.type: FUNC
275  * @tc.require: NA
276  */
277 HWTEST_F(HwCastStreamPlayerTest, GetDuration001, TestSize.Level1)
278 {
279     SLOGI("GetDuration001 begin!");
280     int32_t duration = 40000;
281     ASSERT_EQ(hwCastStreamPlayer->GetDuration(duration), AVSESSION_SUCCESS);
282     SLOGI("GetDuration001 end!");
283 }
284 
285 /**
286  * @tc.name: GetCastAVPlaybackState001
287  * @tc.desc: GetCastAVPlaybackState
288  * @tc.type: FUNC
289  * @tc.require: NA
290  */
291 HWTEST_F(HwCastStreamPlayerTest, GetCastAVPlaybackState001, TestSize.Level1)
292 {
293     SLOGI("GetCastAVPlaybackState001 begin!");
294     AVPlaybackState state;
295     ASSERT_EQ(hwCastStreamPlayer->GetCastAVPlaybackState(state), AVSESSION_SUCCESS);
296     SLOGI("GetCastAVPlaybackState001 end!");
297 }
298 
299 /**
300  * @tc.name: SetDisplaySurface001
301  * @tc.desc: SetDisplaySurface
302  * @tc.type: FUNC
303  * @tc.require: NA
304  */
305 HWTEST_F(HwCastStreamPlayerTest, SetDisplaySurface001, TestSize.Level1)
306 {
307     SLOGI("SetDisplaySurface001 begin!");
308     std::string surfaceId = "surfaceId";
309     ASSERT_EQ(hwCastStreamPlayer->SetDisplaySurface(surfaceId), AVSESSION_SUCCESS);
310     SLOGI("SetDisplaySurface001 end!");
311 }
312 
313 /**
314  * @tc.name: RegisterControllerListener001
315  * @tc.desc: RegisterControllerListener invalid listener
316  * @tc.type: FUNC
317  * @tc.require: NA
318  */
319 HWTEST_F(HwCastStreamPlayerTest, RegisterControllerListener001, TestSize.Level1)
320 {
321     SLOGI("RegisterControllerListener001 begin!");
322     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(nullptr), AVSESSION_ERROR);
323     SLOGI("RegisterControllerListener001 end!");
324 }
325 
326 /**
327  * @tc.name: RegisterControllerListener002
328  * @tc.desc: RegisterControllerListener repeat
329  * @tc.type: FUNC
330  * @tc.require: NA
331  */
332 HWTEST_F(HwCastStreamPlayerTest, RegisterControllerListener002, TestSize.Level1)
333 {
334     SLOGI("RegisterControllerListener002 begin!");
335     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
336     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
337     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_ERROR);
338     SLOGI("RegisterControllerListener002 end!");
339 }
340 
341 /**
342  * @tc.name: UnRegisterControllerListener001
343  * @tc.desc: UnRegisterControllerListener invalid listener
344  * @tc.type: FUNC
345  * @tc.require: NA
346  */
347 HWTEST_F(HwCastStreamPlayerTest, UnRegisterControllerListener001, TestSize.Level1)
348 {
349     SLOGI("UnRegisterControllerListener001 begin!");
350     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(nullptr), AVSESSION_ERROR);
351     SLOGI("UnRegisterControllerListener001 end!");
352 }
353 
354 /**
355  * @tc.name: UnRegisterControllerListener002
356  * @tc.desc: UnRegisterControllerListener success
357  * @tc.type: FUNC
358  * @tc.require: NA
359  */
360 HWTEST_F(HwCastStreamPlayerTest, UnRegisterControllerListener002, TestSize.Level1)
361 {
362     SLOGI("UnRegisterControllerListener002 begin!");
363     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
364     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
365     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
366     SLOGI("UnRegisterControllerListener002 end!");
367 }
368 
369 /**
370  * @tc.name: UnRegisterControllerListener003
371  * @tc.desc: UnRegisterControllerListener failed
372  * @tc.type: FUNC
373  * @tc.require: NA
374  */
375 HWTEST_F(HwCastStreamPlayerTest, UnRegisterControllerListener003, TestSize.Level1)
376 {
377     SLOGI("UnRegisterControllerListener003 begin!");
378     std::shared_ptr<AVCastControllerItem> avCastControllerItem1 = std::make_shared<AVCastControllerItem>();
379     std::shared_ptr<AVCastControllerItem> avCastControllerItem2 = std::make_shared<AVCastControllerItem>();
380     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem1), AVSESSION_SUCCESS);
381     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem2), AVSESSION_ERROR);
382     SLOGI("UnRegisterControllerListener003 end!");
383 }
384 
385 /**
386  * @tc.name: OnStateChanged001
387  * @tc.desc: OnStateChanged
388  * @tc.type: FUNC
389  * @tc.require: NA
390  */
391 HWTEST_F(HwCastStreamPlayerTest, OnStateChanged001, TestSize.Level1)
392 {
393     SLOGI("OnStateChanged001 begin!");
394     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
395     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
396     hwCastStreamPlayer->OnStateChanged(CastEngine::PlayerStates::PLAYER_INITIALIZED, true);
397     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
398     SLOGI("OnStateChanged001 end!");
399 }
400 
401 /**
402  * @tc.name: OnPositionChanged001
403  * @tc.desc: OnPositionChanged invalid
404  * @tc.type: FUNC
405  * @tc.require: NA
406  */
407 HWTEST_F(HwCastStreamPlayerTest, OnPositionChanged001, TestSize.Level1)
408 {
409     SLOGI("OnPositionChanged001 begin!");
410     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
411     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
412     hwCastStreamPlayer->OnPositionChanged(-1, -1, -1);
413     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
414     SLOGI("OnPositionChanged001 end!");
415 }
416 
417 /**
418  * @tc.name: OnPositionChanged002
419  * @tc.desc: OnPositionChanged
420  * @tc.type: FUNC
421  * @tc.require: NA
422  */
423 HWTEST_F(HwCastStreamPlayerTest, OnPositionChanged002, TestSize.Level1)
424 {
425     SLOGI("OnPositionChanged002 begin!");
426     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
427     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
428     hwCastStreamPlayer->OnPositionChanged(0, 0, 10);
429     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
430     SLOGI("OnPositionChanged002 end!");
431 }
432 
433 /**
434  * @tc.name: OnMediaItemChanged001
435  * @tc.desc: OnMediaItemChanged
436  * @tc.type: FUNC
437  * @tc.require: NA
438  */
439 HWTEST_F(HwCastStreamPlayerTest, OnMediaItemChanged001, TestSize.Level1)
440 {
441     SLOGI("OnMediaItemChanged001 begin!");
442     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
443     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
444     CastEngine::MediaInfo mediaInfo;
445     hwCastStreamPlayer->OnMediaItemChanged(mediaInfo);
446     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
447     SLOGI("OnMediaItemChanged001 end!");
448 }
449 
450 /**
451  * @tc.name: OnNextRequest001
452  * @tc.desc: OnNextRequest
453  * @tc.type: FUNC
454  * @tc.require: NA
455  */
456 HWTEST_F(HwCastStreamPlayerTest, OnNextRequest001, TestSize.Level1)
457 {
458     SLOGI("OnNextRequest001 begin!");
459     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
460     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
461     hwCastStreamPlayer->OnNextRequest();
462     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
463     SLOGI("OnNextRequest001 end!");
464 }
465 
466 /**
467  * @tc.name: OnPreviousRequest001
468  * @tc.desc: OnPreviousRequest
469  * @tc.type: FUNC
470  * @tc.require: NA
471  */
472 HWTEST_F(HwCastStreamPlayerTest, OnPreviousRequest001, TestSize.Level1)
473 {
474     SLOGI("OnPreviousRequest001 begin!");
475     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
476     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
477     hwCastStreamPlayer->OnPreviousRequest();
478     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
479     SLOGI("OnPreviousRequest001 end!");
480 }
481 
482 /**
483  * @tc.name: OnVolumeChanged001
484  * @tc.desc: OnVolumeChanged
485  * @tc.type: FUNC
486  * @tc.require: NA
487  */
488 HWTEST_F(HwCastStreamPlayerTest, OnVolumeChanged001, TestSize.Level1)
489 {
490     SLOGI("OnVolumeChanged001 begin!");
491     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
492     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
493     hwCastStreamPlayer->OnVolumeChanged(5, 15);
494     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
495     SLOGI("OnVolumeChanged001 end!");
496 }
497 
498 /**
499  * @tc.name: OnLoopModeChanged001
500  * @tc.desc: OnLoopModeChanged
501  * @tc.type: FUNC
502  * @tc.require: NA
503  */
504 HWTEST_F(HwCastStreamPlayerTest, OnLoopModeChanged001, TestSize.Level1)
505 {
506     SLOGI("OnLoopModeChanged001 begin!");
507     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
508     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
509     hwCastStreamPlayer->OnLoopModeChanged(CastEngine::LoopMode::LOOP_MODE_SINGLE);
510     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
511     SLOGI("OnLoopModeChanged001 end!");
512 }
513 
514 /**
515  * @tc.name: OnPlaySpeedChanged001
516  * @tc.desc: OnPlaySpeedChanged
517  * @tc.type: FUNC
518  * @tc.require: NA
519  */
520 HWTEST_F(HwCastStreamPlayerTest, OnPlaySpeedChanged001, TestSize.Level1)
521 {
522     SLOGI("OnPlaySpeedChanged001 begin!");
523     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
524     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
525     hwCastStreamPlayer->OnPlaySpeedChanged(CastEngine::PlaybackSpeed::SPEED_FORWARD_2_00_X);
526     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
527     SLOGI("OnPlaySpeedChanged001 end!");
528 }
529 
530 /**
531  * @tc.name: OnPlayerError001
532  * @tc.desc: OnPlayerError
533  * @tc.type: FUNC
534  * @tc.require: NA
535  */
536 HWTEST_F(HwCastStreamPlayerTest, OnPlayerError001, TestSize.Level1)
537 {
538     SLOGI("OnPlayerError001 begin!");
539     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
540     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
541     hwCastStreamPlayer->OnPlayerError(10003, "PLAYER_ERROR");
542     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
543     SLOGI("OnPlayerError001 end!");
544 }
545 
546 /**
547  * @tc.name: OnSeekDone001
548  * @tc.desc: OnSeekDone
549  * @tc.type: FUNC
550  * @tc.require: NA
551  */
552 HWTEST_F(HwCastStreamPlayerTest, OnSeekDone001, TestSize.Level1)
553 {
554     SLOGI("OnSeekDone001 begin!");
555     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
556     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
557     int32_t seekNumber = 0;
558     hwCastStreamPlayer->OnSeekDone(seekNumber);
559     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
560     SLOGI("OnSeekDone001 end!");
561 }
562 
563 /**
564  * @tc.name: OnVideoSizeChanged001
565  * @tc.desc: OnVideoSizeChanged
566  * @tc.type: FUNC
567  * @tc.require: NA
568  */
569 HWTEST_F(HwCastStreamPlayerTest, OnVideoSizeChanged001, TestSize.Level1)
570 {
571     SLOGI("OnVideoSizeChanged001 begin!");
572     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
573     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
574     hwCastStreamPlayer->OnVideoSizeChanged(0, 0);
575     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
576     SLOGI("OnVideoSizeChanged001 end!");
577 }
578 
579 /**
580  * @tc.name: OnEndOfStream001
581  * @tc.desc: OnEndOfStream
582  * @tc.type: FUNC
583  * @tc.require: NA
584  */
585 HWTEST_F(HwCastStreamPlayerTest, OnEndOfStream001, TestSize.Level1)
586 {
587     SLOGI("OnEndOfStream001 begin!");
588     std::shared_ptr<AVCastControllerItem> avCastControllerItem = std::make_shared<AVCastControllerItem>();
589     ASSERT_EQ(hwCastStreamPlayer->RegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
590     hwCastStreamPlayer->OnEndOfStream(0);
591     ASSERT_EQ(hwCastStreamPlayer->UnRegisterControllerListener(avCastControllerItem), AVSESSION_SUCCESS);
592     SLOGI("OnEndOfStream001 end!");
593 }
594 } // namespace AVSession
595 } // namespace OHOS
596