107 lines
3.2 KiB
C++
107 lines
3.2 KiB
C++
/*
|
|
* Copyright (c) 2023 Fancy Code.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#include "HuntingCameraTest.h"
|
|
#include "GtestUsing.h"
|
|
#include "ILog.h"
|
|
#include "MainThread.h"
|
|
#include <thread>
|
|
const char *KEY_RESET = "reset";
|
|
const char *LED_DEVICE_STATUS = "device_status";
|
|
void MainThreadTest::CustomizationInit(void)
|
|
{
|
|
// Do nothing here to make sure test tool work.
|
|
}
|
|
HuntingCameraTest::HuntingCameraTest()
|
|
{
|
|
}
|
|
HuntingCameraTest::~HuntingCameraTest()
|
|
{
|
|
}
|
|
void HuntingCameraTest::SetUpTestCase()
|
|
{
|
|
CreateLogModule();
|
|
ILogInit(LOG_INSTANCE_TYPE_END);
|
|
}
|
|
void HuntingCameraTest::TearDownTestCase()
|
|
{
|
|
ILogUnInit();
|
|
}
|
|
void HuntingCameraTest::SetUp()
|
|
{
|
|
CreateAllCamerasMcok();
|
|
std::shared_ptr<MainThread> mainThread = std::make_shared<MainThreadTest>();
|
|
MainThread::GetInstance(&mainThread);
|
|
HalTestTool::Init();
|
|
CreateAllKeysMcok();
|
|
CreateAllLedsMcok();
|
|
AppManagerTestTool::Init();
|
|
MissionManagerTestTool::Init();
|
|
mLinuxTest = LinuxTest::CreateLinuxTest();
|
|
std::shared_ptr<LinuxApiMock> test = mLinuxTest;
|
|
LinuxApiMock::GetInstance(&test);
|
|
LinuxApiMock::GetInstance()->Init();
|
|
McuManagerTestTool::Init(mLinuxTest);
|
|
HalTestTool::InitSdCardHal(mLinuxTest);
|
|
DeviceManagerTestTool::Init();
|
|
TestManager::Init();
|
|
}
|
|
void HuntingCameraTest::TearDown()
|
|
{
|
|
TestManager::UnInit();
|
|
MissionManagerTestTool::UnInit();
|
|
AppManagerTestTool::UnInit();
|
|
HalTestTool::UnInit();
|
|
LinuxApiMock::GetInstance()->UnInit();
|
|
mLinuxTest = std::make_shared<LinuxTest>();
|
|
std::shared_ptr<LinuxApiMock> test = std::make_shared<LinuxApiMock>();
|
|
LinuxApiMock::GetInstance(&test);
|
|
McuManagerTestTool::UnInit();
|
|
MainThread::GetInstance()->UnInit();
|
|
std::shared_ptr<MainThread> mainThread = std::make_shared<MainThread>();
|
|
MainThread::GetInstance(&mainThread);
|
|
DeviceManagerTestTool::UnInit();
|
|
DestroyAllCamerasMock();
|
|
DestroyAllKeysMock();
|
|
DestroyAllLedsMock();
|
|
}
|
|
void HuntingCameraTest::CreateAllCamerasMcok(void)
|
|
{
|
|
std::shared_ptr<VCameraHal> camera = HalTestTool::MakeCameraHalTest(CameraType::MAIN_CAMERA);
|
|
mAllCamerasMock[CameraType::MAIN_CAMERA] = camera;
|
|
}
|
|
void HuntingCameraTest::DestroyAllCamerasMock(void)
|
|
{
|
|
mAllCamerasMock.clear();
|
|
}
|
|
void HuntingCameraTest::CreateAllKeysMcok(void)
|
|
{
|
|
std::shared_ptr<VKeyHal> key = HalTestTool::MakeKeyHalTest(KEY_RESET);
|
|
mAllKeysMock[KEY_RESET] = key;
|
|
HalTestTool::SetAllKeysResult(mAllKeysMock);
|
|
}
|
|
void HuntingCameraTest::DestroyAllKeysMock(void)
|
|
{
|
|
|
|
mAllKeysMock.clear();
|
|
}
|
|
void HuntingCameraTest::CreateAllLedsMcok(void)
|
|
{
|
|
std::shared_ptr<VLedHal> led = HalTestTool::MakeLedHalTest(LED_DEVICE_STATUS);
|
|
mAllLedsMock[LED_DEVICE_STATUS] = led;
|
|
}
|
|
void HuntingCameraTest::DestroyAllLedsMock(void)
|
|
{
|
|
mAllLedsMock.clear();
|
|
} |