Backup
This commit is contained in:
parent
d8f7e2c076
commit
6610558788
|
@ -55,7 +55,7 @@ void SdCardHal::DevDetectingThread(void)
|
|||
const char *dev = SD_CARD_DEV;
|
||||
mThreadRuning = true;
|
||||
while (mThreadRuning) {
|
||||
fd = open(dev, O_RDONLY);
|
||||
fd = fx_open(dev, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
LogInfo("sdCardHal: %s open failed.\n", dev);
|
||||
if (SdCardHalStatus::PULL_OUT != status) {
|
||||
|
|
|
@ -23,7 +23,7 @@ aux_source_directory(./src SRC_FILES)
|
|||
|
||||
set(TARGET_NAME HalTest)
|
||||
add_executable(${TARGET_NAME} ${SRC_FILES})
|
||||
target_link_libraries(${TARGET_NAME} gtest gmock pthread Hal)
|
||||
target_link_libraries(${TARGET_NAME} HalTestTool gtest gmock pthread)
|
||||
if(${TEST_COVERAGE} MATCHES "true")
|
||||
target_link_libraries(${TARGET_NAME} gcov)
|
||||
endif()
|
||||
|
|
|
@ -19,7 +19,7 @@ include_directories(
|
|||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
||||
set(TEST_TOOL_TARGET HalTestTool)
|
||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
||||
target_link_libraries(${TEST_TOOL_TARGET} KeyControl LedControl Log)
|
||||
target_link_libraries(${TEST_TOOL_TARGET} Hal KeyControl LedControl LinuxApiMock Log)
|
||||
|
||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||
add_custom_target(
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
*/
|
||||
#include "KeyControlMock.h"
|
||||
#include "ILog.h"
|
||||
unsigned int KeyControlTest::GetStatusCheckPeriodMs(void)
|
||||
{
|
||||
return PERIPHERAL_CHECK_PERIOD_MS;
|
||||
}
|
||||
KeyControlTest::KeyControlTest(const std::string &keyName) : mKeyName(keyName)
|
||||
{
|
||||
}
|
||||
|
@ -36,6 +40,15 @@ void KeyControlTest::KeyEventTrigger(const std::string &keyName, const KeyEvent
|
|||
}
|
||||
monitor->KeyEventHappened(keyName, static_cast<VirtualKeyEvent>(event), timeMs);
|
||||
}
|
||||
const std::string KeyControlTest::GetKeyName(void)
|
||||
{
|
||||
return mKeyName;
|
||||
}
|
||||
StatusCode KeyControlTest::KeyEventTriggerTrace(const std::string &keyName, const KeyEvent &event,
|
||||
const unsigned int &timeMs)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
KeyControlMock::KeyControlMock(const std::string &keyName) : KeyControlTest(keyName)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -23,24 +23,15 @@ class KeyControlTest : public KeyControl, public VKeyHal
|
|||
public:
|
||||
KeyControlTest(const std::string &keyName);
|
||||
virtual ~KeyControlTest() = default;
|
||||
unsigned int GetStatusCheckPeriodMs(void) override
|
||||
{
|
||||
return PERIPHERAL_CHECK_PERIOD_MS;
|
||||
}
|
||||
unsigned int GetStatusCheckPeriodMs(void) override;
|
||||
void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) override;
|
||||
void CheckKeyStatus(void) override;
|
||||
void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) override;
|
||||
const std::string GetKeyName(void) override
|
||||
{
|
||||
return mKeyName;
|
||||
}
|
||||
const std::string GetKeyName(void) override;
|
||||
|
||||
private:
|
||||
virtual StatusCode KeyEventTriggerTrace(const std::string &keyName, const KeyEvent &event,
|
||||
const unsigned int &timeMs)
|
||||
{
|
||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||
}
|
||||
const unsigned int &timeMs);
|
||||
|
||||
private:
|
||||
const std::string mKeyName;
|
||||
|
@ -51,7 +42,6 @@ class KeyControlMock : public KeyControlTest
|
|||
public:
|
||||
KeyControlMock(const std::string &keyName);
|
||||
virtual ~KeyControlMock() = default;
|
||||
// void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) override;
|
||||
void SetKeyEvent(const KeyHalEvent &event);
|
||||
bool MockKeyClick(const unsigned int &pressingTimeMs = 200);
|
||||
MOCK_METHOD3(KeyEventTriggerTrace, StatusCode(const std::string &, const KeyEvent &, const unsigned int &));
|
||||
|
|
15
test/hal/tool/src/SdCardHalMock.cpp
Normal file
15
test/hal/tool/src/SdCardHalMock.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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 "SdCardHalMock.h"
|
25
test/hal/tool/src/SdCardHalMock.h
Normal file
25
test/hal/tool/src/SdCardHalMock.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef SD_CARD_HAL_MOCK_H
|
||||
#define SD_CARD_HAL_MOCK_H
|
||||
#include "IHalCpp.h"
|
||||
#include "SdCardHal.h"
|
||||
class SdCardHalMock : public SdCardHal
|
||||
{
|
||||
public:
|
||||
SdCardHalMock() = default;
|
||||
virtual ~SdCardHalMock() = default;
|
||||
};
|
||||
#endif
|
|
@ -6,6 +6,7 @@ include_directories(
|
|||
./src
|
||||
./include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
${TEST_SOURCE_PATH}
|
||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include
|
||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include
|
||||
)
|
||||
|
@ -13,8 +14,6 @@ include_directories(
|
|||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||
# )
|
||||
|
||||
|
||||
|
||||
aux_source_directory(./src SRC_FILES)
|
||||
|
||||
set(TARGET_NAME LinuxApiMock)
|
||||
|
|
|
@ -14,36 +14,8 @@
|
|||
*/
|
||||
#ifndef LINUX_API_MOCK_H
|
||||
#define LINUX_API_MOCK_H
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "GtestUsing.h"
|
||||
#include <memory>
|
||||
using ::testing::_;
|
||||
using ::testing::Action;
|
||||
using ::testing::ActionInterface;
|
||||
using ::testing::Assign;
|
||||
using ::testing::ByMove;
|
||||
using ::testing::ByRef;
|
||||
using ::testing::DefaultValue;
|
||||
using ::testing::DoAll;
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::IgnoreResult;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::InvokeWithoutArgs;
|
||||
using ::testing::MakePolymorphicAction;
|
||||
using ::testing::PolymorphicAction;
|
||||
using ::testing::Return;
|
||||
using ::testing::ReturnNew;
|
||||
using ::testing::ReturnNull;
|
||||
using ::testing::ReturnPointee;
|
||||
using ::testing::ReturnRef;
|
||||
using ::testing::ReturnRefOfCopy;
|
||||
using ::testing::ReturnRoundRobin;
|
||||
using ::testing::SaveArg;
|
||||
using ::testing::SetArgPointee;
|
||||
using ::testing::SetArgumentPointee;
|
||||
using ::testing::Unused;
|
||||
using ::testing::WithArgs;
|
||||
using ::testing::internal::BuiltInDefaultValue;
|
||||
constexpr int INVALID_HANDLE = -1;
|
||||
constexpr int MOCK_SELECT_TIME_OUT = 0;
|
||||
class LinuxApiMock
|
||||
|
|
|
@ -10,6 +10,7 @@ include_directories(
|
|||
${UTILS_SOURCE_PATH}/UartDevice/include
|
||||
${UTILS_SOURCE_PATH}/ModBusCRC16/include
|
||||
${UTILS_SOURCE_PATH}/McuProtocol/src
|
||||
${TEST_SOURCE_PATH}
|
||||
${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
|
||||
${TEST_SOURCE_PATH}/utils/UartDevice/tool/include
|
||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include
|
||||
|
@ -19,8 +20,6 @@ include_directories(
|
|||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||
# )
|
||||
|
||||
|
||||
|
||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
||||
set(TEST_TOOL_TARGET McuProtocolTestTool)
|
||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
||||
|
|
|
@ -7,6 +7,7 @@ include_directories(
|
|||
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
${UTILS_SOURCE_PATH}/UartDevice/include
|
||||
${TEST_SOURCE_PATH}
|
||||
${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
|
||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include
|
||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include
|
||||
|
|
|
@ -8,13 +8,12 @@ include_directories(
|
|||
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
|
||||
${TEST_SOURCE_PATH}
|
||||
)
|
||||
# link_directories(
|
||||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
||||
# )
|
||||
|
||||
|
||||
|
||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
||||
set(TEST_TOOL_TARGET UartDeviceTestTool)
|
||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
||||
|
|
Loading…
Reference in New Issue
Block a user