提交 79ec7d72 编写于 作者: O openharmony_ci 提交者: Gitee

!200 解决媒体用例Crash问题

Merge pull request !200 from LeeTestNady/media0515
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
......@@ -16,12 +16,16 @@ import("//test/xts/tools/lite/build/suite_lite.gni")
hcpptest_suite("ActsMediaPlayerTest") {
suite_name = "acts"
sources = [ "src/ActsAudioPlayerTest.cpp" ]
sources = [ "src/ActsAudioPlayerTest.cpp",
"//test/xts/acts/multimedia_lite/utils_posix/common/src/ActsTestMediaUtils.cpp" ]
if (ohos_kernel_type == "liteos_a" &&
enable_ohos_appexecfwk_feature_ability == true) {
sources += [ "src/ActsVideoPlayerTest.cpp" ]
}
include_dirs = [ "src" ]
include_dirs = [
"src",
"//test/xts/acts/multimedia_lite/utils_posix/common/include"
]
ldflags = [ "-lstdc++" ]
ldflags += [ "-lm" ]
if (ohos_kernel_type == "linux") {
......
文件模式从 100644 更改为 100755
......@@ -21,6 +21,7 @@
#include "player.h"
#include "format.h"
#include "PlayerTest.h"
#include "ActsTestMediaUtils.h"
#include "fstream"
#include "iostream"
#include "thread"
......@@ -178,38 +179,67 @@ void SetSchParam(void)
}
} // namespace OHOS
const char *g_audioFileName = "Audiochannel_001.aac";
const char *g_audioFileName1 = "Audiochannel_002.m4a";
// const char *g_audioFileName = "Audiochannel_001.aac";
// const char *g_audioFileName1 = "Audiochannel_002.m4a";
const char *g_audioFileName;
const char *g_audioFileName1;
class ActsAudioPlayerTest : public testing::Test {
protected:
// SetUpTestCase:The preset action of the test suite is executed before the first TestCase
static void SetUpTestCase(void)
{
cout << "=====SetUpTestSuit: init test source" << endl;
std::size_t size1 = fileSize("Audiochannel_001.aac");
unsigned char buffer[size1];
readFile(buffer, size1, "Audiochannel_001.aac");
writeFile(buffer, size1, "/storage/Audiochannel_001.aac");
std::size_t size2 = fileSize("Audiochannel_002.m4a");
unsigned char buffer2[size2];
readFile(buffer2, size2, "Audiochannel_002.m4a");
writeFile(buffer2, size2, "/storage/Audiochannel_002.m4a");
g_audioFileName="/storage/Audiochannel_001.aac";
g_audioFileName1="/storage/Audiochannel_002.m4a";
}
// TearDownTestCase:The test suite cleanup action is executed after the last TestCase
static void TearDownTestCase(void)
{
cout << "=====TearDownTestSuit" << endl;
int32_t ret = std::remove("/storage/Audiochannel_001.aac");
int32_t ret1 = std::remove("/storage/Audiochannel_002.m4a");
cout << "=====TearDownTestSuit end!" << endl;
}
// SetUp:Execute before each test case
virtual void SetUp()
{
cout << "=====SetUpTestCase" << endl;
SetSchParam();
cout << "=====Init Player" << endl;
g_tagTestSample.adaptr = std::make_shared<Player>();
}
// TearDown:Execute after each test case
virtual void TearDown()
{
cout << "=====TearDownTestCase" << endl;
g_tagTestSample.adaptr->Stop();
g_tagTestSample.adaptr->Reset();
g_tagTestSample.adaptr->Release();
sleep(1);
cout << "=====After Release" << endl;
const int audioType = 2;
if (g_tagTestSample.sourceType == audioType) {
pthread_mutex_lock(&g_tagTestSample.mutex);
g_tagTestSample.isThreadRunning = 0;
cout << "=====release stream" << endl;
pthread_mutex_unlock(&g_tagTestSample.mutex);
pthread_join(g_tagTestSample.process, nullptr);
pthread_mutex_destroy(&g_tagTestSample.mutex);
}
sleep(2);
cout << "=====TearDownTestCase end!" << endl;
}
};
......@@ -228,6 +258,7 @@ static int32_t CreateAndSetAudioSource1()
std::map<std::string, std::string> header;
Source source(uri, header);
int32_t ret = g_tagTestSample.adaptr->SetSource(source);
g_tagTestSample.sourceType = 0;
return ret;
}
......@@ -260,6 +291,7 @@ static int32_t CreateAndSetAudioSource2()
EXPECT_EQ(true, flag);
std::shared_ptr<StreamSource> ret2 = source.GetSourceStream();
std::map<std::string, FormatData *> ret3 = formats.GetFormatMap();
g_tagTestSample.sourceType = (int32_t)source.GetSourceType();
pthread_mutex_init(&g_tagTestSample.mutex, nullptr);
g_tagTestSample.isThreadRunning = 1;
pthread_attr_t attr;
......@@ -737,8 +769,8 @@ HWTEST_F(ActsAudioPlayerTest, Test_GetCurrentTime02, Function | MediumTest | Lev
ret = g_tagTestSample.adaptr->Play();
EXPECT_EQ(HI_SUCCESS, ret);
sleep(2);
ret = g_tagTestSample.adaptr->Rewind(4, PLAYER_SEEK_NEXT_SYNC);
EXPECT_EQ(HI_SUCCESS, ret);
ret = g_tagTestSample.adaptr->Rewind(10, PLAYER_SEEK_NEXT_SYNC);
EXPECT_EQ(HI_FAILURE, ret);
int64_t currentPosition;
ret = g_tagTestSample.adaptr->GetCurrentTime(currentPosition);
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -766,7 +798,7 @@ HWTEST_F(ActsAudioPlayerTest, Test_GetCurrentTime03, Function | MediumTest | Lev
ret = g_tagTestSample.adaptr->Pause();
EXPECT_EQ(HI_SUCCESS, ret);
ret = g_tagTestSample.adaptr->Rewind(4, PLAYER_SEEK_NEXT_SYNC);
EXPECT_EQ(HI_SUCCESS, ret);
EXPECT_EQ(HI_FAILURE, ret);
int64_t currentPosition;
ret = g_tagTestSample.adaptr->GetCurrentTime(currentPosition);
EXPECT_EQ(HI_SUCCESS, ret);
......
......@@ -13,15 +13,18 @@
*/
#include "PlayerTest.h"
#include "ActsTestMediaUtils.h"
const char *g_videoFileName = "1080P_25fps.mp4";
// const char *g_videoFileName = "1080P_25fps.mp4";
const char *g_videoFileName;
static void InitSurface()
{
g_surface->SetUserData("region_position_x", "0");
g_surface->SetUserData("region_position_y", "0");
g_surface->SetUserData("region_width", "720");
g_surface->SetUserData("region_height", "540");
g_surface->SetUserData("region_width", "640");
g_surface->SetUserData("region_height", "360");
}
class ActsVideoPlayerTest : public testing::Test {
......@@ -29,10 +32,17 @@ protected:
// SetUpTestCase:The preset action of the test suite is executed before the first TestCase
static void SetUpTestCase(void)
{
cout << "=====SetUpTestSuit: init test source" << endl;
std::size_t size3 = fileSize("1080P_25fps.mp4");
unsigned char buffer[size3];
readFile(buffer, size3, "1080P_25fps.mp4");
writeFile(buffer, size3, "/storage/1080P_25fps.mp4");
g_videoFileName="/storage/1080P_25fps.mp4";
}
// TearDownTestCase:The test suite cleanup action is executed after the last TestCase
static void TearDownTestCase(void)
{
int32_t ret = std::remove("/storage/1080P_25fps.mp4");
}
// SetUp:Execute before each test case
virtual void SetUp()
......@@ -57,7 +67,7 @@ protected:
}
};
static int32_t FileCheck(const char* argv)
static int32_t FileCheckVideo(const char* argv)
{
if (realpath(argv, g_tagTestSample.filePath) == nullptr) {
printf("realpath input file failed, errno: %d!\n", errno);
......@@ -86,7 +96,7 @@ static int32_t CreateAndSetVideoSource()
*/
HWTEST_F(ActsVideoPlayerTest, Test_SetSource03, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
std::string uri(g_tagTestSample.filePath);
Source source(uri);
......@@ -114,7 +124,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_SetSource03, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_SetSource04, Function | MediumTest | Level0)
{
int32_t ret=FileCheck(g_videoFileName);
int32_t ret=FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
Format formats;
formats.PutIntValue("frame-rate", 30);
......@@ -156,7 +166,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_SetSource04, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_SetSource05, Function | MediumTest | Level0)
{
int32_t ret=FileCheck(g_videoFileName);
int32_t ret=FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
Format formats;
std::map<std::string, FormatData *> ret3 = formats.GetFormatMap();
......@@ -207,7 +217,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_SetSource05, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Prepare04, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -229,7 +239,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Prepare04, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Prepare05, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -249,7 +259,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Prepare05, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Play05, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -276,7 +286,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Play05, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Play06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -304,7 +314,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Play06, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Stop06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -333,7 +343,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Stop06, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Stop07, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -360,7 +370,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Stop07, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Stop08, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -382,7 +392,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Stop08, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Stop09, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -409,7 +419,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Stop09, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Stop10, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -439,7 +449,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Stop10, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Pause04, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -466,7 +476,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Pause04, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Pause05, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -493,7 +503,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Pause05, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_SetVolume06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -518,7 +528,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_SetVolume06, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_SetVolume07, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -543,7 +553,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_SetVolume07, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_SetVolume08, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -568,7 +578,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_SetVolume08, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_IsSingleLooping04, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -593,7 +603,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_IsSingleLooping04, Function | MediumTest | Le
*/
HWTEST_F(ActsVideoPlayerTest, Test_IsSingleLooping05, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -621,7 +631,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_IsSingleLooping05, Function | MediumTest | Le
*/
HWTEST_F(ActsVideoPlayerTest, Test_IsSingleLooping06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -649,7 +659,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_IsSingleLooping06, Function | MediumTest | Le
*/
HWTEST_F(ActsVideoPlayerTest, Test_GetCurrentTime05, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -675,7 +685,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_GetCurrentTime05, Function | MediumTest | Lev
*/
HWTEST_F(ActsVideoPlayerTest, Test_GetCurrentTime06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -701,7 +711,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_GetCurrentTime06, Function | MediumTest | Lev
*/
HWTEST_F(ActsVideoPlayerTest, Test_GetDuration03, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -729,7 +739,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_GetDuration03, Function | MediumTest | Level0
*/
HWTEST_F(ActsVideoPlayerTest, Test_GetDuration04, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -755,7 +765,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_GetDuration04, Function | MediumTest | Level0
*/
HWTEST_F(ActsVideoPlayerTest, Test_GetDuration05, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -776,7 +786,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_GetDuration05, Function | MediumTest | Level0
*/
HWTEST_F(ActsVideoPlayerTest, Test_GetVideoSurfaceSize01, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -805,7 +815,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_GetVideoSurfaceSize01, Function | MediumTest
*/
HWTEST_F(ActsVideoPlayerTest, Test_Reset03, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -830,7 +840,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Reset03, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Reset04, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -850,7 +860,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Reset04, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Release03, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -870,7 +880,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Release03, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Release04, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -895,7 +905,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Release04, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Play07, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -922,7 +932,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Play07, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Play08, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -952,7 +962,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Play08, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Pause06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......@@ -972,7 +982,7 @@ HWTEST_F(ActsVideoPlayerTest, Test_Pause06, Function | MediumTest | Level0)
*/
HWTEST_F(ActsVideoPlayerTest, Test_Prepare06, Function | MediumTest | Level0)
{
int32_t ret = FileCheck(g_videoFileName);
int32_t ret = FileCheckVideo(g_videoFileName);
EXPECT_EQ(HI_SUCCESS, ret);
ret = CreateAndSetVideoSource();
EXPECT_EQ(HI_SUCCESS, ret);
......
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
......@@ -35,20 +35,20 @@ const int32_t FrameErrCode = -1; // frame error code
const int32_t RecoderSourceMaxCount = 4; // max recorder source setting
const int32_t FdNull = -1; // fd is null
/* *
/**
* get current dir
* @return string - current file path of the test suits
*/
std::string GetCurDir();
/* *
/**
* check if file exist
* @param filename filename
* @return check result RET_OK or RET_ERR
*/
int32_t FileCheck(const char *filename);
/* *
/**
* Save Capture picture
* @param p char ptr
* @param size char size
......@@ -56,10 +56,26 @@ int32_t FileCheck(const char *filename);
*/
int32_t SampleSaveCapture(std::string g_testPath, const char *p, uint32_t size);
/* *
/**
* get recorder fd
* @return fd
*/
int32_t SampleGetRecordFd(std::string &recordFilePath);
/**
* get file size
* @return size_t file size
*/
std::size_t fileSize(const char* filePath);
/**
* write file
*/
void writeFile(unsigned char* buffer, std::size_t size, const char* filePath);
/**
* read file
*/
void readFile(unsigned char* buffer, std::size_t size, const char* filePath);
#endif // XTS_ACTS_MEDIA_TEST_UTILS_H
\ No newline at end of file
......@@ -101,3 +101,46 @@ int32_t SampleGetRecordFd(string &recordFilePath)
}
return fd;
}
/**
* get file size
* @return size_t file size
*/
std::size_t fileSize(const char* filePath) {
FILE* fin = fopen(filePath, "r");
if (fin == nullptr) {
std::cout<<"open "<<filePath<<" fail"<<std::endl;
exit(0);
}
fseek(fin, 0L, SEEK_END);
std::size_t fileSize = ftell(fin);
fclose(fin);
return fileSize;
}
/**
* write file
*/
void writeFile(unsigned char* buffer, std::size_t size, const char* filePath) {
FILE* fout = fopen(filePath,"wb");
if (fout == nullptr) {
std::cout<<"open "<<filePath<<" fail"<<std::endl;
return;
}
fwrite(buffer, sizeof(unsigned char), size, fout);
}
/**
* read file
*/
void readFile(unsigned char* buffer, std::size_t size, const char* filePath) {
FILE* fin = fopen(filePath, "rb");
if (fin == nullptr) {
std::cout<<"open "<<filePath<<" fail"<<std::endl;
return;
}
fread(buffer, sizeof(unsigned char), size, fin);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册