From a9f698bf8be050f6a7ee058b96cc3ad1e4c2eece Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Sat, 13 Jul 2024 21:34:28 +0800 Subject: [PATCH] Improve:App protocol. --- README.md | 2 +- application/MissionManager/src/AppMonitor.cpp | 47 ++++++++++----- .../MissionManager/src/MediaHandleState.cpp | 15 ++++- .../MissionManager/src/MediaHandleState.h | 4 ++ application/MissionManager/src/MediaTask.cpp | 5 +- application/MissionManager/src/MediaTask.h | 2 + middleware/AppManager/include/IAppManager.h | 4 ++ middleware/AppManager/src/AppManager.cpp | 21 +++++++ middleware/AppManager/src/AppManager.h | 1 + middleware/AppManager/src/IAppManager.cpp | 32 ++++++++++ .../src/Protocol/SixFrame/SixFrameHandle.cpp | 58 +++++++++++++++---- .../FilesManager/src/sqlite3/SqliteHandle.cpp | 16 ++--- .../src_mock/AppMonitor_Mock_Test.cpp | 48 ++++++++++++++- .../tool/src/AppManagerTestTool.cpp | 4 +- 14 files changed, 217 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 7440f11..8d65bdd 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ```code # 项目根目录执行: -$ make install-cmake +$ make install_cmake ``` ### 1.2.2. llvm工具安装 diff --git a/application/MissionManager/src/AppMonitor.cpp b/application/MissionManager/src/AppMonitor.cpp index 8d98fca..55dbd3e 100644 --- a/application/MissionManager/src/AppMonitor.cpp +++ b/application/MissionManager/src/AppMonitor.cpp @@ -101,26 +101,41 @@ StatusCode AppMonitor::GetStorageInfo(std::vector ¶m) } StatusCode AppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector ¶m) { - std::vector types; std::vector info; - types.push_back(FileCreateType::PIR); - IFilesManager::GetInstance()->GetAllFiles(info); - LogInfo("GetStorageFileList: file size = %d.\n", info.size()); - if (StorageFileEvent::LOOP == fileInfo.mEvent) { + if (StorageFileEvent::ALL == fileInfo.mEvent) { + IFilesManager::GetInstance()->GetAllFiles(info); + } + else { + std::vector types; + if (StorageFileEvent::LOOP == fileInfo.mEvent) { + types.push_back(FileCreateType::TIMED); + types.push_back(FileCreateType::MANUAL_TEST); + types.push_back(FileCreateType::MANUAL_PHONE); + types.push_back(FileCreateType::TIMED); + } + if (StorageFileEvent::EMR == fileInfo.mEvent) { + types.push_back(FileCreateType::PIR); + } + if (StorageFileEvent::EVENT == fileInfo.mEvent) { + types.push_back(FileCreateType::MANUAL_TEST); + types.push_back(FileCreateType::MANUAL_PHONE); + } + if (StorageFileEvent::PARK == fileInfo.mEvent) { + types.push_back(FileCreateType::TIMED); + } + IFilesManager::GetInstance()->GetFiles(types, info); + } + LogInfo("GetStorageFileList: file size = %d, event = %s.\n", + info.size(), + IAppManager::GetInstance()->StorageFileEventToString(fileInfo.mEvent)); + for (auto &oneFileInfo : info) { AppGetFileList file; - file.mCreateTime_s = 123456789; - file.mDuration = 182; - file.mName = "/DCIM/2024/01/15/20240115140207-20240115140509.mp4"; - file.mSize = 1024 * 182; + file.mCreateTime_s = oneFileInfo.mCreateTime_s; + file.mDuration = oneFileInfo.mFileDuration; + file.mName = oneFileInfo.mFileName; + file.mSize = oneFileInfo.mFileSize; file.mType = StorageFileType::VIDEO; param.push_back(file); - AppGetFileList file2; - file2.mCreateTime_s = 123456789; - file2.mDuration = 0; - file2.mName = "/34a396526922a33e97906920dbfef2a5.jpg"; - file2.mSize = 1024; - file2.mType = StorageFileType::PICTURE; - param.push_back(file2); } return CreateStatusCode(STATUS_CODE_OK); } diff --git a/application/MissionManager/src/MediaHandleState.cpp b/application/MissionManager/src/MediaHandleState.cpp index 3feb577..deb30bd 100644 --- a/application/MissionManager/src/MediaHandleState.cpp +++ b/application/MissionManager/src/MediaHandleState.cpp @@ -24,6 +24,7 @@ #include "MissionStateMachine.h" #include #include +#include #include MediaHandleState::MediaHandleState() : State("MediaHandleState") { @@ -66,15 +67,25 @@ bool MediaHandleState::MediaTaskFinishedHandle(VStateMachineData *msg) LogInfo("response files = %d.\n", data->mData.mResponse.size()); std::vector files; for (auto &response : data->mData.mResponse) { + auto fileSize = GetFileSize_KB(response.mFileName.c_str()); SyncFileInfo file(data->mData.mSerialNumber, response.mFileName, - 0, + fileSize, response.mDuration_ms, - 0, + data->mData.mCreateTime_s, FileCreateType::MANUAL_TEST, FileStatus::FINISHED_RECORD); files.push_back(file); } IFilesManager::GetInstance()->SaveFiles(files); return EXECUTED; +} +int MediaHandleState::GetFileSize_KB(const char *filePath) +{ + struct stat fileInfo; + if (stat(filePath, &fileInfo) != 0) { + LogError("stat failed.\n"); + return FILE_SIZE_ERROR; + } + return static_cast(fileInfo.st_size) / 1024.0; } \ No newline at end of file diff --git a/application/MissionManager/src/MediaHandleState.h b/application/MissionManager/src/MediaHandleState.h index e68349a..2fe1ab4 100644 --- a/application/MissionManager/src/MediaHandleState.h +++ b/application/MissionManager/src/MediaHandleState.h @@ -17,6 +17,7 @@ #include "DataProcessing.h" #include "IStateMachine.h" #include "MediaTaskHandle.h" +constexpr int FILE_SIZE_ERROR = -1; class MediaHandleState : public State, public DataProcessing, public MediaTaskHandle, @@ -34,5 +35,8 @@ private: void TaskResponse(const MediaTaskInfo &taskinfo) override; bool ResetKeyMediaTaskHandle(VStateMachineData *msg); bool MediaTaskFinishedHandle(VStateMachineData *msg); + +private: + static int GetFileSize_KB(const char *filePath); }; #endif \ No newline at end of file diff --git a/application/MissionManager/src/MediaTask.cpp b/application/MissionManager/src/MediaTask.cpp index 626aa5c..fb45cd0 100644 --- a/application/MissionManager/src/MediaTask.cpp +++ b/application/MissionManager/src/MediaTask.cpp @@ -29,7 +29,8 @@ MediaTask::MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEvent, const std::weak_ptr &iniator, const unsigned long &serialNumber, const std::string &savePath) - : mType(type), mBindEvent(bindEvent), mIniator(iniator), mSerialNumber(serialNumber), mSavePath(savePath) + : mType(type), mBindEvent(bindEvent), mIniator(iniator), mSerialNumber(serialNumber), mSavePath(savePath), + mCreateTime_s(0) { mResponseData.reset(); mTargetName.clear(); @@ -47,6 +48,7 @@ std::string MediaTask::GetTargetNameForSaving(void) time_t t_now = std::chrono::system_clock::to_time_t(now); struct tm tm_now = *std::localtime(&t_now); + mCreateTime_s = std::chrono::duration_cast(now.time_since_epoch()).count(); int hour = tm_now.tm_hour; int minute = tm_now.tm_min; int second = tm_now.tm_sec; @@ -69,6 +71,7 @@ void MediaTask::Response(const std::vector &response) MediaTaskInfo info = { .mResponse = response, .mSerialNumber = mSerialNumber, + .mCreateTime_s = mCreateTime_s, }; iniator->TaskResponse(info); } \ No newline at end of file diff --git a/application/MissionManager/src/MediaTask.h b/application/MissionManager/src/MediaTask.h index 7300492..98e6634 100644 --- a/application/MissionManager/src/MediaTask.h +++ b/application/MissionManager/src/MediaTask.h @@ -22,6 +22,7 @@ typedef struct media_task_info { const std::vector mResponse; const unsigned long mSerialNumber; + const long long mCreateTime_s; } MediaTaskInfo; class VMediaTaskIniator { @@ -50,5 +51,6 @@ private: bool mFinished = false; std::shared_ptr mResponseData; std::string mTargetName; + long long mCreateTime_s; }; #endif \ No newline at end of file diff --git a/middleware/AppManager/include/IAppManager.h b/middleware/AppManager/include/IAppManager.h index 8115fa8..5ce1253 100644 --- a/middleware/AppManager/include/IAppManager.h +++ b/middleware/AppManager/include/IAppManager.h @@ -76,6 +76,9 @@ enum class StorageFileType }; /** * @brief A file classification list mapped to hunting camera scenes based on the dash cam protocol. + * NOTE: ALL is the process of getting all files in the protocol, while LOOP is the "all" files mapped to the hunting + * camera scene according to the protocol. ALL includes LOOP and other types outside LOOP, and LOOP returns the "all" + * file list in the hunting camera scene. */ enum class StorageFileEvent { @@ -340,5 +343,6 @@ public: virtual const StatusCode UnInit(void); virtual const StatusCode SetAppMonitor(std::shared_ptr &monitor); virtual StatusCode SetSdCardStatus(const SdCardStatus &status); + virtual const char *StorageFileEventToString(const StorageFileEvent &event); }; #endif \ No newline at end of file diff --git a/middleware/AppManager/src/AppManager.cpp b/middleware/AppManager/src/AppManager.cpp index 2cd7163..d16a1f8 100644 --- a/middleware/AppManager/src/AppManager.cpp +++ b/middleware/AppManager/src/AppManager.cpp @@ -75,6 +75,27 @@ StatusCode AppManager::SetSdCardStatus(const SdCardStatus &status) } return CreateStatusCode(STATUS_CODE_OK); } +const char *AppManager::StorageFileEventToString(const StorageFileEvent &event) +{ + switch (event) { + case StorageFileEvent::LOOP: + return "LOOP"; + case StorageFileEvent::EMR: + return "EMR"; + case StorageFileEvent::EVENT: + return "EVENT"; + case StorageFileEvent::PARK: + return "PARK"; + case StorageFileEvent::ALL: + return "ALL"; + case StorageFileEvent::END: + return "END"; + + default: + return "UNDEFINE"; + break; + } +} void AppManager::AppRequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle, void *context) { diff --git a/middleware/AppManager/src/AppManager.h b/middleware/AppManager/src/AppManager.h index 0034e8d..3c5c986 100644 --- a/middleware/AppManager/src/AppManager.h +++ b/middleware/AppManager/src/AppManager.h @@ -27,6 +27,7 @@ public: const StatusCode UnInit(void) override; const StatusCode SetAppMonitor(std::shared_ptr &monitor) override; StatusCode SetSdCardStatus(const SdCardStatus &status) override; + const char *StorageFileEventToString(const StorageFileEvent &event) override; void AppRequestHandle(const char *url, const unsigned int urlLength, ResponseHandle responseHandle, void *context); void AppRequestHandleTcp(const char *data, const unsigned int dataLength, ResponseHandle responseHandle, void *context); diff --git a/middleware/AppManager/src/IAppManager.cpp b/middleware/AppManager/src/IAppManager.cpp index aba2ba6..ddf8c23 100644 --- a/middleware/AppManager/src/IAppManager.cpp +++ b/middleware/AppManager/src/IAppManager.cpp @@ -100,92 +100,116 @@ app_param::app_param(const char *ip, const int &httpPort, const int &tcpPort) } void VAppClient::SetRecordingStatus(const RecordingStatus &status) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); } void VAppClient::SetMicrophoneStatus(const MicrophoneStatus &status) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); } void VAppClient::SetBatteryStatus(const BatteryStatus &status, const int &batteryCapacity) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); } void VAppClient::SetSdCardStatus(const SdCardStatus &status) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); } void VAppClient::DeletedFileMessage(const std::string &file, const StorageFileType &type) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); } void VAppClient::CreatedFileMessage(const std::string &file, const StorageFileType &type) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); } StatusCode VAppMonitor::GetProductInfo(AppGetProductInfo ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetDeviceAttr(AppGetDeviceAttr ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetMediaInfo(AppGetMediaInfo ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetBatteryInfo(AppGetBatteryInfo ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetParamValue(AppParamValue ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetCapability(AppGetCapability ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetLockVideoStatus(LockVideoStatus ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetStorageInfo(std::vector ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::SetDateTime(const AppSetDateTime ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::SetTimeZone(const unsigned int &zone) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::SetParamValue(const AppSetParamValue ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::EnterRecorder(void) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::AppPlayback(const PlayBackEvent &event) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::UploadFile(AppUploadFile ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::GetThumbnail(AppGetThumbnail ¶m) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VAppMonitor::AppClientConnected(std::shared_ptr &client) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } std::shared_ptr &IAppManager::GetInstance(std::shared_ptr *impl) @@ -204,17 +228,25 @@ std::shared_ptr &IAppManager::GetInstance(std::shared_ptr &monitor) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode IAppManager::SetSdCardStatus(const SdCardStatus &status) { + LogInfo("STATUS_CODE_VIRTUAL_FUNCTION\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +} +const char *IAppManager::StorageFileEventToString(const StorageFileEvent &event) +{ + return "STATUS_CODE_VIRTUAL_FUNCTION"; } \ No newline at end of file diff --git a/middleware/AppManager/src/Protocol/SixFrame/SixFrameHandle.cpp b/middleware/AppManager/src/Protocol/SixFrame/SixFrameHandle.cpp index 56ed3de..2993de8 100644 --- a/middleware/AppManager/src/Protocol/SixFrame/SixFrameHandle.cpp +++ b/middleware/AppManager/src/Protocol/SixFrame/SixFrameHandle.cpp @@ -597,41 +597,68 @@ AppGetFileInfo inline SixFrameHandle::RequestGetFileListParse(const std::string }; std::shared_ptr parse = std::make_shared>(); std::shared_ptr> parseImpl = std::dynamic_pointer_cast>(parse); + /** + * @brief If there is no "folder" field, it means to obtain all types of files (including: LOOP, EMR, EVENT, PARK). + * Example: http://192.168.1.100/app/getfilelist ==> no "folder" field + */ parseImpl->mData.mEvent = StorageFileEvent::ALL; ExtractParamsFromUrl(url, parseFunc, parse); return parseImpl->mData; } +/** + * @brief The code discussion at this stage is a bit confusing, because it is based on the projection of the file types + * that mobile apps use to hunt for opponents. If you still have doubts, please refer to the README document. + */ void SixFrameHandle::RequestGetFileList(const std::string &url, ResponseHandle responseHandle, void *context) { LogInfo("RequestGetFileList.\n"); std::vector files; AppGetFileInfo info = RequestGetFileListParse(url); - mAppMonitor->GetStorageFileList(info, files); cJSON *result = MakeResponseResult(ResposeResult::SUCCESSFUL); - if (nullptr == result) { + cJSON *infoJson = cJSON_CreateArray(); + if (nullptr == result || nullptr == infoJson) { LogError("MakeResponseResult failed.\n"); responseHandle("Device run out of memory.", context); return; } - ResponseGetFileList(result, files, info); + LogInfo("info.mEvent: %s\n", IAppManager::GetInstance()->StorageFileEventToString(info.mEvent)); + cJSON_AddItemToObject(result, CJSON_INFO_STRING, infoJson); + if (StorageFileEvent::ALL == info.mEvent) { // "ALL" means that all types of files are retrieved once. + for (int i = 0; i < static_cast(StorageFileEvent::ALL); i++) { + files.clear(); + info.mEvent = static_cast(i); + LogInfo("GetStorageFileList: %s\n", IAppManager::GetInstance()->StorageFileEventToString(info.mEvent)); + mAppMonitor->GetStorageFileList(info, files); + ResponseGetFileList(infoJson, files, info); + } + } + else if (StorageFileEvent::LOOP == info.mEvent) { // "LOOP" means to get all files at once. + info.mEvent = StorageFileEvent::ALL; + mAppMonitor->GetStorageFileList(info, files); + ResponseGetFileList(infoJson, files, info); + } + else { + mAppMonitor->GetStorageFileList(info, files); + ResponseGetFileList(infoJson, files, info); + } ResponseJsonString(result, responseHandle, context); cJSON_Delete(result); } -void inline SixFrameHandle::ResponseGetFileList(cJSON *result, const std::vector ¶m, +void inline SixFrameHandle::ResponseGetFileList(cJSON *resultInfo, const std::vector ¶m, const AppGetFileInfo &fileInfo) { - cJSON *info = cJSON_CreateArray(); + // cJSON *info = cJSON_CreateArray(); cJSON *folder = cJSON_CreateObject(); cJSON *files = cJSON_CreateArray(); - if (nullptr == info || nullptr == folder || nullptr == files) { + if (nullptr == resultInfo || nullptr == folder || nullptr == files) { LogError("cJSON_CreateArray failed.\n"); return; } - cJSON_AddItemToObject(result, CJSON_INFO_STRING, info); - cJSON_AddItemToArray(info, folder); + // cJSON_AddItemToObject(result, CJSON_INFO_STRING, info); + cJSON_AddItemToArray(resultInfo, folder); + cJSON_AddStringToObject(folder, "folder", PrintfFileEvent(fileInfo)); + cJSON_AddNumberToObject(folder, "count", param.size()); for (const auto &fileList : param) { - cJSON_AddStringToObject(folder, "folder", PrintfFileEvent(fileInfo)); - cJSON_AddNumberToObject(folder, "count", param.size()); cJSON *file = nullptr; file = cJSON_CreateObject(); if (nullptr != file) { @@ -983,9 +1010,18 @@ void SixFrameHandle::ResponseJsonString(cJSON *json, ResponseHandle responseHand const char *SixFrameHandle::PrintfFileEvent(const AppGetFileInfo &fileInfo) { switch (fileInfo.mEvent) { + case StorageFileEvent::ALL: case StorageFileEvent::LOOP: { return "loop"; - break; + } + case StorageFileEvent::EMR: { + return "emr"; + } + case StorageFileEvent::EVENT: { + return "event"; + } + case StorageFileEvent::PARK: { + return "park"; } default: { diff --git a/middleware/FilesManager/src/sqlite3/SqliteHandle.cpp b/middleware/FilesManager/src/sqlite3/SqliteHandle.cpp index 5c994ff..5946d00 100644 --- a/middleware/FilesManager/src/sqlite3/SqliteHandle.cpp +++ b/middleware/FilesManager/src/sqlite3/SqliteHandle.cpp @@ -143,18 +143,19 @@ bool SqliteHandle::SyncFile(const SyncFileInfo &info) bool SqliteHandle::SearchFiles(const std::vector &types, std::vector &info) { std::string sqlAnd = " "; - if (types.size() > 1) { - sqlAnd = " AND "; - } + // if (types.size() > 1) { + // sqlAnd = " AND "; + // } constexpr FileCreateType END_MEANS_SEARCHING_ALL_FILES = FileCreateType::END; std::stringstream sqlStream; if (types.size() == 1 && types[0] == END_MEANS_SEARCHING_ALL_FILES) { sqlStream << "SELECT * from " FILES_TABLE << ";"; } else { - sqlStream << "SELECT * from " FILES_TABLE; + sqlStream << "SELECT * from " FILES_TABLE " WHERE "; for (auto &type : types) { - sqlStream << sqlAnd << "WHERE " FILE_TYPE " = '" << ConvertFileTypeToString(type) << "'"; + sqlStream << sqlAnd << FILE_TYPE " = '" << ConvertFileTypeToString(type) << "'"; + sqlAnd = " OR "; } sqlStream << ";"; } @@ -312,8 +313,9 @@ bool SqliteHandle::SearchFiles(sqlite3 *db, const std::string &sql, std::vector< * TEXT, size INTEGER, status TEXT, duration INTEGER); * 4 5 6 */ - if (6 != argc) { - LogError("Something wrong happened.\n"); + constexpr int TABLE_MEMBER_NUM = 7; + if (TABLE_MEMBER_NUM != argc) { + LogError("Something wrong happened, argc = %d.\n", argc); return 0; } std::vector *info = (std::vector *)data; diff --git a/test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp b/test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp index 7c40916..71d0a56 100644 --- a/test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp +++ b/test/application/HuntingCamera/src_mock/AppMonitor_Mock_Test.cpp @@ -160,8 +160,8 @@ TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageInfo) MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HuntingCameraTest -// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList -TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList) +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_ALL +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_ALL) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); @@ -171,6 +171,50 @@ TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList) MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_LOOP +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_LOOP) +{ + McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + MockGetStorageFileList(StorageFileEvent::LOOP); + MainThread::GetInstance()->Runing(); +} +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_EMR +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_EMR) +{ + McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + MockGetStorageFileList(StorageFileEvent::EMR); + MainThread::GetInstance()->Runing(); +} +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_EVENT +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_EVENT) +{ + McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + MockGetStorageFileList(StorageFileEvent::EVENT); + MainThread::GetInstance()->Runing(); +} +// ../output_files/test/bin/HuntingCameraTest +// --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_PARK +TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList_PARK) +{ + McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + MockGetStorageFileList(StorageFileEvent::PARK); + MainThread::GetInstance()->Runing(); +} +// ../output_files/test/bin/HuntingCameraTest // --gtest_filter=HuntingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetParamValue TEST_F(HuntingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetParamValue) { diff --git a/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp b/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp index fb8e725..8610704 100644 --- a/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp +++ b/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp @@ -185,8 +185,8 @@ void AppManagerTestTool::MockGetStorageFileList(const StorageFileEvent &event) std::shared_ptr mock = std::dynamic_pointer_cast(mAppMonitorMock); if (mock) { EXPECT_CALL(*mock.get(), GetStorageFileListTrace(_, _)) - .Times(ONLY_BE_CALLED_ONCE) - .WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION)))); + .Times(AtLeast(1)) + .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION)))); } ServersMock::GetInstance()->MockGetStorageFileList(event); }