未验证 提交 d666ce33 编写于 作者: N NOBUGGERS 提交者: Gitee

media test 同步刷新 Signed-off-by: NOBUGGERS <ruanmeng@huawei.com>

上级 7032902b
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
...@@ -14,14 +13,17 @@ ...@@ -14,14 +13,17 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef MEDIA_LOG_TEST_H
#define MEDIA_LOG_TEST_H
#include "media_log.h" #include "media_log.h"
#include "securec.h" #include "securec.h"
#define LOGMAXSIZE 200 #define LOG_MAX_SIZE 200
#define MEDIA_INFO_LOG(fmt, ...) \ #define MEDIA_INFO_LOG(fmt, ...) \
do { \ do { \
char ch[LOGMAXSIZE]; \ char ch[LOG_MAX_SIZE]; \
(void)sprintf_s(ch, LOGMAXSIZE, fmt, ##__VA_ARGS__); \ (void)sprintf_s(ch, LOG_MAX_SIZE, fmt, ##__VA_ARGS__); \
(void)printf("%s", ch); \ (void)printf("%s", ch); \
(void)printf("\n"); \ (void)printf("\n"); \
__MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Info, "%{public}s", ch); \ __MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Info, "%{public}s", ch); \
...@@ -29,15 +31,15 @@ do { \ ...@@ -29,15 +31,15 @@ do { \
#define MEDIA_DEBUG_LOG(fmt, ...) \ #define MEDIA_DEBUG_LOG(fmt, ...) \
do { \ do { \
char ch[LOGMAXSIZE]; \ char ch[LOG_MAX_SIZE]; \
(void)sprintf_s(ch, LOGMAXSIZE, fmt, ##__VA_ARGS__); \ (void)sprintf_s(ch, LOG_MAX_SIZE, fmt, ##__VA_ARGS__); \
__MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Debug, "%{public}s", ch); \ __MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Debug, "%{public}s", ch); \
} while (0) } while (0)
#define MEDIA_ERROR_LOG(fmt, ...) \ #define MEDIA_ERROR_LOG(fmt, ...) \
do { \ do { \
char ch[LOGMAXSIZE]; \ char ch[LOG_MAX_SIZE]; \
(void)sprintf_s(ch, LOGMAXSIZE, fmt, ##__VA_ARGS__); \ (void)sprintf_s(ch, LOG_MAX_SIZE, fmt, ##__VA_ARGS__); \
(void)printf("%s", ch); \ (void)printf("%s", ch); \
(void)printf("\n"); \ (void)printf("\n"); \
__MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Error, "%{public}s", ch); \ __MEDIA_LOG(::OHOS::HiviewDFX::HiLog::Error, "%{public}s", ch); \
...@@ -55,4 +57,5 @@ namespace MediaTest { ...@@ -55,4 +57,5 @@ namespace MediaTest {
const int THIRD_ARG = 3; const int THIRD_ARG = 3;
const int HEIGHT = 720; const int HEIGHT = 720;
const int WIDTH = 1280; const int WIDTH = 1280;
} }
\ No newline at end of file #endif
...@@ -25,6 +25,7 @@ public: ...@@ -25,6 +25,7 @@ public:
static void SetUpTestCase(void) static void SetUpTestCase(void)
{ {
MEDIA_DEBUG_LOG("ActsPlayerAPITest::SetUpTestCase"); MEDIA_DEBUG_LOG("ActsPlayerAPITest::SetUpTestCase");
TestPlayerBasic::TestParamsConfig::GetInstance().InitMountPath();
}; };
// TearDownTestCase: after all testcases // TearDownTestCase: after all testcases
static void TearDownTestCase(void) static void TearDownTestCase(void)
......
...@@ -25,7 +25,7 @@ public: ...@@ -25,7 +25,7 @@ public:
static void SetUpTestCase(void) static void SetUpTestCase(void)
{ {
MEDIA_DEBUG_LOG("ActsPlayerFuncTest::SetUpTestCase"); MEDIA_DEBUG_LOG("ActsPlayerFuncTest::SetUpTestCase");
TestPlayerBasic::TestParamsConfig::GetInstance().InitPlayProtocol(); TestPlayerBasic::TestParamsConfig::GetInstance().InitMountPath();
}; };
// TearDownTestCase: after all testcases // TearDownTestCase: after all testcases
static void TearDownTestCase(void) static void TearDownTestCase(void)
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
// SetUp // SetUp
void SetUp(void) void SetUp(void)
{ {
uri_ = TestPlayerBasic::TestParamsConfig::GetInstance().GetUri();
const ::testing::TestInfo * const testInfo = ::testing::UnitTest::GetInstance()->current_test_info(); const ::testing::TestInfo * const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
MEDIA_DEBUG_LOG("ActsPlayerFuncTest::SetUp:%s", testInfo->name()); MEDIA_DEBUG_LOG("ActsPlayerFuncTest::SetUp:%s", testInfo->name());
}; };
...@@ -45,6 +46,11 @@ public: ...@@ -45,6 +46,11 @@ public:
MEDIA_DEBUG_LOG("ActsPlayerFuncTest::TearDown:%s", testInfo->name()); MEDIA_DEBUG_LOG("ActsPlayerFuncTest::TearDown:%s", testInfo->name());
}; };
static void LocalPlayFunc(const std::string uri, bool isAsync, WindowConfig config = g_sub_config); static void LocalPlayFunc(const std::string uri, bool isAsync, WindowConfig config = g_sub_config);
static void *LocalMultiPlayFunc(void *threadArg);
void PreparePlayEnv(std::shared_ptr<TestPlayer> &player);
std::string uri_ = "";
std::shared_ptr<TestPlayerCallback> testCallback_;
std::shared_ptr<PlayerSignal> testObj_;
}; };
} }
} }
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#ifndef PLAYER_COMMON_TEST_H #ifndef PLAYER_COMMON_TEST_H
#define PLAYER_COMMON_TEST_H #define PLAYER_COMMON_TEST_H
#include "gtest/gtest.h"
#include "mediatest_log.h" #include "mediatest_log.h"
#include "gtest/gtest.h"
#include "player.h" #include "player.h"
namespace { namespace {
...@@ -37,6 +37,7 @@ namespace { ...@@ -37,6 +37,7 @@ namespace {
namespace TestPlayerBasic { namespace TestPlayerBasic {
class TestParamsConfig { class TestParamsConfig {
public: public:
DISALLOW_COPY_AND_MOVE(TestParamsConfig);
static TestParamsConfig &GetInstance() static TestParamsConfig &GetInstance()
{ {
static TestParamsConfig config; static TestParamsConfig config;
...@@ -54,7 +55,7 @@ public: ...@@ -54,7 +55,7 @@ public:
} }
bool CompareTime(int32_t expectTime, int32_t realTme, OHOS::Media::PlayerSeekMode seekMode); bool CompareTime(int32_t expectTime, int32_t realTme, OHOS::Media::PlayerSeekMode seekMode);
std::string GetUri(); std::string GetUri();
void InitPlayProtocol(); void InitMountPath();
private: private:
TestParamsConfig(); TestParamsConfig();
......
...@@ -46,7 +46,6 @@ static WindowConfig g_sub_config = { ...@@ -46,7 +46,6 @@ static WindowConfig g_sub_config = {
class PlayerSignal { class PlayerSignal {
public: public:
PlayerStates state_ = PLAYER_IDLE; PlayerStates state_ = PLAYER_IDLE;
int32_t seekPositon_;
bool seekDoneFlag_; bool seekDoneFlag_;
bool mutexFlag_ = true; bool mutexFlag_ = true;
std::mutex mutexSeek_; std::mutex mutexSeek_;
...@@ -71,6 +70,7 @@ public: ...@@ -71,6 +70,7 @@ public:
sptr<Window> window_ = nullptr; sptr<Window> window_ = nullptr;
explicit TestPlayer(std::shared_ptr<PlayerSignal> test); explicit TestPlayer(std::shared_ptr<PlayerSignal> test);
virtual ~TestPlayer(); virtual ~TestPlayer();
DISALLOW_COPY_AND_MOVE(TestPlayer);
bool CreatePlayer(); bool CreatePlayer();
int32_t SetSource(const std::string &uri); int32_t SetSource(const std::string &uri);
int32_t SetDataSrc(const std::string &uri, bool seekable); int32_t SetDataSrc(const std::string &uri, bool seekable);
...@@ -102,8 +102,9 @@ public: ...@@ -102,8 +102,9 @@ public:
PlayerStates state_ = PLAYER_STATE_ERROR; PlayerStates state_ = PLAYER_STATE_ERROR;
explicit TestPlayerCallback(std::shared_ptr<PlayerSignal> test); explicit TestPlayerCallback(std::shared_ptr<PlayerSignal> test);
virtual ~TestPlayerCallback(); virtual ~TestPlayerCallback();
DISALLOW_COPY_AND_MOVE(TestPlayerCallback);
void OnError(PlayerErrorType errorType, int32_t errorCode); void OnError(PlayerErrorType errorType, int32_t errorCode);
int WaitForSeekDone(int32_t currentPositon); int WaitForSeekDone(int32_t currentPosition);
void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody = {}); void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody = {});
int WaitForState(PlayerStates state); int WaitForState(PlayerStates state);
private: private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册