diff --git a/hal/abstract/IHalCpp.cpp b/hal/abstract/IHalCpp.cpp index 0e469e88..7f92ce37 100644 --- a/hal/abstract/IHalCpp.cpp +++ b/hal/abstract/IHalCpp.cpp @@ -17,26 +17,25 @@ #include std::shared_ptr &IHalCpp::GetInstance(std::shared_ptr *impl) { - static std::shared_ptr instance = std::make_shared(); - static bool instanceChanging = false; - if (impl && false == instanceChanging) { - // Don't use std::mutex for runing faster. - // Sleep for difference thread to release instance. - instanceChanging = true; - // std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Don't sleep and make sure that start fast. - if (instance.use_count() == 1) // bug? - { - LogInfo("Instance change succeed.\n"); + static auto instance = std::make_shared(); + if (impl) { + if (instance.use_count() == 1) { + LogInfo("Instance changed succeed.\n"); instance = *impl; } else { - LogError("[ error ] instance change failed, using by some one.\n"); + LogError("Can't changing the instance becase of using by some one.\n"); } - instanceChanging = false; - } - if (instanceChanging) { - static std::shared_ptr tmporaryInstance = std::make_shared(); - return tmporaryInstance; } return instance; +} +StatusCode IHalCpp::Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +StatusCode IHalCpp::UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +StatusCode IHalCpp::GetLedHals(std::vector> &ledHals) +{ + return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +} +StatusCode IHalCpp::GetAllKeys(std::map> &allKeys) +{ + return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } \ No newline at end of file diff --git a/hal/include/IHalCpp.h b/hal/include/IHalCpp.h index 6c4e10ec..7da9ecc3 100644 --- a/hal/include/IHalCpp.h +++ b/hal/include/IHalCpp.h @@ -16,96 +16,45 @@ #define IHALCPP_H #include "StatusCode.h" #include +#include #include #include +using VirtualLedState = unsigned char; +using VirtualKeyEvent = unsigned char; constexpr int INVALID_PERIOD = -1; constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100; constexpr int IMEI_LEN = 15; constexpr long int KEY_DO_NOT_HOLD_PRESSING = -1; -enum class KeyHalEvent -{ - PRESSING = 0, - NOT_PRESSING, - END -}; -class VKeyHalOwner -{ -public: - VKeyHalOwner() = default; - virtual ~VKeyHalOwner() = default; - virtual void KeyEventTrigger(const KeyHalEvent &event) {} - virtual void TimerKeyEventTrigger(const KeyHalEvent &event) {} - virtual long int GetHoldPressingTimeMs(void) { return KEY_DO_NOT_HOLD_PRESSING; } -}; +void CreateHalCppModule(void); class VKeyHal { public: VKeyHal() = default; virtual ~VKeyHal() = default; - virtual void SetKeyHalOwner(std::shared_ptr owner) {} + virtual void CheckKeyStatus(void) {} virtual const std::string GetKeyName(void) { return "undefine"; } + virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event) {} }; - -enum HalLedState -{ - HAL_LED_STATE_OFF = 0, - HAL_LED_STATE_ON, - HAL_LED_STATE_GREEN, - HAL_LED_STATE_RED, - HAL_LED_STATE_YELLOW, - HAL_LED_STATE_LEVEL_0, - HAL_LED_STATE_LEVEL_1, - HAL_LED_STATE_LEVEL_2, - HAL_LED_STATE_LEVEL_3, - HAL_LED_STATE_LEVEL_4, - HAL_LED_STATE_LEVEL_END, - HAL_LED_STATE_END -}; - class VLedHal { public: VLedHal() = default; ~VLedHal() = default; - virtual StatusCode SetHalLedState(const HalLedState &state) + virtual StatusCode SetHalLedState(const VirtualLedState &state) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } virtual std::string GetLedName(void) { return "undefine"; } }; - -#if 0 -class WifiLed : public VLedHalOwner, public VLedHal -{ -public: - WifiLed() = default; - ~WifiLed() = default; - - // StatusCode SetLedHalOwner(std::shared_ptr owner) override; - StatusCode SetHalLedState(const HalLedState &state) override; - std::string GetLedName(void) override; - -private: - // VLedHalOwner m_LedHalOwner; - std::string m_LedName; - SF_LED_GPIO_IDX_E mPinRed; - SF_LED_GPIO_IDX_E mPinGreen; -} -#endif - class IHalCpp { public: IHalCpp() = default; virtual ~IHalCpp() = default; static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); - virtual StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } - virtual StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } - virtual StatusCode GetLedHals(std::vector> &ledHals) - { - return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); - } + virtual StatusCode Init(void); + virtual StatusCode UnInit(void); + virtual StatusCode GetLedHals(std::vector> &ledHals); + virtual StatusCode GetAllKeys(std::map> &allKeys); }; -void CreateHalCppModule(void); - #endif diff --git a/middleware/DeviceManager/include/IDeviceManager.h b/middleware/DeviceManager/include/IDeviceManager.h index ad1321f3..9f16d610 100644 --- a/middleware/DeviceManager/include/IDeviceManager.h +++ b/middleware/DeviceManager/include/IDeviceManager.h @@ -19,30 +19,18 @@ #include #include bool CreateDeviceManagerModule(void); -enum class KeyEvent +bool DestroyDeviceManagerModule(void); +using VirtualLedState = unsigned char; +using VirtualKeyEvent = unsigned char; +typedef struct key_status { - SHORT_CLICK = 0, - HOLD_DOWN, - HOLD_UP, - END -}; - -enum class LedState -{ - OFF = 0, - ON, - GREEN, - RED, - YELLOW, - LEVEL_0, - LEVEL_1, - LEVEL_2, - LEVEL_3, - LEVEL_4, - LEVEL_END, - END -}; - + key_status(const VirtualKeyEvent &keyEvent, const long int holdTimeMs) + : mKeyEvent(keyEvent), mHoldTimeMs(holdTimeMs) + { + } + const VirtualKeyEvent mKeyEvent; + const long int mHoldTimeMs; +} KeyStatus; class IDeviceManager { public: @@ -51,7 +39,7 @@ public: static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); virtual const StatusCode Init(void); virtual const StatusCode UnInit(void); - virtual const StatusCode SetLedState(const std::string &ledName, const LedState ¤tState, + virtual const StatusCode SetLedState(const std::string &ledName, const VirtualLedState ¤tState, const unsigned int &KeepAliveTime, const unsigned int &blinkPeriod); }; #endif \ No newline at end of file diff --git a/middleware/DeviceManager/src/DeviceManager.cpp b/middleware/DeviceManager/src/DeviceManager.cpp index 876d3363..e38ad59a 100644 --- a/middleware/DeviceManager/src/DeviceManager.cpp +++ b/middleware/DeviceManager/src/DeviceManager.cpp @@ -15,45 +15,18 @@ #include "DeviceManager.h" #include "ILog.h" -#include "LedTimer.h" +#include "KeyManager.h" #include const StatusCode DeviceManager::Init(void) { - std::vector> ledHals; - IHalCpp::GetInstance()->GetLedHals(ledHals); - - for (auto it = ledHals.begin(); it != ledHals.end(); ++it) { - std::shared_ptr ledHal = *it; - std::shared_ptr ledOut = - std::make_shared(ledHal, NEW_LED_STATE, DEFAULT_KEEP_ALIVE_TIME, LED_NOT_BLINK); - mLedManagers.push_back(ledOut); - LedTimer::GetInstance()->AddTimerLedManager(ledOut); - } - - LedTimer::GetInstance()->Init(); + KeyManager::GetInstance()->Init(); + KeyManager::GetInstance()->StartTimer(); return CreateStatusCode(STATUS_CODE_OK); } const StatusCode DeviceManager::UnInit(void) { - if (!mLedManagers.empty()) { - mLedManagers.clear(); - } - LedTimer::GetInstance()->UnInit(); + KeyManager::GetInstance()->UnInit(); return CreateStatusCode(STATUS_CODE_OK); } - -const StatusCode DeviceManager::SetLedState(const std::string &ledName, const LedState ¤tState, - const unsigned int &KeepAliveTime, const unsigned int &blinkPeriod) -{ - for (auto it = mLedManagers.begin(); it != mLedManagers.end(); ++it) { - std::shared_ptr ledOut = *it; - if (ledOut->GetLedHal()->GetLedName() == ledName) { - ledOut->SetLedState(currentState, KeepAliveTime, blinkPeriod); - return CreateStatusCode(STATUS_CODE_OK); - } - } - LogWarning("ledName(%s) not found", ledName.c_str()); - return CreateStatusCode(STATUS_CODE_NOT_OK); -} diff --git a/middleware/DeviceManager/src/DeviceManager.h b/middleware/DeviceManager/src/DeviceManager.h index 974ef660..f47cc2e0 100644 --- a/middleware/DeviceManager/src/DeviceManager.h +++ b/middleware/DeviceManager/src/DeviceManager.h @@ -15,7 +15,7 @@ #ifndef DEVICEMANAGER_H #define DEVICEMANAGER_H #include "IDeviceManager.h" -#include "LedManager.h" +// #include "LedManager.h" class DeviceManager : public IDeviceManager { @@ -25,12 +25,12 @@ public: const StatusCode Init(void) override; const StatusCode UnInit(void) override; - const StatusCode SetLedState(const std::string &ledName, const LedState ¤tState, - const unsigned int &keepAliveTime = DEFAULT_KEEP_ALIVE_TIME, - const unsigned int &blinkPeriod = LED_NOT_BLINK) override; + // const StatusCode SetLedState(const std::string &ledName, const VirtualLedState ¤tState, + // const unsigned int &keepAliveTime = DEFAULT_KEEP_ALIVE_TIME, + // const unsigned int &blinkPeriod = LED_NOT_BLINK) override; private: - std::vector> mLedManagers; + // std::vector> mLedManagers; }; #endif diff --git a/middleware/DeviceManager/src/DeviceManagerMakePtr.cpp b/middleware/DeviceManager/src/DeviceManagerMakePtr.cpp index 26ed9e9d..bb8d2452 100644 --- a/middleware/DeviceManager/src/DeviceManagerMakePtr.cpp +++ b/middleware/DeviceManager/src/DeviceManagerMakePtr.cpp @@ -26,6 +26,13 @@ bool CreateDeviceManagerModule(void) } return false; } +bool DestroyDeviceManagerModule(void) +{ + auto instance = std::make_shared(); + IDeviceManager::GetInstance()->UnInit(); + IDeviceManager::GetInstance(&instance); + return true; +} std::shared_ptr &DeviceManagerMakePtr::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared(); diff --git a/middleware/DeviceManager/src/IDeviceManager.cpp b/middleware/DeviceManager/src/IDeviceManager.cpp index d41f493d..38efd80b 100644 --- a/middleware/DeviceManager/src/IDeviceManager.cpp +++ b/middleware/DeviceManager/src/IDeviceManager.cpp @@ -30,7 +30,7 @@ std::shared_ptr &IDeviceManager::GetInstance(std::shared_ptr &KeyManager::GetInstance(std::shared_ptr *impl) { - mKeyHal = nullptr; - mKeyActionReport = nullptr; - mPressingTime = KEY_NOT_PRESSING; - mLongClickTime = 0; -} -KeyManager::KeyManager(std::shared_ptr &keyHal, const KeyActionReport &keyAction, - const long int &longClickTime) - : mKeyHal(keyHal), mKeyActionReport(keyAction), mLongClickTime(longClickTime) -{ - mPressingTime = KEY_NOT_PRESSING; -} -KeyManager::~KeyManager() {} -void KeyManager::KeyEventTrigger(const KeyHalEvent &event) -{ - std::lock_guard locker(mMutex); - ActionReport(mKeyHal->GetKeyName(), event); -} -void KeyManager::TimerKeyEventTrigger(const KeyHalEvent &event) -{ - std::lock_guard locker(mMutex); - if (IsKeyPressing()) { - ActionReport(mKeyHal->GetKeyName(), event); - } -} -long int KeyManager::GetHoldPressingTimeMs(void) { return mPressingTime; } -bool KeyManager::IsKeyPressing(void) { return mPressingTime >= KEY_PRESSING ? true : false; } -void KeyManager::Init(void) { mKeyHal->SetKeyHalOwner(shared_from_this()); } -void KeyManager::UnInit(void) {} -void KeyManager::ActionReport(const std::string &key, const KeyHalEvent &keyEvent) -{ - if (KEY_PRESSING <= mPressingTime) { - mPressingTime += PERIPHERAL_CHECK_PERIOD_MS; - } - switch (keyEvent) { - case KeyHalEvent::PRESSING: - KeyPressingTrigger(key); - break; - case KeyHalEvent::NOT_PRESSING: - KeyNotPressingTrigger(key); - break; - - default: - break; - } -} -void KeyManager::KeyPressingTrigger(const std::string &key) -{ - if (mLongClickTime <= mPressingTime) // Do not support long click, it should be count in application code. - { - if (mKeyActionReport) { - // mKeyActionReport(key, KeyEvent::SF_KEY_ACTION_LONG_CLICK, NOT_A_HOLD_KEY_ACTION); + static auto instance = std::make_shared(); + if (impl) { + if (instance.use_count() == 1) { + LogInfo("Instance changed succeed.\n"); + instance = *impl; + } + else { + LogError("Can't changing the instance becase of using by some one.\n"); } } - if (mPressingTime != KEY_NOT_PRESSING && mPressingTime % KEY_ACTION_HOLD_DWON == 0) { - if (mKeyActionReport) { - mKeyActionReport(key, KeyEvent::HOLD_DOWN, mPressingTime); - } + return instance; +} +void KeyManager::Init(void) +{ + // + IHalCpp::GetInstance()->GetAllKeys(mAllKeyHal); +} +void KeyManager::UnInit(void) +{ + // + mAllKeyHal.clear(); +} +void KeyManager::StartTimer(void) +{ + if (mAllKeyHal.size() == 0) { + LogError("StartTimer failed, no key to manager.\n"); + return; } - if (KEY_NOT_PRESSING == mPressingTime) { - mPressingTime = KEY_PRESSING; + auto timerThread = [](std::shared_ptr timer) { + LogInfo("Key timer started.\n"); + timer->Timer(); + }; + mTimer = std::thread(timerThread, shared_from_this()); +} +void KeyManager::StopTimer(void) +{ + mTimerRuning = false; + if (mTimer.joinable()) { + mTimer.join(); } } -void KeyManager::KeyNotPressingTrigger(const std::string &key) +void KeyManager::Timer(void) { - if (KEY_ACTION_SHORT_CLICK <= mPressingTime && mPressingTime < KEY_ACTION_HOLD_DWON) { - if (mKeyActionReport) { - mKeyActionReport(key, KeyEvent::SHORT_CLICK, NOT_A_HOLD_KEY_ACTION); + mTimerRuning = true; + std::map>::iterator iter; + while (mTimerRuning) { + // for (int i = 0; i < static_cast(SfKeyDefine::KEY_PIN_END); i++) + // { + // mKeyManagers[static_cast(i)]->TimerKeyEventHappened(static_cast(i), + // SfKeyEvent::KEY_EVENT_PRESSED, nullptr); + // } + for (iter = mAllKeyHal.begin(); iter != mAllKeyHal.end(); ++iter) { + std::shared_ptr keyHal = iter->second; + keyHal->CheckKeyStatus(); } + std::this_thread::sleep_for(std::chrono::milliseconds(PERIPHERAL_CHECK_PERIOD_MS)); } - if (KEY_ACTION_HOLD_DWON <= mPressingTime) { - if (mKeyActionReport) { - mKeyActionReport(key, KeyEvent::HOLD_UP, mPressingTime); - } +} +void KeyManager::GetAllKeysState(std::map &status) +{ + std::map>::iterator iter; + for (iter = mAllKeyHal.begin(); iter != mAllKeyHal.end(); ++iter) { + std::shared_ptr keyHal = iter->second; + long int holdTimeMs = 0; + VirtualKeyEvent holdPressingEvent = 0x00; + keyHal->GetHoldPressingTimeMs(holdTimeMs, holdPressingEvent); + KeyStatus result(holdPressingEvent, holdTimeMs); + status.insert(std::make_pair(iter->first, result)); } - mPressingTime = KEY_NOT_PRESSING; } \ No newline at end of file diff --git a/middleware/DeviceManager/src/KeyManager.h b/middleware/DeviceManager/src/KeyManager.h index 7711e154..a8f614b8 100644 --- a/middleware/DeviceManager/src/KeyManager.h +++ b/middleware/DeviceManager/src/KeyManager.h @@ -16,37 +16,27 @@ #define KEY_MANAGER_H #include "IDeviceManager.h" #include "IHalCpp.h" -#include +#include +#include #include -using KeyActionReport = std::function; -constexpr int KEY_ACTION_LONG_CLICK = 1000 * 5; -constexpr int KEY_ACTION_SHORT_CLICK = 200; -constexpr int KEY_ACTION_HOLD_DWON = 500; -constexpr long int KEY_NOT_PRESSING = -1; -class KeyManager : public VKeyHalOwner, public std::enable_shared_from_this +#include +class KeyManager : public std::enable_shared_from_this { public: - KeyManager(); - KeyManager(std::shared_ptr &keyHal, const KeyActionReport &keyAction, - const long int &longClickTime = KEY_ACTION_LONG_CLICK); - ~KeyManager(); - void KeyEventTrigger(const KeyHalEvent &event) override; - void TimerKeyEventTrigger(const KeyHalEvent &event) override; - long int GetHoldPressingTimeMs(void) override; + KeyManager() = default; + ~KeyManager() = default; + static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); void Init(void); void UnInit(void); - void ActionReport(const std::string &key, const KeyHalEvent &keyEvent); - -private: - void KeyPressingTrigger(const std::string &key); - void KeyNotPressingTrigger(const std::string &key); - bool IsKeyPressing(void); + void StartTimer(void); + void StopTimer(void); + void Timer(void); + void GetAllKeysState(std::map &status); private: std::mutex mMutex; - std::shared_ptr mKeyHal; - KeyActionReport mKeyActionReport; - long int mPressingTime; - long int mLongClickTime; + std::map> mAllKeyHal; + bool mTimerRuning; + std::thread mTimer; }; #endif \ No newline at end of file diff --git a/middleware/DeviceManager/src/LedManager.cpp b/middleware/DeviceManager/src/LedManager.cpp deleted file mode 100644 index 618c4dd3..00000000 --- a/middleware/DeviceManager/src/LedManager.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 "LedManager.h" -#include "ILog.h" - -LedManager::LedManager() -{ - mLedHal = nullptr; - mCurrentState = NEW_LED_STATE; - mBlinkPeriod = LED_NOT_BLINK; - mKeepAliveTime = DEFAULT_KEEP_ALIVE_TIME; - mStateAliveTime = 0; -} - -LedManager::LedManager(std::shared_ptr &LedHal, const LedState &urrentState, const unsigned int &KeepAliveTime, - const unsigned int &blinkPeriod) -{ - mLedHal = LedHal; - mCurrentState = urrentState; - mKeepAliveTime = KeepAliveTime; - mBlinkPeriod = blinkPeriod; - mStateAliveTime = 0; -} - -std::shared_ptr LedManager::GetLedHal(void) { return mLedHal; } - -StatusCode LedManager::SetLedState(const LedState ¤tState, const unsigned int &keepAliveTime, - const unsigned int &blinkPeriod) -{ - mCurrentState = currentState; - mKeepAliveTime = keepAliveTime; - mBlinkPeriod = blinkPeriod; - return CreateStatusCode(STATUS_CODE_OK); -} - -StatusCode LedManager::GetLedState(LedState &urrentState) -{ - urrentState = mCurrentState; - return CreateStatusCode(STATUS_CODE_OK); -} - -// StatusCode LedManager::BlinkOn(LedState urrentState, unsigned int KeepAliveTime) -// { -// mKeepAliveTime = KeepAliveTime; -// return CreateStatusCode(STATUS_CODE_OK); -// } - -// StatusCode LedManager::BlinkOff(void) -// { -// mCurrentState = LedState::OFF; -// return CreateStatusCode(STATUS_CODE_OK); -// } diff --git a/middleware/DeviceManager/src/LedManager.h b/middleware/DeviceManager/src/LedManager.h deleted file mode 100644 index 4ecbecd8..00000000 --- a/middleware/DeviceManager/src/LedManager.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 LED_MANAGER_H -#define LED_MANAGER_H - -#include "IDeviceManager.h" -#include "IHalCpp.h" -#include -#include - -constexpr LedState NEW_LED_STATE = LedState::OFF; -constexpr unsigned int LED_NOT_BLINK = 0; -constexpr unsigned int BLINKING_FAST_MS = 500; -constexpr unsigned int BLINKING_SLOW_MS = 1000; -constexpr long int DEFAULT_KEEP_ALIVE_TIME = 1500; -constexpr unsigned int DELETED_LED_STATE = -1; -constexpr unsigned int DO_NOT_KEEP_ALIVE = -2; - -class LedManager -{ -public: - LedManager(); - LedManager(std::shared_ptr &LedHal, const LedState &CurrentState, - const unsigned int &keepAliveTime = DEFAULT_KEEP_ALIVE_TIME, - const unsigned int &blinkPeriod = LED_NOT_BLINK); - ~LedManager() = default; - StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_NOT_OK); } - StatusCode Unit(void) { return CreateStatusCode(STATUS_CODE_NOT_OK); } - -public: - std::shared_ptr GetLedHal(void); - StatusCode SetLedState(const LedState &CurrentState, const unsigned int &keepAliveTime = DEFAULT_KEEP_ALIVE_TIME, - const unsigned int &blinkPeriod = LED_NOT_BLINK); - StatusCode GetLedState(LedState &CurrentState); - // StatusCode BlinkOn(LedState CurrentState, unsigned int KeepAliveTime); - // StatusCode BlinkOff(void); - -private: - std::shared_ptr mLedHal; - LedState mCurrentState; - unsigned int mBlinkPeriod; - unsigned int mKeepAliveTime; - unsigned int mStateAliveTime; -}; - -#endif diff --git a/middleware/DeviceManager/src/LedTimer.cpp b/middleware/DeviceManager/src/LedTimer.cpp deleted file mode 100644 index b0ae9eb2..00000000 --- a/middleware/DeviceManager/src/LedTimer.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 "LedTimer.h" -#include "ILog.h" -LedTimer::LedTimer() { mTimerRuning = false; } -std::shared_ptr &LedTimer::GetInstance(std::shared_ptr *impl) -{ - static auto instance = std::make_shared(); - // if (impl) - // { - // instance = *impl; - // } - return instance; -} - -// void LedTimer::Init(std::vector> &LedManagers) -void LedTimer::Init(void) -{ - // TimerLedManagers = LedManagers; - StartTimer(); -} -void LedTimer::UnInit(void) -{ - StopTimer(); - TimerLedManagers.clear(); -} -void LedTimer::StartTimer(void) -{ - - auto timerThread = [](std::shared_ptr timer) { timer->Timer(); }; - mTimer = std::thread(timerThread, shared_from_this()); -} -void LedTimer::StopTimer(void) -{ - mTimerRuning = false; - if (mTimer.joinable()) { - mTimer.join(); - } -} -void LedTimer::Timer(void) -{ - mTimerRuning = true; - while (mTimerRuning) { - mMutex.lock(); - CheckState(); - mMutex.unlock(); - std::this_thread::sleep_for(std::chrono::milliseconds(LED_STATE_CHECK_PERIOD_MS)); - } -} -const StatusCode LedTimer::AddTimerLedManager(std::shared_ptr &LedManager) -{ - TimerLedManagers.push_back(LedManager); - return CreateStatusCode(STATUS_CODE_OK); -} -const StatusCode LedTimer::CheckState(void) -{ - int count = 0; - for (auto it = TimerLedManagers.begin(); it != TimerLedManagers.end(); ++it) { - std::shared_ptr LedManager = *it; - } - return CreateStatusCode(STATUS_CODE_OK); -} diff --git a/middleware/DeviceManager/src/LedTimer.h b/middleware/DeviceManager/src/LedTimer.h deleted file mode 100644 index 68c9aef9..00000000 --- a/middleware/DeviceManager/src/LedTimer.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 LEDTIMER_H -#define LEDTIMER_H - -#include "LedManager.h" -#include -#include -#include -#include - -constexpr int LED_STATE_CHECK_PERIOD_MS = 100; - -class LedTimer : public std::enable_shared_from_this -{ -public: - LedTimer(); - ~LedTimer() = default; - static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); - // void Init(std::vector> &LedManagers); - void Init(void); - void UnInit(void); - void Timer(void); - const StatusCode CheckState(void); - const StatusCode AddTimerLedManager(std::shared_ptr &LedManager); - -private: - void StartTimer(void); - void StopTimer(void); - -private: - std::vector> TimerLedManagers; - std::mutex mMutex; - bool mTimerRuning; - std::thread mTimer; -}; - -#endif \ No newline at end of file diff --git a/test/hal/CMakeLists.txt b/test/hal/CMakeLists.txt index 0841d634..4e2f6110 100644 --- a/test/hal/CMakeLists.txt +++ b/test/hal/CMakeLists.txt @@ -20,12 +20,54 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) -aux_source_directory(./ SRC_FILES) +aux_source_directory(. SRC_FILES) aux_source_directory(./src SRC_FILES) -set(TARGET_NAME IHalTest) +set(TARGET_NAME HalTest) add_executable(${TARGET_NAME} ${SRC_FILES}) target_link_libraries(${TARGET_NAME} gtest gmock pthread Hal) if(${TEST_COVERAGE} MATCHES "true") target_link_libraries(${TARGET_NAME} gcov) -endif() \ No newline at end of file +endif() + +if ("${CLANG_TIDY_SUPPORT}" MATCHES "true") +add_custom_target( + HalTest_code_check + COMMAND ${CLANG_TIDY_EXE} + -checks='${CLANG_TIDY_CHECKS}' + --header-filter=.* + --system-headers=false + ${SRC_FILES} + ${CLANG_TIDY_CONFIG} + # --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/gtest.h\"}]' + --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/*.h\"}]' + -p ${PLATFORM_PATH}/cmake-shell + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/hal +) +add_custom_command( + TARGET ${TARGET_NAME} + PRE_BUILD + COMMAND make HalTest_code_check + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) + +file(GLOB_RECURSE HEADER_FILES *.h) +add_custom_target( + HalTest_code_format + COMMAND ${CLANG_FORMAT_EXE} + -style=file + -i ${SRC_FILES} ${SRC_FILES_MAIN} ${HEADER_FILES} + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/hal +) +add_custom_command( + TARGET ${TARGET_NAME} + PRE_BUILD + COMMAND make HalTest_code_check + COMMAND make HalTest_code_format + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) +endif() + +define_file_name(${TARGET_NAME}) + +add_subdirectory(tool) \ No newline at end of file diff --git a/test/hal/mainTest.cpp b/test/hal/mainTest.cpp index fb1d91b4..475ceee4 100644 --- a/test/hal/mainTest.cpp +++ b/test/hal/mainTest.cpp @@ -1,3 +1,17 @@ +/* + * 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 #include #include diff --git a/test/hal/src/IHalTest.cpp b/test/hal/src/IHalTest.cpp index b2b8ede8..e628205b 100644 --- a/test/hal/src/IHalTest.cpp +++ b/test/hal/src/IHalTest.cpp @@ -1,22 +1,34 @@ - -#include "ILog.h" +/* + * 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 "IHal.h" +#include "ILog.h" #include #include namespace IHalTest { - // ../output_files/test/bin/IHalTest --gtest_filter=IHalTest.Demo - TEST(IHalTest, Demo) - { - ILogInit(LOG_EASYLOGGING); - CreateHalModule(); - StatusCode code = IHalInit(); - if (IsCodeOK(code)) - { - PrintStringCode(code); - } - IHalUnInit(); - DestroyHalModule(); - ILogUnInit(); +// ../output_files/test/bin/IHalTest --gtest_filter=IHalTest.Demo +TEST(IHalTest, Demo) +{ + ILogInit(LOG_EASYLOGGING); + CreateHalModule(); + StatusCode code = IHalInit(); + if (IsCodeOK(code)) { + PrintStringCode(code); } -} \ No newline at end of file + IHalUnInit(); + DestroyHalModule(); + ILogUnInit(); +} +} // namespace IHalTest \ No newline at end of file diff --git a/test/hal/tool/CMakeLists.txt b/test/hal/tool/CMakeLists.txt new file mode 100644 index 00000000..7cea352c --- /dev/null +++ b/test/hal/tool/CMakeLists.txt @@ -0,0 +1,56 @@ +include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) +set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH}) +set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) + +include_directories( + ./src + ./include + ${UTILS_SOURCE_PATH}/StatusCode/include + ${UTILS_SOURCE_PATH}/Log/include + # ${UTILS_SOURCE_PATH}/McuProtocol/include + # ${MIDDLEWARE_SOURCE_PATH}/Hal/src + # ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include + # ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include +) +# link_directories( +# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs +# ) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +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} Log) + +if ("${CLANG_TIDY_SUPPORT}" MATCHES "true") +add_custom_target( + HalTestTool_code_check + COMMAND ${CLANG_TIDY_EXE} + -checks='${CLANG_TIDY_CHECKS}' + --header-filter=.* + --system-headers=false + ${TEST_TOOL_SRC_FILES} + ${CLANG_TIDY_CONFIG} + -p ${PLATFORM_PATH}/cmake-shell + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/hal/tool +) +file(GLOB_RECURSE HEADER_FILES *.h) +add_custom_target( + HalTestTool_code_format + COMMAND ${CLANG_FORMAT_EXE} + -style=file + -i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES} + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/hal/tool +) +add_custom_command( + TARGET ${TEST_TOOL_TARGET} + PRE_BUILD + COMMAND make HalTestTool_code_check + COMMAND make HalTestTool_code_format + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) +endif() + +define_file_name(${TEST_TOOL_TARGET}) \ No newline at end of file diff --git a/test/hal/tool/include/HalTestTool.h b/test/hal/tool/include/HalTestTool.h new file mode 100644 index 00000000..f80e05ad --- /dev/null +++ b/test/hal/tool/include/HalTestTool.h @@ -0,0 +1,18 @@ +/* + * 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 HAL_TEST_TOOL_H +#define HAL_TEST_TOOL_H + +#endif \ No newline at end of file diff --git a/test/hal/tool/src/HalTestTool.cpp b/test/hal/tool/src/HalTestTool.cpp new file mode 100644 index 00000000..6f566131 --- /dev/null +++ b/test/hal/tool/src/HalTestTool.cpp @@ -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 "HalTestTool.h" \ No newline at end of file diff --git a/test/middleware/CMakeLists.txt b/test/middleware/CMakeLists.txt index d6d93b9e..f6731ccc 100644 --- a/test/middleware/CMakeLists.txt +++ b/test/middleware/CMakeLists.txt @@ -3,4 +3,4 @@ add_subdirectory(IpcConfig) add_subdirectory(McuManager) add_subdirectory(McuAskBase) -add_subdirectory(LedTest) \ No newline at end of file +add_subdirectory(DeviceManager) \ No newline at end of file diff --git a/test/middleware/LedTest/CMakeLists.txt b/test/middleware/DeviceManager/CMakeLists.txt similarity index 58% rename from test/middleware/LedTest/CMakeLists.txt rename to test/middleware/DeviceManager/CMakeLists.txt index f77eea0d..e023fce0 100644 --- a/test/middleware/LedTest/CMakeLists.txt +++ b/test/middleware/DeviceManager/CMakeLists.txt @@ -1,23 +1,26 @@ # include(${CMAKE_SOURCE_DIR}/build/independent_source.cmake) - -# 变量赋值 include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) set(EXECUTABLE_OUTPUT_PATH ${TEST_OUTPUT_PATH}/bin) -# 链接提供头文件的路径 include_directories( - . ./src ./include + ./tool/include ${UTILS_SOURCE_PATH}/Log/include ${UTILS_SOURCE_PATH}/StatusCode/include - # ${MIDDLEWARE_SOURCE_PATH}/IpcConfig/include + ${UTILS_SOURCE_PATH}/UartDevice/include + ${UTILS_SOURCE_PATH}/McuProtocol/include ${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include + ${MIDDLEWARE_SOURCE_PATH}/DeviceManager/src + ${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include + ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include + ${TEST_SOURCE_PATH}/utils/UartDevice/tool/include + ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include + ${TEST_SOURCE_PATH}/middleware/McuAskBase/tool/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include ) -# 链接提供库的路径 link_directories( ${LIBS_OUTPUT_PATH} ${EXTERNAL_LIBS_OUTPUT_PATH} @@ -26,59 +29,57 @@ link_directories( set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) - -# 获取当前路径下的所有源文件, 添加到 SRC_FILES_MAIN 变量中 aux_source_directory(. SRC_FILES_MAIN) -# 获取./src路径下的所有源文件, 添加到 SRC_FILES 变量中 aux_source_directory(./src SRC_FILES) +if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX}) + aux_source_directory(./src_mock SRC_FILES) +endif() -set(TARGET_NAME Led_Test) - -# 生成可执行文件 +set(TARGET_NAME DeviceManagerTest) add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES}) - -target_link_libraries(${TARGET_NAME} DeviceManager gtest gmock pthread) +target_link_libraries(${TARGET_NAME} DeviceManager HalTestTool gtest gmock pthread) if(${TEST_COVERAGE} MATCHES "true") target_link_libraries(${TARGET_NAME} gcov) endif() - - - if ("${CLANG_TIDY_SUPPORT}" MATCHES "true") add_custom_target( - Led_Test_code_check + DeviceManagerTest_code_check COMMAND ${CLANG_TIDY_EXE} -checks='${CLANG_TIDY_CHECKS}' --header-filter=.* --system-headers=false ${SRC_FILES} ${CLANG_TIDY_CONFIG} + # --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/gtest.h\"}]' --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/*.h\"}]' -p ${PLATFORM_PATH}/cmake-shell - WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/LedTest + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/DeviceManager ) add_custom_command( TARGET ${TARGET_NAME} PRE_BUILD - COMMAND make Led_Test_code_check + COMMAND make DeviceManagerTest_code_check WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ ) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( - Led_Test_code_format + DeviceManagerTest_code_format COMMAND ${CLANG_FORMAT_EXE} -style=file -i ${SRC_FILES} ${SRC_FILES_MAIN} ${HEADER_FILES} - WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/LedTest + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/DeviceManager ) add_custom_command( TARGET ${TARGET_NAME} PRE_BUILD - COMMAND make Led_Test_code_check - COMMAND make Led_Test_code_format + COMMAND make DeviceManagerTest_code_check + COMMAND make DeviceManagerTest_code_format WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ ) endif() -define_file_name(${TARGET_NAME}) \ No newline at end of file + +define_file_name(${TARGET_NAME}) + +# add_subdirectory(tool) \ No newline at end of file diff --git a/test/middleware/DeviceManager/mainTest.cpp b/test/middleware/DeviceManager/mainTest.cpp new file mode 100644 index 00000000..475ceee4 --- /dev/null +++ b/test/middleware/DeviceManager/mainTest.cpp @@ -0,0 +1,23 @@ +/* + * 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 +#include +#include +#include +int main(int argc, char *argv[]) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/test/middleware/DeviceManager/src/DeviceManager_Test.cpp b/test/middleware/DeviceManager/src/DeviceManager_Test.cpp new file mode 100644 index 00000000..47c6864a --- /dev/null +++ b/test/middleware/DeviceManager/src/DeviceManager_Test.cpp @@ -0,0 +1,64 @@ +/* + * 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 "IDeviceManager.h" +#include "ILog.h" +#include +#include +#include +namespace DeviceManagerTest +{ +class DeviceManagerTest : public testing::Test +{ +public: + DeviceManagerTest() {} + virtual ~DeviceManagerTest() {} + static void SetUpTestCase() + { + CreateLogModule(); + ILogInit(LOG_INSTANCE_TYPE_END); + } + static void TearDownTestCase() { ILogUnInit(); } + virtual void SetUp() + { + CreateDeviceManagerModule(); + // mLinuxTest = LinuxTest::CreateLinuxTest(); + // std::shared_ptr test = mLinuxTest; + // LinuxApiMock::GetInstance(&test); + // LinuxApiMock::GetInstance()->Init(); + // McuManagerTestTool::Init(mLinuxTest); + // CreateMcuManager(); + } + virtual void TearDown() + { + // LinuxApiMock::GetInstance()->UnInit(); + // mLinuxTest = std::make_shared(); + // std::shared_ptr test = std::make_shared(); + // LinuxApiMock::GetInstance(&test); + // McuManagerTestTool::UnInit(); + // DestroyMcuManager(); + DestroyDeviceManagerModule(); + } + +public: + // std::shared_ptr mLinuxTest; +}; +// ../output_files/test/bin/DeviceManagerTest --gtest_filter=DeviceManagerTest.INTEGRATION_DeviceManager_EXAMPLE_Demo +TEST_F(DeviceManagerTest, INTEGRATION_DeviceManager_EXAMPLE_Demo) +{ + IDeviceManager::GetInstance()->Init(); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + IDeviceManager::GetInstance()->UnInit(); +} +} // namespace DeviceManagerTest \ No newline at end of file diff --git a/test/middleware/LedTest/mainTest.cpp b/test/middleware/LedTest/mainTest.cpp deleted file mode 100644 index fb1d91b4..00000000 --- a/test/middleware/LedTest/mainTest.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include -#include -int main(int argc, char *argv[]) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} \ No newline at end of file diff --git a/test/middleware/LedTest/src/Led_Test.cpp b/test/middleware/LedTest/src/Led_Test.cpp deleted file mode 100644 index 78edbe61..00000000 --- a/test/middleware/LedTest/src/Led_Test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "IDeviceManager.h" -#include "ILog.h" -#include - -namespace Led_Test -{ -// ../output_files/test/bin/Led_Test --gtest_filter=Led_Test.Demo - -TEST(Led_Test, Demo) -{ - // 初始化Log - CreateLogModule(); - CreateDeviceManagerModule(); - - IDeviceManager::GetInstance()->Init(); - LedState _Led_State = LED_STATE_RED; - IDeviceManager::GetInstance()->SetLedState("Led_testing", _Led_State, 10, 0); - IDeviceManager::GetInstance()->UnInit(); -} - -} /*namespace Led_Test*/ diff --git a/test/utils/UartDevice/src_mock/UartDevice_Mock_Test.cpp b/test/utils/UartDevice/src_mock/UartDevice_Mock_Test.cpp index fac88497..b4f09a3a 100644 --- a/test/utils/UartDevice/src_mock/UartDevice_Mock_Test.cpp +++ b/test/utils/UartDevice/src_mock/UartDevice_Mock_Test.cpp @@ -167,7 +167,7 @@ TEST_F(UartDeviceMockTest, UNIT_UartDevice_AUTO_RecvData) TEST_F(UartDeviceMockTest, UNIT_UartDevice_AUTO_MultiThreadTest) { auto openThread = [](void) { - LogInfo("===========openThread \n"); + LogInfo("openThread.\n"); void *object = CreateUartDevice(gUartDevice); IUartOpen(object); IUartDeviceFree(object);