提交 e56f3a64 编写于 作者: A apperception 提交者: Gitee

Signed-off-by: zhaochen <zhaochen69@huawei.com>

上级 e969a100
...@@ -23,6 +23,9 @@ hcpptest_suite("ActsMediaCameraTest") { ...@@ -23,6 +23,9 @@ hcpptest_suite("ActsMediaCameraTest") {
include_dirs = [ include_dirs = [
"src", "src",
"//test/xts/acts/multimedia_lite/utils_posix/common/include", "//test/xts/acts/multimedia_lite/utils_posix/common/include",
"//foundation/multimedia/camera_lite/interfaces/kits",
"//foundation/multimedia/media_lite/interfaces/kits/recorder_lite",
"//foundation/multimedia/camera_lite/test/unittest",
] ]
ldflags = [ "-lstdc++" ] ldflags = [ "-lstdc++" ]
ldflags += [ "-lm" ] ldflags += [ "-lm" ]
...@@ -32,6 +35,8 @@ hcpptest_suite("ActsMediaCameraTest") { ...@@ -32,6 +35,8 @@ hcpptest_suite("ActsMediaCameraTest") {
ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ] ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ]
deps = [ deps = [
"//foundation/graphic/surface:lite_surface",
"//foundation/graphic/ui:lite_ui",
"//foundation/multimedia/camera_lite/frameworks:camera_lite", "//foundation/multimedia/camera_lite/frameworks:camera_lite",
"//foundation/multimedia/media_lite/frameworks/recorder_lite:recorder_lite", "//foundation/multimedia/media_lite/frameworks/recorder_lite:recorder_lite",
] ]
......
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (C) 2020-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");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -14,58 +14,123 @@ ...@@ -14,58 +14,123 @@
*/ */
#include "ActsMediaCameraTest.h" #include "ActsMediaCameraTest.h"
#include "ActsTestMediaUtils.h"
#include <components/ui_surface_view.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include "camera_kit.h"
using namespace std; using namespace std;
using namespace OHOS; using namespace OHOS;
using namespace OHOS::Media; using namespace OHOS::Media;
using namespace testing::ext; using namespace testing::ext;
namespace OHOS {
/* *
* get current dir
* @return string current file path of the test suits
*/
string GetCurDir()
{
string filePath = "";
char *buffer;
if ((buffer = getcwd(NULL, 0)) == NULL) {
perror("get file path error");
} else {
printf("Current Dir: %s\r\n", buffer);
filePath = buffer;
free(buffer);
}
return filePath + "/";
}
// SetUpTestCase // SetUpTestCase
void ActsMediaCameraTest::SetUpTestCase(void) void CameraLiteTest::SetUpTestCase(void)
{ {
g_testPath = GetCurDir(); g_testPath = GetCurDir();
cout << "SetUpTestCase" << endl; cout << "SetUpTestCase" << endl;
} }
// TearDownTestCase // TearDownTestCase
void ActsMediaCameraTest::TearDownTestCase(void) void CameraLiteTest::TearDownTestCase(void)
{ {
g_testPath = ""; g_testPath = "";
cout << "TearDownTestCase" << endl; cout << "TearDownTestCase" << endl;
} }
void ActsMediaCameraTest::SetUp(void) void CameraLiteTest::SetUp(void)
{ {
// CameraSetUp // CameraSetUp
CameraFlag::g_onGetCameraAbilityFlag = FLAG0; g_onGetCameraAbilityFlag = false;
CameraFlag::g_onConfigureFlag = FLAG0; g_onConfigureFlag = false;
CameraFlag::g_onGetSupportedSizesFlag = FLAG0; g_onGetSupportedSizesFlag = false;
// CameraDeviceCallBack // CameraDeviceCallBack
CameraFlag::g_onCameraAvailableFlag = FLAG0; g_onCameraAvailableFlag = false;
CameraFlag::g_onCameraUnavailableFlag = FLAG0; g_onCameraUnavailableFlag = false;
// CameraStateCallback // CameraStateCallback
CameraFlag::g_onCreatedFlag = FLAG0; g_onCreatedFlag = false;
CameraFlag::g_onCreateFailedFlag = FLAG0; g_onCreateFailedFlag = false;
CameraFlag::g_onConfiguredFlag = FLAG0; g_onConfiguredFlag = false;
CameraFlag::g_onConfigureFailedFlag = FLAG0; g_onConfigureFailedFlag = false;
CameraFlag::g_onReleasedFlag = FLAG0; g_onReleasedFlag = false;
// FrameStateCallback // FrameStateCallback
CameraFlag::g_onCaptureTriggerAbortedFlag = FLAG0; g_onCaptureTriggerAbortedFlag = false;
CameraFlag::g_onCaptureTriggerCompletedFlag = FLAG0; g_onCaptureTriggerCompletedFlag = false;
CameraFlag::g_onCaptureTriggerStartedFlag = FLAG0; g_onCaptureTriggerStartedFlag = false;
CameraFlag::g_onFrameFinishedFlag = FLAG0; g_onFrameFinishedFlag = false;
CameraFlag::g_onGetFrameConfigureType = FLAG0; g_onGetFrameConfigureType = false;
CameraFlag::g_onFrameErrorFlag = FLAG0; g_onFrameErrorFlag = false;
CameraFlag::g_onFrameProgressedFlag = FLAG0; g_onFrameProgressedFlag = false;
CameraFlag::g_onFrameStartedFlag = FLAG0; g_onFrameStartedFlag = false;
g_onRecorderFlag = false;
cout << "SetUp" << endl; cout << "SetUp" << endl;
} }
// Tear down // Tear down
void ActsMediaCameraTest::TearDown(void) void CameraLiteTest::TearDown(void) { cout << "TearDown." << endl; }
int32_t SetupAudioSource(const Recorder &rec)
{ {
cout << "TearDown." << endl; Recorder *recorder = (Recorder *)&rec;
int32_t ret = SUCCESS;
int32_t audioSourceId = 0;
AudioCodecFormat audioFormat = AAC_LC;
AudioSourceType inputSource = AUDIO_MIC;
int32_t sampleRate = 48000;
int32_t channelCount = 1;
int32_t audioEncodingBitRate = sampleRate;
if ((ret = recorder->SetAudioSource(inputSource, audioSourceId)) != SUCCESS) {
cout << "SetAudioSource failed." << ret << endl;
return FAIL;
}
if ((ret = recorder->SetAudioEncoder(audioSourceId, audioFormat)) != SUCCESS) {
cout << "SetAudioEncoder failed." << ret << endl;
return FAIL;
}
if ((ret = recorder->SetAudioSampleRate(audioSourceId, sampleRate)) != SUCCESS) {
cout << "SetAudioSampleRate failed." << ret << endl;
return FAIL;
}
if ((ret = recorder->SetAudioChannels(audioSourceId, channelCount)) != SUCCESS) {
cout << "SetAudioChannels failed." << ret << endl;
return FAIL;
}
if ((ret = recorder->SetAudioEncodingBitRate(audioSourceId, audioEncodingBitRate)) != SUCCESS) {
cout << "SetAudioEncodingBitRate failed." << ret << endl;
return FAIL;
}
return SUCCESS;
} }
/* * /* *
...@@ -74,25 +139,17 @@ void ActsMediaCameraTest::TearDown(void) ...@@ -74,25 +139,17 @@ void ActsMediaCameraTest::TearDown(void)
Recorder *SampleCreateRecorder() Recorder *SampleCreateRecorder()
{ {
int ret = 0; int ret = 0;
int32_t sampleRate = 48000;
int32_t channelCount = 1;
AudioCodecFormat audioFormat = AAC_LC;
AudioSourceType inputSource = AUDIO_MIC;
int32_t audioEncodingBitRate = sampleRate;
VideoSourceType source = VIDEO_SOURCE_SURFACE_ES; VideoSourceType source = VIDEO_SOURCE_SURFACE_ES;
int32_t frameRate = 30; int32_t frameRate = 30;
double fps = 30; double fps = 30;
int32_t rate = 4096; int32_t rate = 4096;
int32_t sourceId = 0; int32_t sourceId = 0;
int32_t audioSourceId = 0;
int32_t width = 1920; int32_t width = 1920;
int32_t height = 1080; int32_t height = 1080;
VideoCodecFormat encoder; VideoCodecFormat encoder = HEVC;
encoder = HEVC;
Recorder *recorder = new Recorder(); Recorder *recorder = new Recorder();
if ((ret = recorder->SetVideoSource(source, sourceId)) != SUCCESS) { if ((ret = recorder->SetVideoSource(source, sourceId)) != SUCCESS) {
cout << "SetVideoSource failed." << ret << endl; cout << "SetVideoSource failed." << ret << endl;
delete recorder;
return nullptr; return nullptr;
} }
if ((ret = recorder->SetVideoEncoder(sourceId, encoder)) != SUCCESS) { if ((ret = recorder->SetVideoEncoder(sourceId, encoder)) != SUCCESS) {
...@@ -120,28 +177,7 @@ Recorder *SampleCreateRecorder() ...@@ -120,28 +177,7 @@ Recorder *SampleCreateRecorder()
delete recorder; delete recorder;
return nullptr; return nullptr;
} }
if ((ret = recorder->SetAudioSource(inputSource, audioSourceId)) != SUCCESS) { if ((ret = SetupAudioSource(*recorder) != SUCCESS)) {
cout << "SetAudioSource failed." << ret << endl;
delete recorder;
return nullptr;
}
if ((ret = recorder->SetAudioEncoder(audioSourceId, audioFormat)) != SUCCESS) {
cout << "SetAudioEncoder failed." << ret << endl;
delete recorder;
return nullptr;
}
if ((ret = recorder->SetAudioSampleRate(audioSourceId, sampleRate)) != SUCCESS) {
cout << "SetAudioSampleRate failed." << ret << endl;
delete recorder;
return nullptr;
}
if ((ret = recorder->SetAudioChannels(audioSourceId, channelCount)) != SUCCESS) {
cout << "SetAudioChannels failed." << ret << endl;
delete recorder;
return nullptr;
}
if ((ret = recorder->SetAudioEncodingBitRate(audioSourceId, audioEncodingBitRate)) != SUCCESS) {
cout << "SetAudioEncodingBitRate failed." << ret << endl;
delete recorder; delete recorder;
return nullptr; return nullptr;
} }
...@@ -152,13 +188,63 @@ Recorder *SampleCreateRecorder() ...@@ -152,13 +188,63 @@ Recorder *SampleCreateRecorder()
* Create Frame StateCallback * Create Frame StateCallback
*/ */
class SampleFrameStateCallback : public FrameStateCallback { class SampleFrameStateCallback : public FrameStateCallback {
void OnFrameFinished(Camera &camera, FrameConfig &fc, FrameResult &result) override /* *
* check file exist
*
* @param filename the filename
* @return check result
*/
int32_t FileCheck(const string &filename)
{
fstream fileTmp;
fileTmp.open(filename);
if (!fileTmp) {
cout << "file is not exist!" << endl;
return RET_ERR;
} else {
cout << "file is exist!" << endl;
fileTmp.close();
return RET_OK;
}
}
/* *
* Save Capture
*
* @param testPath the file path
* @param buffer the buffer
* @param size the size
* @return save result
*/
int32_t SampleSaveCapture(string testPath, char *buffer, uint32_t size)
{
cout << "Start saving picture" << endl;
string filePath = "";
struct timeval tv = {0};
gettimeofday(&tv, NULL);
struct tm *ltm = localtime(&tv.tv_sec);
if (ltm != nullptr) {
ostringstream ss("Capture_");
ss << "Capture" << ltm->tm_hour << "_" << ltm->tm_min << "_" << ltm->tm_sec << ".jpg";
filePath = testPath + ss.str();
ofstream pic(testPath + ss.str(), ofstream::out | ofstream::trunc);
cout << "write " << size << " bytes" << endl;
pic.write(buffer, size);
cout << "Saving picture end" << endl;
}
const char *filename = filePath.data();
int32_t ret = FileCheck(string(filename));
return ret;
}
void OnFrameFinished(Camera &cam, FrameConfig &fc, FrameResult &res) override
{ {
CameraFlag::g_onFrameStartedFlag = FLAG1; g_onFrameStartedFlag = true;
CameraFlag::g_onFrameProgressedFlag = FLAG1; g_onFrameProgressedFlag = true;
cout << "Receive frame complete inform." << endl; cout << "Receive frame complete inform." << endl;
if (fc.GetFrameConfigType() == FRAME_CONFIG_CAPTURE) { if (fc.GetFrameConfigType() == FRAME_CONFIG_CAPTURE) {
CameraFlag::g_onGetFrameConfigureType = FLAG1; g_onGetFrameConfigureType = true;
cout << "Capture frame received." << endl; cout << "Capture frame received." << endl;
list<Surface *> surfaceList = fc.GetSurfaces(); list<Surface *> surfaceList = fc.GetSurfaces();
for (Surface *surface : surfaceList) { for (Surface *surface : surfaceList) {
...@@ -168,19 +254,19 @@ class SampleFrameStateCallback : public FrameStateCallback { ...@@ -168,19 +254,19 @@ class SampleFrameStateCallback : public FrameStateCallback {
if (virtAddr != nullptr) { if (virtAddr != nullptr) {
SampleSaveCapture(g_testPath, virtAddr, buffer->GetSize()); SampleSaveCapture(g_testPath, virtAddr, buffer->GetSize());
} else { } else {
CameraFlag::g_onFrameErrorFlag = FLAG1; g_onFrameErrorFlag = true;
} }
surface->ReleaseBuffer(buffer); surface->ReleaseBuffer(buffer);
} else { } else {
CameraFlag::g_onFrameErrorFlag = FLAG1; g_onFrameErrorFlag = true;
} }
delete surface; delete surface;
} }
delete &fc; delete &fc;
} else { } else {
CameraFlag::g_onFrameErrorFlag = FLAG1; g_onFrameErrorFlag = true;
} }
CameraFlag::g_onFrameFinishedFlag = FLAG1; g_onFrameFinishedFlag = true;
} }
}; };
...@@ -197,7 +283,6 @@ public: ...@@ -197,7 +283,6 @@ public:
{ {
if (recorder_ != nullptr) { if (recorder_ != nullptr) {
recorder_->Release(); recorder_->Release();
delete recorder_;
} }
if (cam_ != nullptr) { if (cam_ != nullptr) {
cam_->Release(); cam_->Release();
...@@ -206,24 +291,25 @@ public: ...@@ -206,24 +291,25 @@ public:
void OnCreated(Camera &c) override void OnCreated(Camera &c) override
{ {
CameraFlag::g_onCreatedFlag = FLAG1; g_onCreatedFlag = true;
cout << "Sample recv OnCreate camera." << endl; cout << "Sample recv OnCreate camera." << endl;
auto config = CameraConfig::CreateCameraConfig(); auto config = CameraConfig::CreateCameraConfig();
config->SetFrameStateCallback(&fsCb_, &eventHandler_); config->SetFrameStateCallback(&fsCb, &eventHandler_);
c.Configure(*config); c.Configure(*config);
CameraFlag::g_onConfigureFlag = FLAG1; g_onConfigureFlag = true;
cam_ = &c; cam_ = &c;
} }
void OnCreateFailed(const std::string cameraId, int32_t errorCode) override void OnCreateFailed(const std::string cameraId, int32_t errorCode) override
{ {
CameraFlag::g_onCreateFailedFlag = FLAG1; g_onCreateFailedFlag = true;
cout << "Sample recv OnCreateFailed camera." << endl; cout << "Camera ID: " << cameraId << endl;
cout << "Sample recv OnCreateFailed camera.: " << errorCode << endl;
} }
void OnReleased(Camera &c) override void OnReleased(Camera &c) override
{ {
CameraFlag::g_onReleasedFlag = FLAG1; g_onReleasedFlag = true;
cout << "Sample recv OnReleased camera." << endl; cout << "Sample recv OnReleased camera." << endl;
} }
...@@ -234,9 +320,10 @@ public: ...@@ -234,9 +320,10 @@ public:
cout << "Camera is already recording." << endl; cout << "Camera is already recording." << endl;
return; return;
} }
if (recorder_ == nullptr) { if (recorder_ != nullptr) {
recorder_ = SampleCreateRecorder(); cout << "Recorder is not null" << endl;
} }
recorder_ = SampleCreateRecorder();
if (recorder_ == nullptr) { if (recorder_ == nullptr) {
cout << "Recorder not available" << endl; cout << "Recorder not available" << endl;
return; return;
...@@ -253,7 +340,7 @@ public: ...@@ -253,7 +340,7 @@ public:
cout << "Prepare failed.=" << ret << endl; cout << "Prepare failed.=" << ret << endl;
return; return;
} }
Surface *surface = (recorder_->GetSurface(0)).get(); auto surface = recorder_->GetSurface(0);
surface->SetWidthAndHeight(WIDTH, HEIGHT); surface->SetWidthAndHeight(WIDTH, HEIGHT);
surface->SetQueueSize(QUEUE_SIZE); surface->SetQueueSize(QUEUE_SIZE);
surface->SetSize(BUFFER_SIZE * BUFFER_SIZE); surface->SetSize(BUFFER_SIZE * BUFFER_SIZE);
...@@ -261,8 +348,8 @@ public: ...@@ -261,8 +348,8 @@ public:
fc->AddSurface(*surface); fc->AddSurface(*surface);
ret = recorder_->Start(); ret = recorder_->Start();
if (ret != SUCCESS) { if (ret != SUCCESS) {
delete fc;
cout << "recorder start failed. ret=" << ret << endl; cout << "recorder start failed. ret=" << ret << endl;
delete fc;
return; return;
} }
static int cnt = 3; static int cnt = 3;
...@@ -275,11 +362,11 @@ public: ...@@ -275,11 +362,11 @@ public:
ret = cam_->TriggerLoopingCapture(*fc); ret = cam_->TriggerLoopingCapture(*fc);
if (ret != 0) { if (ret != 0) {
delete fc;
cout << "camera start recording failed. ret=" << ret << endl; cout << "camera start recording failed. ret=" << ret << endl;
return; return;
} }
isRecording_ = true; isRecording_ = true;
g_onRecorderFlag = true;
cout << "camera start recording succeed." << endl; cout << "camera start recording succeed." << endl;
} }
...@@ -290,18 +377,17 @@ public: ...@@ -290,18 +377,17 @@ public:
return; return;
} }
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_PREVIEW); FrameConfig *fc = new FrameConfig(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface(); UISurfaceView *surface = new UISurfaceView();
int width = 960;
int height = 480;
surface->SetPosition(0, 0, width, height);
surface->GetSurface()->SetWidthAndHeight(WIDTH, HEIGHT);
if (surface == nullptr) { if (surface == nullptr) {
delete fc;
cout << "CreateSurface failed" << endl; cout << "CreateSurface failed" << endl;
delete fc;
return; return;
} }
surface->SetWidthAndHeight(WIDTH, HEIGHT); fc->AddSurface(*(surface->GetSurface()));
surface->SetUserData("region_position_x", "0");
surface->SetUserData("region_position_y", "0");
surface->SetUserData("region_width", "480");
surface->SetUserData("region_height", "480");
fc->AddSurface(*surface);
static int cnt = 3; static int cnt = 3;
while (cam_ == nullptr) { while (cam_ == nullptr) {
if (cnt-- < 0) if (cnt-- < 0)
...@@ -311,26 +397,25 @@ public: ...@@ -311,26 +397,25 @@ public:
} }
int32_t ret = cam_->TriggerLoopingCapture(*fc); int32_t ret = cam_->TriggerLoopingCapture(*fc);
if (ret != 0) { if (ret != 0) {
delete fc;
cout << "camera start preview failed. ret=" << ret << endl; cout << "camera start preview failed. ret=" << ret << endl;
delete fc;
return; return;
} }
CameraFlag::g_onCaptureTriggerCompletedFlag = FLAG1;
delete surface;
isPreviewing_ = true; isPreviewing_ = true;
g_onPreviewFlag = true;
cout << "camera start preview succeed." << endl; cout << "camera start preview succeed." << endl;
} }
void Capture() void Capture(void)
{ {
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE); FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface(); Surface *surface = Surface::CreateSurface();
if (surface == nullptr) { if (surface == nullptr) {
delete fc;
cout << "CreateSurface failed" << endl; cout << "CreateSurface failed" << endl;
delete fc;
return; return;
} }
surface->SetWidthAndHeight(1920, 1080); /* 1920:width,1080:height */ surface->SetWidthAndHeight(WIDTH, HEIGHT);
fc->AddSurface(*surface); fc->AddSurface(*surface);
static int cnt = 3; static int cnt = 3;
while (cam_ == nullptr) { while (cam_ == nullptr) {
...@@ -339,15 +424,18 @@ public: ...@@ -339,15 +424,18 @@ public:
cout << "Wait camera created success" << endl; cout << "Wait camera created success" << endl;
sleep(1); sleep(1);
} }
CameraFlag::g_onCaptureTriggerStartedFlag = FLAG1; g_onCaptureTriggerStartedFlag = true;
cam_->TriggerSingleCapture(*fc); cam_->TriggerSingleCapture(*fc);
CameraFlag::g_onCaptureTriggerCompletedFlag = FLAG1; g_onCaptureTriggerCompletedFlag = true;
} }
void Stop() void Stop()
{ {
if (recorder_ != nullptr) { if (recorder_ != nullptr) {
recorder_->Stop(false); int32_t ret = recorder_->Stop(true);
if (ret != 0) {
cout << "recorder_ stop failed. ret=" << ret << endl;
}
} }
while (cam_ == nullptr) { while (cam_ == nullptr) {
...@@ -357,6 +445,8 @@ public: ...@@ -357,6 +445,8 @@ public:
cam_->StopLoopingCapture(); cam_->StopLoopingCapture();
isPreviewing_ = false; isPreviewing_ = false;
isRecording_ = false; isRecording_ = false;
g_onRecorderFlag = false;
g_onPreviewFlag = false;
} }
bool isPreviewing_ = false; bool isPreviewing_ = false;
...@@ -364,7 +454,7 @@ public: ...@@ -364,7 +454,7 @@ public:
EventHandler &eventHandler_; EventHandler &eventHandler_;
Camera *cam_ = nullptr; Camera *cam_ = nullptr;
Recorder *recorder_ = nullptr; Recorder *recorder_ = nullptr;
SampleFrameStateCallback fsCb_; SampleFrameStateCallback fsCb;
}; };
/* * /* *
...@@ -385,41 +475,43 @@ public: ...@@ -385,41 +475,43 @@ public:
void OnCreated(Camera &c) override void OnCreated(Camera &c) override
{ {
CameraFlag::g_onCreatedFlag = FLAG1; g_onCreatedFlag = true;
cout << "camera Create success." << endl; cout << "camera Create success." << endl;
auto config = CameraConfig::CreateCameraConfig(); auto config = CameraConfig::CreateCameraConfig();
config->SetFrameStateCallback(&fsCb_, &eventHandler_); config->SetFrameStateCallback(&fsCb, &eventHandler_);
c.Configure(*config); c.Configure(*config);
cam_ = &c; cam_ = &c;
} }
void OnCreateFailed(const std::string cameraId, int32_t errorCode) override void OnCreateFailed(const std::string cameraId, int32_t errorCode) override
{ {
CameraFlag::g_onCreateFailedFlag = FLAG1; g_onCreateFailedFlag = true;
cout << "Camera Create Failed." << endl; cout << "Camera ID: " << cameraId << endl;
cout << "Camera Create Failed: " << errorCode << endl;
} }
void OnReleased(Camera &c) override void OnReleased(Camera &c) override
{ {
CameraFlag::g_onReleasedFlag = FLAG1; g_onReleasedFlag = true;
cout << "camera Releasedsuccess." << endl; cout << "camera Releasedsuccess." << endl;
} }
void OnConfigured(Camera &c) override void OnConfigured(Camera &c) override
{ {
CameraFlag::g_onConfiguredFlag = FLAG1; g_onConfiguredFlag = true;
cout << "Camera Configured success." << endl; cout << "Camera Configured success." << endl;
} }
void OnConfigureFailed(const std::string cameraId, int32_t errorCode) override void OnConfigureFailed(const std::string cameraId, int32_t errorCode) override
{ {
CameraFlag::g_onConfigureFailedFlag = FLAG1; g_onConfigureFailedFlag = true;
cout << "Camera Configured failed." << endl; cout << "Camera ID: " << cameraId << endl;
cout << "Camera Configured failed: " << errorCode << endl;
} }
EventHandler &eventHandler_; EventHandler &eventHandler_;
Camera *cam_ = nullptr; Camera *cam_ = nullptr;
SampleFrameStateCallback fsCb_; SampleFrameStateCallback fsCb;
}; };
/* * /* *
...@@ -434,12 +526,12 @@ public: ...@@ -434,12 +526,12 @@ public:
// camera device status changed // camera device status changed
void OnCameraStatus(std::string cameraId, int32_t status) override void OnCameraStatus(std::string cameraId, int32_t status) override
{ {
cout << "SampleCameraDeviceCallback OnCameraStatus\n" << endl; cout << "SampleCameraDeviceCallback OnCameraStatus cam Id: \n" << cameraId << endl;
if (status == CAMERA_DEVICE_STATE_AVAILABLE) { if (status == CAMERA_DEVICE_STATE_AVAILABLE) {
CameraFlag::g_onCameraAvailableFlag = FLAG1; g_onCameraAvailableFlag = true;
cout << "SampleCameraDeviceCallback onCameraAvailable\n" << endl; cout << "SampleCameraDeviceCallback onCameraAvailable\n" << endl;
} else if (status == CAMERA_DEVICE_STATE_UNAVAILABLE) { } else if (status == CAMERA_DEVICE_STATE_UNAVAILABLE) {
CameraFlag::g_onCameraUnavailableFlag = FLAG1; g_onCameraUnavailableFlag = true;
cout << "SampleCameraDeviceCallback onCameraUnavailable\n" << endl; cout << "SampleCameraDeviceCallback onCameraUnavailable\n" << endl;
} }
} }
...@@ -448,498 +540,1656 @@ public: ...@@ -448,498 +540,1656 @@ public:
/* * /* *
* Get camera Id * Get camera Id
*/ */
void GetCameraId(CameraKit *cameraKit, list<string> &camList, string &camId) void GetCameraId(CameraKit *cameraKit, list<string> &cameraList, string &cameraId)
{ {
cameraKit = CameraKit::GetInstance(); cameraKit = CameraKit::GetInstance();
camList = cameraKit->GetCameraIds(); cameraList = cameraKit->GetCameraIds();
for (auto &cam : camList) { for (auto &cam : cameraList) {
cout << "camera name:" << cam << endl; cout << "camera name:" << cam << endl;
const CameraAbility *ability = cameraKit->GetCameraAbility(cam); const CameraAbility *ability = cameraKit->GetCameraAbility(cam);
ASSERT_NE(ability, nullptr); g_onGetCameraAbilityFlag = true;
CameraFlag::g_onGetCameraAbilityFlag = FLAG1;
/* find camera which fits user's ability */ /* find camera which fits user's ability */
list<CameraPicSize> sizeList = ability->GetSupportedSizes(0); list<CameraPicSize> sizeList = ability->GetSupportedSizes(0);
if (sizeList.size() != 0) { if (sizeList.size() != 0) {
CameraFlag::g_onGetSupportedSizesFlag = FLAG1; g_onGetSupportedSizesFlag = true;
} }
for (auto &pic : sizeList) { for (auto &pic : sizeList) {
cout << "Pic size: " << pic.width << "x" << pic.height << endl; cout << "Pic size: " << pic.width << "x" << pic.height << endl;
if (pic.width == WIDTH && pic.height == HEIGHT) { if (pic.width == WIDTH && pic.height == HEIGHT) {
/* 1920:width,1080:height */ /* 1920:width,1080:height */
camId = cam; cameraId = cam;
break; break;
} }
} }
} }
if (camId.empty()) {
if (cameraId.empty()) {
cout << "No available camera.(1080p wanted)" << endl; cout << "No available camera.(1080p wanted)" << endl;
return; return;
} }
} }
using namespace OHOS; /* start camera kit interface test */
using namespace std;
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0100 * @tc.number : SUB_MEDIA_CAMERA_DEV_0100
* @tc.name : Get cameraIDs * @tc.name : Get Instance
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, Test_GetCameraIDs, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetInstance_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
EXPECT_NE(cameraKit, nullptr);
}
HWTEST_F(CameraLiteTest, PrfTest_GetInstance_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = nullptr;
list<string> camList; struct timespec tv1 = {0};
string camId; struct timespec tv2 = {0};
EventHandler eventHdlr; int64_t performanceTestTimes = 10;
GetCameraId(cameraKit, camList, camId); int64_t usecTimes = 1000000;
EXPECT_FALSE(camId.empty()); int64_t totalTime = 0;
EXPECT_EQ("main", camId); for (int32_t i = 0; i < performanceTestTimes; i++) {
cameraKit = NULL; clock_gettime(CLOCK_REALTIME, &tv1);
cameraKit = CameraKit::GetInstance();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0200 * @tc.number : SUB_MEDIA_CAMERA_DEV_0200
* @tc.name : Get cameraAbility * @tc.name : Get cameraIDs
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, Test_GetCameraAbility, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetCameraIds_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; list<string> cameraList = cameraKit->GetCameraIds();
string camId; EXPECT_TRUE(cameraList.size() > 0);
EventHandler eventHdlr; }
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); HWTEST_F(CameraLiteTest, PrfTest_GetCameraIds_001, Level1)
EXPECT_EQ(CameraFlag::g_onGetCameraAbilityFlag, FLAG1); {
cameraKit = NULL; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> cameraList;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
cameraList = cameraKit->GetCameraIds();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0300 * @tc.number : SUB_MEDIA_CAMERA_DEV_0300
* @tc.name : CameraKit get instance * @tc.name : Get cameraAbility
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestCreatCamerakit, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetCameraAbility_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
cameraKit = CameraKit::GetInstance(); string cameraId = "0";
EXPECT_NE(nullptr, cameraKit); const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
cameraKit = NULL; EXPECT_NE(ability, nullptr);
}
HWTEST_F(CameraLiteTest, Test_GetCameraAbility_002, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string errorCameraId = "-1";
const CameraAbility *ability = cameraKit->GetCameraAbility(errorCameraId);
EXPECT_EQ(ability, nullptr);
}
HWTEST_F(CameraLiteTest, Test_GetCameraAbility_003, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string errorCameraId = "main";
const CameraAbility *ability = cameraKit->GetCameraAbility(errorCameraId);
EXPECT_EQ(ability, nullptr);
}
HWTEST_F(CameraLiteTest, PrfTest_GetCameraAbility_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
const CameraAbility *ability = nullptr;
string cameraId = "0";
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
ability = cameraKit->GetCameraAbility(cameraId);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0400 * @tc.number : SUB_MEDIA_CAMERA_DEV_0400
* @tc.name : Get cameraKit deviceCallback * @tc.name : CameraKit get Info
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestNewDeviceCallback, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetCameraInfo_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
list<string> cameraList = cameraKit->GetCameraIds();
for (auto &cameraId : cameraList) {
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(cameraId);
EXPECT_NE(cameraInfo, nullptr);
}
}
HWTEST_F(CameraLiteTest, Test_GetCameraInfo_002, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string errorCameraId = "-1";
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(errorCameraId);
EXPECT_EQ(cameraInfo, nullptr);
}
HWTEST_F(CameraLiteTest, Test_GetCameraInfo_003, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string errorCameraId = "main";
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(errorCameraId);
EXPECT_EQ(cameraInfo, nullptr);
}
HWTEST_F(CameraLiteTest, PrfTest_GetCameraInfo_001, Level1)
{ {
SampleCameraDeviceCallback *deviceCallback = nullptr; struct timespec tv1 = {0};
deviceCallback = new SampleCameraDeviceCallback(); struct timespec tv2 = {0};
EXPECT_NE(nullptr, deviceCallback); CameraKit *cameraKit = CameraKit::GetInstance();
delete deviceCallback; string cameraId = "0";
deviceCallback = nullptr; int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
cameraKit->GetCameraInfo(cameraId);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0500 * @tc.number : SUB_MEDIA_CAMERA_DEV_0500
* @tc.name : Get cameraKit supported Size * @tc.name : Register Camera device callback
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestGetSupportedSizes, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_RegisterCameraDeviceCallback_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = nullptr;
list<string> camList; list<string> cameraList;
string camId; string cameraId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); GetCameraId(cameraKit, cameraList, cameraId);
EXPECT_EQ(CameraFlag::g_onGetSupportedSizesFlag, FLAG1); SampleCameraStateMng camStateMng(eventHdlr);
cameraKit = NULL; SampleCameraDeviceCallback deviceCallback = SampleCameraDeviceCallback();
g_onCameraAvailableFlag = false;
cameraKit->RegisterCameraDeviceCallback(deviceCallback, eventHdlr);
sleep(2);
EXPECT_TRUE(g_onCameraAvailableFlag);
} }
/* * HWTEST_F(CameraLiteTest, PrfTest_RegisterCameraDeviceCallback_001, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_0600
* @tc.name : Register Camera device callback
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, Test_RegisterCameraDeviceCallback, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = nullptr;
list<string> camList; list<string> cameraList;
string camId; string cameraId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
SampleCameraDeviceCallback *deviceCallback = nullptr; SampleCameraDeviceCallback deviceCallback = SampleCameraDeviceCallback();
deviceCallback = new SampleCameraDeviceCallback(); struct timespec tv1 = {0};
ASSERT_NE(nullptr, deviceCallback); struct timespec tv2 = {0};
cameraKit->RegisterCameraDeviceCallback(*deviceCallback, eventHdlr); int64_t performanceTestTimes = 10;
sleep(1); int64_t usecTimes = 1000000;
EXPECT_EQ(CameraFlag::g_onCameraAvailableFlag, FLAG1); int64_t totalTime = 0;
delete deviceCallback; for (int32_t i = 0; i < performanceTestTimes; i++) {
deviceCallback = nullptr; clock_gettime(CLOCK_REALTIME, &tv1);
cameraKit = NULL; cameraKit->RegisterCameraDeviceCallback(deviceCallback, eventHdlr);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0700 * @tc.number : SUB_MEDIA_CAMERA_DEV_0600
* @tc.name : Unregister Camera Device Callback * @tc.name : Unregister Camera Device Callback
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, Test_UnregisterCameraDeviceCallback, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_UnregisterCameraDeviceCallback_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = nullptr;
list<string> camList; list<string> cameraList;
string camId; string cameraId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
SampleCameraDeviceCallback *deviceCallback = nullptr; SampleCameraDeviceCallback deviceCallback = SampleCameraDeviceCallback();
deviceCallback = new SampleCameraDeviceCallback(); g_onCameraAvailableFlag = false;
ASSERT_NE(nullptr, deviceCallback); cameraKit->RegisterCameraDeviceCallback(deviceCallback, eventHdlr);
cameraKit->RegisterCameraDeviceCallback(*deviceCallback, eventHdlr); sleep(2);
sleep(1); g_onCameraAvailableFlag = false;
EXPECT_EQ(CameraFlag::g_onCameraAvailableFlag, FLAG1); cameraKit->UnregisterCameraDeviceCallback(deviceCallback);
cameraKit->UnregisterCameraDeviceCallback(*deviceCallback); sleep(2);
sleep(1); EXPECT_EQ(g_onCameraAvailableFlag, false);
EXPECT_EQ(CameraFlag::g_onCameraUnavailableFlag, FLAG0);
delete deviceCallback;
deviceCallback = nullptr;
cameraKit = NULL;
} }
/* * HWTEST_F(CameraLiteTest, PrfTest_UnregisterCameraDeviceCallback_001, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_0800
* @tc.name : Capture On Configure
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestCaptureOnConfigure, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = nullptr;
list<string> camList; list<string> cameraList;
string camId; string cameraId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(1); SampleCameraDeviceCallback deviceCallback = SampleCameraDeviceCallback();
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); struct timespec tv1 = {0};
sleep(1); struct timespec tv2 = {0};
EXPECT_EQ(CameraFlag::g_onConfigureFlag, FLAG1); int64_t performanceTestTimes = 10;
EXPECT_NE(camStateMng.cam_, nullptr); int64_t usecTimes = 1000000;
cameraKit = NULL; int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
cameraKit->RegisterCameraDeviceCallback(deviceCallback, eventHdlr);
clock_gettime(CLOCK_REALTIME, &tv1);
cameraKit->UnregisterCameraDeviceCallback(deviceCallback);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_0900 * @tc.number : SUB_MEDIA_CAMERA_DEV_0700
* @tc.name : Create Camera * @tc.name : Create Camera
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestCreateCamera, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_CreateCamera_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "0";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); g_onCreatedFlag = false;
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); g_onCreateFailedFlag = false;
sleep(3); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
EXPECT_EQ(CameraFlag::g_onCreatedFlag, FLAG1); sleep(2);
EXPECT_NE(CameraFlag::g_onCreateFailedFlag, FLAG1); EXPECT_EQ(g_onCreatedFlag, true);
EXPECT_NE(camStateMng.cam_, nullptr); EXPECT_EQ(g_onCreateFailedFlag, false);
cameraKit = NULL;
} }
/* * HWTEST_F(CameraLiteTest, Test_CreateCamera_002, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_1000
* @tc.name : Create Camera with error camera id
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestCapture_Create_Camera_ERROR_cameraId, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
cameraKit = CameraKit::GetInstance(); string cameraId = "main";
string camId = "0";
EventHandler eventHdlr; EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); g_onCreatedFlag = false;
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); g_onCreateFailedFlag = false;
sleep(3); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
EXPECT_EQ(CameraFlag::g_onCreatedFlag, FLAG0); sleep(2);
EXPECT_EQ(CameraFlag::g_onCreateFailedFlag, FLAG1); EXPECT_EQ(g_onCreatedFlag, false);
cameraKit = NULL; EXPECT_EQ(g_onCreateFailedFlag, true);
} }
/* * HWTEST_F(CameraLiteTest, Test_CreateCamera_003, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_1100
* @tc.name : Test Capture Frame config
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestCapture_Frame_config, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; list<string> cameraList;
string camId; string cameraId = "0";
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); g_onCreatedFlag = false;
g_onCreateFailedFlag = false;
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(3); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE); sleep(2);
EXPECT_NE(fc, nullptr); EXPECT_EQ(g_onCreatedFlag, true);
delete fc;
cameraKit = NULL;
} }
/* * HWTEST_F(CameraLiteTest, Test_CreateCamera_004, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_1200
* @tc.name : Test Create Surface
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestCapture_Create_Surface, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "0";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); g_onCreatedFlag = false;
g_onCreateFailedFlag = false;
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); sleep(2);
sleep(3); cameraId = "-1";
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
Surface *surface = Surface::CreateSurface(); sleep(2);
if (surface == nullptr) { EXPECT_EQ(g_onCreatedFlag, true);
delete fc; EXPECT_EQ(g_onCreateFailedFlag, true);
cout << "CreateSurface failed" << endl;
}
EXPECT_NE(surface, nullptr);
delete surface;
delete fc;
cameraKit = NULL;
} }
/* * HWTEST_F(CameraLiteTest, PrfTest_CreateCamera_001, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_1300
* @tc.name : Get Surface Size
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestCapture_GetSurfaceSize, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "0";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); struct timespec tv1 = {0};
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); struct timespec tv2 = {0};
sleep(3); int64_t performanceTestTimes = 10;
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE); int64_t totalTime = 0;
Surface *surface = Surface::CreateSurface(); int64_t usecTimes = 1000000;
if (surface == nullptr) { for (int32_t i = 0; i < performanceTestTimes; i++) {
delete fc; clock_gettime(CLOCK_REALTIME, &tv1);
cout << "CreateSurface failed" << endl; cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
} }
surface->SetWidthAndHeight(1920, 1080); /* 1920:width,1080:height */ int64_t expectTime = 500000000;
EXPECT_EQ(1920, surface->GetWidth()); EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
EXPECT_EQ(1080, surface->GetHeight()); } /* end camera kit interface test */
delete surface;
delete fc;
cameraKit = NULL;
}
/* start camera ability interface test */
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1400 * @tc.number : SUB_MEDIA_CAMERA_DEV_0800
* @tc.name : Get FrameConfig size * @tc.name : Get cameraKit supported Size
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestCapture_frameConfig_getsize, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetSupportedSizes_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; list<string> cameraList = cameraKit->GetCameraIds();
string camId; for (auto &cameraId : cameraList) {
EventHandler eventHdlr; const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
GetCameraId(cameraKit, camList, camId); list<CameraPicSize> cameraPicSizes = ability->GetSupportedSizes(0);
SampleCameraStateMng camStateMng(eventHdlr); EXPECT_TRUE(cameraPicSizes.size() > 0);
sleep(3);
cameraKit->CreateCamera(camId, camStateMng, eventHdlr);
sleep(3);
FrameConfig *fc = new FrameConfig(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface();
if (surface == nullptr) {
delete fc;
cout << "CreateSurface failed" << endl;
} }
surface->SetWidthAndHeight(1920, 1080); /* 1920:width,1080:height */ }
fc->AddSurface(*surface);
EXPECT_NE(0, fc->GetSurfaces().size()); HWTEST_F(CameraLiteTest, PrfTest_GetSupportedSizes_001, Level1)
delete surface; {
delete fc; CameraKit *cameraKit = CameraKit::GetInstance();
cameraKit = NULL; string cameraId = "0";
const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
ability->GetSupportedSizes(0);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1500 * @tc.number : SUB_MEDIA_CAMERA_DEV_0900
* @tc.name : Test Get Frame * @tc.name : Get supported AfModes
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestOnFrameProgressed, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetSupportedAfModes_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; list<string> cameraList = cameraKit->GetCameraIds();
string camId; for (auto &cameraId : cameraList) {
EventHandler eventHdlr; const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
GetCameraId(cameraKit, camList, camId); list<int32_t> afModes = ability->GetSupportedAfModes();
SampleCameraStateMng camStateMng(eventHdlr); EXPECT_TRUE(afModes.size() >= 0);
sleep(3); }
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); }
sleep(3);
camStateMng.Capture(); HWTEST_F(CameraLiteTest, PrfTest_GetSupportedAfModes_001, Level1)
sleep(1); {
EXPECT_EQ(CameraFlag::g_onFrameStartedFlag, FLAG1); CameraKit *cameraKit = CameraKit::GetInstance();
EXPECT_EQ(CameraFlag::g_onFrameProgressedFlag, FLAG1); string cameraId = "0";
cameraKit = NULL; const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
ability->GetSupportedAfModes();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1600 * @tc.number : SUB_MEDIA_CAMERA_DEV_1000
* @tc.name : Get FrameConfig onConfig * @tc.name : Get supported AeModes
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestGetFrameConfigureType, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_GetSupportedAeModes_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; list<string> cameraList = cameraKit->GetCameraIds();
string camId; for (auto &cameraId : cameraList) {
EventHandler eventHdlr; const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
GetCameraId(cameraKit, camList, camId); list<int32_t> aeModes = ability->GetSupportedAeModes();
SampleCameraStateMng camStateMng(eventHdlr); EXPECT_TRUE(aeModes.size() >= 0);
sleep(3); }
cameraKit->CreateCamera(camId, camStateMng, eventHdlr);
sleep(3);
camStateMng.Capture();
sleep(1);
EXPECT_EQ(CameraFlag::g_onGetFrameConfigureType, FLAG1);
cameraKit = NULL;
} }
HWTEST_F(CameraLiteTest, PrfTest_GetSupportedAeModes_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
const CameraAbility *ability = cameraKit->GetCameraAbility(cameraId);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t totalTime = 0;
int64_t usecTimes = 1000000;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
ability->GetSupportedAeModes();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} /* end camera ability interface test*/
/* start camera state callback test */
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1700 * @tc.number : SUB_MEDIA_CAMERA_DEV_1100
* @tc.name : Test Get Frame finished * @tc.name : On Create
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestFrameCompletedFlag, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_OnCreate_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "0";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); g_onCreatedFlag = false;
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); g_onCreateFailedFlag = false;
sleep(3); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
camStateMng.Capture(); sleep(2);
sleep(1); EXPECT_EQ(g_onCreatedFlag, true);
EXPECT_EQ(CameraFlag::g_onFrameFinishedFlag, FLAG1); EXPECT_EQ(g_onCreateFailedFlag, false);
cameraKit = NULL;
} }
/* * HWTEST_F(CameraLiteTest, Test_OnCreate_002, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_1800
* @tc.name : Test GetFrame Error
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestonFrameErrorFlag, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "0";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); g_onCreatedFlag = false;
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); g_onCreateFailedFlag = false;
sleep(3); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
camStateMng.Capture(); sleep(2);
sleep(1); camStateMng.Stop();
EXPECT_NE(CameraFlag::g_onFrameErrorFlag, FLAG1); EXPECT_EQ(g_onCreatedFlag, true);
cameraKit = NULL; EXPECT_NE(g_onCreateFailedFlag, true);
} }
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1900 * @tc.number : SUB_MEDIA_CAMERA_DEV_1200
* @tc.name : Test Capture Success * @tc.name : On Create Failed
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestCapture01, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_OnCreateFailed_001, Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "-1";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); g_onCreateFailedFlag = false;
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(3); sleep(2);
camStateMng.Capture(); EXPECT_EQ(g_onCreateFailedFlag, true);
sleep(1);
EXPECT_EQ(CameraFlag::g_onCaptureTriggerStartedFlag, FLAG1);
EXPECT_EQ(CameraFlag::g_onCaptureTriggerCompletedFlag, FLAG1);
cameraKit = NULL;
} }
/* * HWTEST_F(CameraLiteTest, Test_OnCreateFailed_002, Level1)
* @tc.number : SUB_MEDIA_CAMERA_DEV_2000
* @tc.name : Test capture and record
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsMediaCameraTest, TestRecord01, Function | MediumTest | Level1)
{ {
CameraKit *cameraKit = nullptr; CameraKit *cameraKit = CameraKit::GetInstance();
list<string> camList; string cameraId = "main";
string camId;
EventHandler eventHdlr; EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId);
SampleCameraStateMng camStateMng(eventHdlr); SampleCameraStateMng camStateMng(eventHdlr);
sleep(3); g_onCreateFailedFlag = false;
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(3); sleep(2);
EXPECT_EQ(CameraFlag::g_onCreatedFlag, FLAG1); EXPECT_EQ(g_onCreateFailedFlag, true);
EXPECT_EQ(CameraFlag::g_onConfigureFlag, FLAG1); } /* end camera state callback test */
camStateMng.Capture();
sleep(3);
camStateMng.StartRecord();
sleep(3);
camStateMng.Stop();
cameraKit = NULL;
}
/* start frame config & frame state call back interface test */
/* * /* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2100 * @tc.number : SUB_MEDIA_CAMERA_DEV_1300
* @tc.name : Test get event handler * @tc.name : Frame Config
* @tc.desc : [C- SOFTWARE -0200] * @tc.desc : [C- SOFTWARE -0200]
*/ */
HWTEST_F(ActsMediaCameraTest, TestGetEventHandler, Function | MediumTest | Level1) HWTEST_F(CameraLiteTest, Test_FrameConfig_001, Level1)
{ {
CameraKit *cameraKit = nullptr; shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
list<string> camList; EXPECT_NE(frameConfig.get(), nullptr);
string camId; }
EventHandler eventHdlr;
GetCameraId(cameraKit, camList, camId); HWTEST_F(CameraLiteTest, Test_FrameConfig_002, Level1)
SampleCameraStateMng camStateMng(eventHdlr); {
sleep(3); shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
cameraKit->CreateCamera(camId, camStateMng, eventHdlr); EXPECT_NE(frameConfig.get(), nullptr);
sleep(3); }
EXPECT_EQ(CameraFlag::g_onCreatedFlag, FLAG1);
EXPECT_EQ(CameraFlag::g_onConfigureFlag, FLAG1); HWTEST_F(CameraLiteTest, Test_FrameConfig_003, Level1)
camStateMng.Capture(); {
sleep(3); shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
camStateMng.StartRecord(); EXPECT_NE(frameConfig.get(), nullptr);
sleep(3); }
camStateMng.Stop();
cameraKit = NULL; HWTEST_F(CameraLiteTest, Test_FrameConfig_004, Level1)
} {
\ No newline at end of file shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
EXPECT_NE(frameConfig.get(), nullptr);
}
HWTEST_F(CameraLiteTest, PrfTest_Frameconfig_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = nullptr;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
HWTEST_F(CameraLiteTest, PrfTest_Frameconfig_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = nullptr;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
HWTEST_F(CameraLiteTest, PrfTest_Frameconfig_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = nullptr;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
HWTEST_F(CameraLiteTest, PrfTest_Frameconfig_004, Level1)
{
shared_ptr<FrameConfig> frameConfig = nullptr;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1400
* @tc.name : Get Frame Configure Type
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_GetFrameConfigureType_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onGetFrameConfigureType = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_EQ(g_onGetFrameConfigureType, true);
}
HWTEST_F(CameraLiteTest, Test_GetFrameConfigureType_002, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onGetFrameConfigureType = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
camStateMng.Stop();
EXPECT_EQ(g_onGetFrameConfigureType, true);
}
HWTEST_F(CameraLiteTest, Test_GetFrameConfigureType_003, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onGetFrameConfigureType = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
EXPECT_EQ(g_onGetFrameConfigureType, false);
}
HWTEST_F(CameraLiteTest, Test_GetFrameConfigureType_004, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onGetFrameConfigureType = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
EXPECT_EQ(g_onGetFrameConfigureType, true);
}
HWTEST_F(CameraLiteTest, Test_GetFrameConfigureType_005, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onGetFrameConfigureType = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Capture();
sleep(2);
camStateMng.Stop();
EXPECT_EQ(g_onGetFrameConfigureType, true);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1500
* @tc.name : Set Vendor Parameter
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_SetVendorParameter_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[4] = 5;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
uint8_t *privateTagTemp = new uint8_t[10];
frameConfig->GetVendorParameter(privateTagTemp, 10);
EXPECT_TRUE(privateTagTemp[4] == 5);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, Test_SetVendorParameter_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[10] = 10;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
EXPECT_TRUE(privateTagTemp[10] == 10);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, Test_SetVendorParameter_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[0] = 1;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
EXPECT_TRUE(privateTagTemp[0] == 1);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, Test_SetVendorParameter_004, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[31] = 31;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
EXPECT_TRUE(privateTagTemp[31] == 31);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, PrfTest_SetVendorParameter_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[1] = 1;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
}
HWTEST_F(CameraLiteTest, PrfTest_SetVendorParameter_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[2] = 2;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
}
HWTEST_F(CameraLiteTest, PrfTest_SetVendorParameter_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[3] = 3;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
}
HWTEST_F(CameraLiteTest, PrfTest_SetVendorParameter_004, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[4] = 4;
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1600
* @tc.name : Get Vendor Parameter
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, PrfTest_GetVendorParameter_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[1] = 1;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, PrfTest_GetVendorParameter_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[2] = 2;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, PrfTest_GetVendorParameter_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[3] = 3;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
delete[] privateTagTemp;
}
HWTEST_F(CameraLiteTest, PrfTest_GetVendorParameter_004, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
uint8_t *privateTag = new uint8_t[PRIVATE_TAG_LEN];
privateTag[4] = 4;
frameConfig->SetVendorParameter(privateTag, PRIVATE_TAG_LEN);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
uint8_t *privateTagTemp = new uint8_t[PRIVATE_TAG_LEN];
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetVendorParameter(privateTagTemp, PRIVATE_TAG_LEN);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
delete[] privateTag;
delete[] privateTagTemp;
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1700
* @tc.name : Get Surface
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_GetSurface_001, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface();
surface->SetWidthAndHeight(1920, 1080);
EXPECT_EQ(1920, surface->GetWidth());
EXPECT_EQ(1080, surface->GetHeight());
}
HWTEST_F(CameraLiteTest, Test_GetSurface_002, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface();
surface->SetWidthAndHeight(480, 360);
EXPECT_EQ(480, surface->GetWidth());
EXPECT_EQ(360, surface->GetHeight());
}
HWTEST_F(CameraLiteTest, Test_GetSurface_003, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface();
surface->SetWidthAndHeight(1920, 1080);
frameConfig->AddSurface(*surface);
EXPECT_FALSE(frameConfig->GetSurfaces().size() == 0);
}
HWTEST_F(CameraLiteTest, Test_GetSurface_004, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
frameConfig->RemoveSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 0);
}
HWTEST_F(CameraLiteTest, Test_GetSurface_005, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 1);
}
HWTEST_F(CameraLiteTest, Test_GetSurface_006, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 1);
}
HWTEST_F(CameraLiteTest, PrfTest_GetSurfaces_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetSurfaces();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
HWTEST_F(CameraLiteTest, PrfTest_GetSurfaces_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CAPTURE);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetSurfaces();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
HWTEST_F(CameraLiteTest, PrfTest_GetSurfaces_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_RECORD);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetSurfaces();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
HWTEST_F(CameraLiteTest, PrfTest_GetSurfaces_004, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_CALLBACK);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->GetSurfaces();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1800
* @tc.name : On Frame Progressed
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_OnFrameProgressed_001, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_EQ(g_onFrameStartedFlag, true);
EXPECT_EQ(g_onFrameProgressedFlag, true);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_1900
* @tc.name : On Frame Completed
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_OnFrameCompletedFlag_001, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_EQ(g_onFrameFinishedFlag, true);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2000
* @tc.name : On Frame Error
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_OnFrameErrorFlag_001, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_NE(g_onFrameErrorFlag, true);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2100
* @tc.name : Add Surface
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_AddSurface_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 1);
}
HWTEST_F(CameraLiteTest, Test_AddSurface_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
frameConfig->AddSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 2);
}
HWTEST_F(CameraLiteTest, Test_AddSurface_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
frameConfig->AddSurface(*surface);
frameConfig->AddSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 3);
}
HWTEST_F(CameraLiteTest, PrfTest_AddSurface_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->AddSurface(*surface);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2200
* @tc.name : Remove Surface
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_RemoveSurface_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
frameConfig->RemoveSurface(*surface);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 0);
}
HWTEST_F(CameraLiteTest, Test_RemoveSurface_002, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
Surface *surface1 = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
frameConfig->AddSurface(*surface1);
frameConfig->RemoveSurface(*surface1);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 1);
}
HWTEST_F(CameraLiteTest, Test_RemoveSurface_003, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
Surface *surface1 = Surface::CreateSurface();
frameConfig->AddSurface(*surface);
frameConfig->AddSurface(*surface1);
frameConfig->RemoveSurface(*surface);
frameConfig->RemoveSurface(*surface1);
list<Surface *> list = frameConfig->GetSurfaces();
EXPECT_TRUE(list.size() == 0);
}
HWTEST_F(CameraLiteTest, PrfTest_RemoveSurface_001, Level1)
{
shared_ptr<FrameConfig> frameConfig = make_shared<FrameConfig>(FRAME_CONFIG_PREVIEW);
Surface *surface = Surface::CreateSurface();
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
frameConfig->AddSurface(*surface);
clock_gettime(CLOCK_REALTIME, &tv1);
frameConfig->RemoveSurface(*surface);
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2300
* @tc.name : Capture
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_Capture_001, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_EQ(g_onCaptureTriggerStartedFlag, true);
EXPECT_EQ(g_onCaptureTriggerCompletedFlag, true);
}
HWTEST_F(CameraLiteTest, Test_Capture_002, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Capture();
sleep(2);
camStateMng.Stop();
sleep(2);
EXPECT_EQ(g_onCaptureTriggerStartedFlag, true);
EXPECT_EQ(g_onCaptureTriggerCompletedFlag, true);
}
HWTEST_F(CameraLiteTest, Test_Capture_003, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
EventHandler eventHdlr;
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
sleep(2);
EXPECT_EQ(g_onCaptureTriggerStartedFlag, false);
EXPECT_EQ(g_onCaptureTriggerCompletedFlag, false);
}
HWTEST_F(CameraLiteTest, Test_Capture_004, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
camStateMng.Stop();
sleep(2);
EXPECT_EQ(g_onCaptureTriggerStartedFlag, true);
EXPECT_EQ(g_onCaptureTriggerCompletedFlag, true);
}
HWTEST_F(CameraLiteTest, Test_Capture_005, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_EQ(g_onCaptureTriggerStartedFlag, true);
EXPECT_EQ(g_onCaptureTriggerCompletedFlag, true);
}
HWTEST_F(CameraLiteTest, Test_Capture_006, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_TRUE(g_onCaptureTriggerStartedFlag);
EXPECT_TRUE(g_onCaptureTriggerCompletedFlag);
}
HWTEST_F(CameraLiteTest, Test_Capture_007, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.Stop();
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_TRUE(g_onCaptureTriggerStartedFlag);
EXPECT_TRUE(g_onCaptureTriggerCompletedFlag);
}
HWTEST_F(CameraLiteTest, Test_Capture_008, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
g_onCaptureTriggerStartedFlag = false;
g_onCaptureTriggerCompletedFlag = false;
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
sleep(2);
camStateMng.Capture();
sleep(2);
EXPECT_EQ(g_onCaptureTriggerStartedFlag, true);
EXPECT_EQ(g_onCaptureTriggerCompletedFlag, true);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2400
* @tc.name : Preview
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_Preview_001, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
g_onPreviewFlag = false;
camStateMng.StartPreview();
sleep(2);
EXPECT_TRUE(g_onPreviewFlag);
camStateMng.Stop();
}
HWTEST_F(CameraLiteTest, Test_Preview_002, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
g_onPreviewFlag = false;
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
EXPECT_FALSE(g_onPreviewFlag);
}
HWTEST_F(CameraLiteTest, Test_Preview_003, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
g_onPreviewFlag = false;
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
camStateMng.StartPreview();
sleep(2);
EXPECT_TRUE(g_onPreviewFlag);
}
HWTEST_F(CameraLiteTest, Test_Preview_004, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
g_onPreviewFlag = false;
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
EXPECT_FALSE(g_onPreviewFlag);
}
HWTEST_F(CameraLiteTest, Test_Preview_005, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
g_onPreviewFlag = false;
camStateMng.Capture();
sleep(2);
camStateMng.Stop();
sleep(2);
camStateMng.StartPreview();
sleep(2);
EXPECT_TRUE(g_onPreviewFlag);
camStateMng.Stop();
}
HWTEST_F(CameraLiteTest, Test_Preview_006, Level1)
{
CameraKit *cameraKit = nullptr;
list<string> cameraList;
string cameraId;
EventHandler eventHdlr;
GetCameraId(cameraKit, cameraList, cameraId);
SampleCameraStateMng camStateMng(eventHdlr);
cameraKit->CreateCamera(cameraId, camStateMng, eventHdlr);
g_onPreviewFlag = false;
camStateMng.Capture();
sleep(2);
camStateMng.StartPreview();
sleep(2);
camStateMng.Stop();
EXPECT_FALSE(g_onPreviewFlag);
} /* end frame config & frame state call back interface test */
/* start camera info interface test */
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2500
* @tc.name : Get Camera Type
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_GetCameraType_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(cameraId);
int32_t cameraType = cameraInfo->GetCameraType();
EXPECT_TRUE(cameraType <= 3);
EXPECT_TRUE(cameraType >= 0);
}
HWTEST_F(CameraLiteTest, PrfTest_GetCameraType_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(cameraId);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
cameraInfo->GetCameraType();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
}
/* *
* @tc.number : SUB_MEDIA_CAMERA_DEV_2600
* @tc.name : Get Camera Facing Type
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(CameraLiteTest, Test_GetCameraFacingType_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(cameraId);
int32_t cameraFacingType = cameraInfo->GetCameraFacingType();
EXPECT_TRUE(cameraFacingType <= 2);
EXPECT_TRUE(cameraFacingType >= 0);
}
HWTEST_F(CameraLiteTest, PrfTest_GetCameraFacingType_001, Level1)
{
CameraKit *cameraKit = CameraKit::GetInstance();
string cameraId = "0";
const CameraInfo *cameraInfo = cameraKit->GetCameraInfo(cameraId);
struct timespec tv1 = {0};
struct timespec tv2 = {0};
int64_t performanceTestTimes = 10;
int64_t usecTimes = 1000000;
int64_t totalTime = 0;
for (int32_t i = 0; i < performanceTestTimes; i++) {
clock_gettime(CLOCK_REALTIME, &tv1);
cameraInfo->GetCameraFacingType();
clock_gettime(CLOCK_REALTIME, &tv2);
totalTime += tv2.tv_sec * usecTimes + tv2.tv_nsec - (tv1.tv_sec * usecTimes + tv1.tv_nsec);
}
int64_t expectTime = 1000000;
EXPECT_TRUE(totalTime <= expectTime * performanceTestTimes);
} /* end camera info interface test */
} // namespace OHOS
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (C) 2020-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");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,19 +13,15 @@ ...@@ -13,19 +13,15 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef CAMERA_DEMO_TEST_H #ifndef CAMERA_LITE_TEST_H
#define CAMERA_DEMO_TEST_H #define CAMERA_LITE_TEST_H
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <sys/time.h>
#include "camera_kit.h"
#include "recorder.h" #include "recorder.h"
namespace OHOS {
const int32_t RET_OK = 0;
const int32_t RET_ERR = -1;
const int32_t FRAME_RATE_DEFAULT = 30; const int32_t FRAME_RATE_DEFAULT = 30;
const int32_t OK = 0; const int32_t OK = 0;
const int32_t FAIL = -1; const int32_t FAIL = -1;
...@@ -34,11 +30,29 @@ const int32_t BUFFER_SIZE = 1024; ...@@ -34,11 +30,29 @@ const int32_t BUFFER_SIZE = 1024;
static std::string g_filePath = "/test_root/multimedia/"; static std::string g_filePath = "/test_root/multimedia/";
std::string g_testPath; std::string g_testPath;
// CallBack Flag bool g_onGetCameraAbilityFlag;
enum TestCallBackFlag { bool g_onConfigureFlag;
FLAG0 = 0, bool g_onGetSupportedSizesFlag;
FLAG1 = 1, // CameraDeviceCallBack Flag
}; bool g_onCameraAvailableFlag;
bool g_onCameraUnavailableFlag;
// CameraStateCallback
bool g_onCreatedFlag;
bool g_onCreateFailedFlag;
bool g_onReleasedFlag;
bool g_onConfiguredFlag;
bool g_onConfigureFailedFlag;
// FrameStateCallback
bool g_onCaptureTriggerAbortedFlag;
bool g_onCaptureTriggerCompletedFlag;
bool g_onCaptureTriggerStartedFlag;
bool g_onGetFrameConfigureType;
bool g_onFrameFinishedFlag;
bool g_onFrameErrorFlag;
bool g_onFrameProgressedFlag;
bool g_onFrameStartedFlag;
bool g_onRecorderFlag;
bool g_onPreviewFlag;
// VideoSize // VideoSize
enum TestVideoSize { enum TestVideoSize {
...@@ -46,7 +60,7 @@ enum TestVideoSize { ...@@ -46,7 +60,7 @@ enum TestVideoSize {
HEIGHT = 1080, HEIGHT = 1080,
}; };
class ActsMediaCameraTest : public testing::Test { class CameraLiteTest : public testing::Test {
public: public:
// SetUpTestCase: before all testcasee // SetUpTestCase: before all testcasee
static void SetUpTestCase(void); static void SetUpTestCase(void);
...@@ -57,53 +71,5 @@ public: ...@@ -57,53 +71,5 @@ public:
// TearDown // TearDown
void TearDown(void); void TearDown(void);
}; };
} // namespace OHOS
class CameraFlag { #endif // CAMERA_LITE_TEST_H
public: \ No newline at end of file
// CameraSetupFlag
static int32_t g_onGetCameraAbilityFlag;
static int32_t g_onConfigureFlag;
static int32_t g_onGetSupportedSizesFlag;
// CameraDeviceCallBack Flag
static int32_t g_onCameraAvailableFlag;
static int32_t g_onCameraUnavailableFlag;
// CameraStateCallback
static int32_t g_onCreatedFlag;
static int32_t g_onCreateFailedFlag;
static int32_t g_onReleasedFlag;
static int32_t g_onConfiguredFlag;
static int32_t g_onConfigureFailedFlag;
// FrameStateCallback
static int32_t g_onCaptureTriggerAbortedFlag;
static int32_t g_onCaptureTriggerCompletedFlag;
static int32_t g_onCaptureTriggerStartedFlag;
static int32_t g_onGetFrameConfigureType;
static int32_t g_onFrameFinishedFlag;
static int32_t g_onFrameErrorFlag;
static int32_t g_onFrameProgressedFlag;
static int32_t g_onFrameStartedFlag;
};
// CameraSetup
int32_t CameraFlag::g_onGetCameraAbilityFlag = FLAG0;
int32_t CameraFlag::g_onConfigureFlag = FLAG0;
int32_t CameraFlag::g_onGetSupportedSizesFlag = FLAG0;
// CameraDeviceCallBack
int32_t CameraFlag::g_onCameraAvailableFlag = FLAG0;
int32_t CameraFlag::g_onCameraUnavailableFlag = FLAG0;
// CameraStateCallback
int32_t CameraFlag::g_onCreatedFlag = FLAG0;
int32_t CameraFlag::g_onCreateFailedFlag = FLAG0;
int32_t CameraFlag::g_onConfiguredFlag = FLAG0;
int32_t CameraFlag::g_onConfigureFailedFlag = FLAG0;
int32_t CameraFlag::g_onReleasedFlag = FLAG0;
// FrameStateCallback
int32_t CameraFlag::g_onCaptureTriggerAbortedFlag = FLAG0;
int32_t CameraFlag::g_onCaptureTriggerCompletedFlag = FLAG0;
int32_t CameraFlag::g_onCaptureTriggerStartedFlag = FLAG0;
int32_t CameraFlag::g_onGetFrameConfigureType = FLAG0;
int32_t CameraFlag::g_onFrameFinishedFlag = FLAG0;
int32_t CameraFlag::g_onFrameErrorFlag = FLAG0;
int32_t CameraFlag::g_onFrameProgressedFlag = FLAG0;
int32_t CameraFlag::g_onFrameStartedFlag = FLAG0;
#endif
\ No newline at end of file
...@@ -1006,7 +1006,7 @@ HWTEST_F(ActsMediaRecorderNDKTest, Test_SetMaxFileSize2, Function | MediumTest | ...@@ -1006,7 +1006,7 @@ HWTEST_F(ActsMediaRecorderNDKTest, Test_SetMaxFileSize2, Function | MediumTest |
HWTEST_F(ActsMediaRecorderNDKTest, Test_SetOutputFile1, Function | MediumTest | Level0) HWTEST_F(ActsMediaRecorderNDKTest, Test_SetOutputFile1, Function | MediumTest | Level0)
{ {
Recorder *recorder = new Recorder(); Recorder *recorder = new Recorder();
int32_t ret = recorder->SetOutputFile(-1); int32_t ret = recorder->SetOutputFile(1);
EXPECT_EQ(ERR_INVALID_PARAM, ret); EXPECT_EQ(ERR_INVALID_PARAM, ret);
delete recorder; delete recorder;
recorder = NULL; recorder = NULL;
...@@ -1020,7 +1020,7 @@ HWTEST_F(ActsMediaRecorderNDKTest, Test_SetOutputFile1, Function | MediumTest | ...@@ -1020,7 +1020,7 @@ HWTEST_F(ActsMediaRecorderNDKTest, Test_SetOutputFile1, Function | MediumTest |
HWTEST_F(ActsMediaRecorderNDKTest, Test_SetNextOutputFile1, Function | MediumTest | Level0) HWTEST_F(ActsMediaRecorderNDKTest, Test_SetNextOutputFile1, Function | MediumTest | Level0)
{ {
Recorder *recorder = new Recorder(); Recorder *recorder = new Recorder();
int32_t ret = recorder->SetNextOutputFile(-1); int32_t ret = recorder->SetNextOutputFile(1);
EXPECT_EQ(ERR_INVALID_PARAM, ret); EXPECT_EQ(ERR_INVALID_PARAM, ret);
delete recorder; delete recorder;
recorder = NULL; recorder = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册