1fa7767c5Sopenharmony_ci/*
2fa7767c5Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd.
3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License.
5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at
6fa7767c5Sopenharmony_ci *
7fa7767c5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fa7767c5Sopenharmony_ci *
9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and
13fa7767c5Sopenharmony_ci * limitations under the License.
14fa7767c5Sopenharmony_ci */
15fa7767c5Sopenharmony_ci#ifndef OHOS_LITE
16fa7767c5Sopenharmony_ci
17fa7767c5Sopenharmony_ci#include <thread>
18fa7767c5Sopenharmony_ci#include <chrono>
19fa7767c5Sopenharmony_ci#include "helper/test_player.hpp"
20fa7767c5Sopenharmony_ci#include "plugin/common/plugin_types.h"
21fa7767c5Sopenharmony_ci#include "testngpp/testngpp.hpp"
22fa7767c5Sopenharmony_ci
23fa7767c5Sopenharmony_ciusing namespace OHOS::Media::Test;
24fa7767c5Sopenharmony_ci
25fa7767c5Sopenharmony_ci// @fixture(tags=stdstream)
26fa7767c5Sopenharmony_ciFIXTURE(TestStdStreamPlayerFast)
27fa7767c5Sopenharmony_ci{
28fa7767c5Sopenharmony_ci    DATA_PROVIDER(musicUrls, 1,
29fa7767c5Sopenharmony_ci    DATA_GROUP(std::string(RESOURCE_DIR "/MP3/mp3_stream")));
30fa7767c5Sopenharmony_ci
31fa7767c5Sopenharmony_ci    // @test(data="musicUrls")
32fa7767c5Sopenharmony_ci    PTEST((std::string url), Test single player play std stream seekable, and finished automatically)
33fa7767c5Sopenharmony_ci    {
34fa7767c5Sopenharmony_ci        std::unique_ptr<TestPlayer> player = TestPlayer::Create();
35fa7767c5Sopenharmony_ci        auto testsrc = TestSource::CreateTestSource(url, TestSourceType::STREAM,
36fa7767c5Sopenharmony_ci                                                    OHOS::Media::Plugin::Seekable::SEEKABLE);
37fa7767c5Sopenharmony_ci        ASSERT_EQ(0, player->SetSource(testsrc));
38fa7767c5Sopenharmony_ci        ASSERT_EQ(0, player->Prepare());
39fa7767c5Sopenharmony_ci        ASSERT_EQ(0, player->Play());
40fa7767c5Sopenharmony_ci        while (player->IsPlaying()) {
41fa7767c5Sopenharmony_ci            std::this_thread::sleep_for(std::chrono::milliseconds(1000));
42fa7767c5Sopenharmony_ci        }
43fa7767c5Sopenharmony_ci    }
44fa7767c5Sopenharmony_ci
45fa7767c5Sopenharmony_ci    // @test(data="musicUrls")
46fa7767c5Sopenharmony_ci    PTEST((std::string url), Test single player play std stream unseekable, and finished automatically)
47fa7767c5Sopenharmony_ci    {
48fa7767c5Sopenharmony_ci        std::unique_ptr<TestPlayer> player = TestPlayer::Create();
49fa7767c5Sopenharmony_ci        auto testsrc = TestSource::CreateTestSource(url, TestSourceType::STREAM,
50fa7767c5Sopenharmony_ci                                                    OHOS::Media::Plugin::Seekable::UNSEEKABLE);
51fa7767c5Sopenharmony_ci        ASSERT_EQ(0, player->SetSource(testsrc));
52fa7767c5Sopenharmony_ci        ASSERT_EQ(0, player->Prepare());
53fa7767c5Sopenharmony_ci        ASSERT_EQ(0, player->Play());
54fa7767c5Sopenharmony_ci        while (player->IsPlaying()) {
55fa7767c5Sopenharmony_ci            std::this_thread::sleep_for(std::chrono::milliseconds(1000));
56fa7767c5Sopenharmony_ci        }
57fa7767c5Sopenharmony_ci    }
58fa7767c5Sopenharmony_ci};
59fa7767c5Sopenharmony_ci#endif
60