hunting/test/middleware/McuManager/src_mock/McuManager_AbnormalData_Test.cpp
2024-06-15 08:39:16 +08:00

71 lines
3.4 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 "McuAskBase.h"
#include "McuAskBaseTestTool.h"
#include "McuManagerMockTest.h"
#include <thread>
const unsigned char McuRecvData[] = {
0xFA, 0xC1, 0x00, 0x00, 0x00, 0x08, 0x41, 0x01, 0x00, 0x0A, 0x03, 0x08, 0xEC, 0xFA, 0xC1, 0x00, 0x00, 0x00,
0x0A, 0x41, 0x03, 0x08, 0xEC, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x41, 0x07, 0x00, 0x0C, 0x35, 0x88, 0xFA,
0xC1, 0x00, 0x03, 0x08, 0xEC, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x41, 0x07, 0x00, 0x0C, 0x35, 0x88, 0xFA,
0xC1, 0x00, 0x00, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x03, 0x08, 0xEC, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A,
0x41, 0x07, 0x00, 0x0C, 0x35, 0x88, 0xFA, 0xC1, 0x00, 0x00, 0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A};
const unsigned char McuSendData_GetDateTime[] = {
0xFA, 0xC1, 0x00, 0x00, 0x00, 0x0A, 0x41, 0x07, 0x00, 0x0C, 0x35, 0x88};
const unsigned char McuSendData_OtherSideReplyGetIpcMission[] = {
0xFA, 0xC1, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x0D, 0x03, 0x09, 0xBA};
namespace McuManager_AbnormalData_Test
{
/**
* @brief Construct a new test f object
* ../output_files/test/bin/McuManagerTest
* --gtest_filter=McuManagerMockTest.HS_INTEGRATION_McuManager_EXAMPLE_ProtocolLengthIsWrong
*/
TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_ProtocolLengthIsWrong)
{
IMcuManager::GetInstance()->Init();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
McuManagerTestTool::MockOtherSideSendData(mLinuxTest, McuRecvData, sizeof(McuRecvData));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
IMcuManager::GetInstance()->UnInit();
}
/**
* @brief Construct a new test f object
* ../output_files/test/bin/McuManagerTest
* --gtest_filter=McuManagerMockTest.HS_INTEGRATION_McuManager_EXAMPLE_OtherSideGetDateTime
*/
TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_OtherSideGetDateTime)
{
IMcuManager::GetInstance()->Init();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
McuManagerTestTool::MockOtherSideSendData(mLinuxTest, McuSendData_GetDateTime, sizeof(McuSendData_GetDateTime));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
IMcuManager::GetInstance()->UnInit();
}
/**
* @brief Construct a new test f object
* ../output_files/test/bin/McuManagerTest
* --gtest_filter=McuManagerMockTest.HS_INTEGRATION_McuManager_EXAMPLE_OtherSideReplyGetIpcMission
*/
TEST_F(McuManagerMockTest, HS_INTEGRATION_McuManager_EXAMPLE_OtherSideReplyGetIpcMission)
{
IMcuManager::GetInstance()->Init();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
McuManagerTestTool::MockOtherSideSendData(
mLinuxTest, McuSendData_OtherSideReplyGetIpcMission, sizeof(McuSendData_OtherSideReplyGetIpcMission));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
IMcuManager::GetInstance()->UnInit();
}
} // namespace McuManager_AbnormalData_Test