提交 971b4768 编写于 作者: O openharmony_ci 提交者: Gitee

!893 【媒体子系统】解决3516 recorder用例失败

Merge pull request !893 from apperception/master
......@@ -15,11 +15,19 @@ import("//test/xts/tools/lite/build/suite_lite.gni")
hcpptest_suite("ActsMediaRecorderTest") {
suite_name = "acts"
sources = [ "src/testcase/ActsMediaRecorderNDKTest.cpp" ]
sources = [ "src/ActsMediaRecorderTest.cpp" ]
include_dirs = [
"src/include",
"src",
"//test/xts/acts/multimedia_lite/utils_posix/common/include",
"//third_party/bounds_checking_function/include",
"//drivers/peripheral/codec/interfaces/include",
"//foundation/multimedia/utils/lite/hals",
"//foundation/multimedia/media_lite/test/unittest/recorder_lite",
"//foundation/multimedia/media_lite/interfaces/kits/recorder_lite",
"//foundation/multimedia/media_lite/frameworks/recorder_lite",
"//foundation/multimedia/media_lite/frameworks/recorder_lite/recoder_sink/include",
"//foundation/multimedia/media_lite/frameworks/recorder_lite/recoder_source/include",
]
deps = [
......
/*
* 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 RECORDER_LITE_TEST_H
#define RECORDER_LITE_TEST_H
#include "gtest/gtest.h"
#include "recorder.h"
using OHOS::Media::RecorderCallback;
namespace OHOS {
class RecoderLiteTest : public testing::Test {
public:
// SetUpTestCase: before all testcasee
static void SetUpTestCase(void);
// TearDownTestCase: after all testcase
static void TearDownTestCase(void);
// SetUp
void SetUp(void);
// TearDown
void TearDown(void);
void OnError(const int32_t errorType, const int32_t errorCode);
void OnInfo(const int32_t type, const int32_t extra);
};
namespace Media {
class TestVideoRecorderCallback : public RecorderCallback {
public:
void OnError(int32_t errorType, int32_t errorCode);
void OnInfo(int32_t type, int32_t extra);
};
}
}
#endif // RECORDER_LITE_TEST_H
/*
* 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 ACTS_MEDIA_RECODER_TEST_H
#define ACTS_MEDIA_RECODER_TEST_H
#include <unistd.h>
#include "recorder.h"
#include "gtest/gtest.h"
#include "camera_kit.h"
#include "TestCaseParse.h"
#include "ActsTestMediaUtils.h"
#define TESTCASECOUNT 38
const string g_testPath;
const string g_recordFilePath;
static int32_t g_fdNull = -1; // fd is null
static int32_t g_sleepTime = 1;
using namespace std;
using namespace OHOS;
using namespace OHOS::Media;
using namespace testing::ext;
/* *
* creat camera device callback
*/
class SampleCameraDeviceCallback : public CameraDeviceCallback {
public:
SampleCameraDeviceCallback()
{
cout << "camera device call back created" << endl;
}
~SampleCameraDeviceCallback()
{
cout << "camera device call back destroyed" << endl;
}
/* *
* camera statu changed
*/
void OnCameraStatus(std::string cameraId, int32_t status) override;
};
/* *
* create FrameStateCallback
*/
class SampleFrameStateCallback : public FrameStateCallback {
void OnFrameFinished(Camera &camera, FrameConfig &fc, FrameResult &result) override;
void OnFrameError(Camera &camera, FrameConfig &frameConfig, int32_t errorCode, FrameResult &frameResult) override;
};
/* *
* create CameraStateCallback
*/
class SampleCameraStateMng : public CameraStateCallback {
public:
SampleCameraStateMng() = delete;
SampleCameraStateMng(EventHandler &eventHandler) : eventHandler(eventHandler) {}
~SampleCameraStateMng()
{
CloseRecorder();
if (cam_ != nullptr) {
cam_->Release();
}
}
// close Recorder
void CloseRecorder();
// 相机创建成功
void OnCreated(Camera &c) override;
// 相机创建失败
void OnCreateFailed(const std::string cameraId, int32_t errorCode) override
{
cout << "CameraStateCallback OnCreateFailed\n" << endl;
}
void OnReleased(Camera &c) override
{
cout << "CameraStateCallback OnReleased\n" << endl;
}
void OnConfigured(Camera &c) override
{
cout << "CameraStateCallback OnConfigured\n" << endl;
}
void OnConfigureFailed(const std::string cameraId, int32_t errorCode) override
{
cout << "CameraStateCallback OnConfigureFailed\n" << endl;
}
// 创建Reorder
int32_t SampleCreateRecorder(TestCase &ft);
// 准备录像
int32_t PrepareRecorder();
// 开始录像
int32_t StartRecord();
/* *
* 开始预览
*/
int32_t StartPreview();
/* *
* 拍照,并保存文件
*/
int32_t Capture();
/* *
* 停止录像
*/
int32_t Stop();
private:
enum State : int32_t {
STATE_IDLE,
STATE_RUNNING,
STATE_BUTT
};
State previewState_ = STATE_IDLE;
State recordState_ = STATE_IDLE;
EventHandler &eventHandler;
Recorder *recorder_ = nullptr;
Camera *cam_ = nullptr;
int32_t recordFd_ = g_fdNull;
SampleFrameStateCallback fsCb_;
};
/* *
* Media Recorder test
*/
class ActsMediaRecorderTest : public testing::Test {
public:
/* *
* @tc.setup:This is before test class
*/
static void SetUpTestCase(void);
/* *
* @tc.setup:This is after test class
*/
static void TearDownTestCase(void);
/* *
* @tc.setup:This is before test case
*/
virtual void SetUp(void);
/* *
* @tc.setup:This is after test case
*/
virtual void TearDown(void);
/* *
* Create CameraKit
*/
virtual void CreateCameraKit(void);
/* *
* release Camera
*/
virtual void ReleaseCameraKit(void);
CameraKit *cameraKit_;
string camId;
};
#endif // ACTS_MEDIA_RECODER_TEST_H
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册