提交 22afadd2 编写于 作者: O openharmony_ci 提交者: Gitee

!442 sync code from OHOS_STD

Merge pull request !442 from sharpshooter/sync_code
......@@ -17,8 +17,10 @@ group("multimedia") {
testonly = true
if (is_standard_system) {
deps = [
"audio/audio_js_standard/audioPlayer:audio_player_js_hap" ,
"audio/audio_js_standard/audioPlayer_API:audio_player_api_js_hap"]
"audio/audio_js_standard/audioPlayer:audio_player_js_hap" ,
"audio/audio_js_standard/audioPlayer_API:audio_player_api_js_hap",
"media/media_cpp_test_standard:ActsMediaCppStandardTest",
]
} else {
deps = [
#"audio/audio_hap_test:MediaAudio_test_hap",
......
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
module_output_path = "hit/ActsMediaCppStandardTest"
###############################################################################
config("media_cpp_config") {
visibility = [ ":*" ]
include_dirs = [
"include",
"//multimedia/media_standard/frameworks/innerkitsimpl/native/player/include",
]
}
ohos_moduletest_suite("ActsMediaCppStandardTest") {
module_out_path = module_output_path
sources = [
"recorder/src/fuction/ActsVideoRecorderTest.cpp",
"recorder/src/fuction/ActsAudioRecoederTest.cpp",
"player/Testplayer.cpp",
"player/src/function/ActsPlayerFuncTest.cpp",
"player/src/function/ActsPlayerFuncAsyncTest.cpp",
"player/src/function/ActsPlayerStateTest.cpp",
"player/src/function/ActsPlayerStateAsyncTest.cpp",
"player/src/api/01.SetSource.cpp",
"player/src/api/02.Prepare.cpp",
"player/src/api/03.Play.cpp",
"player/src/api/04.Pause.cpp",
"player/src/api/05.Stop.cpp",
"player/src/api/06.Reset.cpp",
"player/src/api/07.Seek.cpp",
"player/src/api/08.SetVolume.cpp",
"player/src/api/09.SetLooping.cpp",
"player/src/api/10.SetPlaybackSpeed.cpp",
"player/src/api/11.PrepareAsync.cpp",
"player/src/api/12.GetCurrentTime.cpp",
]
include_dirs = [
"include",
"player/include",
"recorder/include",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
]
cflags = [
"-Wall"
]
cflags_cc = cflags
deps = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
"//foundation/graphic/standard:libwms_client",
"//third_party/googletest:gtest_main",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
external_deps = [
"ipc:ipc_core",
"multimedia_media_standard:media_client",
]
configs = [ ":media_cpp_config" ]
}
{
"kits": [
{
"push": [
"ActsMediaCppStandardTest->/data/local/tmp/ActsMediaCppStandardTest"
],
"type": "PushKit",
"post-push": [
"chmod -R 777 /data/local/tmp/*"
]
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "ActsMediaCppStandardTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for ActsMediaCppStandardTest Tests"
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "media_log.h"
#define MEDIA_DEBUG_LOG(fmt, ...) \
do { \
printf(fmt, ##__VA_ARGS__); \
printf("\n"); \
__MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Debug, fmt, ##__VA_ARGS__); \
} while (0) \
#define MEDIA_INFO_LOG(fmt, ...) \
do { \
printf(fmt, ##__VA_ARGS__); \
printf("\n"); \
__MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Info, fmt, ##__VA_ARGS__); \
} while (0) \
#define MEDIA_ERROR_LOG(fmt, ...) \
do { \
printf(fmt, ##__VA_ARGS__); \
printf("\n"); \
__MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Error, fmt, ##__VA_ARGS__); \
} while (0) \
namespace {
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "MediaTest"};
}
namespace MediaTest {
constexpr int SURFACE_QUEUE_SIZE = 5;
const float VOLUME = 0.5f;
const int FIRST_ARG_IDX = 1;
const int SECOND_ARG_IDX = 2;
const int THIRD_ARG = 3;
const int HEIGHT = 720;
const int WIDTH = 1280;
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Testplayer.h"
#include "parameter.h"
using namespace OHOS;
using namespace OHOS::Media;
using namespace PlayerNameSpace;
namespace PlayerNameSpace {
std::string GetUri()
{
char path[256] = "/data/1.mp4";
GetParameter("sys.media.test.stream.path", "/data/1.mp4", &path[0], 256);
MEDIA_INFO_LOG("PATH : %s", path);
return path;
}
}
TestPlayer::TestPlayer(PlayerSignal *test)
: test_(test)
{
}
TestPlayer::~TestPlayer()
{
}
bool TestPlayer::CreatePlayer()
{
player = PlayerFactory::CreatePlayer();
if (player == nullptr) {
return false;
}
return true;
}
int32_t TestPlayer::SetSource(const std::string &uri)
{
return player->SetSource(uri);
}
int32_t TestPlayer::Play()
{
int32_t ret = player->Play();
if (test_->mutexFlag_ == true && test_->state_ != PLAYER_STARTED) {
std::unique_lock<std::mutex> lockPlay(test_->mutexPlay_);
test_->condVarPlay_.wait_for(lockPlay, std::chrono::seconds(WAITSECOND));
if (test_->state_ != PLAYER_STARTED) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::Prepare()
{
int32_t ret = player->Prepare();
if (test_->mutexFlag_ == true && test_->state_ != PLAYER_PREPARED) {
std::unique_lock<std::mutex> lockPrepare(test_->mutexPrepare_);
test_->condVarPrepare_.wait_for(lockPrepare, std::chrono::seconds(WAITSECOND));
if (test_->state_ != PLAYER_PREPARED) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::PrepareAsync()
{
int32_t ret = player->PrepareAsync();
if (test_->mutexFlag_ == true && test_->state_ != PLAYER_PREPARED) {
std::unique_lock<std::mutex> lockPrepare(test_->mutexPrepare_);
test_->condVarPrepare_.wait_for(lockPrepare, std::chrono::seconds(WAITSECOND));
if (test_->state_ != PLAYER_PREPARED) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::Pause()
{
int32_t ret = player->Pause();
if (test_->mutexFlag_ == true && test_->state_ != PLAYER_PAUSED) {
std::unique_lock<std::mutex> lockPause(test_->mutexPause_);
test_->condVarPause_.wait_for(lockPause, std::chrono::seconds(WAITSECOND));
if (test_->state_ != PLAYER_PAUSED) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::Stop()
{
int32_t ret = player->Stop();
if (test_->mutexFlag_ == true && test_->state_ != PLAYER_STOPPED) {
std::unique_lock<std::mutex> lockStop(test_->mutexStop_);
test_->condVarStop_.wait_for(lockStop, std::chrono::seconds(WAITSECOND));
if (test_->state_ != PLAYER_STOPPED) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::Reset()
{
int32_t ret = player->Reset();
if (test_->mutexFlag_ == true && test_->state_ != PLAYER_IDLE) {
std::unique_lock<std::mutex> lockReset(test_->mutexReset_);
test_->condVarReset_.wait_for(lockReset, std::chrono::seconds(WAITSECOND));
if (test_->state_ != PLAYER_IDLE) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::Release()
{
return player->Release();
}
int32_t TestPlayer::SetVolume(float leftVolume, float rightVolume)
{
return player->SetVolume(leftVolume, rightVolume);
}
int32_t TestPlayer::Seek(int32_t mseconds, PlayerSeekMode mode)
{
test_->seekDoneFlag_ = false;
test_->seekPositon_ = mseconds;
int32_t ret = player->Seek(mseconds, mode);
if (test_->mutexFlag_ == true && test_->seekDoneFlag_ == false) {
std::unique_lock<std::mutex> lockSeek(test_->mutexSeek_);
test_->condVarSeek_.wait_for(lockSeek, std::chrono::seconds(WAITSECOND));
if (test_->seekDoneFlag_ != true) {
return -1;
}
}
return ret;
}
int32_t TestPlayer::GetCurrentTime(int32_t &currentTime)
{
return player->GetCurrentTime(currentTime);
}
int32_t TestPlayer::GetDuration(int32_t &duration)
{
return player->GetDuration(duration);
}
int32_t TestPlayer::SetPlaybackSpeed(PlaybackRateMode mode)
{
return player->SetPlaybackSpeed(mode);
}
int32_t TestPlayer::GetPlaybackSpeed(PlaybackRateMode &mode)
{
return player->GetPlaybackSpeed(mode);
}
sptr<Surface> TestPlayer::GetVideoSurface(WindowConfig sub_config)
{
char surface[256] = "null";
GetParameter("sys.media.test.surface", "null", &surface[0], 256);
mwindow = WindowManager::GetInstance()->CreateWindow(&g_config);
if (mwindow == nullptr) {
MEDIA_ERROR_LOG("Create mwindow failed!!!");
return nullptr;
}
sptr<Surface> videoSurface = nullptr;
if (strcmp(surface, "null") == 0) {
return videoSurface;
}
if (strcmp(surface, "subwindow") == 0) {
InitSubWindow(sub_config);
videoSurface = window->GetSurface();
} else if (strcmp(surface, "window") == 0) {
videoSurface = mwindow->GetSurface();
videoSurface->SetUserData(SURFACE_FORMAT, std::to_string(PIXEL_FMT_RGBA_8888));
std::string format = videoSurface->GetUserData(SURFACE_FORMAT);
MEDIA_INFO_LOG("SetUserData SURFACE_FORMAT = %s", format.c_str());
}
return videoSurface;
}
int32_t TestPlayer::SetVideoSurface(const sptr<Surface> surface)
{
char parameter[256] = "null";
GetParameter("sys.media.test.surface", "null", &parameter[0], 256);
if (strcmp(parameter, "null") == 0) {
MEDIA_INFO_LOG("sys.media.test.surface null");
return 0;
}
return player->SetVideoSurface(surface);
}
bool TestPlayer::IsPlaying()
{
return player->IsPlaying();
}
bool TestPlayer::IsLooping()
{
return player->IsLooping();
}
int32_t TestPlayer::SetLooping(bool loop)
{
return player->SetLooping(loop);
}
int32_t TestPlayer::SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback)
{
return player->SetPlayerCallback(callback);
}
void TestPlayer::InitSubWindow(WindowConfig sub_config)
{
sptr<SurfaceBuffer> buffer;
BufferRequestConfig requestConfig;
int32_t releaseFence;
mwindow->GetRequestConfig(requestConfig);
(void)mwindow->GetSurface()->RequestBuffer(buffer, releaseFence, requestConfig);
uint32_t buffSize = buffer->GetSize();
void *bufferVirAddr = buffer->GetVirAddr();
(void)memset_s(bufferVirAddr, buffSize, 0, buffSize);
BufferFlushConfig flushConfig = {
.damage = {
.x = 0,
.y = 0,
.w = requestConfig.width,
.h = requestConfig.height,
},
.timestamp = 0,
};
if (mwindow->GetSurface()->FlushBuffer(buffer, -1, flushConfig) != 0) {
MEDIA_ERROR_LOG("FlushBuffer failed");
}
window = WindowManager::GetInstance()->CreateSubWindow(mwindow->GetWindowID(), &sub_config);
ASSERT_NE(nullptr, window);
if (window == nullptr) {
MEDIA_ERROR_LOG("Create window failed!!!");
return;
}
return;
}
TestPlayerCallback::TestPlayerCallback(PlayerSignal *test)
: test_(test)
{
}
TestPlayerCallback::~TestPlayerCallback()
{
}
void TestPlayerCallback::OnError(PlayerErrorType errorType, int32_t errorCode)
{
errorNum++;
errorType_ = errorType;
errorCode_ = errorCode;
MEDIA_INFO_LOG("TestPlayerCallback: OnError errorType is %d, errorCode is %d", errorType_, errorCode_);
}
void TestPlayerCallback::OnInfo(PlayerOnInfoType type, int32_t extra, const Format &InfoBody)
{
switch (type) {
case INFO_TYPE_SEEKDONE:
seekDoneFlag = true;
test_->SetSeekResult(true);
MEDIA_INFO_LOG("TestPlayerCallback: OnSeekDone currentPositon is %d", extra);
if (abs(test_->seekPositon_ - extra) <= DELTA_TIME) {
test_->condVarSeek_.notify_all();
} else {
test_->SetSeekResult(false);
}
break;
case INFO_TYPE_EOS:
MEDIA_INFO_LOG("TestPlayerCallback: OnEndOfStream isLooping is %d", extra);
break;
case INFO_TYPE_STATE_CHANGE:
state_ = static_cast<PlayerStates>(extra);
test_->SetState(state_);
PrintState(state_);
break;
case INFO_TYPE_POSITION_UPDATE:
postion_ = extra;
break;
case INFO_TYPE_MESSAGE:
MEDIA_INFO_LOG("TestPlayerCallback: OnMessage type is %d", extra);
break;
default:
break;
}
}
int TestPlayerCallback::WaitForSeekDone(int32_t currentPositon)
{
int64_t waitTime = 0;
seekDoneFlag = false;
while (seekDoneFlag != true && waitTime < WAITSECOND * 1000) {
usleep(1000);
waitTime += 1;
}
seekDoneFlag = false;
if (waitTime >= WAITSECOND * 1000) {
MEDIA_INFO_LOG("Failed to seek [%d]s ", currentPositon);
return -1;
}
return 0;
}
int TestPlayerCallback::WaitForState(PlayerStates state)
{
int64_t waitTime = 0;
while (state_ != state && waitTime < WAITSECOND * 1000) {
usleep(1000);
waitTime += 1;
}
if (waitTime >= WAITSECOND * 1000) {
MEDIA_INFO_LOG("Failed to wait for state[%d] down", state);
return -1;
}
return 0;
}
void TestPlayerCallback::PrintState(PlayerStates state)
{
switch (state) {
case PLAYER_STATE_ERROR:
MEDIA_INFO_LOG("State: Error");
break;
case PLAYER_IDLE:
MEDIA_INFO_LOG("State: IDLE");
test_->condVarReset_.notify_all();
break;
case PLAYER_INITIALIZED:
MEDIA_INFO_LOG("State: Initialized");
break;
case PLAYER_PREPARING:
MEDIA_INFO_LOG("State: Preparing");
break;
case PLAYER_PREPARED:
MEDIA_INFO_LOG("State: Prepared");
test_->condVarPrepare_.notify_all();
break;
case PLAYER_STARTED:
MEDIA_INFO_LOG("State: Started");
test_->condVarPlay_.notify_all();
break;
case PLAYER_PAUSED:
MEDIA_INFO_LOG("State: Paused");
test_->condVarPause_.notify_all();
break;
case PLAYER_STOPPED:
MEDIA_INFO_LOG("State: Stopped");
test_->condVarStop_.notify_all();
break;
case PLAYER_PLAYBACK_COMPLETE:
MEDIA_INFO_LOG("State: Complete");
break;
default:
MEDIA_INFO_LOG("Invalid state");
break;
}
}
void PlayerSignal::SetState(PlayerStates state)
{
state_ = state;
}
void PlayerSignal::SetSeekResult(bool seekDoneFlag)
{
seekDoneFlag_ = seekDoneFlag;
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PLAYER_API_TEST_H
#define PLAYER_API_TEST_H
#include "Testplayer.h"
namespace OHOS {
namespace Media {
class ActsPlayerAPITest : public testing::Test {
public:
// SetUpTestCase: before all testcasee
static void SetUpTestCase(void)
{
MEDIA_INFO_LOG("ActsPlayerAPITest::SetUpTestCase");
};
// TearDownTestCase: after all testcase
static void TearDownTestCase(void)
{
MEDIA_INFO_LOG("ActsPlayerAPITest::TearDownTestCase");
};
// SetUp
void SetUp(void)
{
MEDIA_INFO_LOG("ActsPlayerAPITest::SetUp");
};
// TearDown
void TearDown(void)
{
MEDIA_INFO_LOG("ActsPlayerAPITest::TearDown");
};
void LocalPlayFunc(const std::string uri, bool isAsync, WindowConfig config = g_config);
};
}
}
#endif
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PLAYER_FUNC_TEST_H
#define PLAYER_FUNC_TEST_H
#include "Testplayer.h"
namespace OHOS {
namespace Media {
class ActsPlayerFuncTest : public testing::Test {
public:
// SetUpTestCase: before all testcasee
static void SetUpTestCase(void)
{
MEDIA_INFO_LOG("ActsPlayerFuncTest::SetUpTestCase");
};
// TearDownTestCase: after all testcase
static void TearDownTestCase(void)
{
MEDIA_INFO_LOG("ActsPlayerFuncTest::TearDownTestCase");
};
// SetUp
void SetUp(void)
{
MEDIA_INFO_LOG("ActsPlayerFuncTest::SetUp");
};
// TearDown
void TearDown(void)
{
MEDIA_INFO_LOG("ActsPlayerFuncTest::TearDown");
};
static void LocalPlayFunc(const std::string uri, bool isAsync, WindowConfig config = g_sub_config);
static void *LocalMulitPlayFunc(void *threadarg);
};
}
}
#endif
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "securec.h"
#include "common.h"
#include "player.h"
#include "mediatest_log.h"
#include "window_manager.h"
#include "surface_type.h"
#include "display_type.h"
namespace PlayerNameSpace {
static const int MAX_THREADS = 16;
static const int32_t PLAYING_TIME = 3;
static const int32_t PAUSED_TIME = 1;
static const int32_t SEEK_TIME_5_SEC = 5000;
static const int32_t SEEK_TIME_2_SEC = 2000;
static const int DELTA_TIME = 1000;
static const int WAITSECOND = 2;
static const int MAXTIME = 20;
static const int RET_OK = 0;
static const int32_t FILE_BEGIN = 0;
std::string GetUri();
}
namespace OHOS {
namespace Media {
static const std::string SURFACE_STRIDE_ALIGNMENT = "SURFACE_STRIDE_ALIGNMENT";
static const std::string SURFACE_FORMAT = "SURFACE_FORMAT";
static WindowConfig g_config = {
1920,
1080,
PIXEL_FMT_RGBA_8888,
0,
0,
WINDOW_TYPE_NORMAL
};
static WindowConfig g_sub_config = {
720,
480,
PIXEL_FMT_YCRCB_420_SP,
0,
0,
WINDOW_TYPE_VIDEO,
};
class PlayerSignal {
public:
PlayerStates state_ = PLAYER_IDLE;
int32_t seekPositon_;
bool seekDoneFlag_;
bool mutexFlag_ = true;
std::mutex mutexSeek_;
std::mutex mutexReset_;
std::mutex mutexPrepare_;
std::mutex mutexPlay_;
std::mutex mutexPause_;
std::mutex mutexStop_;
std::condition_variable condVarSeek_;
std::condition_variable condVarReset_;
std::condition_variable condVarPrepare_;
std::condition_variable condVarPlay_;
std::condition_variable condVarPause_;
std::condition_variable condVarStop_;
void SetState(PlayerStates state);
void SetSeekResult(bool seekDoneFlag);
};
class TestPlayer {
public:
std::shared_ptr<Player> player;
std::unique_ptr<Window> mwindow;
std::unique_ptr<SubWindow> window;
explicit TestPlayer(PlayerSignal *test);
~TestPlayer();
bool CreatePlayer();
int32_t SetSource(const std::string &uri);
int32_t Play();
int32_t Prepare();
int32_t PrepareAsync();
int32_t Pause();
int32_t Stop();
int32_t Reset();
int32_t Release();
int32_t SetVolume(float leftVolume, float rightVolume);
int32_t Seek(int32_t mseconds, PlayerSeekMode mode);
int32_t GetCurrentTime(int32_t &currentTime);
int32_t GetDuration(int32_t &duration);
int32_t SetPlaybackSpeed(PlaybackRateMode mode);
int32_t GetPlaybackSpeed(PlaybackRateMode &mode);
sptr<Surface> GetVideoSurface(WindowConfig g_sub_config);
int32_t SetVideoSurface(sptr<Surface> surface);
bool IsPlaying();
bool IsLooping();
int32_t SetLooping(bool loop);
int32_t SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback);
private:
void InitSubWindow(WindowConfig sub_config);
PlayerSignal *test_;
};
class TestPlayerCallback : public PlayerCallback {
public:
int errorNum = 0;
PlayerStates state_ = PLAYER_STATE_ERROR;
explicit TestPlayerCallback(PlayerSignal *test);
~TestPlayerCallback();
void OnError(PlayerErrorType errorType, int32_t errorCode);
int WaitForSeekDone(int32_t currentPositon);
void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &InfoBody = {});
int WaitForState(PlayerStates state);
private:
PlayerErrorType errorType_ = PLAYER_ERROR_UNKNOWN;
int32_t errorCode_ = -1;
bool seekDoneFlag = false;
int32_t postion_ = 0;
void PrintState(PlayerStates state);
PlayerSignal *test_;
};
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#define MOUNT_147 "/data/147"
#define MOUNT_189 "/data/189"
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0100
* @tc.name : 01.SetSource操作在new之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0200
* @tc.name : 02.SetSource操作在PrepareAsync之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0300
* @tc.name : 03.SetSource操作在Prepare之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0400
* @tc.name : 04.SetSource操作在Play之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0500
* @tc.name : 05.SetSource操作在Pause之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0600
* @tc.name : 06.SetSource操作在Seek之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0700
* @tc.name : 07.SetSource操作在Stop之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0800
* @tc.name : 08.SetSource操作在Reset之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_0900
* @tc.name : 09.SetSource操作在SetVideoSurface之后
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
EXPECT_NE(RET_OK, player->SetSource(uri));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_1000
* @tc.name : 10.SetSource操作调用3次
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_NE(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetSource_1100
* @tc.name : 11.SetSource操作在每个可进行的操作后都调用一次
* @tc.desc : test SetSource
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetSource_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->SetSource(uri));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, player->Reset());
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0100
* @tc.name : 01.Prepare操作在new之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0100, Reliability | SmallTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_NE(RET_OK, player->Prepare());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0200
* @tc.name : 02.Prepare操作在PrepareAsync之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0300
* @tc.name : 03.Prepare操作在SetSource之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
player->SetVideoSurface(videoSurface);
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0400
* @tc.name : 04.Prepare操作在Play之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0500
* @tc.name : 05.Prepare操作在Pause之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0600
* @tc.name : 06.Prepare操作在Seek之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0700
* @tc.name : 07.Prepare操作在Stop之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0800
* @tc.name : 08.Prepare操作在Reset之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_0900
* @tc.name : 09.Prepare操作在SetVideoSurface之后
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_1000
* @tc.name : 10.Prepare操作调用3次
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Prepare_1100
* @tc.name : 11.Prepare操作在每个可进行的操作后都调用一次
* @tc.desc : test Prepare
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Prepare_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0100
* @tc.name : 01.Play操作在new之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0100, Reliability | SmallTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_NE(RET_OK, player->Prepare());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0200
* @tc.name : 02.Play操作在PrepareAsync之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0300
* @tc.name : 03.Play操作在Prepare之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0400
* @tc.name : 03.Play操作在SetSource之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
int32_t time;
EXPECT_NE(RET_OK, player->Play());
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_EQ(2000, time);
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0500
* @tc.name : 05.Play操作在Pause之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0600
* @tc.name : 06.Play操作在Seek之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0700
* @tc.name : 07.Play操作在Stop之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Play());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0800
* @tc.name : 08.Play操作在Reset之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_0900
* @tc.name : 09.Play操作在SetVideoSurface之后
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
EXPECT_NE(RET_OK, player->Play());
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_1000
* @tc.name : 10.Play操作调用3次
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Play_1100
* @tc.name : 11.Play操作在每个可进行的操作后都调用一次
* @tc.desc : test Play
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Play_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0100
* @tc.name : 01.Pause操作在new之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0100, Reliability | SmallTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_NE(RET_OK, player->Pause());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0200
* @tc.name : 02.Pause操作在PrepareAsync之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0300
* @tc.name : 03.Pause操作在Prepare之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0500
* @tc.name : 05.Pause操作在Play之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0600
* @tc.name : 06.Pause操作在Seek之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0700
* @tc.name : 07.Pause操作在Stop之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0800
* @tc.name : 08.Pause操作在Reset之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_0900
* @tc.name : 09.Pause操作在SetVideoSurface之后
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_1000
* @tc.name : 10.Pause操作调用3次
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Pause_1100
* @tc.name : 10.Pause操作在每个可进行的操作后都调用一次
* @tc.desc : test Pause
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Pause_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_NE(RET_OK, player->Pause());
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->Pause());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0100
* @tc.name : 01.Stop操作在new之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0100, Reliability | SmallTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_NE(RET_OK, player->Stop());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0200
* @tc.name : 02.Stop操作在PrepareAsync之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0300
* @tc.name : 03.Stop操作在Prepare之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0400
* @tc.name : 04.Stop操作在Play之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0500
* @tc.name : 05.Stop操作在Pause之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0600
* @tc.name : 06.Stop操作在Seek之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0800
* @tc.name : 08.Stop操作在Reset之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_0900
* @tc.name : 09.Stop操作在SetVideoSurface之后
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_1000
* @tc.name : 10.Stop操作调用3次
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Stop_1100
* @tc.name : 11.Stop操作在每个可进行的操作后都调用一次
* @tc.desc : test Stop
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Stop_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_NE(RET_OK, player->Stop());
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->Stop());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_NE(RET_OK, player->Play());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_NE(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0100
* @tc.name : 01.Reset操作在new之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0100, Reliability | SmallTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_EQ(RET_OK, player->Reset());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0200
* @tc.name : 02.Reset操作在PrepareAsync之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0300
* @tc.name : 03.Reset操作在Prepare之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Reset());
ASSERT_EQ(RET_OK, player->SetSource(uri));
videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0400
* @tc.name : 04.Reset操作在Play之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0500
* @tc.name : 05.Reset操作在Pause之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0600
* @tc.name : 06.Reset操作在Seek之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0700
* @tc.name : 07.Reset操作在Stop之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_0900
* @tc.name : 09.Reset操作在SetVideoSurface之后
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Reset_1000
* @tc.name : 10.Reset操作调用3次
* @tc.desc : test Reset
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_Reset_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetVolume_0100
* @tc.name : 01.SetVolume 0 0
* @tc.desc : test SetVolume
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetVolume_0100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
sleep(PLAYING_TIME);
EXPECT_EQ(RET_OK, player->SetVolume(0, 0));
sleep(PLAYING_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetVolume_0200
* @tc.name : 02.SetVolume 1.0 1.0
* @tc.desc : test SetVolume
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetVolume_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
sleep(PLAYING_TIME);
EXPECT_EQ(RET_OK, player->SetVolume(1.0, 1.0));
sleep(PLAYING_TIME);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0100
* @tc.name : 01.set loop true操作在createAudioPlayer之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_NE(RET_OK, player->SetLooping(true));
EXPECT_FALSE(player->IsLooping());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0200
* @tc.name : 02.set loop true操作在play之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0300
* @tc.name : 03.set loop true操作在pause之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0400
* @tc.name : 04.set loop true操作在stop之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0500
* @tc.name : 05.set loop true操作在seek之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0600
* @tc.name : 06.set loop true操作在set loop true之后的每个可进行的操作后都调用一次
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0700
* @tc.name : 07.set loop true操作调用3次
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsLooping());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0800
* @tc.name : 08.set loop false操作在play之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_0900
* @tc.name : 09.set loop false操作在pause之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1000
* @tc.name : 010.set loop false操作在stop之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1100
* @tc.name : 011.set loop false操作在seek之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1200
* @tc.name : 012.set loop false操作在set loop false之后的每个可进行的操作后都调用一次
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->SetLooping(false));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetLooping_1300
* @tc.name : 013.set loop false操作调用3次
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetLooping_1300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->SetLooping(false));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0100
* @tc.name : 01.SetPlaybackSpeed操作在createAudioPlayer之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
PlaybackRateMode mode;
EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_NE(RET_OK, player->GetPlaybackSpeed(mode));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0200
* @tc.name : 02.SetPlaybackSpeed操作在play之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
PlaybackRateMode mode;
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0300
* @tc.name : 03.SetPlaybackSpeed操作在pause之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
PlaybackRateMode mode;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0400
* @tc.name : 04.SetPlaybackSpeed操作在stop之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
PlaybackRateMode mode;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0500
* @tc.name : 05.SetPlaybackSpeed操作在seek之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
PlaybackRateMode mode;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0600
* @tc.name : 06.SetPlaybackSpeed操作在SetPlaybackSpeed之后的每个可进行的操作后都调用一次
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
PlaybackRateMode mode;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0700
* @tc.name : 07.SetPlaybackSpeed操作调用3次
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
PlaybackRateMode mode;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_1_25_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_1_25_X, mode);
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_1_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_1_75_X, mode);
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_2_00_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_2_00_X, mode);
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0800
* @tc.name : 08.SetPlaybackSpeed操作在Prepare之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
PlaybackRateMode mode;
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0900
* @tc.name : 08.SetPlaybackSpeed操作在PrepareAsync之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
PlaybackRateMode mode;
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1000
* @tc.name : 10.SetPlaybackSpeed操作在SetSource之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
PlaybackRateMode mode;
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_NE(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_NE(RET_OK, player->GetPlaybackSpeed(mode));
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1100
* @tc.name : 10.SetPlaybackSpeed操作在PLAYER_PLAYBACK_COMPLETE之后
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
PlaybackRateMode mode;
int32_t durationTime;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->GetDuration(durationTime));
EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE));
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1200
* @tc.name : 10.SetPlaybackSpeed操作在PLAYER_PLAYBACK_COMPLETE之后,loop=1
* @tc.desc :
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_SetPlaybackSpeed_1200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
PlaybackRateMode mode;
int32_t durationTime;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->Prepare());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->SetLooping(true));
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->GetDuration(durationTime));
EXPECT_EQ(RET_OK, player->Seek(durationTime, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, testCallback->WaitForState(PLAYER_PLAYBACK_COMPLETE));
EXPECT_EQ(RET_OK, player->SetPlaybackSpeed(SPEED_FORWARD_0_75_X));
EXPECT_EQ(RET_OK, player->GetPlaybackSpeed(mode));
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
sleep(PLAYING_TIME);
EXPECT_EQ(SPEED_FORWARD_0_75_X, mode);
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0100
* @tc.name : 01.PrepareAsync操作在new之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0100, Reliability | SmallTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
EXPECT_NE(RET_OK, player->PrepareAsync());
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0200
* @tc.name : 02.PrepareAsync操作在PrepareAsync之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0200, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0300
* @tc.name : 03.PrepareAsync操作在SetSource之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0300, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_NE(RET_OK, player->SetVideoSurface(videoSurface));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0400
* @tc.name : 04.PrepareAsync操作在Play之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0400, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0500
* @tc.name : 05.PrepareAsync操作在Pause之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0500, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0600
* @tc.name : 06.PrepareAsync操作在Seek之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0600, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0700
* @tc.name : 07.PrepareAsync操作在Stop之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0700, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0800
* @tc.name : 08.PrepareAsync操作在Reset之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0800, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_0900
* @tc.name : 09.PrepareAsync操作在SetVideoSurface之后
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_0900, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Play());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_1000
* @tc.name : 10.PrepareAsync操作调用3次
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_1000, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/**
* @tc.number : SUB_MEDIA_PLAYER_API_PrepareAsync_1100
* @tc.name : 11.PrepareAsync操作在每个可进行的操作后都调用一次
* @tc.desc : test PrepareAsync
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_PrepareAsync_1100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
ASSERT_EQ(RET_OK, player->SetSource(uri));
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsPlayerAPITest.h"
#include "player.h"
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
using namespace PlayerNameSpace;
/**
* @tc.number : SUB_MEDIA_PLAYER_API_Seek_1500
* @tc.name : 15.GET操作在每个可进行的操作后都调用一次
* @tc.desc : test Seek
*/
HWTEST_F(ActsPlayerAPITest, SUB_MEDIA_PLAYER_API_GetParameter_0100, Reliability | MediumTest | Level2)
{
PlayerSignal testObj;
std::shared_ptr<TestPlayer> player = std::make_shared<TestPlayer>(&testObj);
ASSERT_NE(nullptr, player);
ASSERT_EQ(true, player->CreatePlayer());
std::string uri = GetUri();
int32_t time;
int32_t duration;
int32_t defaultDuration;
EXPECT_NE(RET_OK, player->GetCurrentTime(time));
EXPECT_EQ(0, time);
EXPECT_FALSE(player->IsPlaying());
ASSERT_EQ(RET_OK, player->SetSource(uri));
EXPECT_NE(RET_OK, player->GetCurrentTime(time));
EXPECT_NE(RET_OK, player->GetDuration(duration));
EXPECT_FALSE(player->IsPlaying());
sptr<Surface> videoSurface = player->GetVideoSurface(g_sub_config);
EXPECT_EQ(RET_OK, player->SetVideoSurface(videoSurface));
EXPECT_NE(RET_OK, player->GetCurrentTime(time));
EXPECT_NE(RET_OK, player->GetDuration(duration));
EXPECT_FALSE(player->IsPlaying());
std::shared_ptr<TestPlayerCallback> testCallback = std::make_shared<TestPlayerCallback>(&testObj);
EXPECT_EQ(RET_OK, player->SetPlayerCallback(testCallback));
EXPECT_NE(RET_OK, player->GetCurrentTime(time));
EXPECT_NE(RET_OK, player->GetDuration(duration));
EXPECT_FALSE(player->IsPlaying());
// prepare
ASSERT_EQ(RET_OK, player->PrepareAsync());
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_EQ(FILE_BEGIN, time);
EXPECT_EQ(RET_OK, player->GetDuration(defaultDuration));
EXPECT_FALSE(player->IsPlaying());
// play
EXPECT_EQ(RET_OK, player->Play());
EXPECT_TRUE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->GetDuration(duration));
EXPECT_EQ(defaultDuration, duration);
EXPECT_TRUE(player->IsPlaying());
// seek
EXPECT_EQ(RET_OK, player->Seek(SEEK_TIME_2_SEC, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->GetDuration(duration));
EXPECT_EQ(defaultDuration, duration);
// pause
EXPECT_EQ(RET_OK, player->Pause());
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(SEEK_TIME_2_SEC, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->GetDuration(duration));
EXPECT_EQ(defaultDuration, duration);
// seek duration
EXPECT_EQ(RET_OK, player->Seek(defaultDuration + 1, SEEK_PREVIOUS_SYNC));
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_EQ(defaultDuration, time);
EXPECT_EQ(RET_OK, player->GetDuration(duration));
EXPECT_EQ(defaultDuration, duration);
// stop
EXPECT_EQ(RET_OK, player->Stop());
EXPECT_EQ(RET_OK, player->GetCurrentTime(time));
EXPECT_NEAR(FILE_BEGIN, time, DELTA_TIME);
EXPECT_EQ(RET_OK, player->GetDuration(duration));
EXPECT_EQ(defaultDuration, duration);
EXPECT_FALSE(player->IsPlaying());
// reset
EXPECT_EQ(RET_OK, player->Reset());
EXPECT_NE(RET_OK, player->GetCurrentTime(time));
EXPECT_NE(RET_OK, player->GetDuration(duration));
EXPECT_FALSE(player->IsPlaying());
EXPECT_EQ(RET_OK, testCallback->errorNum);
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RECODER_DEMO_TEST_H
#define RECODER_DEMO_TEST_H
#include "gtest/gtest.h"
#include "recorder.h"
namespace OHOS {
namespace Media {
struct AudioRecorderConfig {
int32_t audioSourceId;
int32_t audioEncodingBitRate;
int32_t channelCount;
int32_t duration;
std::string outPath;
int32_t sampleRate;
AudioCodecFormat audioFormat;
AudioSourceType inputSource;
OutputFormatType outPutFormat;
};
class ActsAudioRecorderTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp(void);
void TearDown(void);
void ConfigAudioRecorder(std::shared_ptr<Recorder> recorder, AudioRecorderConfig audioConfig);
void AudioRecorderStart(std::shared_ptr<Recorder> recorder);
};
class TestAudioRecorderCallback : public RecorderCallback {
public:
void OnError(int32_t errorType, int32_t errorCode);
void OnInfo(int32_t type, int32_t extra);
};
}
}
#endif
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RECODER_VIDEO_TEST_H
#define RECODER_VIDEO_TEST_H
#include "gtest/gtest.h"
#include "recorder.h"
namespace OHOS {
namespace Media {
struct VideoRecorderConfig {
int32_t audioSourceId;
int32_t videoSourceId;
int32_t audioEncodingBitRate;
int32_t channelCount;
int32_t duration;
int32_t width;
int32_t height;
int32_t frameRate;
int32_t videoEncodingBitRate;
int32_t sampleRate;
double captureFps;
std::string outPath;
AudioCodecFormat audioFormat;
AudioSourceType aSource;
OutputFormatType outPutFormat;
VideoSourceType vSource;
VideoCodecFormat videoFormat;
};
class ActsVideoRecorderTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp(void);
void TearDown(void);
void ConfigvideoRecorder(std::shared_ptr<Recorder> recorder, VideoRecorderConfig videoConfig, bool isAudio);
void VideoRecorderStart(std::shared_ptr<Recorder> recorder);
};
class TestVideoRecorderCallback : public RecorderCallback {
public:
void OnError(int32_t errorType, int32_t errorCode);
void OnInfo(int32_t type, int32_t extra);
};
}
}
#endif
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ActsAudioRecoederTest.h"
#include "mediatest_log.h"
using namespace std;
using namespace OHOS::Media;
using namespace testing::ext;
static AudioRecorderConfig g_audioRecorderConfig = {
0,
48000,
2,
60,
"/data/recorder",
48000,
AAC_LC,
AUDIO_MIC,
FORMAT_M4A,
};
void TestAudioRecorderCallback::OnError(int32_t errorType, int32_t errorCode)
{
MEDIA_INFO_LOG("OnError errorType is %d, errorCode is %d", errorType, errorCode);
}
void TestAudioRecorderCallback::OnInfo(int32_t type, int32_t extra)
{
MEDIA_INFO_LOG("OnInfo type is %d, extra is %d", type, extra);
}
void ActsAudioRecorderTest::SetUpTestCase(void)
{
MEDIA_INFO_LOG("ActsAudioRecorderTest::SetUpTestCase");
}
void ActsAudioRecorderTest::TearDownTestCase(void)
{
MEDIA_INFO_LOG("ActsAudioRecorderTest::TearDownTestCase");
}
void ActsAudioRecorderTest::SetUp(void)
{
MEDIA_INFO_LOG("ActsAudioRecorderTest::SetUp");
}
void ActsAudioRecorderTest::TearDown(void)
{
MEDIA_INFO_LOG("ActsAudioRecorderTest::TearDown");
}
void ActsAudioRecorderTest::ConfigAudioRecorder(std::shared_ptr<Recorder> recorder, AudioRecorderConfig audioConfig)
{
std::shared_ptr<TestAudioRecorderCallback> testCallback = std::make_shared<TestAudioRecorderCallback>();
ASSERT_NE(nullptr, testCallback);
EXPECT_EQ(0, recorder->SetAudioSource(audioConfig.inputSource, audioConfig.audioSourceId));
EXPECT_EQ(0, recorder->SetOutputFormat(audioConfig.outPutFormat));
EXPECT_EQ(0, recorder->SetAudioEncoder(audioConfig.audioSourceId, audioConfig.audioFormat));
EXPECT_EQ(0, recorder->SetAudioSampleRate(audioConfig.audioSourceId, audioConfig.sampleRate));
EXPECT_EQ(0, recorder->SetAudioChannels(audioConfig.audioSourceId, audioConfig.channelCount));
EXPECT_EQ(0, recorder->SetAudioEncodingBitRate(audioConfig.audioSourceId, audioConfig.audioEncodingBitRate));
EXPECT_EQ(0, recorder->SetMaxDuration(audioConfig.duration));
EXPECT_EQ(0, recorder->SetOutputPath(audioConfig.outPath));
EXPECT_EQ(0, recorder->SetRecorderCallback(testCallback));
}
void ActsAudioRecorderTest::AudioRecorderStart(std::shared_ptr<Recorder> recorder)
{
EXPECT_EQ(0, recorder->Prepare());
EXPECT_EQ(0, recorder->Start());
sleep(2);
EXPECT_EQ(0, recorder->Stop(false));
EXPECT_EQ(0, recorder->Reset());
EXPECT_EQ(0, recorder->Release());
}
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0100
* @tc.name : 01.set audio format to AAC
* @tc.desc : The test case is successfully executed.
The video file can be played properly.
*/
HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Codec_AAC_Function_0100, Function | MediumTest | Level0)
{
std::shared_ptr<Recorder> recorder = RecorderFactory::CreateRecorder();
ASSERT_NE(nullptr, recorder);
ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig);
ActsAudioRecorderTest::AudioRecorderStart(recorder);
}
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0300
* @tc.name : 03.Set different samplerate 8-96KHz
* @tc.desc : The test case is successfully executed.
The video file can be played properly.
*/
HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Codec_AAC_Function_0300, Function | MediumTest | Level0)
{
for (int i = 8000; i < 96000; i = i + 10000) {
g_audioRecorderConfig.sampleRate = i;
g_audioRecorderConfig.outPath = "/data/recorder";
std::shared_ptr<Recorder> recorder = RecorderFactory::CreateRecorder();
ASSERT_NE(nullptr, recorder);
ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig);
ActsAudioRecorderTest::AudioRecorderStart(recorder);
}
}
/* *
* @tc.number : SUB_MEDIA_RECORDER_Format_MP4_Function_05_0200
* @tc.name : 02.Set outPutFormat to FORMAT_MPEG_4
* @tc.desc : The test case is successfully executed.
The video file can be played properly.
*/
HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Format_MP4_Function_05_0200, Function | MediumTest | Level0)
{
g_audioRecorderConfig.outPutFormat = FORMAT_MPEG_4;
std::shared_ptr<Recorder> recorder = RecorderFactory::CreateRecorder();
ASSERT_NE(nullptr, recorder);
ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig);
ActsAudioRecorderTest::AudioRecorderStart(recorder);
}
/* *
* @tc.number : SUB_MEDIA_RECORDER_Function_09_01_0100
* @tc.name : 001.Stopping Recording in DRAIN Mode When Recording Pure Audio Files
* @tc.desc : The test case is successfully executed.
The video file can be played properly.
*/
HWTEST_F(ActsAudioRecorderTest, SUB_MEDIA_RECORDER_Function_09_01_0100, Function | MediumTest | Level0)
{
std::shared_ptr<Recorder> recorder = RecorderFactory::CreateRecorder();
ASSERT_NE(nullptr, recorder);
ActsAudioRecorderTest::ConfigAudioRecorder(recorder, g_audioRecorderConfig);
EXPECT_EQ(0, recorder->Prepare());
EXPECT_EQ(0, recorder->Start());
sleep(5);
EXPECT_EQ(0, recorder->Stop(true));
EXPECT_EQ(0, recorder->Release());
}
require('../test/fuction/media_player/PlayerLocalTestAudioFUNC.test.js');
require('../test/reliability/media_player/PlayerLocalTestAudioAPI.test.js');
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册