• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 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 #include <chrono>
16 #include <thread>
17 #include "helper/test_player.hpp"
18 #include "testngpp/testngpp.hpp"
19 
20 using namespace OHOS::Media::Test;
21 
22 // Run these http tests, should run hfs.exe and add resource folder to it.
23 
24 // @fixture(tags=audio_play_fast)
FIXTURE(TestPlayerExit)25 FIXTURE(TestPlayerExit)
26 {
27     bool StartPlayer(std::string url)
28     {
29         std::unique_ptr<TestPlayer> player = TestPlayer::Create();
30         ASSERT_EQ(0, player->SetSource(TestSource(url)));
31         ASSERT_EQ(0, player->Prepare());
32         ASSERT_EQ(0, player->Play());
33         while (player->IsPlaying()) {
34             std::this_thread::sleep_for(std::chrono::milliseconds(1000));
35         }
36         return true;
37     }
38 
39     TEST(Test play local source two times)
40     {
41         ASSERT_TRUE(StartPlayer(RESOURCE_DIR "/MP3/MP3_48000_32_SHORT.mp3"));
42         ASSERT_TRUE(StartPlayer(RESOURCE_DIR "/MP3/MP3_48000_32_SHORT.mp3"));
43     }
44 
45     TEST(Test play http non live source two times)
46     {
47         ASSERT_TRUE(StartPlayer("http://localhost/resource-src/media/MP3/MP3_48000_32_SHORT.mp3"));
48         ASSERT_TRUE(StartPlayer("http://localhost/resource-src/media/MP3/MP3_48000_32_SHORT.mp3"));
49     }
50 };