Delete test tool.
This commit is contained in:
parent
f0c02cef1a
commit
d85e4ed790
|
@ -1,42 +0,0 @@
|
||||||
# 1. clang-tidy使用指南
|
|
||||||
|
|
||||||
   使用clang-tidy工具进行代码规范管理。
|
|
||||||
1. 编译时实时报错;
|
|
||||||
2. 指定自研源码检测;
|
|
||||||
|
|
||||||
## 1.1. 环境搭建
|
|
||||||
|
|
||||||
1. llvm使用cmake编译,cmake版本要求 3.20以上,此处使用cmake-3.27.4
|
|
||||||
```
|
|
||||||
// cmake源码目录://tools/cmake/cmake-3.27.4.tar.gz
|
|
||||||
// cmake源码安装:
|
|
||||||
tar zxvf cmake-3.27.4.tar.gz
|
|
||||||
cd cmake-3.27.4/
|
|
||||||
sudo apt-get install openssl // 如果执行./bootstrap提示缺少ssl相关资源,执行此安装命令
|
|
||||||
./bootstrap
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
2. 安装llvm
|
|
||||||
```
|
|
||||||
// 下载源码
|
|
||||||
git clone https://github.com/llvm/llvm-project.git
|
|
||||||
cd llvm-project/
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ../llvm
|
|
||||||
make -j8
|
|
||||||
find ./ -name clang-tidy // 确认编译完成
|
|
||||||
```
|
|
||||||
|
|
||||||
## 1.2. clang-tidy使用
|
|
||||||
修改配置:< IPC-SDK >/build/global_config.cmake
|
|
||||||
```
|
|
||||||
# ------------ build clang-tools ------------ #
|
|
||||||
if(${LINUX_TEST} MATCHES "true")
|
|
||||||
set(CLANG_TIDY_SUPPORT "true") // 使能工具
|
|
||||||
set(CLANG_FORMAT_SUPPORT "true")
|
|
||||||
set(LLVM_PATH "/home/xiaojiazhu/project/tmp/llvm-project") // llvm安装目录
|
|
||||||
endif()
|
|
||||||
# ------------ build clang-tools end ------------ #
|
|
||||||
```
|
|
|
@ -1,54 +0,0 @@
|
||||||
# 1.cmake开发报告
|
|
||||||
|
|
||||||
## 1.1 前言
|
|
||||||
该篇md用于ipc项目下log功能的cmakelist的开发报告,以阐述其功能和组成。
|
|
||||||
|
|
||||||
## 1.2 功能介绍
|
|
||||||
* 设置库文件输出路径:`set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})`.
|
|
||||||
该语句用于设置该功能的静态库的生成路径,其中`${LIBS_OUTPUT_PATH}`在/build/cmake/global_config.cmake被定义在项目根目录的/output_files/libs/。
|
|
||||||
|
|
||||||
* 添加实现功能的文件目录:`include_directories(./)`.
|
|
||||||
该语句旨在向编译器告知该功能的实现文件和头文件的所在位置。
|
|
||||||
|
|
||||||
* 添加功能目录到搜索路径:`set(CMAKE_AUTOMOC ON);set(CMAKE_INCLUDE_CURRENT_DIR ON)`
|
|
||||||
这些 CMake 命令支持自动处理 Qt moc(元对象编译器),并将当前目录设置为包含在包含文件的搜索路径中;在构建过程中自动运行Qt moc编译器,用于包含Q_OBJECT宏的任何源文件。这对于为信号和插槽生成必要的C++代码是必需的;该选项将当前源目录添加到包含文件的搜索路径中。这允许构建系统查找与正在编译的源文件位于同一目录中的头文件。
|
|
||||||
|
|
||||||
* 收集、生成头文件列表:`file(GLOB_RECURSE HEADER_FILES "*.h")`
|
|
||||||
该语句的功能是搜索当前目录及其子目录中扩展名为 .h 的所有文件。生成的文件列表存储在 HEADER_FILES 变量中。
|
|
||||||
|
|
||||||
* 收集源文件列表:`aux_source_directory(. SRC_FILES)`
|
|
||||||
在本语句中,aux_source_directory(.SRC_FILES) 从当前目录(由 .) 及其子目录中收集所有源文件(例如,.cpp 个文件),生成的文件列表存储在 SRC_FILES 变量中。
|
|
||||||
|
|
||||||
* 添加编译器标志和定义到当前目录及其子目录:`add_definitions("-fexceptions")`
|
|
||||||
添加编译器标志`-fexceptions`以在代码中启用异常处理。此标志告诉编译器生成支持捕获和引发异常的代码。通过使用 add_definitions(),可以将特定的编译器标志或定义全局应用于项目或特定源文件。
|
|
||||||
|
|
||||||
* 创建静态库目标:`add_library(xlog STATIC ${SRC_FILES} ${HEADER_FILES})`
|
|
||||||
在这种情况下,本语句使用提供的源文件和头文件列表创建一个名为“xlog”的静态库目标;`STATIC`关键字指定库将构建为静态库,这意味着库代码将在编译时直接链接到最终可执行文件中;`${SRC_FILES}`变量包含应编译并链接到库中的源文件(通常.cpp文件)的列表。${HEADER_FILES} 变量包含头文件(通常为 .h 文件)的列表,这些文件定义库使用的接口和声明。
|
|
||||||
|
|
||||||
## 1.3 总结
|
|
||||||
该篇cmakelists.txt的主要用途是对ipc项目下xlog功能的显现文件的编译和汇总。
|
|
||||||
|
|
||||||
## 2.1 返回码管理库概述
|
|
||||||
提供整个应用程序的返回码管理功能,例如:打印返回码的字符串含义。提供C语言接口,内部实现不限于C或者C++,形成项目内部唯一返回码标准。
|
|
||||||
|
|
||||||
## 2.2 功能介绍
|
|
||||||
* 设置可执行文件的输出路径:`set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})`;`set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})`
|
|
||||||
|
|
||||||
* 引入头文件目录:`include_directories`。`include_directories`表示引入头文件搜索路径,当工程要用到某个头文件的时候,就会去该路径下搜索。
|
|
||||||
|
|
||||||
* 开启自动编译:`set(CMAKE_AUTOMOC ON)` `set(CMAKE_INCLUDE_CURRENT_DIR ON)`. 这段代码开启了 CMake 的元对象编译器、界面编译器和资源编译器自动编译,这样当项目使用了包含元对象的文件、界面文件和资源文件时 CMake 可以自动检测并编译。
|
|
||||||
|
|
||||||
* 查找在./src路径下的所有源文件:`aux_source_directory(./src SRC_FILES)` 。
|
|
||||||
|
|
||||||
* 设置ReturnCode地址:`set(TARGET_NAME ReturnCode)`。根据提供的源文件创建一个叫ReturnCode的静态库。然后将目标文件与库文件进行链接:`target_link_libraries(${TARGET_NAME} Log)`。
|
|
||||||
|
|
||||||
## 2.3 返回码test
|
|
||||||
* 添加test文件到目录,本目录为测试代码目录,目录结构保持与源码目录结构一致。
|
|
||||||
|
|
||||||
* 在test各个文件夹里添加相对应的CMakeLists.txt文件,通过`add_subdirectory(utils)`添加与源码目录结构相对应的子文件夹。
|
|
||||||
|
|
||||||
* 在src文件夹下创建ReturnCodeTest.cpp,调用返回码管理接口。在根目录添加第三方库文件,存放需要用到的第三方库。
|
|
||||||
|
|
||||||
## 2.4 总结
|
|
||||||
Cmake的语句都在CMakeLists.txt的文件中,Cmake运行之后就会产生想要的makefile文件,然后再直接make就可以编译出可执行程序。
|
|
||||||
|
|
1103
doc/design.md
1103
doc/design.md
File diff suppressed because it is too large
Load Diff
|
@ -1,111 +0,0 @@
|
||||||
# 1. SDK开发规范
|
|
||||||
|
|
||||||
## 1.1. 编码规范
|
|
||||||
|
|
||||||
### 1.1.1. 指针/智能指针
|
|
||||||
|
|
||||||
* C++编码只能使用智能指针;
|
|
||||||
* 指针遵循谁使用谁进行“非空”判断,且无比使用前进行“非空”判断;
|
|
||||||
* 智能指针经过转换后务必进行“非空”判断;
|
|
||||||
|
|
||||||
理论上,**明显不可能为空的指针,可以不进行“非空”判断**,可以不进行“非空”判断的场景:
|
|
||||||
|
|
||||||
```
|
|
||||||
void McuManagerImpl::OtherSideSendIpcMission(const unsigned int &serialNumber, const unsigned char &mission)
|
|
||||||
{
|
|
||||||
class McuRecvIpcMission : public McuRecvImpl, public McuRecv<unsigned char>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
McuRecvIpcMission(std::shared_ptr<McuManagerImpl> &mcuManager, const unsigned int &serialNumber,
|
|
||||||
const OtherSideSendType &sendType, const unsigned char &mission)
|
|
||||||
: McuRecvImpl(serialNumber, sendType)
|
|
||||||
{
|
|
||||||
McuRecv::mDataRecvReply = mission;
|
|
||||||
McuRecvImpl::mMcuManager = mcuManager;
|
|
||||||
}
|
|
||||||
~McuRecvIpcMission() = default;
|
|
||||||
void ReplyFinished(const bool result) override
|
|
||||||
{
|
|
||||||
// 此处可以不进行“非空”判断,该值在有限范围内(OtherSideSendIpcMission函数内部)就能看出是否为空
|
|
||||||
McuRecvImpl::mMcuManager->ReplyOtherSideSendIpcMission(ASK_RESULT::SUCCEED, McuRecvImpl::mSerialNumber);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
std::shared_ptr<VMcuMonitor> monitor = GetMcuMonitor();
|
|
||||||
std::shared_ptr<McuManagerImpl> manager = std::dynamic_pointer_cast<McuManagerImpl>(SharedFromThis());
|
|
||||||
std::shared_ptr<VMcuRecv> recv =
|
|
||||||
std::make_shared<McuRecvIpcMission>(manager, serialNumber, OtherSideSendType::SEND_IPC_MISSION, mission);
|
|
||||||
if (monitor) {
|
|
||||||
monitor->RecvIpcMissionEvent(recv, static_cast<IpcMission>(mission));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("mMonitor is nullptr, AddMcuRecv.\n");
|
|
||||||
AddMcuRecv(recv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**没有进行“非空”判断的代码,应该开发测试用例,保证“空指针”的报错。**
|
|
||||||
|
|
||||||
### 1.1.2. 注释
|
|
||||||
|
|
||||||
* 注释必须使用英文,且使用翻译器翻译;
|
|
||||||
  避免编码问题导致的乱码,且需要保证阅读困难时可使用翻译器翻译成可读的中文;
|
|
||||||
|
|
||||||
**注:** 注释翻译工具使用[百度翻译](https://fanyi.baidu.com/);翻译的注释在使用doxygen工具生成接口文档时,在网页上方便翻译成中文。
|
|
||||||
|
|
||||||
### 1.1.3. C++继承
|
|
||||||
|
|
||||||
* 子类使用父类的函数时,函数前必须加父类名,降低阅读难度,没有父类名的一律为本类函数(有可能是虚函数);
|
|
||||||
|
|
||||||
### 1.1.4. 变量命名
|
|
||||||
|
|
||||||
#### 1.1.4.1. 结构体/类成员
|
|
||||||
|
|
||||||
* 结构体和类成员必须要使用驼峰命名法,且首字母必须为m表示成员变量;
|
|
||||||
|
|
||||||
```
|
|
||||||
typedef struct app_get_product_info
|
|
||||||
{
|
|
||||||
app_get_product_info();
|
|
||||||
std::string mModel;
|
|
||||||
std::string mCompany;
|
|
||||||
std::string mSoc;
|
|
||||||
std::string mSp;
|
|
||||||
} AppGetProductInfo;
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.1.5. 文件命名
|
|
||||||
|
|
||||||
* 文件名必须使用驼峰命名法,且首字母大写;
|
|
||||||
|
|
||||||
### 1.1.6. 代码排版
|
|
||||||
|
|
||||||
* 使用统一标准的代码排版风格,保持多人开发时代码的整洁,避免因为排版(特别是编辑工具的自动排版功能)导致每次提交时都产生大量的排版修改,影响后续代码异常排查;
|
|
||||||
|
|
||||||
  请使用仓库跟目录下.clang-format配置文件进行排版,如果使用vscode编辑器开发代码,可直接使用快捷键ctrl+alt+f进行排版;也可以使用构建脚本对代码进行排版。
|
|
||||||
|
|
||||||
**对发生修改的代码进行格式化:**
|
|
||||||
|
|
||||||
```code
|
|
||||||
$ make cmake // 在仓库根目录执行,对发生修改的文件创建格式化命令
|
|
||||||
$ cd cmake-shell/
|
|
||||||
$ make improve_modified_code // 文件格式化命令,统一排版,此命名只对发生修改的文件进行格式化
|
|
||||||
```
|
|
||||||
|
|
||||||
**对全部文件进行格式化:**
|
|
||||||
|
|
||||||
```code
|
|
||||||
详见配置文件://build/global_config.cmake
|
|
||||||
把 COMPILE_IMPROVE_SUPPORT 设置为 true 时,将会在每次编译代码时进行格式化。
|
|
||||||
if(${LINUX_TEST} MATCHES "true")
|
|
||||||
set(CLANG_TIDY_SUPPORT "true")
|
|
||||||
set(CLANG_FORMAT_SUPPORT "true")
|
|
||||||
set(COMPILE_IMPROVE_SUPPORT "false") # 开启后每次编译可能会很慢
|
|
||||||
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
|
||||||
endif()
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.1.7. 函数
|
|
||||||
|
|
||||||
* 单个函数代码行控制在50行内,阅读时无需上下滚动去理解代码逻辑;极少数初始化数据的无逻辑推理的代码除外;
|
|
||||||
* 函数参数不能超过10个;
|
|
|
@ -1,21 +0,0 @@
|
||||||
# 1. Linux嵌入式项目使用Doxygen生成API文档
|
|
||||||
|
|
||||||
## 1.1. Doxygen简介
|
|
||||||
|
|
||||||
  Doxygen是一个开源的文档生成工具,可以用来生成项目源代码的API文档。
|
|
||||||
|
|
||||||
## 1.2. Doxygen安装
|
|
||||||
|
|
||||||
  Doxygen安装非常简单,直接在官网下载最新版本即可。
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt-get install doxygen
|
|
||||||
```
|
|
||||||
|
|
||||||
## 1.3. 安装Graphviz
|
|
||||||
|
|
||||||
  Doxygen本身不直接支持画图功能,但它可以生成DOT格式的图形描述文件,然后使用Graphviz工具进行渲染。
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt-get install graphviz
|
|
||||||
```
|
|
|
@ -1,209 +0,0 @@
|
||||||
# 1. gdb coredump分析
|
|
||||||
|
|
||||||
  本文介绍ubuntu系统环境下coredump文件的分析方法。
|
|
||||||
|
|
||||||
**一个coredump示例:**
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ../output_files/test/bin/McuManagerTest --gtest_filter=McuManagerTest.RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission
|
|
||||||
Note: Google Test filter = McuManagerTest.RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission
|
|
||||||
[==========] Running 1 test from 1 test suite.
|
|
||||||
[----------] Global test environment set-up.
|
|
||||||
[----------] 1 test from McuManagerTest
|
|
||||||
NewLog succeed.
|
|
||||||
LogImplInit
|
|
||||||
[ RUN ] McuManagerTest.RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission
|
|
||||||
2024-05-15 17:43:04,782 INFO [default] [McuManagerMakePtr.cpp:23]:CreateMcuManager is ok.
|
|
||||||
|
|
||||||
2024-05-15 17:43:04,783 INFO [default] [IMcuManager.cpp:72]:Instance changed succeed.
|
|
||||||
|
|
||||||
2024-05-15 17:43:04,783 INFO [default] [UartDeviceImpl.cpp:277]:Create the uart device object.
|
|
||||||
|
|
||||||
Can't Open Serial Port: No such file or directory
|
|
||||||
2024-05-15 17:43:04,784 ERROR [default] [McuDevice.cpp:51]:IUartOpen failed.
|
|
||||||
|
|
||||||
2024-05-15 17:43:04,787 INFO [default] [UartDeviceImpl.cpp:277]:Create the uart device object.
|
|
||||||
|
|
||||||
Can't Open Serial Port: No such file or directory
|
|
||||||
2024-05-15 17:43:04,787 ERROR [default] [McuDevice.cpp:51]:IUartOpen failed.
|
|
||||||
|
|
||||||
terminate called without an active exception
|
|
||||||
Aborted (core dumped)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 1.1. coredump文件生成路径查询
|
|
||||||
|
|
||||||
```
|
|
||||||
$ cat /proc/sys/kernel/core_pattern
|
|
||||||
|/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E
|
|
||||||
```
|
|
||||||
|
|
||||||
修改coredump文件生成路径:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo sh -c 'echo /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p > /proc/sys/kernel/core_pattern'
|
|
||||||
$ cat /proc/sys/kernel/core_pattern
|
|
||||||
/home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p
|
|
||||||
```
|
|
||||||
命令:
|
|
||||||
sudo sh -c 'echo /path/core.%e.%p > /proc/sys/kernel/core_pattern'
|
|
||||||
|
|
||||||
例如:
|
|
||||||
```
|
|
||||||
sudo sh -c 'echo /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p > /proc/sys/kernel/core_pattern'
|
|
||||||
```
|
|
||||||
|
|
||||||
**发现路径下并未生成coredump文件**
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ulimit -a
|
|
||||||
core file size (blocks, -c) 0 // 0表示终端未开启core dump
|
|
||||||
data seg size (kbytes, -d) unlimited
|
|
||||||
scheduling priority (-e) 0
|
|
||||||
file size (blocks, -f) unlimited
|
|
||||||
pending signals (-i) 63499
|
|
||||||
max locked memory (kbytes, -l) 65536
|
|
||||||
max memory size (kbytes, -m) unlimited
|
|
||||||
open files (-n) 1024
|
|
||||||
pipe size (512 bytes, -p) 8
|
|
||||||
POSIX message queues (bytes, -q) 819200
|
|
||||||
real-time priority (-r) 0
|
|
||||||
stack size (kbytes, -s) 8192
|
|
||||||
cpu time (seconds, -t) unlimited
|
|
||||||
max user processes (-u) 63499
|
|
||||||
virtual memory (kbytes, -v) unlimited
|
|
||||||
file locks (-x) unlimited
|
|
||||||
```
|
|
||||||
|
|
||||||
解决:
|
|
||||||
```
|
|
||||||
$ ulimit -c unlimited
|
|
||||||
```
|
|
||||||
|
|
||||||
sudo echo /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell/core.%e.%p > /proc/sys/kernel/core_pattern
|
|
||||||
|
|
||||||
## 1.2. gdb查看堆栈信息
|
|
||||||
|
|
||||||
**Ubuntu系统需要加sudo执行程序才会生成coredump文件。**
|
|
||||||
|
|
||||||
### 1.2.1. 无法识别coredump文件
|
|
||||||
|
|
||||||
  在gdb中无法识别coredump文件,如下所示:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo gdb ../output_files/test/bin/McuManagerTest core.smbd.3390383
|
|
||||||
[sudo] password for xiaojiazhu:
|
|
||||||
Sorry, try again.
|
|
||||||
[sudo] password for xiaojiazhu:
|
|
||||||
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
|
|
||||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
||||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
||||||
This is free software: you are free to change and redistribute it.
|
|
||||||
There is NO WARRANTY, to the extent permitted by law.
|
|
||||||
Type "show copying" and "show warranty" for details.
|
|
||||||
This GDB was configured as "x86_64-linux-gnu".
|
|
||||||
Type "show configuration" for configuration details.
|
|
||||||
For bug reporting instructions, please see:
|
|
||||||
<http://www.gnu.org/software/gdb/bugs/>.
|
|
||||||
Find the GDB manual and other documentation resources online at:
|
|
||||||
<http://www.gnu.org/software/gdb/documentation/>.
|
|
||||||
|
|
||||||
For help, type "help".
|
|
||||||
Type "apropos word" to search for commands related to "word"...
|
|
||||||
Reading symbols from ../output_files/test/bin/McuManagerTest...
|
|
||||||
|
|
||||||
warning: core file may not match specified executable file. // 表示coredump文件与可执行文件不匹配
|
|
||||||
[New LWP 3390383]
|
|
||||||
Core was generated by `/usr/sbin/smbd --foreground --no-process-group'.
|
|
||||||
Program terminated with signal SIGABRT, Aborted.
|
|
||||||
#0 0x00007fd59718600b in ?? ()
|
|
||||||
(gdb) bt
|
|
||||||
#0 0x00007fd59718600b in ?? ()
|
|
||||||
#1 0x0000000000001c80 in ?? ()
|
|
||||||
#2 0x0000000000000000 in ?? ()
|
|
||||||
```
|
|
||||||
|
|
||||||
由于gdb和asan同时启用会冲突,导致无法识别coredump文件。解决办法如下:
|
|
||||||
|
|
||||||
修改://build/sdk_config.cmake
|
|
||||||
|
|
||||||
```
|
|
||||||
# Gdb debug
|
|
||||||
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
|
||||||
message("---------------------------Debug mode.-----------------------")
|
|
||||||
SET(CMAKE_BUILD_TYPE "Debug")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -g -ggdb")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -Wall -g -ggdb")
|
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
|
|
||||||
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
|
|
||||||
# asan
|
|
||||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=leak -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined")
|
|
||||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined")
|
|
||||||
else()
|
|
||||||
message("---------------------------Release mode.-----------------------")
|
|
||||||
SET(CMAKE_BUILD_TYPE "Release")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os")
|
|
||||||
endif()
|
|
||||||
```
|
|
||||||
|
|
||||||
解决后:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo gdb ../output_files/test/bin/McuManagerTest core.McuManagerTest.3406751
|
|
||||||
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
|
|
||||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
||||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
||||||
This is free software: you are free to change and redistribute it.
|
|
||||||
There is NO WARRANTY, to the extent permitted by law.
|
|
||||||
Type "show copying" and "show warranty" for details.
|
|
||||||
This GDB was configured as "x86_64-linux-gnu".
|
|
||||||
Type "show configuration" for configuration details.
|
|
||||||
For bug reporting instructions, please see:
|
|
||||||
<http://www.gnu.org/software/gdb/bugs/>.
|
|
||||||
Find the GDB manual and other documentation resources online at:
|
|
||||||
<http://www.gnu.org/software/gdb/documentation/>.
|
|
||||||
|
|
||||||
For help, type "help".
|
|
||||||
Type "apropos word" to search for commands related to "word"...
|
|
||||||
Reading symbols from ../output_files/test/bin/McuManagerTest...
|
|
||||||
[New LWP 3406751]
|
|
||||||
[New LWP 3406753]
|
|
||||||
[New LWP 3406752]
|
|
||||||
[Thread debugging using libthread_db enabled]
|
|
||||||
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
|
|
||||||
Core was generated by `../output_files/test/bin/McuManagerTest --gtest_filter=McuManagerTest.RH_INTEGR'.
|
|
||||||
Program terminated with signal SIGABRT, Aborted.
|
|
||||||
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
|
|
||||||
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
|
|
||||||
[Current thread is 1 (Thread 0x7fd355968740 (LWP 3406751))]
|
|
||||||
(gdb) bt
|
|
||||||
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
|
|
||||||
#1 0x00007fd35598f859 in __GI_abort () at abort.c:79
|
|
||||||
#2 0x00007fd355d678d1 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
|
|
||||||
#3 0x00007fd355d7337c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
|
|
||||||
#4 0x00007fd355d733e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
|
|
||||||
#5 0x000055c247b3ae41 in std::thread::operator= (__t=..., this=0x55c248d19748) at /usr/include/c++/9/thread:152
|
|
||||||
#6 McuProtocol::Init (this=this@entry=0x55c248d196f8) at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/src/McuProtocol.cpp:58
|
|
||||||
#7 0x000055c247b03e57 in McuManagerImpl::Init (this=0x55c248d19680)
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/middleware/McuManager/src/McuManagerImpl.cpp:46
|
|
||||||
#8 0x000055c247acd3d4 in McuManagerTest::McuManagerTest_RH_INTEGRATION_McuManager_AUTO_OtherSideSendIpcMission_Test::TestBody (this=<optimized out>)
|
|
||||||
at /usr/include/c++/9/bits/shared_ptr_base.h:1020
|
|
||||||
#9 0x000055c247b303fd in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) () at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#10 0x000055c247b23343 in testing::Test::Run() () at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#11 0x000055c247b2342b in testing::TestInfo::Run() ()
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#12 0x000055c247b2376e in testing::TestSuite::Run() ()
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#13 0x000055c247b2a0fa in testing::internal::UnitTestImpl::RunAllTests() ()
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#14 0x000055c247b3085e in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ()
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#15 0x000055c247b23529 in testing::UnitTest::Run() ()
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/utils/McuProtocol/./include/McuProtocol.h:121
|
|
||||||
#16 0x000055c247ac9287 in RUN_ALL_TESTS ()
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/external/gtest/googletest-release-1.11.0/googletest/include/gtest/gtest.h:2490
|
|
||||||
#17 main (argc=<optimized out>, argv=<optimized out>)
|
|
||||||
at /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/test/middleware/McuManager/mainTest.cpp:22
|
|
||||||
(gdb)
|
|
||||||
```
|
|
|
@ -1,67 +0,0 @@
|
||||||
### 背景
|
|
||||||
|
|
||||||
Git每次提交代码都需要写commit message,否则就不允许提交。一般来说,commit message应该清晰明了,说明本次提交的目的,具体做了什么操作……但是在日常开发中,大家的commit message千奇百怪,中英文混合使用、fix bug等各种笼统的message司空见怪,这就导致后续代码维护成本特别大,有时自己都不知道自己的fix bug修改的是什么问题。基于以上这些问题,我们希望通过某种方式来监控用户的git commit message,让规范更好的服务于质量,提高大家的研发效率。
|
|
||||||
|
|
||||||
### 规范建设
|
|
||||||
|
|
||||||
#### 规范梳理
|
|
||||||
|
|
||||||
初期我们在互联网上搜索了大量有关git commit规范的资料,但只有Angular规范是目前使用最广的写法,比较合理和系统化,并且有配套的工具(IDEA就有插件支持这种写法)。最后综合阿里巴巴高德地图相关部门已有的规范总结出了一套git commit规范。
|
|
||||||
|
|
||||||
## **commit message格式**
|
|
||||||
|
|
||||||
```plain
|
|
||||||
<type>(scope):<subject>
|
|
||||||
```
|
|
||||||
## type (必须)
|
|
||||||
|
|
||||||
用于说明git commit的类别,只允许使用下面的标识。
|
|
||||||
|
|
||||||
feat:新功能(feature)。
|
|
||||||
|
|
||||||
fix/to:修复bug,可以是QA发现的BUG,也可以是研发自己发现的BUG。
|
|
||||||
|
|
||||||
* fix:产生diff并自动修复此问题。适合于一次提交直接修复问题
|
|
||||||
* to:只产生diff不自动修复此问题。适合于多次提交。最终修复问题提交时使用fix
|
|
||||||
docs:文档(documentation)。
|
|
||||||
|
|
||||||
style:格式(不影响代码运行的变动)。
|
|
||||||
|
|
||||||
refactor:重构(即不是新增功能,也不是修改bug的代码变动)。
|
|
||||||
|
|
||||||
perf:优化相关,比如提升性能、体验。
|
|
||||||
|
|
||||||
test:增加测试。
|
|
||||||
|
|
||||||
chore:构建过程或辅助工具的变动。
|
|
||||||
|
|
||||||
revert:回滚到上一个版本。
|
|
||||||
|
|
||||||
merge:代码合并。
|
|
||||||
|
|
||||||
sync:同步主线或分支的Bug。
|
|
||||||
|
|
||||||
## scope (可选)
|
|
||||||
|
|
||||||
scope用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。
|
|
||||||
|
|
||||||
例如在Angular,可以是location,browser,compile,compile,rootScope, ngHref,ngClick,ngView等。如果你的修改影响了不止一个scope,你可以使用*代替。
|
|
||||||
|
|
||||||
## subject (必须)
|
|
||||||
|
|
||||||
ubject是commit目的的简短描述,不超过50个字符。
|
|
||||||
|
|
||||||
建议使用中文(感觉中国人用中文描述问题能更清楚一些)。
|
|
||||||
|
|
||||||
* 结尾不加句号或其他标点符号。
|
|
||||||
* 根据以上规范git commit message将是如下的格式:
|
|
||||||
```plain
|
|
||||||
fix(DAO):用户查询缺少username属性
|
|
||||||
feat(Controller):用户查询接口开发
|
|
||||||
```
|
|
||||||
以上就是我们梳理的git commit规范,那么我们这样规范git commit到底有哪些好处呢?
|
|
||||||
* 便于程序员对提交历史进行追溯,了解发生了什么情况。
|
|
||||||
* 一旦约束了commit message,意味着我们将慎重的进行每一次提交,不能再一股脑的把各种各样的改动都放在一个git commit里面,这样一来整个代码改动的历史也将更加清晰。
|
|
||||||
* 格式化的commit message才可以用于自动化输出Change log。
|
|
||||||
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
|
|
||||||
## git rebase 合并多条 commit 记录
|
|
||||||
|
|
||||||
### PS:gedit 不太好用,可以执行如下命令将编辑器修改为熟悉的 vim
|
|
||||||
```shell
|
|
||||||
git config --global core.editor "vim"
|
|
||||||
```
|
|
||||||
|
|
||||||
如图,我们有一些 commit 是比较凌乱的,现在希望将其整理为一条合适的 commit 提交到 远程仓库。
|
|
||||||
|
|
||||||

|
|
||||||
我们需要将 day1 day2 add file 这三条记录合并为一条,执行
|
|
||||||
|
|
||||||
```shell
|
|
||||||
git rebase -i [commit]
|
|
||||||
```
|
|
||||||
**commit** 为你要合并的最后一条提交的下一个 commit,
|
|
||||||
|
|
||||||
这里为 <font color=red>640f9a20c7bb7e9e3dfc76b089745d5c95818fed </font>
|
|
||||||
|
|
||||||
指令如下
|
|
||||||
```shell
|
|
||||||
git rebase -i 640f9a20c7bb7e9e3dfc76b089745d5c95818fed
|
|
||||||
```
|
|
||||||

|
|
||||||
|
|
||||||
这里将弹出 vim 编辑窗口,可以看到有此次 rebase 涉及到三个 commit id,我们选取需要 pick 的 commit id,其余的参考下面注释,添加 s 前缀,表示 commit 用于提交但是归并到 pick 的 commit 中。
|
|
||||||
|
|
||||||
:wq 保存,将进入下一个 vim 编辑界面
|
|
||||||

|
|
||||||
|
|
||||||
将所有的 commit msg 编辑一个合适的归并 commit msg。
|
|
||||||
再次执行 :wq 保存即可。
|
|
||||||

|
|
||||||
可以看到,我们将两条不希望留存的 commit 记录归并到了
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
<font color=red>640f9a20c7bb7e9e3dfc76b089745d5c95818fed </font> 提交之中,并且,这样的操作并不会改变原本这个 commit id 的值。
|
|
||||||
|
|
||||||
PS: 具体 rebase 指令细节参考 ```git rebase --help```
|
|
299
doc/git/git.md
299
doc/git/git.md
|
@ -1,299 +0,0 @@
|
||||||
# git初步使用
|
|
||||||
|
|
||||||
```
|
|
||||||
git init
|
|
||||||
|
|
||||||
//设置仓库的公共信息,这个user信息会体现在commit信息中
|
|
||||||
git config --global user.name "yourname"
|
|
||||||
git config --global user.email "your email"
|
|
||||||
|
|
||||||
//在远程仓库方面,有两种模式,一种ssh一种https
|
|
||||||
//https 简单方便,但每次push都要输入密码
|
|
||||||
|
|
||||||
git remote add origin https://github.com/yourgit/your warehouse.git
|
|
||||||
|
|
||||||
git add --all
|
|
||||||
git commit -m "you commit info"
|
|
||||||
git push -u origin master //第一次,以后可以用git push简化
|
|
||||||
|
|
||||||
//ssh模式 需要先在github中添加自己的sshkey
|
|
||||||
|
|
||||||
//首先看自己的本地目录下是否有 .ssh目录
|
|
||||||
//没有的话
|
|
||||||
ssh-keygen -t rsa -C "youremail@example.com"
|
|
||||||
//并将 .ssh/id_rsa.pub中的key添加到github.com中
|
|
||||||
|
|
||||||
git remote add origin git@github.com:yourgit/your warehouse.git
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## git alias
|
|
||||||
~/.gitconfig配置文件可以配置当前用户全局git属性,当然每个字母了git仓库下也可以有一个.gitconfig配置当前仓库属性,属性中有一个alias属性来给git一些命令提供别名,方便使用
|
|
||||||
|
|
||||||
配置方法参考 ```git config --help```
|
|
||||||
|
|
||||||
下面给出我的配置仅供参考
|
|
||||||
|
|
||||||
```shell
|
|
||||||
[user]
|
|
||||||
email = liaojia138797@163.com
|
|
||||||
name = ljx
|
|
||||||
[alias]
|
|
||||||
st = status
|
|
||||||
co = checkout
|
|
||||||
br = branch
|
|
||||||
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
|
|
||||||
type = cat-file -t
|
|
||||||
dump = cat-file -p
|
|
||||||
cm = commit -m
|
|
||||||
df = diff
|
|
||||||
|
|
||||||
[core]
|
|
||||||
editor = vim
|
|
||||||
```
|
|
||||||
|
|
||||||
## gitignore
|
|
||||||
|
|
||||||
```
|
|
||||||
所有空行或者以注释符号 # 开头的行都会被 Git 忽略。
|
|
||||||
可以使用标准的 glob 模式匹配。
|
|
||||||
匹配模式最后跟反斜杠(/)说明要忽略的是目录。
|
|
||||||
要忽略指定模式以外的文件或目录,可以在模式前加上惊叹号(!)取反。
|
|
||||||
|
|
||||||
所谓的 glob 模式是指 shell 所使用的简化了的正则表达式。星号(*)匹配零个或多个任意字符;[abc]匹配任何一个列在方括号中的字符(这个例子要么匹配一个 a,要么匹配一个 b,要么匹配一个 c);问号(?)只匹配一个任意字符;如果在方括号中使用短划线分隔两个字符,表示所有在这两个字符范围内的都可以匹配(比如 [0-9] 表示匹配所有 0 到 9 的数字)。
|
|
||||||
```
|
|
||||||
## git命令
|
|
||||||
|
|
||||||
* git rm / git rm --cached
|
|
||||||
```
|
|
||||||
//当我们要删除文件filename, 并且工作区也不需要这个文件了
|
|
||||||
git rm filename
|
|
||||||
|
|
||||||
//当我们需要删除暂存区或者分支的文件,但是本地需要保留这个文件,只是不希望此文件被版本控制时
|
|
||||||
git rm --cached filename
|
|
||||||
```
|
|
||||||
* git branch
|
|
||||||
```
|
|
||||||
查看本地分支:$ git branch
|
|
||||||
查看远程分支:$ git branch -r
|
|
||||||
创建本地分支:$ git branch [name] ----注意新分支创建后不会自动切换为当前分支
|
|
||||||
切换分支:$ git checkout [name]
|
|
||||||
创建新分支并立即切换到新分支:$ git checkout -b [name]
|
|
||||||
删除分支:$ git branch -d [name] ---- -d选项只能删除已经参与了合并的分支,对于未有合并的分支是无法删除的。如果想强制删除一个分支,可以使用-D选项
|
|
||||||
合并分支:$ git merge [name] ----将名称为[name]的分支与当前分支合并
|
|
||||||
创建远程分支(本地分支push到远程):$ git push origin [name]
|
|
||||||
删除远程分支:$ git push origin :heads/[name]
|
|
||||||
或 $ git push origin :[name]
|
|
||||||
```
|
|
||||||
* git remote
|
|
||||||
```c++
|
|
||||||
查看远程仓库:$ git remote -v
|
|
||||||
添加远程仓库:$ git remote add [name] [url]
|
|
||||||
删除远程仓库:$ git remote rm [name]
|
|
||||||
修改远程仓库:$ git remote set-url --push [name] [newUrl]
|
|
||||||
拉取远程仓库:$ git pull [remoteName] [localBranchName]
|
|
||||||
推送远程仓库:$ git push [remoteName] [localBranchName]
|
|
||||||
|
|
||||||
*如果想把本地的某个分支test提交到远程仓库,并作为远程仓库的master分支,或者作为另外一个名叫test的分支,如下:
|
|
||||||
$git push origin test:master // 提交本地test分支作为远程的master分支
|
|
||||||
$git push origin test:test // 提交本地test分支作为远程的test分支
|
|
||||||
```
|
|
||||||
* git merge
|
|
||||||
```
|
|
||||||
//合并a分支到master
|
|
||||||
git checkout master
|
|
||||||
git merge a
|
|
||||||
|
|
||||||
```
|
|
||||||
* git tag
|
|
||||||
```
|
|
||||||
//标签
|
|
||||||
git tag v1.0
|
|
||||||
```
|
|
||||||
* git reset
|
|
||||||
```
|
|
||||||
当将不想staging的文件add进了index,可以
|
|
||||||
git reset HEAD <file>
|
|
||||||
git reset --hard xxx
|
|
||||||
xxx可以是connid,可以退回到此id的版本
|
|
||||||
hard (修改版本库,修改暂存区,修改工作区)
|
|
||||||
--hard HEAD~1 (或是commid)意为将版本库回退1个版本,但是不仅仅是将本地版本库的头指针全部重置到指定版本,也会重置暂存区,并且会将工作区代码也回退到这个版本
|
|
||||||
这个操作非常危险,需要谨慎执行,如果不小心丢失掉了一些commit的话,执行
|
|
||||||
git reflog找到丢失掉的commit再次git reset --hard 回去
|
|
||||||
|
|
||||||
git reset --soft xxx
|
|
||||||
soft (修改版本库,保留暂存区,保留工作区)
|
|
||||||
--soft HEAD~1 意为将版本库软回退1个版本,所谓软回退表示将本地版本库的头指针全部重置到指定版本,且将这次提交之后的所有变更都移动到暂存区。
|
|
||||||
意思是当你commit后,又执行 git reset --soft HEAD^1,你本次commit直接从repository退回到index,未commit状态,如果是退回多个版本,则多次commit回退
|
|
||||||
|
|
||||||
不加参数(--mixed)
|
|
||||||
意思是:不删除工作空间改动代码,撤销commit,并且撤销git add . 操作
|
|
||||||
这个为默认参数,git reset --mixed HEAD^ 和 git reset HEAD^ 效果是一样的。
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
git revert xxx
|
|
||||||
revert
|
|
||||||
-- git revert 也是撤销命令,区别在于reset是指向原地或者向前移动指针,git revert是创建一个commit来覆盖当前的commit,指针向后移动。
|
|
||||||
|
|
||||||
https://www.jianshu.com/p/c2ec5f06cf1a
|
|
||||||
|
|
||||||
git reset --hard <commit>:
|
|
||||||
1.替换引用的指向.引用指向新的提交ID;
|
|
||||||
2.替换暂存区.替换后,暂存区的内容和引用指向的目录树一致;
|
|
||||||
3.替换工作区.替换后,工作区的内容变得和暂存区一致,也和HEAD所指向的目录树内容相同.
|
|
||||||
|
|
||||||
git reset --soft <commit>:
|
|
||||||
1.替换引用的指向.引用指向新的提交ID.
|
|
||||||
即只更改引用的指向,不该编暂存区和工作区.
|
|
||||||
|
|
||||||
git reset --mixed <commit>或git reset <commit>:
|
|
||||||
1.替换引用的指向.引用指向新的提交ID;
|
|
||||||
2.替换暂存区.替换后,暂存区的内容和引用指向的目录树一致;
|
|
||||||
即更改引用的指向及重置暂存区,但是工作区不变.
|
|
||||||
|
|
||||||
实例:
|
|
||||||
git reset
|
|
||||||
仅用HEAD指向的目录树重置暂存区,工作区不受影响,相当于将之前用git add命令更新到暂存区的内容撤出暂存区.引用也未改变,因为引用重置到HEAD相当于没有重置.
|
|
||||||
|
|
||||||
git reset HEAD
|
|
||||||
同上
|
|
||||||
|
|
||||||
git reset -- filename
|
|
||||||
仅将文件filename的改动撤出暂存区,暂存区中其他文件不该变.相当于git add filename的反向操作.
|
|
||||||
|
|
||||||
git reset HEAD filename
|
|
||||||
同上
|
|
||||||
|
|
||||||
git reset --soft HEAD^
|
|
||||||
工作区和暂存区不改变,但是引用向前回退一次.当对最新提交的提交说明或提交不满意更改时,撤销最新的提交一遍重新提交.
|
|
||||||
|
|
||||||
git reset HEAD^
|
|
||||||
工作区不变,但是暂存区会回退到上一次提交之前,引用也会回退一次.
|
|
||||||
|
|
||||||
git reset --mixed HEAD^
|
|
||||||
同上
|
|
||||||
|
|
||||||
git reset --hard HEAD^
|
|
||||||
彻底撤销最近的提交.引用回退到前一次,而且工作区和暂存区都会回退到上一次提交的状态.自上一次以来的提交全部丢失.
|
|
||||||
```
|
|
||||||
* git checkout
|
|
||||||
```
|
|
||||||
git checkout
|
|
||||||
git checkout <commit> [--] <paths>
|
|
||||||
1.<commit>是可选项,如果省略则相当于从暂存区进行检出.和reset命令大不相同:重置的默认值是HEAD,而检出的默认值是暂存区.
|
|
||||||
2.因此重置一般用于重置暂存区(除非使用--hard,否则不重置工作区),而检出命令主要是覆盖工作区(如果<commit>不省略,也会替换暂存区中相应的文件).
|
|
||||||
3.该命令不会改变HEAD的头指针,主要用于指定版本文件覆盖工作区中对应的文件.如果省略<commit>,则会用暂存区的文件覆盖工作区的文件,否则用指定提交中的文件覆盖暂存区和工作区中的对应文件.
|
|
||||||
|
|
||||||
git checkout <branch>
|
|
||||||
|
|
||||||
1.会改变HEAD头指针.之所以后面的参数写作<branch>,是因为只有HEAD切换到一个分支才可以对提交进行跟踪,否则仍然会进入"分离头指针"的状态.在"分离头指针"的状态下的提交并不能被引用关联到,从而可能丢失.所以该命令主要作用是切换分支.
|
|
||||||
2.如果省略<branch>则相当于对工作区进行状态检查.
|
|
||||||
|
|
||||||
实例:
|
|
||||||
git checkout branch
|
|
||||||
检出branch分支,更新HEAD以指向branch分支,以及用branch指向的树更新暂存区和工作区.
|
|
||||||
|
|
||||||
git checkout
|
|
||||||
汇总显示工作区,暂存区与HEAD的差异
|
|
||||||
|
|
||||||
git checkout HEAD
|
|
||||||
同上
|
|
||||||
|
|
||||||
git checkout -- filename
|
|
||||||
用暂存区中的filename文件来覆盖工作区中的filename文件.相当于取消自上次执行git add filename以来(如果执行过)的本地修改
|
|
||||||
//放弃修改回到以前的状态
|
|
||||||
//这条命令有些危险,所有对文件的修改都没有了,因为我们刚刚把之前版本的文件复制过来重写了此文件。所以在用这条命令前,请务必确定真的不再需要保留刚才的修改
|
|
||||||
|
|
||||||
git checkout branch -- filename
|
|
||||||
维持HEAD的指向不变.用branch所指向的提交中的filename替换暂存区和工作区中相应的文件.会将暂存区和工作区中的filename直接覆盖
|
|
||||||
|
|
||||||
git checkout -- .或者git checkout .
|
|
||||||
会取消本地所有修改,相当于用暂存区的所有文件直接覆盖本地文件.
|
|
||||||
```
|
|
||||||
* git stash
|
|
||||||
```
|
|
||||||
当你做某个工作时遇到紧急情况需要切换branch,又不想commit当前未完成工作来造成不必要的繁琐log时,执行
|
|
||||||
git stash
|
|
||||||
或者执行
|
|
||||||
git stash save "something"
|
|
||||||
当你完成紧急工作后想要继续当时停下来的开发
|
|
||||||
在原分支 git stash save -a "messeag",网上很多很多资料都没有加 -a 这个option选项,我想他们的代码开发可能都是在原代码上进行修改吧。而对于在项目里加入了代码新文件的开发来说,-a选项才会将新加入的代码文件同时放入暂存区。
|
|
||||||
|
|
||||||
git stash pop可以弹回到最后一次的stash
|
|
||||||
也可以
|
|
||||||
git stash list查看有几个stash
|
|
||||||
git stash apply stash@{}来回到你想要的stash
|
|
||||||
git stash clear清除所有缓存的stash
|
|
||||||
git stash show stash@{}来查看diff
|
|
||||||
|
|
||||||
stash信息不回被删除,除非你弹回去了,但如果你不想要那时候的stash了。比如认为当时的改动是错误的,你可以
|
|
||||||
git stash drop <stash@{id}> 如果不加stash编号,默认的就是删除最新的,也就是编号为0的那个,加编号就是删除指定编号的stash。git stash clear 是清除所有stash,整个世界一下子清净了!
|
|
||||||
git stash pop 与 git stash apply <stash@{id}> 的区别。
|
|
||||||
当我使用git stash pop 和 git stash apply 几次以后,我发现stash list 好像比我预计的多了几个stash。于是我便上网去了解了一下这两个命令的区别。原来git stash pop stash@{id}命令会在执行后将对应的stash id 从stash list里删除,而 git stash apply stash@{id} 命令则会继续保存stash id。对于有点强迫症的我来说,是容不下越来越多的陈旧stash id 仍然存在的,所以我更习惯于用git stash pop 命令。
|
|
||||||
```
|
|
||||||
* git log
|
|
||||||
```
|
|
||||||
$ git log -p -2
|
|
||||||
//我们常用 -p 选项展开显示每次提交的内容差异,用 -2 则仅显示最近的两次更新
|
|
||||||
$ git log -U1 --word-diff
|
|
||||||
//上下文行数1行,以单词来看差异,单词前后以+wold+ - - 表示出来
|
|
||||||
```
|
|
||||||
* git commit
|
|
||||||
```
|
|
||||||
$ git commit amend
|
|
||||||
//有时候我们提交完了才发现漏掉了几个文件没有加,或者提交信息写错了。想要撤消刚才的提交操作,可以使用 --amend 选项重新提交
|
|
||||||
```
|
|
||||||
* git clone
|
|
||||||
```
|
|
||||||
git clone git@github.com:ljx791863565/xxx.git
|
|
||||||
git clone https://github.com/ljx791863565/xxx.git
|
|
||||||
```
|
|
||||||
* git diff
|
|
||||||
```
|
|
||||||
//比较暂存区与版本库的改动
|
|
||||||
git diff --staged
|
|
||||||
|
|
||||||
git diff commid1 commid2
|
|
||||||
git diff branch1 branch2
|
|
||||||
|
|
||||||
git diff : 对比工作区(未 git add)和暂存区(git add 之后)
|
|
||||||
git diff --cached: 对比暂存区(git add 之后)和版本库(git commit 之后)
|
|
||||||
git diff HEAD: 对比工作区(未 git add)和版本库(git commit 之后)
|
|
||||||
|
|
||||||
```
|
|
||||||
* git config
|
|
||||||
Git 提供了一个叫做 git config 的工具(译注:实际是 git-config 命令,只不过可以通过 git 加一个名字来呼叫此命令。),专门用来配置或读取相应的工作环境变量。而正是由这些环境变量,决定了 Git 在各个环节的具体工作方式和行为。这些变量可以存放在以下三个不同的地方:
|
|
||||||
|
|
||||||
* /etc/gitconfig 文件:系统中对所有用户都普遍适用的配置。若使用 git config 时用 --system选项,读写的就是这个文件。
|
|
||||||
* ~/.gitconfig 文件:用户目录下的配置文件只适用于该用户。若使用 git config 时用 --global选项,读写的就是这个文件。
|
|
||||||
当前项目的 Git 目录中的配置文件(也就是工作目录中的 .git/config 文件):这里的配置仅仅针对当前项目有效。每一个级别的配置都会覆盖上层的相同配置,所以 .git/config 里的配置会覆盖 /etc/gitconfig 中的同名变量。
|
|
||||||
|
|
||||||
供了一个叫做 git config 的工具(译注:实际是 git-config 命令,只不过可以通过 git 加一个名字来呼叫此命令。),专门用来配置或读取相应的工作环境变量。而正是由这些环境变量,决定了 Git 在各个环节的具体工作方式和行为。这些变量可以存放在以下三个不同的地方:
|
|
||||||
|
|
||||||
* /etc/gitconfig 文件:系统中对所有用户都普遍适用的配置。若使用 git config 时用 --system选项,读写的就是这个文件。
|
|
||||||
* ~/.gitconfig 文件:用户目录下的配置文件只适用于该用户。若使用 git config 时用 --global选项,读写的就是这个文件。
|
|
||||||
当前项目的 Git 目录中的配置文件(也就是工作目录中的 .git/config 文件):这里的配置仅仅针对当前项目有效。每一个级别的配置都会覆盖上层的相同配置,所以 .git/config 里的配置会覆盖 /etc/gitconfig 中的同名变量。
|
|
||||||
|
|
||||||
```
|
|
||||||
第一个要配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录:
|
|
||||||
$ git config --global user.name "John Doe"
|
|
||||||
$ git config --global user.email johndoe@example.com
|
|
||||||
如果用了 --global 选项,那么更改的配置文件就是位于你用户主目录下的那个,以后你所有的项目都会默认使用这里配置的用户信息。如果要在某个特定的项目中使用其他名字或者电邮,只要去掉 --global选项重新配置即可,新的设定保存在当前项目的 .git/config 文件里。
|
|
||||||
|
|
||||||
还有一个比较常用的是,在解决合并冲突时使用哪种差异分析工具。比如要改用 vimdiff 的话:
|
|
||||||
$ git config --global merge.tool vimdiff
|
|
||||||
Git 可以理解 kdiff3,tkdiff,meld,xxdiff,emerge,vimdiff,gvimdiff,ecmerge,和 opendiff 等合并工具的输出信息。当然,你也可以指定使用自己开发的工具
|
|
||||||
|
|
||||||
```
|
|
||||||
## git问题解决
|
|
||||||
|
|
||||||
* fatal: object 906d1543778b940af481c0ca7f5ce9d3d9771140 is corrupted
|
|
||||||
```
|
|
||||||
rm -rf .git
|
|
||||||
git init
|
|
||||||
git remote add origin git@github.com:yourgit/yourwarehouse.git
|
|
||||||
git fetch
|
|
||||||
git reset --hard origin/master
|
|
||||||
```
|
|
||||||
[https://blog.csdn.net/dengjianqiang2011/article/details/9260435](https://blog.csdn.net/dengjianqiang2011/article/details/9260435)
|
|
Binary file not shown.
Before Width: | Height: | Size: 118 KiB |
Binary file not shown.
Before Width: | Height: | Size: 86 KiB |
Binary file not shown.
Before Width: | Height: | Size: 263 KiB |
Binary file not shown.
Before Width: | Height: | Size: 205 KiB |
Binary file not shown.
Before Width: | Height: | Size: 183 KiB |
179
doc/git_guide.md
179
doc/git_guide.md
|
@ -1,179 +0,0 @@
|
||||||
# 1. git使用手册
|
|
||||||
|
|
||||||
## 1.1. 概述
|
|
||||||
|
|
||||||
  git是分布式版本控制系统,在多人开发中,git可以很好的管理代码的版本。
|
|
||||||
|
|
||||||
## 1.2. 源码托管服务器
|
|
||||||
|
|
||||||
  github和gitlab还有gitee(国产)都是开源的代码托管服务器,可以用来管理源码。
|
|
||||||
|
|
||||||
## 1.3. git安装
|
|
||||||
|
|
||||||
## 1.4. git分支管理
|
|
||||||
|
|
||||||
### 1.4.1. git创建本地分支
|
|
||||||
|
|
||||||
* 基于远端分支创建一个本地分支,同时新建一个对应的远端分支:
|
|
||||||
|
|
||||||
  当主干发生较大变化,例如:原厂更新sdk时,需要新建分支,划分界限。
|
|
||||||
|
|
||||||
```code
|
|
||||||
$ git branch -a
|
|
||||||
----------------
|
|
||||||
* master
|
|
||||||
remotes/origin/HEAD -> origin/master
|
|
||||||
remotes/origin/app_test
|
|
||||||
remotes/origin/master
|
|
||||||
$ git checkout -b master-sdk-202405 origin/master
|
|
||||||
-------------------------------------------------
|
|
||||||
M ipc-sdk
|
|
||||||
Branch 'master-sdk-202405' set up to track remote branch 'master' from 'origin'.
|
|
||||||
Switched to a new branch 'master-sdk-202405'
|
|
||||||
$ git branch -a
|
|
||||||
----------------
|
|
||||||
master
|
|
||||||
* master-sdk-202405
|
|
||||||
remotes/origin/HEAD -> origin/master
|
|
||||||
remotes/origin/app_test
|
|
||||||
remotes/origin/master
|
|
||||||
$ git push origin master-sdk-202405:sdk-202405
|
|
||||||
----------------------------------------------
|
|
||||||
Enumerating objects: 3, done.
|
|
||||||
Counting objects: 100% (3/3), done.
|
|
||||||
Delta compression using up to 8 threads
|
|
||||||
Compressing objects: 100% (2/2), done.
|
|
||||||
Writing objects: 100% (2/2), 250 bytes | 250.00 KiB/s, done.
|
|
||||||
Total 2 (delta 1), reused 0 (delta 0)
|
|
||||||
remote: Powered by GITEE.COM [GNK-6.4]
|
|
||||||
remote: Create a pull request for 'sdk-202405' on Gitee by visiting:
|
|
||||||
remote: https://gitee.com/shenzhen-jiuyilian/ipc-rk1106/pull/new/shenzhen-jiuyilian:sdk-202405...shenzhen-jiuyilian:master
|
|
||||||
To gitee.com:shenzhen-jiuyilian/ipc-rk1106.git
|
|
||||||
* [new branch] master-sdk-202405 -> sdk-202405
|
|
||||||
$ git branch -a
|
|
||||||
---------------
|
|
||||||
master
|
|
||||||
* master-sdk-202405
|
|
||||||
remotes/origin/HEAD -> origin/master
|
|
||||||
remotes/origin/app_test
|
|
||||||
remotes/origin/master
|
|
||||||
remotes/origin/sdk-202405
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.4.2. git获取远端分支
|
|
||||||
|
|
||||||
  当想知道远端是否新建了分支,可使用git fetch命令获取远端分支。
|
|
||||||
|
|
||||||
**git fetch示例:**
|
|
||||||
|
|
||||||
```code
|
|
||||||
$ git fetch
|
|
||||||
------------
|
|
||||||
remote: Enumerating objects: 21, done.
|
|
||||||
remote: Counting objects: 100% (21/21), done.
|
|
||||||
remote: Compressing objects: 100% (11/11), done.
|
|
||||||
remote: Total 14 (delta 8), reused 0 (delta 0), pack-reused 0
|
|
||||||
Unpacking objects: 100% (14/14), 2.14 KiB | 156.00 KiB/s, done.
|
|
||||||
From gitee.com:shenzhen-jiuyilian/ipc-rk1106
|
|
||||||
bf71a01..2b9b803 master -> origin/master
|
|
||||||
* [new branch] sdk-202402 -> origin/sdk-202402 // 此处发现远端新建了分支
|
|
||||||
Fetching submodule ipc-sdk
|
|
||||||
From gitee.com:shenzhen-jiuyilian/ipc
|
|
||||||
7c261bd..eec9fb4 master-develop -> origin/master-develop
|
|
||||||
```
|
|
||||||
|
|
||||||
**多个远端仓库git fetch示例:**
|
|
||||||
|
|
||||||
```code
|
|
||||||
$ git remote -v
|
|
||||||
----------------
|
|
||||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (fetch)
|
|
||||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (push)
|
|
||||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (fetch)
|
|
||||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (push)
|
|
||||||
$ git fetch dgiot // git fetch + 远端仓库名称
|
|
||||||
---------------------------------------------
|
|
||||||
remote: Enumerating objects: 9, done.
|
|
||||||
remote: Counting objects: 100% (9/9), done.
|
|
||||||
remote: Compressing objects: 100% (7/7), done.
|
|
||||||
remote: Total 9 (delta 3), reused 5 (delta 2), pack-reused 0
|
|
||||||
Unpacking objects: 100% (9/9), 8.74 KiB | 746.00 KiB/s, done.
|
|
||||||
From gitee.com:shenzhen-jiuyilian/fastbootserver
|
|
||||||
* [new branch] sdk-202405 -> dgiot/sdk-202405
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.4.3. git新增远端地址
|
|
||||||
|
|
||||||
  在一个git仓库中,可以同时管理多个远端地址,例如:在原厂的git仓库中,可以在仓库添加一个私人的git仓库,这样后续把修改提交到自己的仓库进行代码管理。
|
|
||||||
|
|
||||||
**git remote add示例:**
|
|
||||||
|
|
||||||
命令格式:
|
|
||||||
|
|
||||||
```code
|
|
||||||
git remote add <remote-name> <remote-url>
|
|
||||||
```
|
|
||||||
|
|
||||||
示例:
|
|
||||||
|
|
||||||
```code
|
|
||||||
$ git remote add dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
$ git remote -v
|
|
||||||
----------------
|
|
||||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (fetch)
|
|
||||||
dgiot git@gitee.com:shenzhen-jiuyilian/fastbootserver.git (push)
|
|
||||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (fetch)
|
|
||||||
rk https://gerrit.rock-chips.com:8443/linux/linux/ipc/app/fastboot_server (push)
|
|
||||||
$ git fetch dgiot
|
|
||||||
------------------
|
|
||||||
remote: Enumerating objects: 107, done.
|
|
||||||
remote: Counting objects: 100% (104/104), done.
|
|
||||||
remote: Compressing objects: 100% (45/45), done.
|
|
||||||
remote: Total 99 (delta 47), reused 89 (delta 42), pack-reused 0
|
|
||||||
Unpacking objects: 100% (99/99), 29.55 KiB | 315.00 KiB/s, done.
|
|
||||||
From gitee.com:shenzhen-jiuyilian/fastbootserver
|
|
||||||
* [new branch] master -> dgiot/master
|
|
||||||
* [new branch] sdk-202405 -> dgiot/sdk-202405
|
|
||||||
$ git branch -a
|
|
||||||
----------------
|
|
||||||
* (HEAD detached at bf91101)
|
|
||||||
remotes/dgiot/master
|
|
||||||
remotes/dgiot/sdk-202405
|
|
||||||
remotes/m/master
|
|
||||||
remotes/rk/master
|
|
||||||
$ git checkout -b sdk-202405 m/master
|
|
||||||
--------------------------------------
|
|
||||||
Switched to a new branch 'sdk-202405'
|
|
||||||
$ git branch -a
|
|
||||||
----------------
|
|
||||||
* sdk-202405
|
|
||||||
remotes/dgiot/master
|
|
||||||
remotes/dgiot/sdk-202405
|
|
||||||
remotes/m/master
|
|
||||||
remotes/rk/master
|
|
||||||
$ git pull dgiot sdk-202405
|
|
||||||
---------------------------
|
|
||||||
From gitee.com:shenzhen-jiuyilian/fastbootserver
|
|
||||||
* branch sdk-202405 -> FETCH_HEAD
|
|
||||||
Updating bf91101..dc76264
|
|
||||||
Fast-forward
|
|
||||||
.clang-format | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
.gitmodules | 3 +++
|
|
||||||
README.md | 30 ++++++++++++++++++++++++++++++
|
|
||||||
rv1106_ipc_sdk | 1 +
|
|
||||||
4 files changed, 170 insertions(+)
|
|
||||||
create mode 100644 .clang-format
|
|
||||||
create mode 100644 .gitmodules
|
|
||||||
create mode 100755 README.md
|
|
||||||
create mode 160000 rv1106_ipc_sdk
|
|
||||||
$ git submodule update --init
|
|
||||||
-----------------------------
|
|
||||||
Submodule 'rv1106_ipc_sdk' (git@gitee.com:shenzhen-jiuyilian/ipc-rk1106.git) registered for path 'rv1106_ipc_sdk'
|
|
||||||
Cloning into '/home/xiaojiazhu/project/rkipc/ipc_20240517/project/app/component/fastboot_server/rv1106_ipc_sdk'...
|
|
||||||
Submodule path 'rv1106_ipc_sdk': checked out 'ff8da760b201d365300aed78190de8564f0d2171'
|
|
||||||
```
|
|
||||||
|
|
||||||
## 1.5. 存疑
|
|
||||||
|
|
||||||
* 不同的分支之间如何同步某个文件?
|
|
|
@ -1,20 +0,0 @@
|
||||||
# 1. 项目进度汇总
|
|
||||||
|
|
||||||
## 1.1. 软件开发进度
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
gantt
|
|
||||||
dateFormat YYYY-MM-DD
|
|
||||||
title 软件进度-3月
|
|
||||||
section 3月
|
|
||||||
6帧探RTSP推流 : done, rtsp_media, 2024-03-18,3d
|
|
||||||
SC230AI快启验证(快启报错) : crit, active, 2024-03-21,3d
|
|
||||||
6帧探视频回放 : active, 2024-03-25,3d
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.1.1. 总结
|
|
||||||
|
|
||||||
* 截至2024-3-25:
|
|
||||||
1. 6侦探协议框架含http和tcp,http协议框架开发完成,rtsp推流到手机APP完成;
|
|
||||||
2. 存在问题:rtsp推流存在卡顿问题,待优化;
|
|
||||||
3. 更换SC230AI调试快启,快启报错,需要提问题单找原厂协助;
|
|
|
@ -1,101 +0,0 @@
|
||||||
# 1. Markdown使用手册
|
|
||||||
|
|
||||||
## 1.1. 概述
|
|
||||||
|
|
||||||
使用markdown编辑开发文档有以下好处:
|
|
||||||
|
|
||||||
* markdown语法是一种语言,类似代码一样可以方便git管理,查看修改记录;
|
|
||||||
* 对代码显示支持良好;
|
|
||||||
* 可以进行UML类图和时序图的编辑/迭代/维护(强烈推荐);
|
|
||||||
|
|
||||||
## 1.2. 如何使用Markdown
|
|
||||||
|
|
||||||
此处介绍基于vscode编辑环境下使用Markdown的方法:
|
|
||||||
|
|
||||||
* 首先安装vscode插件:
|
|
||||||
1. Markdown All in One
|
|
||||||
2. Markdown Preview Enhanced
|
|
||||||
* 使用Markdown语法编辑开发文档,并使用vscode预览;
|
|
||||||
* 右键使用浏览器打开并打印可生成PDF文档;
|
|
||||||
|
|
||||||
## 1.3. 基本语法介绍
|
|
||||||
|
|
||||||
提供常用语法参考,直接copy模块代码进行编辑。
|
|
||||||
|
|
||||||
### 1.3.1. 常用命令
|
|
||||||
|
|
||||||
```
|
|
||||||
Markdown All in One: Create Table of Contents 创建目录
|
|
||||||
Markdown All in One: Update Table of Contents 更新目录
|
|
||||||
Markdown All in One: Add/Update section numbers 添加 / 更新章节编号
|
|
||||||
Markdown All in One: Remove section numbers 删除章节编号
|
|
||||||
Markdown All in One: Toggle code span 触发设置代码范围(`code`)
|
|
||||||
Markdown All in One: Toggle code block 触发设置代码块(```codes```)
|
|
||||||
Markdown All in One: Print current document to HTML
|
|
||||||
Markdown All in One: Toggle math environment 触发设置数学环境
|
|
||||||
Markdown All in One: Toggle list 触发设置列表环境
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.3.2. 代码段
|
|
||||||
|
|
||||||
```
|
|
||||||
/*This is your code.*/
|
|
||||||
#include <stdio.h>
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.3.3. UML类图语法
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
classDiagram
|
|
||||||
Animal <|-- Fish:继承
|
|
||||||
Animal <|.. Zebra:实现
|
|
||||||
Animal : +int age
|
|
||||||
Animal : +String gender
|
|
||||||
Animal: +isMammal()
|
|
||||||
Animal: +mate()
|
|
||||||
class Animal{
|
|
||||||
<<interface>>
|
|
||||||
+call() int
|
|
||||||
}
|
|
||||||
class Fish{
|
|
||||||
-int sizeInFeet
|
|
||||||
-canEat()
|
|
||||||
}
|
|
||||||
class Zebra{
|
|
||||||
<<class>>
|
|
||||||
-func(int, int) int
|
|
||||||
+bool is_wild
|
|
||||||
+run(void)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
实现:一般指对抽象类的实例类 \
|
|
||||||
继承:一般指对普通功能基类的派生/重载
|
|
||||||
|
|
||||||
### 1.3.4. UML时序图
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
sequenceDiagram
|
|
||||||
Alice->>+Jhon:Call function
|
|
||||||
Jhon->>Jhon:handle
|
|
||||||
Jhon-->>-Alice:Call return
|
|
||||||
note left of Alice:function
|
|
||||||
|
|
||||||
Alice->>+Jhon:Call function
|
|
||||||
Jhon->>+Fancy:Call
|
|
||||||
Fancy-->>-Jhon:Call return
|
|
||||||
Jhon-->>-Alice:Call return
|
|
||||||
|
|
||||||
Alice->>+Jhon:Call function
|
|
||||||
Jhon->>+Fancy:Call
|
|
||||||
Fancy->>-Fancy:End
|
|
||||||
Jhon-->>-Alice:Call return
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.3.5. 踩坑记录
|
|
||||||
|
|
||||||
1. 状态图不能使用default关键字作为一个状态名称,无法画图;
|
|
|
@ -1,9 +0,0 @@
|
||||||
# 1. SDK构建设计文档
|
|
||||||
|
|
||||||
## 1.1. 概述
|
|
||||||
|
|
||||||
  SDK使用cmake构建,把分层解耦合的独立模块编译成静态库,应用程序根据依赖关系进行自动关联链接。
|
|
||||||
|
|
||||||
## 1.2. 启用/禁用功能模块
|
|
||||||
|
|
||||||
  根据不同的产品需求来启用/禁用功能模块,避免编译不需要的模块。
|
|
|
@ -1,89 +0,0 @@
|
||||||
# 1. vscode使用ssh链接虚拟机服务器
|
|
||||||
|
|
||||||
# 2. 前言
|
|
||||||
|
|
||||||
   在vscode使用ssh工具远程登录虚拟机服务器进行代码编辑。
|
|
||||||
|
|
||||||
| 内容 | 时间 | 作者 | 备注 |
|
|
||||||
|----|----|----|----|
|
|
||||||
| 首版 | 2024-2-26 | xjz | - |
|
|
||||||
|
|
||||||
## 2.1. Windows系统
|
|
||||||
|
|
||||||
* 安装ssh
|
|
||||||
|
|
||||||
   直接安装git工具即可支持ssh
|
|
||||||
|
|
||||||
安装完后确认:
|
|
||||||
```
|
|
||||||
xiaojiazhu@ubuntu:~/project/rkipc/battery/ipc-rk1106/ipc-sdk/cmake-shell$ ssh
|
|
||||||
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
|
|
||||||
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
|
|
||||||
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
|
|
||||||
[-i identity_file] [-J [user@]host[:port]] [-L address]
|
|
||||||
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
|
|
||||||
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
|
|
||||||
[-w local_tun[:remote_tun]] destination [command]
|
|
||||||
```
|
|
||||||
|
|
||||||
* vscode安装ssh插件
|
|
||||||
|
|
||||||
   使用 Remote - SSH 插件
|
|
||||||
|
|
||||||
* ssh密钥配置
|
|
||||||
|
|
||||||
1. Windows生成密钥;
|
|
||||||
2. 把xxx.pub文件内容拷贝到虚拟机的ssh目录下的authorized_keys文件;
|
|
||||||
此处是:
|
|
||||||
|
|
||||||
```
|
|
||||||
xiaojiazhu@ubuntu:~/project/.ssh$ pwd
|
|
||||||
/home/xiaojiazhu/project/.ssh
|
|
||||||
xiaojiazhu@ubuntu:~/project/.ssh$ ls
|
|
||||||
authorized_keys id_rsa id_rsa.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
这样设置后,每次登录ssh无需手动输入密码;
|
|
||||||
|
|
||||||
3. 在Windows远程登录虚拟机:
|
|
||||||
|
|
||||||
参考命令:ssh xiaojiazhu@192.168.1.29
|
|
||||||
|
|
||||||
```
|
|
||||||
PS C:\Users\xjz\.ssh> ssh xiaojiazhu@192.168.1.29
|
|
||||||
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-94-generic x86_64)
|
|
||||||
|
|
||||||
* Documentation: https://help.ubuntu.com
|
|
||||||
* Management: https://landscape.canonical.com
|
|
||||||
* Support: https://ubuntu.com/advantage
|
|
||||||
|
|
||||||
Expanded Security Maintenance for Applications is not enabled.
|
|
||||||
|
|
||||||
75 updates can be applied immediately.
|
|
||||||
To see these additional updates run: apt list --upgradable
|
|
||||||
|
|
||||||
9 additional security updates can be applied with ESM Apps.
|
|
||||||
Learn more about enabling ESM Apps service at https://ubuntu.com/esm
|
|
||||||
|
|
||||||
New release '22.04.3 LTS' available.
|
|
||||||
Run 'do-release-upgrade' to upgrade to it.
|
|
||||||
|
|
||||||
Your Hardware Enablement Stack (HWE) is supported until April 2025.
|
|
||||||
*** System restart required ***
|
|
||||||
Last login: Sun Feb 25 17:20:04 2024 from 192.168.1.29
|
|
||||||
xiaojiazhu@ubuntu:~$
|
|
||||||
```
|
|
||||||
## 2.2. vscode设置
|
|
||||||
|
|
||||||
配置文件参考
|
|
||||||
|
|
||||||
```
|
|
||||||
Host dgiot // 自定义的主机名
|
|
||||||
HostName 192.168.1.29 // 远端的IP地址
|
|
||||||
User xiaojiazhu 用户名
|
|
||||||
Port 22
|
|
||||||
IdentityFile "C:\Users\xjz\.ssh\id_ed25519" // 本端的私钥文件路径
|
|
||||||
ForwardAgent yes // 忽略
|
|
||||||
```
|
|
||||||
|
|
||||||
多个远端IP复制即可。
|
|
|
@ -1,71 +0,0 @@
|
||||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
|
||||||
include(${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade/build/hunting_upgrade.cmake)
|
|
||||||
include(${HAL_SOURCE_PATH}/build/hal.cmake)
|
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})
|
|
||||||
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
./src
|
|
||||||
./include
|
|
||||||
${APPLICATION_SOURCE_PATH}/MissionManager/include
|
|
||||||
${APPLICATION_SOURCE_PATH}/MissionManager/src
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/AppManager/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/MediaManager/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/StateMachine/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/StorageManager/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/StorageManager/src
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/FilesManager/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include
|
|
||||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
|
||||||
${UTILS_SOURCE_PATH}/Log/include
|
|
||||||
${UTILS_SOURCE_PATH}/LinuxApi/include
|
|
||||||
${UTILS_SOURCE_PATH}/UpgradeTool/include
|
|
||||||
${UTILS_SOURCE_PATH}/KeyControl/include
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${TEST_SOURCE_PATH}/middleware/AppManager/tool/include
|
|
||||||
${TEST_SOURCE_PATH}/middleware/AppManager/tool/src
|
|
||||||
${TEST_SOURCE_PATH}/middleware/MediaManager/tool/include
|
|
||||||
${TEST_SOURCE_PATH}/middleware/MediaManager/tool/src
|
|
||||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include
|
|
||||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include
|
|
||||||
)
|
|
||||||
# link_directories(
|
|
||||||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
|
||||||
# )
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET MissionManagerTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} MissionManager AppManagerTestTool MediaManagerTestTool KeyControl UpgradeTool StatusCode Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
MissionManagerTestTool_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}/application/MissionManager/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
MissionManagerTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/MissionManager/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make MissionManagerTestTool_code_check
|
|
||||||
COMMAND make MissionManagerTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,78 +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 "MissionManagerMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "OnMissionStateMock.h"
|
|
||||||
#include "PirTriggeredMissionStateMock.h"
|
|
||||||
#include "TestMissionStateMock.h"
|
|
||||||
#include "TopStateMock.h"
|
|
||||||
void OverrideMissionManagerMakePtrObject(std::shared_ptr<MissionManagerMock> &appManagerMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MissionManagerMakePtr> impl = std::make_shared<MissionManagerMakePtrTest>();
|
|
||||||
std::shared_ptr<MissionManagerMakePtrTest> test = std::dynamic_pointer_cast<MissionManagerMakePtrTest>(impl);
|
|
||||||
if (test) {
|
|
||||||
test->mMissionManagerMock = appManagerMock;
|
|
||||||
}
|
|
||||||
MissionManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
void CancelOverrideMissionManagerMakePtrObject(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MissionManagerMakePtr> tmp = MissionManagerMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<MissionManagerMakePtrTest> test = std::dynamic_pointer_cast<MissionManagerMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mMissionManagerMock.reset();
|
|
||||||
}
|
|
||||||
tmp.reset();
|
|
||||||
test.reset();
|
|
||||||
std::shared_ptr<MissionManagerMakePtr> impl = std::make_shared<MissionManagerMakePtrTest>();
|
|
||||||
MissionManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
MissionManagerMakePtrTest::MissionManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
MissionManagerMakePtrTest::~MissionManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
mMissionManagerMock.reset();
|
|
||||||
}
|
|
||||||
std::shared_ptr<State> MissionManagerMakePtrTest::CreateTopState(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<State> state = std::make_shared<TopStateMock>();
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
std::shared_ptr<State> MissionManagerMakePtrTest::CreateMissionState(const IpcMission &mission)
|
|
||||||
{
|
|
||||||
LogInfo("MissionManagerMakePtrTest::CreateMissionState\n");
|
|
||||||
std::shared_ptr<State> state;
|
|
||||||
switch (mission) {
|
|
||||||
case IpcMission::PIR_TRIGGERED:
|
|
||||||
LogInfo("Create PirTriggeredMissionStateMock.\n");
|
|
||||||
state = std::make_shared<PirTriggeredMissionStateMock>();
|
|
||||||
break;
|
|
||||||
case IpcMission::TEST:
|
|
||||||
LogInfo("Create TestMissionStateMock.\n");
|
|
||||||
state = std::make_shared<TestMissionStateMock>();
|
|
||||||
break;
|
|
||||||
case IpcMission::ON:
|
|
||||||
LogInfo("Create OnMissionStateMock.\n");
|
|
||||||
state = std::make_shared<OnMissionStateMock>();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
LogWarning("Unknown mission.\n");
|
|
||||||
state = std::make_shared<TestMissionStateMock>();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
|
@ -1,33 +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 MISSION_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#define MISSION_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#include "MissionManagerMakePtr.h"
|
|
||||||
#include "MissionManagerMock.h"
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
void OverrideMissionManagerMakePtrObject(std::shared_ptr<MissionManagerMock> &appManagerMock);
|
|
||||||
void CancelOverrideMissionManagerMakePtrObject(void);
|
|
||||||
class MissionManagerMakePtrTest : public MissionManagerMakePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MissionManagerMakePtrTest();
|
|
||||||
virtual ~MissionManagerMakePtrTest();
|
|
||||||
std::shared_ptr<State> CreateTopState(void) override;
|
|
||||||
std::shared_ptr<State> CreateMissionState(const IpcMission &mission) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<MissionManagerMock> mMissionManagerMock;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,40 +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 "MissionManagerMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
// const StatusCode MissionManagerTest::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
|
||||||
// {
|
|
||||||
// LogInfo("MissionManagerTest::SetAppMonitor\n");
|
|
||||||
// StatusCode code = SetAppMonitorTrace(monitor);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return MissionManager::SetAppMonitor(monitor);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// const StatusCode MissionManagerTest::SetAppMonitorTrace(std::shared_ptr<VAppMonitor> &monitor)
|
|
||||||
// {
|
|
||||||
// LogInfo("MissionManagerTest::SetAppMonitorTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MissionManagerTest::GetAllLedsTrace(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
|
||||||
// {
|
|
||||||
// LogInfo("MissionManagerTest::GetAllLedsTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MissionManagerTest::GetAllKeysTrace(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
|
||||||
// {
|
|
||||||
// LogInfo("MissionManagerTest::GetAllKeysTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
|
@ -1,36 +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 MISSION_MANAGER_MOCK_H
|
|
||||||
#define MISSION_MANAGER_MOCK_H
|
|
||||||
#include "MissionManager.h"
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
class MissionManagerTest : public MissionManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MissionManagerTest() = default;
|
|
||||||
virtual ~MissionManagerTest() = default;
|
|
||||||
// const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// virtual const StatusCode SetAppMonitorTrace(std::shared_ptr<VAppMonitor> &monitor);
|
|
||||||
};
|
|
||||||
class MissionManagerMock : public MissionManagerTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MissionManagerMock() = default;
|
|
||||||
virtual ~MissionManagerMock() = default;
|
|
||||||
// MOCK_METHOD1(SetAppMonitorTrace, const StatusCode(std::shared_ptr<VAppMonitor> &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,45 +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 "MissionManagerTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "LinuxApi.h"
|
|
||||||
#include "MissionManagerMakePtrTest.h"
|
|
||||||
#include "MissionManagerMock.h"
|
|
||||||
#include "UpgradeTool.h"
|
|
||||||
void MissionManagerTestTool::Init(void)
|
|
||||||
{
|
|
||||||
mMissionManagerMock = std::make_shared<MissionManagerMock>();
|
|
||||||
std::shared_ptr<MissionManagerMock> mock = std::dynamic_pointer_cast<MissionManagerMock>(mMissionManagerMock);
|
|
||||||
OverrideMissionManagerMakePtrObject(mock);
|
|
||||||
}
|
|
||||||
void MissionManagerTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
mMissionManagerMock.reset();
|
|
||||||
CancelOverrideMissionManagerMakePtrObject();
|
|
||||||
}
|
|
||||||
void MissionManagerTestTool::CreateUpgradeFile(void)
|
|
||||||
{
|
|
||||||
fx_system("touch " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
|
||||||
UpgradeTool::GetInstance()->PackFile(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test",
|
|
||||||
SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH,
|
|
||||||
"1.0.0.0",
|
|
||||||
"hunting",
|
|
||||||
"dgiot",
|
|
||||||
"app");
|
|
||||||
}
|
|
||||||
void MissionManagerTestTool::RemoveUpgradeFile(void)
|
|
||||||
{
|
|
||||||
fx_system("rm " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH);
|
|
||||||
}
|
|
|
@ -1,16 +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 "OnMissionStateMock.h"
|
|
||||||
#include "ILog.h"
|
|
|
@ -1,33 +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 ON_MISSION_STATE_MOCK_H
|
|
||||||
#define ON_MISSION_STATE_MOCK_H
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
#include "OnMissionState.h"
|
|
||||||
class OnMissionStateTest : public OnMissionState
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OnMissionStateTest() = default;
|
|
||||||
virtual ~OnMissionStateTest() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
class OnMissionStateMock : public OnMissionStateTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OnMissionStateMock() = default;
|
|
||||||
virtual ~OnMissionStateMock() = default;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,16 +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 "PirTriggeredMissionStateMock.h"
|
|
||||||
#include "ILog.h"
|
|
|
@ -1,33 +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 PIR_TRIGGERED_MISSION_STATE_MOCK_H
|
|
||||||
#define PIR_TRIGGERED_MISSION_STATE_MOCK_H
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
#include "PirTriggeredMissionState.h"
|
|
||||||
class PirTriggeredMissionStateTest : public PirTriggeredMissionState
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PirTriggeredMissionStateTest() = default;
|
|
||||||
virtual ~PirTriggeredMissionStateTest() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
class PirTriggeredMissionStateMock : public PirTriggeredMissionStateTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PirTriggeredMissionStateMock() = default;
|
|
||||||
virtual ~PirTriggeredMissionStateMock() = default;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,34 +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 "SdCardHandleStateMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "StatusCode.h"
|
|
||||||
SdCardHandleStateTest::SdCardHandleStateTest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
bool SdCardHandleStateTest::SdCardEventHandle(VStateMachineData *msg)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MissionMessage> message = std::dynamic_pointer_cast<MissionMessage>(msg->GetMessageObj());
|
|
||||||
std::shared_ptr<VMissionDataV2<StorageEvent>> data =
|
|
||||||
std::dynamic_pointer_cast<VMissionDataV2<StorageEvent>>(message->mMissionData);
|
|
||||||
if (StorageEvent::SD_CARD_INSERT == data->mData) {
|
|
||||||
const std::string realSavePah = SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH;
|
|
||||||
bool directoryExist = StorageBase::CheckDirectory(realSavePah.c_str());
|
|
||||||
if (false == directoryExist) {
|
|
||||||
LogWarning("Directory not exist.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SdCardHandleState::SdCardEventHandle(msg);
|
|
||||||
}
|
|
|
@ -1,36 +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 SD_CARD_HANDLE_STATE_MOCK_H
|
|
||||||
#define SD_CARD_HANDLE_STATE_MOCK_H
|
|
||||||
#include "MediaMonitorMock.h"
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
#include "SdCardHandleState.h"
|
|
||||||
#include "StorageBase.h"
|
|
||||||
class SdCardHandleStateTest : public SdCardHandleState, virtual public MediaMonitorTrace, public StorageBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SdCardHandleStateTest();
|
|
||||||
virtual ~SdCardHandleStateTest() = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool SdCardEventHandle(VStateMachineData *msg);
|
|
||||||
};
|
|
||||||
class SdCardHandleStateMock : public MediaMonitorMock, public SdCardHandleStateTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SdCardHandleStateMock() = default;
|
|
||||||
virtual ~SdCardHandleStateMock() = default;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,176 +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 "TestMissionStateMock.h"
|
|
||||||
#include "AppMonitorMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
StatusCode TestMissionStateTest::GetProductInfo(AppGetProductInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetProductInfo\n");
|
|
||||||
StatusCode code = GetProductInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetProductInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetDeviceAttr(AppGetDeviceAttr ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetDeviceAttr\n");
|
|
||||||
StatusCode code = GetDeviceAttrTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetDeviceAttr(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetMediaInfo(AppGetMediaInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetMediaInfo\n");
|
|
||||||
StatusCode code = GetMediaInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetMediaInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetSdCardInfo\n");
|
|
||||||
StatusCode code = GetSdCardInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetSdCardInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetBatteryInfo(AppGetBatteryInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetBatteryInfo\n");
|
|
||||||
StatusCode code = GetBatteryInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetBatteryInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetParamValue(AppParamValue ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetParamValue\n");
|
|
||||||
StatusCode code = GetParamValueTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetParamValue(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetCapability(AppGetCapability ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetCapability\n");
|
|
||||||
StatusCode code = GetCapabilityTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetCapability(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetLockVideoStatus(LockVideoStatus ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetLockVideoStatus\n");
|
|
||||||
StatusCode code = GetLockVideoStatusTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetLockVideoStatus(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetStorageInfo(std::vector<AppGetStorageInfo> ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetStorageInfo\n");
|
|
||||||
StatusCode code = GetStorageInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetStorageInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::GetStorageFileList\n");
|
|
||||||
StatusCode code = GetStorageFileListTrace(fileInfo, param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::GetStorageFileList(fileInfo, param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::SetDateTime(const AppSetDateTime ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::SetDateTime\n");
|
|
||||||
LogInfo("mYear = %u\n", param.mYear);
|
|
||||||
LogInfo("mMonth = %02u\n", param.mMonth);
|
|
||||||
LogInfo("mDay = %02u\n", param.mDay);
|
|
||||||
LogInfo("mHour = %02u\n", param.mHour);
|
|
||||||
LogInfo("mMinute = %02u\n", param.mMinute);
|
|
||||||
LogInfo("mSecond = %02u\n", param.mSecond);
|
|
||||||
StatusCode code = SetDateTimeTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::SetDateTime(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::SetTimeZone(const unsigned int &zone)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::SetTimeZone = %u\n", zone);
|
|
||||||
StatusCode code = SetTimeZoneTrace(zone);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::SetTimeZone(zone);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::SetParamValue(const AppSetParamValue ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::SetParamValue.\n");
|
|
||||||
StatusCode code = SetParamValueTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::SetParamValue(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::EnterRecorder(void)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::EnterRecorder.\n");
|
|
||||||
StatusCode code = EnterRecorderTrace();
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::EnterRecorder();
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::AppPlayback(const PlayBackEvent &event)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::AppPlayback.\n");
|
|
||||||
StatusCode code = AppPlaybackTrace(event);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::AppPlayback(event);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::UploadFile(AppUploadFile ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::UploadFile\n");
|
|
||||||
StatusCode code = UploadFileTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::UploadFile(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode TestMissionStateTest::AppClientConnected(std::shared_ptr<VAppClient> &client)
|
|
||||||
{
|
|
||||||
LogInfo("TestMissionStateTest::AppClientConnected\n");
|
|
||||||
StatusCode code = AppClientConnectedTrace(client);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppMonitor::AppClientConnected(client);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
|
@ -1,51 +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 TEST_MISSION_STATE_MOCK_H
|
|
||||||
#define TEST_MISSION_STATE_MOCK_H
|
|
||||||
#include "AppMonitorMock.h"
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
#include "TestMissionState.h"
|
|
||||||
class TestMissionStateTest : public TestMissionState, virtual public AppMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TestMissionStateTest() = default;
|
|
||||||
virtual ~TestMissionStateTest() = default;
|
|
||||||
StatusCode GetProductInfo(AppGetProductInfo ¶m) override;
|
|
||||||
StatusCode GetDeviceAttr(AppGetDeviceAttr ¶m) override;
|
|
||||||
StatusCode GetMediaInfo(AppGetMediaInfo ¶m) override;
|
|
||||||
StatusCode GetSdCardInfo(AppGetSdCardInfo ¶m) override;
|
|
||||||
StatusCode GetBatteryInfo(AppGetBatteryInfo ¶m) override;
|
|
||||||
StatusCode GetParamValue(AppParamValue ¶m) override;
|
|
||||||
StatusCode GetCapability(AppGetCapability ¶m) override;
|
|
||||||
StatusCode GetLockVideoStatus(LockVideoStatus ¶m) override;
|
|
||||||
StatusCode GetStorageInfo(std::vector<AppGetStorageInfo> ¶m) override;
|
|
||||||
StatusCode GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m) override;
|
|
||||||
StatusCode SetDateTime(const AppSetDateTime ¶m) override;
|
|
||||||
StatusCode SetTimeZone(const unsigned int &zone) override;
|
|
||||||
StatusCode SetParamValue(const AppSetParamValue ¶m) override;
|
|
||||||
StatusCode EnterRecorder(void) override;
|
|
||||||
StatusCode AppPlayback(const PlayBackEvent &event) override;
|
|
||||||
StatusCode UploadFile(AppUploadFile ¶m) override;
|
|
||||||
StatusCode AppClientConnected(std::shared_ptr<VAppClient> &client) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
class TestMissionStateMock : public AppMonitorMock, public TestMissionStateTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TestMissionStateMock() = default;
|
|
||||||
virtual ~TestMissionStateMock() = default;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,15 +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 "TopStateMock.h"
|
|
|
@ -1,34 +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 TOP_STATE_MOCK_H
|
|
||||||
#define TOP_STATE_MOCK_H
|
|
||||||
#include "MediaMonitorMock.h"
|
|
||||||
#include "MissionManagerTestTool.h"
|
|
||||||
#include "TopState.h"
|
|
||||||
class TopStateTest : public TopState, virtual public MediaMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TopStateTest() = default;
|
|
||||||
virtual ~TopStateTest() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
class TopStateMock : public MediaMonitorMock, public TopStateTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TopStateMock() = default;
|
|
||||||
virtual ~TopStateMock() = default;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,55 +0,0 @@
|
||||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
|
||||||
include(${HAL_SOURCE_PATH}/build/hal.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}/KeyControl/include
|
|
||||||
${UTILS_SOURCE_PATH}/LedControl/include
|
|
||||||
${HAL_SOURCE_PATH}/src
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
|
|
||||||
)
|
|
||||||
# link_directories(
|
|
||||||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
|
||||||
# )
|
|
||||||
|
|
||||||
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} Hal KeyControl LedControl LinuxApiMock Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_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})
|
|
|
@ -1,60 +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 "CameraHalMock.h"
|
|
||||||
#include "HalCppMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
CameraHalTest::CameraHalTest(const CameraType &cameraType) : mCameraType(cameraType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void CameraHalTest::SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogInfo("CameraHalTest::SetCameraMonitor.\n");
|
|
||||||
mMonitor = monitor;
|
|
||||||
SetCameraMonitorTrace(monitor);
|
|
||||||
if (nullptr != mFastBootEvent) {
|
|
||||||
monitor->ReportEvent(*(mFastBootEvent.get()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void CameraHalTest::SetCameraMonitorTrace(std::shared_ptr<VCameraHalMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogWarning("SetCameraMonitorTrace.\n");
|
|
||||||
}
|
|
||||||
StatusCode CameraHalTest::StartSingleTask(const CameraTaskParam ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("CameraHalTest::StartSingleTask\n");
|
|
||||||
StatusCode code = StartSingleTaskTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return HalCpp::GetAllKeys(allKeys);
|
|
||||||
// }
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode CameraHalTest::StartSingleTaskTrace(const CameraTaskParam ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("CameraHalTest::StartSingleTaskTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
CameraHalMock::CameraHalMock(const CameraType &cameraType) : CameraHalTest(cameraType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void CameraHalMock::MockReportCameraEvent(const CameraReportEvent &event)
|
|
||||||
{
|
|
||||||
auto monitor = mMonitor.lock();
|
|
||||||
if (mMonitor.expired()) {
|
|
||||||
LogWarning("monitor is nullptr.\n");
|
|
||||||
mFastBootEvent = std::make_shared<CameraReportEvent>(event.mFileName, event.mCameraType);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
monitor->ReportEvent(event);
|
|
||||||
}
|
|
|
@ -1,45 +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 CAMERA_HAL_MOCK_H
|
|
||||||
#define CAMERA_HAL_MOCK_H
|
|
||||||
#include "HalCpp.h"
|
|
||||||
#include "HalTestTool.h"
|
|
||||||
class CameraHalTest : public VCameraHal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CameraHalTest(const CameraType &cameraType);
|
|
||||||
virtual ~CameraHalTest() = default;
|
|
||||||
void SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor) override;
|
|
||||||
StatusCode StartSingleTask(const CameraTaskParam ¶m) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual void SetCameraMonitorTrace(std::shared_ptr<VCameraHalMonitor> &monitor);
|
|
||||||
virtual StatusCode StartSingleTaskTrace(const CameraTaskParam ¶m);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
const CameraType mCameraType;
|
|
||||||
std::weak_ptr<VCameraHalMonitor> mMonitor;
|
|
||||||
std::shared_ptr<CameraReportEvent> mFastBootEvent;
|
|
||||||
};
|
|
||||||
class CameraHalMock : public CameraHalTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CameraHalMock(const CameraType &cameraType);
|
|
||||||
virtual ~CameraHalMock() = default;
|
|
||||||
void MockReportCameraEvent(const CameraReportEvent &event);
|
|
||||||
MOCK_METHOD1(SetCameraMonitorTrace, void(std::shared_ptr<VCameraHalMonitor> &));
|
|
||||||
MOCK_METHOD1(StartSingleTaskTrace, StatusCode(const CameraTaskParam &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,72 +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 "HalCppMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
StatusCode HalCppTest::GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetAllLeds\n");
|
|
||||||
StatusCode code = GetAllLedsTrace(allLeds);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return HalCpp::GetAllLeds(allLeds);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetAllLedsTrace(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetAllLedsTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetAllKeys\n");
|
|
||||||
StatusCode code = GetAllKeysTrace(allKeys);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return HalCpp::GetAllKeys(allKeys);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetAllKeysTrace(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetAllKeysTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetWifiHal(std::shared_ptr<VWifiHal> &wifi)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetAllKeys\n");
|
|
||||||
StatusCode code = GetWifiHalTrace(wifi);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return HalCpp::GetWifiHal(wifi);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetCameraHal(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetCameraHal\n");
|
|
||||||
StatusCode code = GetCameraHalTrace(allCameras);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return HalCpp::GetCameraHal(allCameras);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetWifiHalTrace(std::shared_ptr<VWifiHal> &wifi)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetWifiHalTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode HalCppTest::GetCameraHalTrace(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras)
|
|
||||||
{
|
|
||||||
LogInfo("HalCppTest::GetCameraHalTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
|
@ -1,45 +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 HAL_CPP_MOCK_H
|
|
||||||
#define HAL_CPP_MOCK_H
|
|
||||||
#include "HalCpp.h"
|
|
||||||
#include "HalTestTool.h"
|
|
||||||
class HalCppTest : public HalCpp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HalCppTest() = default;
|
|
||||||
virtual ~HalCppTest() = default;
|
|
||||||
StatusCode GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds) override;
|
|
||||||
StatusCode GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys) override;
|
|
||||||
StatusCode GetWifiHal(std::shared_ptr<VWifiHal> &wifi) override;
|
|
||||||
StatusCode GetCameraHal(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual StatusCode GetAllLedsTrace(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds);
|
|
||||||
virtual StatusCode GetAllKeysTrace(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
|
|
||||||
virtual StatusCode GetWifiHalTrace(std::shared_ptr<VWifiHal> &wifi);
|
|
||||||
virtual StatusCode GetCameraHalTrace(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras);
|
|
||||||
};
|
|
||||||
class HalCppMock : public HalCppTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HalCppMock() = default;
|
|
||||||
virtual ~HalCppMock() = default;
|
|
||||||
MOCK_METHOD1(GetAllLedsTrace, StatusCode(std::map<std::string, std::shared_ptr<VLedHal>> &));
|
|
||||||
MOCK_METHOD1(GetAllKeysTrace, StatusCode(std::map<std::string, std::shared_ptr<VKeyHal>> &));
|
|
||||||
MOCK_METHOD1(GetWifiHalTrace, StatusCode(std::shared_ptr<VWifiHal> &));
|
|
||||||
MOCK_METHOD1(GetCameraHalTrace, StatusCode(std::map<CameraType, std::shared_ptr<VCameraHal>> &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,72 +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 "HalMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
void OverrideHalMakePtrObject(std::shared_ptr<HalCppMock> &halMock, std::shared_ptr<SdCardHalMock> &sdCardHalMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<HalMakePtr> impl = std::make_shared<HalMakePtrTest>();
|
|
||||||
std::shared_ptr<HalMakePtrTest> test = std::dynamic_pointer_cast<HalMakePtrTest>(impl);
|
|
||||||
if (test) {
|
|
||||||
test->mHalCppMock = halMock;
|
|
||||||
test->mSdCardHalMock = sdCardHalMock;
|
|
||||||
}
|
|
||||||
HalMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
void CancelOverrideHalMakePtrObject(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<HalMakePtr> tmp = HalMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<HalMakePtrTest> test = std::dynamic_pointer_cast<HalMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mHalCppMock.reset();
|
|
||||||
test->mSdCardHalMock.reset();
|
|
||||||
}
|
|
||||||
std::shared_ptr<HalMakePtr> impl = std::make_shared<HalMakePtrTest>();
|
|
||||||
HalMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
HalMakePtrTest::HalMakePtrTest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
HalMakePtrTest::~HalMakePtrTest()
|
|
||||||
{
|
|
||||||
mHalCppMock.reset();
|
|
||||||
mSdCardHalMock.reset();
|
|
||||||
}
|
|
||||||
StatusCode HalMakePtrTest::CreateHalSharePtr(std::shared_ptr<IHalCpp> &impl)
|
|
||||||
{
|
|
||||||
if (mHalCppMock) {
|
|
||||||
LogInfo("CreateHalSharePtr mHalCppMock\n");
|
|
||||||
impl = mHalCppMock;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("CreateMcuManager failed:mHalCppMock is nullptr.\n");
|
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
||||||
StatusCode HalMakePtrTest::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl)
|
|
||||||
{
|
|
||||||
impl = mSdCardHalMock;
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
||||||
StatusCode HalMakePtrTest::CreateAllKeyHal(std::vector<std::shared_ptr<VKeyControl>> &keys)
|
|
||||||
{
|
|
||||||
if (mKeysMock.size() > 0) {
|
|
||||||
LogInfo("Create mock keys.size = %d\n", mKeysMock.size());
|
|
||||||
keys = mKeysMock;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
HalMakePtr::CreateAllKeyHal(keys);
|
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
|
@ -1,38 +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 HAL_MAKE_PTR_TEST_H
|
|
||||||
#define HAL_MAKE_PTR_TEST_H
|
|
||||||
#include "HalCppMock.h"
|
|
||||||
#include "HalMakePtr.h"
|
|
||||||
#include "HalTestTool.h"
|
|
||||||
#include "KeyControlMock.h"
|
|
||||||
#include "SdCardHalMock.h"
|
|
||||||
void OverrideHalMakePtrObject(std::shared_ptr<HalCppMock> &halMock, std::shared_ptr<SdCardHalMock> &sdCardHalMock);
|
|
||||||
void CancelOverrideHalMakePtrObject(void);
|
|
||||||
class HalMakePtrTest : public HalMakePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HalMakePtrTest();
|
|
||||||
virtual ~HalMakePtrTest();
|
|
||||||
StatusCode CreateHalSharePtr(std::shared_ptr<IHalCpp> &impl) override;
|
|
||||||
StatusCode CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl) override;
|
|
||||||
StatusCode CreateAllKeyHal(std::vector<std::shared_ptr<VKeyControl>> &keys) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<HalCppMock> mHalCppMock;
|
|
||||||
std::shared_ptr<SdCardHalMock> mSdCardHalMock;
|
|
||||||
std::vector<std::shared_ptr<VKeyControl>> mKeysMock;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,369 +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 "HalTestTool.h"
|
|
||||||
#include "CameraHalMock.h"
|
|
||||||
#include "HalCppMock.h"
|
|
||||||
#include "HalMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "KeyControl.h"
|
|
||||||
#include "KeyControlMock.h"
|
|
||||||
#include "LedControlMock.h"
|
|
||||||
#include "SdCardHalMock.h"
|
|
||||||
#include "WifiHalMock.h"
|
|
||||||
#include <thread>
|
|
||||||
void HalTestTool::Init(void)
|
|
||||||
{
|
|
||||||
mHalMock = std::make_shared<HalCppMock>();
|
|
||||||
mSdCardHal = std::make_shared<SdCardHalMock>();
|
|
||||||
HalMockInit(mHalMock);
|
|
||||||
// TODO: 初始化mSdCardHal
|
|
||||||
std::shared_ptr<HalCppMock> halMock = std::dynamic_pointer_cast<HalCppMock>(mHalMock);
|
|
||||||
std::shared_ptr<SdCardHalMock> sdCardHalMock = std::dynamic_pointer_cast<SdCardHalMock>(mSdCardHal);
|
|
||||||
OverrideHalMakePtrObject(halMock, sdCardHalMock);
|
|
||||||
}
|
|
||||||
void HalTestTool::InitSdCardHal(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<SdCardHalMock> sdCardHal = std::dynamic_pointer_cast<SdCardHalMock>(mSdCardHal);
|
|
||||||
if (nullptr == sdCardHal) {
|
|
||||||
LogError("SdCardHalMock is null.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sdCardHal->SetLinuxTest(mock);
|
|
||||||
}
|
|
||||||
void HalTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
mHalMock.reset();
|
|
||||||
CancelOverrideHalMakePtrObject();
|
|
||||||
mAllKeys.clear();
|
|
||||||
mAllLeds.clear();
|
|
||||||
}
|
|
||||||
void HalTestTool::SetAllKeysResult(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
|
||||||
{
|
|
||||||
std::shared_ptr<IHalCpp> halMock = mHalMock;
|
|
||||||
SetAllKeysResult(halMock, allKeys);
|
|
||||||
mAllKeys = allKeys;
|
|
||||||
}
|
|
||||||
void HalTestTool::SetAllLedsResult(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
|
||||||
{
|
|
||||||
std::shared_ptr<IHalCpp> halMock = mHalMock;
|
|
||||||
SetAllLedsResult(halMock, allLeds);
|
|
||||||
mAllLeds = allLeds;
|
|
||||||
}
|
|
||||||
void HalTestTool::SetAllCamerasResult(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras)
|
|
||||||
{
|
|
||||||
std::shared_ptr<IHalCpp> halMock = mHalMock;
|
|
||||||
SetAllCamerasResult(halMock, allCameras);
|
|
||||||
mAllCameras = allCameras;
|
|
||||||
}
|
|
||||||
void HalTestTool::MockKeyClick(const std::string &keyName, const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VKeyHal> key = SearchKey(keyName);
|
|
||||||
if (!key) {
|
|
||||||
LogError("Can't mock key event, key not found.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::shared_ptr<KeyControlMock> keyMock = std::dynamic_pointer_cast<KeyControlMock>(key);
|
|
||||||
if (keyMock) {
|
|
||||||
if (keyMock->MockKeyClick(pressingTimeMs)) {
|
|
||||||
DeviceManagerNotice(keyName, pressingTimeMs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("Key mock error.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HalTestTool::SetLedStateExpectations(const std::string &ledName, const LedState &state,
|
|
||||||
const unsigned int &aliveTimeMs, const unsigned int &blinkTimeMs)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VLedHal> &led = SearchLed(ledName);
|
|
||||||
// if (!led) {
|
|
||||||
// LogError("Can't set led state, led not found.\n");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// std::shared_ptr<LedControlMock> ledMock = std::dynamic_pointer_cast<LedControlMock>(led);
|
|
||||||
// if (ledMock) {
|
|
||||||
// LedControlMock::SetLedStateMock(ledMock, state, aliveTimeMs, blinkTimeMs);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// LogWarning("led mock error.\n");
|
|
||||||
// }
|
|
||||||
LedControlMock::SetLedStateMock(led, state, aliveTimeMs, blinkTimeMs);
|
|
||||||
}
|
|
||||||
void HalTestTool::MockReportCameraEvent(const std::string &fileName, const CameraType &cameraType)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VCameraHal> camera = SearchCamera(cameraType);
|
|
||||||
if (!camera) {
|
|
||||||
LogError("Can't mock camera event, camera not found.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::shared_ptr<CameraHalMock> cameraMock = std::dynamic_pointer_cast<CameraHalMock>(camera);
|
|
||||||
if (cameraMock) {
|
|
||||||
CameraReportEvent report(fileName, cameraType);
|
|
||||||
cameraMock->MockReportCameraEvent(report);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("camera mock error.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HalTestTool::DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void HalTestTool::KeyEventHappendOnce(std::shared_ptr<VKeyHal> &vMock, const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
std::shared_ptr<KeyControlMock> mock = std::dynamic_pointer_cast<KeyControlMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(_, _, _))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
constexpr int CLICK_EVENT_HAPPENED_ONLY_ONCE = 1;
|
|
||||||
if (KEY_ACTION_SHORT_CLICK <= pressingTimeMs && pressingTimeMs < KEY_ACTION_HOLD_DWON) {
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), KeyEvent::SHORT_CLICK, _))
|
|
||||||
.Times(CLICK_EVENT_HAPPENED_ONLY_ONCE)
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
if (KEY_ACTION_HOLD_DWON <= pressingTimeMs) {
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), KeyEvent::HOLD_DOWN, _))
|
|
||||||
.Times(AtLeast(1))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::shared_ptr<VKeyHal> HalTestTool::SearchKey(const std::string &keyName)
|
|
||||||
{
|
|
||||||
std::shared_ptr<KeyControlMock> mock;
|
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>>::iterator iter;
|
|
||||||
iter = mAllKeys.find(keyName);
|
|
||||||
if (iter != mAllKeys.end()) {
|
|
||||||
mock = std::dynamic_pointer_cast<KeyControlMock>(mAllKeys[keyName]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("Can't found the key control.\n");
|
|
||||||
}
|
|
||||||
return mock;
|
|
||||||
}
|
|
||||||
void HalTestTool::InitAllKeysMock(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
|
||||||
{
|
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>>::iterator iter;
|
|
||||||
for (iter = allKeys.begin(); iter != allKeys.end(); ++iter) {
|
|
||||||
std::shared_ptr<VKeyHal> keyHal = iter->second;
|
|
||||||
InitKeysMock(keyHal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HalTestTool::InitKeysMock(std::shared_ptr<VKeyHal> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<KeyControlMock> mock = std::dynamic_pointer_cast<KeyControlMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
constexpr int KEY_SHOULD_NOT_TRIGGER_WHEN_NOBODY_SET_KEY_RESULT = 0;
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(_, _, _)).Times(KEY_SHOULD_NOT_TRIGGER_WHEN_NOBODY_SET_KEY_RESULT);
|
|
||||||
}
|
|
||||||
void HalTestTool::HalMockInit(std::shared_ptr<IHalCpp> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<HalCppMock> mock = std::dynamic_pointer_cast<HalCppMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EXPECT_CALL(*mock.get(), GetAllLedsTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetAllKeysTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
std::shared_ptr<VWifiHal> wifiHal = std::make_shared<WifiHalMock>();
|
|
||||||
std::shared_ptr<WifiHalMock> wifiHalMock = std::dynamic_pointer_cast<WifiHalMock>(wifiHal);
|
|
||||||
EXPECT_CALL(*wifiHalMock.get(), OpenApMode()).WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetWifiHalTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(SetArgReferee<0>(wifiHal), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetCameraHalTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
void HalTestTool::SetAllKeysResult(std::shared_ptr<IHalCpp> &vMock,
|
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
|
||||||
{
|
|
||||||
std::shared_ptr<HalCppMock> mock = std::dynamic_pointer_cast<HalCppMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// EXPECT_CALL(*mock.get(), GetAllKeysTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(SetArgReferee<0>(allKeys), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
// InitAllKeysMock(allKeys);
|
|
||||||
std::vector<std::shared_ptr<VKeyControl>> keysMock;
|
|
||||||
std::shared_ptr<HalMakePtr> impl = HalMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<HalMakePtrTest> test = std::dynamic_pointer_cast<HalMakePtrTest>(impl);
|
|
||||||
if (test) {
|
|
||||||
for (auto &key : allKeys) {
|
|
||||||
std::shared_ptr<KeyControlMock> keyMock = std::dynamic_pointer_cast<KeyControlMock>(key.second);
|
|
||||||
if (keyMock) {
|
|
||||||
keysMock.push_back(keyMock);
|
|
||||||
LogInfo("Create key mock. name = %s\n", keyMock->GetKeyName().c_str());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("Can't create key mock.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
test->mKeysMock = keysMock;
|
|
||||||
LogInfo("Create all keys mock. size = %d\n", keysMock.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HalTestTool::SetAllLedsResult(std::shared_ptr<IHalCpp> &vMock,
|
|
||||||
std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
|
||||||
{
|
|
||||||
std::shared_ptr<HalCppMock> mock = std::dynamic_pointer_cast<HalCppMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
* Note: The SetArgReference function cannot be used here, as it will prevent the smart pointer from being released
|
|
||||||
* within the TEST range, resulting in an error only being reported after all test cases have finished running.
|
|
||||||
* Can't use:
|
|
||||||
* EXPECT_CALL(*mock.get(), GetAllLedsTrace(_))
|
|
||||||
* .WillRepeatedly(DoAll(SetArgReferee<0>(allLeds), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
*/
|
|
||||||
auto getAllLeds = [=, &allLeds](std::map<std::string, std::shared_ptr<VLedHal>> &setAllLeds) {
|
|
||||||
setAllLeds = allLeds;
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), GetAllLedsTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0>(Invoke(getAllLeds)), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
InitAllLedsMock(allLeds);
|
|
||||||
}
|
|
||||||
std::shared_ptr<VLedHal> &HalTestTool::SearchLed(const std::string &ledName)
|
|
||||||
{
|
|
||||||
static std::shared_ptr<VLedHal> noLed = std::make_shared<VLedHal>();
|
|
||||||
std::shared_ptr<LedControlMock> mock;
|
|
||||||
std::map<std::string, std::shared_ptr<VLedHal>>::iterator iter;
|
|
||||||
iter = mAllLeds.find(ledName);
|
|
||||||
if (iter != mAllLeds.end()) {
|
|
||||||
// mock = std::dynamic_pointer_cast<LedControlMock>(mAllLeds[ledName]);
|
|
||||||
std::shared_ptr<VLedHal> &existLed = mAllLeds[ledName];
|
|
||||||
return existLed;
|
|
||||||
}
|
|
||||||
LogWarning("Can't found the led control.\n");
|
|
||||||
return noLed;
|
|
||||||
}
|
|
||||||
void HalTestTool::InitAllLedsMock(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
|
|
||||||
{
|
|
||||||
std::map<std::string, std::shared_ptr<VLedHal>>::iterator iter;
|
|
||||||
for (iter = allLeds.begin(); iter != allLeds.end(); ++iter) {
|
|
||||||
std::shared_ptr<VLedHal> ledHal = iter->second;
|
|
||||||
InitLedsMock(ledHal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HalTestTool::InitLedsMock(std::shared_ptr<VLedHal> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<LedControlMock> mock = std::dynamic_pointer_cast<LedControlMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
constexpr int LED_SHOULD_NOT_BE_CONTROLED_WHEN_NOBODY_CONTROL_IT = 0;
|
|
||||||
EXPECT_CALL(*mock.get(), SetLedStateTrace(_)).Times(LED_SHOULD_NOT_BE_CONTROLED_WHEN_NOBODY_CONTROL_IT);
|
|
||||||
}
|
|
||||||
void HalTestTool::SetAllCamerasResult(std::shared_ptr<IHalCpp> &vMock,
|
|
||||||
std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras)
|
|
||||||
{
|
|
||||||
std::shared_ptr<HalCppMock> mock = std::dynamic_pointer_cast<HalCppMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
* Note: The SetArgReference function cannot be used here, as it will prevent the smart pointer from being released
|
|
||||||
* within the TEST range, resulting in an error only being reported after all test cases have finished running.
|
|
||||||
* Can't use:
|
|
||||||
* EXPECT_CALL(*mock.get(), GetCameraHalTrace(_))
|
|
||||||
* .WillRepeatedly(DoAll(SetArgReferee<0>(allCameras), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
*/
|
|
||||||
auto getAllCameras = [=, &allCameras](std::map<CameraType, std::shared_ptr<VCameraHal>> &setAllCameras) {
|
|
||||||
setAllCameras = allCameras;
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), GetCameraHalTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0>(Invoke(getAllCameras)), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
InitAllCamerasMock(allCameras);
|
|
||||||
}
|
|
||||||
std::shared_ptr<VCameraHal> HalTestTool::SearchCamera(const CameraType &cameraType)
|
|
||||||
{
|
|
||||||
std::shared_ptr<CameraHalMock> mock;
|
|
||||||
std::map<CameraType, std::shared_ptr<VCameraHal>>::iterator iter;
|
|
||||||
iter = mAllCameras.find(cameraType);
|
|
||||||
if (iter != mAllCameras.end()) {
|
|
||||||
mock = std::dynamic_pointer_cast<CameraHalMock>(mAllCameras[cameraType]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("Can't found the camera control.\n");
|
|
||||||
}
|
|
||||||
return mock;
|
|
||||||
}
|
|
||||||
void HalTestTool::InitAllCamerasMock(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras)
|
|
||||||
{
|
|
||||||
std::map<CameraType, std::shared_ptr<VCameraHal>>::iterator iter;
|
|
||||||
for (iter = allCameras.begin(); iter != allCameras.end(); ++iter) {
|
|
||||||
std::shared_ptr<VCameraHal> cameraHal = iter->second;
|
|
||||||
InitCamerasMock(cameraHal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HalTestTool::InitCamerasMock(std::shared_ptr<VCameraHal> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<CameraHalMock> mock = std::dynamic_pointer_cast<CameraHalMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
constexpr int USER_SHOULD_SET_CAMERA_MONITER = 1;
|
|
||||||
// constexpr int SINGLE_TASK_DEFAULT_TIMES = 0;
|
|
||||||
EXPECT_CALL(*mock.get(), SetCameraMonitorTrace(_)).Times(USER_SHOULD_SET_CAMERA_MONITER);
|
|
||||||
EXPECT_CALL(*mock.get(), StartSingleTaskTrace(_))
|
|
||||||
.Times(AnyNumber())
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
}
|
|
||||||
void HalTestTool::MockSdCardRemove(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<SdCardHalMock> sdCardHal = std::dynamic_pointer_cast<SdCardHalMock>(mSdCardHal);
|
|
||||||
if (nullptr == sdCardHal) {
|
|
||||||
LogError("SdCardHalMock is null.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sdCardHal->MockSdCardRemove(mock);
|
|
||||||
}
|
|
||||||
void HalTestTool::MockSdCardInsert(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<SdCardHalMock> sdCardHal = std::dynamic_pointer_cast<SdCardHalMock>(mSdCardHal);
|
|
||||||
if (nullptr == sdCardHal) {
|
|
||||||
LogError("SdCardHalMock is null.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sdCardHal->MockSdCardInsert(mock);
|
|
||||||
}
|
|
||||||
std::shared_ptr<VKeyHal> HalTestTool::MakeKeyHalTest(const std::string &keyName)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VKeyHal> key = std::make_shared<KeyControlMock>(keyName);
|
|
||||||
std::dynamic_pointer_cast<KeyControlMock>(key)->InitKeyControlMock();
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
std::shared_ptr<VLedHal> HalTestTool::MakeLedHalTest(const std::string &ledName)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VLedHal> led = std::make_shared<LedControlMock>(ledName);
|
|
||||||
return led;
|
|
||||||
}
|
|
||||||
std::shared_ptr<VCameraHal> HalTestTool::MakeCameraHalTest(const CameraType &type)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VCameraHal> camera = std::make_shared<CameraHalMock>(type);
|
|
||||||
return camera;
|
|
||||||
}
|
|
|
@ -1,122 +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 "KeyControlMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
unsigned int KeyControlTest::GetStatusCheckPeriodMs(void)
|
|
||||||
{
|
|
||||||
return PERIPHERAL_CHECK_PERIOD_MS;
|
|
||||||
}
|
|
||||||
KeyControlTest::KeyControlTest(const std::string &keyName) : mKeyName(keyName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void KeyControlTest::SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor)
|
|
||||||
{
|
|
||||||
mMonitor = monitor;
|
|
||||||
}
|
|
||||||
void KeyControlMock::CheckKeyStatus(void)
|
|
||||||
{
|
|
||||||
KeyHalEvent pinValue = mKeyStatus;
|
|
||||||
// LogInfo("KeyContrl::CheckKeyValue pin = %d, pinValue = %d\n", mGpioPin, pinValue);
|
|
||||||
if (pinValue == KeyHalEvent::NOT_PRESSING && KeyHalEvent::NOT_PRESSING != mLastKeyStatus) {
|
|
||||||
KeyControl::KeyHalEventTrigger(KeyHalEvent::NOT_PRESSING);
|
|
||||||
}
|
|
||||||
else if (pinValue != KeyHalEvent::NOT_PRESSING && KeyHalEvent::NOT_PRESSING == mLastKeyStatus) {
|
|
||||||
KeyControl::KeyHalEventTrigger(KeyHalEvent::PRESSING);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
KeyControl::TimerKeyEventTrigger(KeyHalEvent::PRESSING);
|
|
||||||
}
|
|
||||||
mLastKeyStatus = pinValue;
|
|
||||||
}
|
|
||||||
void KeyControlTest::KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs)
|
|
||||||
{
|
|
||||||
// LogInfo("KeyEventTrigger keyName = %s, event = %s, time = %u\n", keyName.c_str(), PrintKeyEvent(event), timeMs);
|
|
||||||
KeyEventTriggerTrace(keyName, event, timeMs);
|
|
||||||
auto monitor = mMonitor.lock();
|
|
||||||
if (mMonitor.expired()) {
|
|
||||||
LogError("monitor is nullptr.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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), mKeyStatus(KeyHalEvent::NOT_PRESSING), mLastKeyStatus(KeyHalEvent::NOT_PRESSING)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void KeyControlMock::InitKeyControlMock(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<KeyControlMock> mock = std::dynamic_pointer_cast<KeyControlMock>(KeyControl::shared_from_this());
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), _, _))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
void KeyControlMock::SetKeyEvent(const KeyHalEvent &event)
|
|
||||||
{
|
|
||||||
KeyHalEventTrigger(event);
|
|
||||||
}
|
|
||||||
bool KeyControlMock::MockKeyClick(const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
if (mMutex.try_lock()) {
|
|
||||||
auto keyClickThread = [=](std::shared_ptr<KeyControlMock> key) {
|
|
||||||
KeyEventHappendOnce(key, pressingTimeMs);
|
|
||||||
// key->KeyHalEventTrigger(KeyHalEvent::PRESSING);
|
|
||||||
mKeyStatus = KeyHalEvent::PRESSING;
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(pressingTimeMs));
|
|
||||||
// key->KeyHalEventTrigger(KeyHalEvent::NOT_PRESSING);
|
|
||||||
mKeyStatus = KeyHalEvent::NOT_PRESSING;
|
|
||||||
mMutex.unlock();
|
|
||||||
};
|
|
||||||
std::shared_ptr<KeyControl> tmp = KeyControl::shared_from_this();
|
|
||||||
std::shared_ptr<KeyControlMock> key = std::dynamic_pointer_cast<KeyControlMock>(tmp);
|
|
||||||
std::thread clickThread = std::thread(keyClickThread, key);
|
|
||||||
clickThread.detach();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
LogWarning("MockKeyClick failed, becase key was lock.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void KeyControlMock::KeyEventHappendOnce(std::shared_ptr<KeyControlMock> &mock, const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(_, _, _))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
constexpr int CLICK_EVENT_HAPPENED_ONLY_ONCE = 1;
|
|
||||||
constexpr int HOLD_UP_EVENT_HAPPENED_ONLY_ONCE = 1;
|
|
||||||
if (KEY_ACTION_SHORT_CLICK <= pressingTimeMs && pressingTimeMs < KEY_ACTION_HOLD_DWON) {
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), KeyEvent::SHORT_CLICK, _))
|
|
||||||
.Times(CLICK_EVENT_HAPPENED_ONLY_ONCE)
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (KEY_ACTION_HOLD_DWON <= pressingTimeMs) {
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), KeyEvent::HOLD_DOWN, _))
|
|
||||||
.Times(AtLeast(1))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), KeyEvent::HOLD_UP, _))
|
|
||||||
.Times(HOLD_UP_EVENT_HAPPENED_ONLY_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
constexpr int KEY_SHOULD_NOT_TRIGGER_WHEN_NOBODY_SET_KEY_RESULT = 0;
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventTriggerTrace(mock->GetKeyName(), _, _))
|
|
||||||
.Times(KEY_SHOULD_NOT_TRIGGER_WHEN_NOBODY_SET_KEY_RESULT);
|
|
||||||
}
|
|
|
@ -1,59 +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 KEY_CONTROL_MOCK_H
|
|
||||||
#define KEY_CONTROL_MOCK_H
|
|
||||||
#include "HalTestTool.h"
|
|
||||||
#include "IHalCpp.h"
|
|
||||||
#include "KeyControl.h"
|
|
||||||
#include <thread>
|
|
||||||
class KeyControlTest : public KeyControl, public VKeyHal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
KeyControlTest(const std::string &keyName);
|
|
||||||
virtual ~KeyControlTest() = default;
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual StatusCode KeyEventTriggerTrace(const std::string &keyName, const KeyEvent &event,
|
|
||||||
const unsigned int &timeMs);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::string mKeyName;
|
|
||||||
std::weak_ptr<VKeyHalMonitor> mMonitor;
|
|
||||||
};
|
|
||||||
class KeyControlMock : public KeyControlTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
KeyControlMock(const std::string &keyName);
|
|
||||||
virtual ~KeyControlMock() = default;
|
|
||||||
void CheckKeyStatus(void) override;
|
|
||||||
void InitKeyControlMock(void);
|
|
||||||
void SetKeyEvent(const KeyHalEvent &event);
|
|
||||||
bool MockKeyClick(const unsigned int &pressingTimeMs = 200);
|
|
||||||
MOCK_METHOD3(KeyEventTriggerTrace, StatusCode(const std::string &, const KeyEvent &, const unsigned int &));
|
|
||||||
|
|
||||||
private:
|
|
||||||
void KeyEventHappendOnce(std::shared_ptr<KeyControlMock> &mock, const unsigned int &pressingTimeMs);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::mutex mMutex;
|
|
||||||
KeyHalEvent mKeyStatus;
|
|
||||||
KeyHalEvent mLastKeyStatus;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,69 +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 "LedControlMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
LedControlTest::LedControlTest(const std::string &ledName) : mLedName(ledName)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
LedControlMock::LedControlMock(const std::string &ledName) : LedControlTest(ledName)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
StatusCode LedControlTest::SetLedState(const LedState &state)
|
|
||||||
{
|
|
||||||
LogInfo("SetLedState mLedName = %s, state = %s\n", mLedName.c_str(), PrintLedState(state));
|
|
||||||
StatusCode code = SetLedStateTrace(state);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return SetLedState(state);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode LedControlTest::SetLedStateTrace(const LedState &state)
|
|
||||||
{
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
void LedControlMock::SetLedStateMock(std::shared_ptr<VLedHal> &vMock, const LedState &state,
|
|
||||||
const unsigned int &aliveTimeMs, const unsigned int &blinkTimeMs)
|
|
||||||
{
|
|
||||||
LogInfo("LedControlMock::SetLedState\n");
|
|
||||||
std::shared_ptr<LedControlMock> mock = std::dynamic_pointer_cast<LedControlMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("Can't set led state, led not found.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
constexpr int SOMEBODY_CONTROL_LED = 1;
|
|
||||||
EXPECT_CALL(*mock.get(), SetLedStateTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
auto defaultExpectations = [=, &vMock]() {
|
|
||||||
// std::shared_ptr<LedControlMock> mock = std::dynamic_pointer_cast<LedControlMock>(vMock);
|
|
||||||
// if (!mock) {
|
|
||||||
// LogError("Can't set led state, led not found.\n");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// EXPECT_CALL(*mock.get(), SetLedStateTrace(state))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
};
|
|
||||||
if (blinkTimeMs == LED_NOT_BLINK) {
|
|
||||||
EXPECT_CALL(*mock.get(), SetLedStateTrace(state))
|
|
||||||
.Times(SOMEBODY_CONTROL_LED)
|
|
||||||
.WillRepeatedly(DoAll(Invoke(defaultExpectations), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
EXPECT_CALL(*mock.get(), SetLedStateTrace(state))
|
|
||||||
.Times(AtLeast(SOMEBODY_CONTROL_LED))
|
|
||||||
.WillRepeatedly(DoAll(Invoke(defaultExpectations), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +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_CONTROL_MOCK_H
|
|
||||||
#define LED_CONTROL_MOCK_H
|
|
||||||
#include "HalTestTool.h"
|
|
||||||
#include "IHalCpp.h"
|
|
||||||
#include "LedControl.h"
|
|
||||||
class LedControlTest : public LedControl, public VLedHal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LedControlTest(const std::string &ledName);
|
|
||||||
virtual ~LedControlTest() = default;
|
|
||||||
StatusCode SetLedState(const LedState &state) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual StatusCode SetLedStateTrace(const LedState &state);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::string mLedName;
|
|
||||||
};
|
|
||||||
class LedControlMock : public LedControlTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LedControlMock(const std::string &ledName);
|
|
||||||
virtual ~LedControlMock() = default;
|
|
||||||
MOCK_METHOD1(SetLedStateTrace, StatusCode(const LedState &));
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void SetLedStateMock(std::shared_ptr<VLedHal> &vMock, const LedState &state, const unsigned int &aliveTimeMs,
|
|
||||||
const unsigned int &blinkTimeMs);
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,44 +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 "SdCardHalMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
extern const char *SD_CARD_DEVICE;
|
|
||||||
constexpr int FSTAT_SUCCESS = 0;
|
|
||||||
constexpr int FILE_EXIST = 0;
|
|
||||||
constexpr int FILE_NOT_EXIST = -1;
|
|
||||||
SdCardHalMock::SdCardHalMock()
|
|
||||||
{
|
|
||||||
mDevFd = -1;
|
|
||||||
}
|
|
||||||
void SdCardHalMock::SetLinuxTest(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
mLinuxTest = mock;
|
|
||||||
mDevFd = mLinuxTest->GetHandleForMock();
|
|
||||||
EXPECT_CALL(*mock.get(), fx_access(SD_CARD_DEVICE, F_OK)).WillRepeatedly(DoAll(Return(FILE_EXIST)));
|
|
||||||
EXPECT_CALL(*mock.get(), fx_open(SD_CARD_DEVICE, _)).WillRepeatedly(DoAll((Return(mDevFd))));
|
|
||||||
auto fstatFunc = [=, &mock](int fd, struct stat *statbuf) {
|
|
||||||
statbuf->st_mode = S_IFBLK | 0600;
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), fx_fstat(mDevFd, _))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0, 1>(Invoke(fstatFunc)), Return(FSTAT_SUCCESS)));
|
|
||||||
}
|
|
||||||
void SdCardHalMock::MockSdCardRemove(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
EXPECT_CALL(*mock.get(), fx_access(SD_CARD_DEVICE, F_OK)).WillRepeatedly(DoAll(Return(FILE_NOT_EXIST)));
|
|
||||||
}
|
|
||||||
void SdCardHalMock::MockSdCardInsert(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
EXPECT_CALL(*mock.get(), fx_access(SD_CARD_DEVICE, F_OK)).WillRepeatedly(DoAll(Return(FILE_EXIST)));
|
|
||||||
}
|
|
|
@ -1,33 +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 SD_CARD_HAL_MOCK_H
|
|
||||||
#define SD_CARD_HAL_MOCK_H
|
|
||||||
#include "IHalCpp.h"
|
|
||||||
#include "LinuxApiMock.h"
|
|
||||||
#include "SdCardHal.h"
|
|
||||||
class SdCardHalMock : public SdCardHal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SdCardHalMock();
|
|
||||||
virtual ~SdCardHalMock() = default;
|
|
||||||
void SetLinuxTest(std::shared_ptr<LinuxTest> &mock);
|
|
||||||
void MockSdCardRemove(std::shared_ptr<LinuxTest> &mock);
|
|
||||||
void MockSdCardInsert(std::shared_ptr<LinuxTest> &mock);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<LinuxTest> mLinuxTest;
|
|
||||||
int mDevFd;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,16 +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 "HalCppMock.h"
|
|
||||||
#include "ILog.h"
|
|
|
@ -1,32 +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 WIFI_HAL_MOCK_H
|
|
||||||
#define WIFI_HAL_MOCK_H
|
|
||||||
#include "HalCpp.h"
|
|
||||||
#include "HalTestTool.h"
|
|
||||||
class WifiHalTest : public VWifiHal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WifiHalTest() = default;
|
|
||||||
virtual ~WifiHalTest() = default;
|
|
||||||
};
|
|
||||||
class WifiHalMock : public WifiHalTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WifiHalMock() = default;
|
|
||||||
virtual ~WifiHalMock() = default;
|
|
||||||
MOCK_METHOD0(OpenApMode, StatusCode(void));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,57 +0,0 @@
|
||||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
|
||||||
include(${MIDDLEWARE_SOURCE_PATH}/AppManager/build/app_manager.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}/Servers/include
|
|
||||||
${UTILS_SOURCE_PATH}/TcpModule/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/AppManager/src
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/AppManager/src/Protocol/SixFrame
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${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
|
|
||||||
# )
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET AppManagerTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} AppManager Servers Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
AppManagerTestTool_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}/middleware/AppManager/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
AppManagerTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/AppManager/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make AppManagerTestTool_code_check
|
|
||||||
COMMAND make AppManagerTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,57 +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 "AppManagerMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
void OverrideAppManagerMakePtrObject(std::shared_ptr<AppManagerMock> &appManagerMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppManagerMakePtr> impl = std::make_shared<AppManagerMakePtrTest>();
|
|
||||||
std::shared_ptr<AppManagerMakePtrTest> test = std::dynamic_pointer_cast<AppManagerMakePtrTest>(impl);
|
|
||||||
if (test) {
|
|
||||||
test->mAppManagerMock = appManagerMock;
|
|
||||||
}
|
|
||||||
AppManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
void CancelOverrideAppManagerMakePtrObject(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppManagerMakePtr> tmp = AppManagerMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<AppManagerMakePtrTest> test = std::dynamic_pointer_cast<AppManagerMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mAppManagerMock.reset();
|
|
||||||
}
|
|
||||||
tmp.reset();
|
|
||||||
test.reset();
|
|
||||||
std::shared_ptr<AppManagerMakePtr> impl = std::make_shared<AppManagerMakePtrTest>();
|
|
||||||
AppManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
AppManagerMakePtrTest::AppManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
AppManagerMakePtrTest::~AppManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
mAppManagerMock.reset();
|
|
||||||
}
|
|
||||||
const StatusCode AppManagerMakePtrTest::CreateAppManager(std::shared_ptr<IAppManager> &impl)
|
|
||||||
{
|
|
||||||
if (mAppManagerMock) {
|
|
||||||
LogInfo("CreateAppManager mAppManagerMock\n");
|
|
||||||
impl = mAppManagerMock;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("CreateMcuManager failed:mAppManagerMock is nullptr.\n");
|
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
|
@ -1,32 +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 APP_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#define APP_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#include "AppManagerMock.h"
|
|
||||||
#include "AppManagerTestTool.h"
|
|
||||||
#include "SixFrameMakePtr.h"
|
|
||||||
void OverrideAppManagerMakePtrObject(std::shared_ptr<AppManagerMock> &appManagerMock);
|
|
||||||
void CancelOverrideAppManagerMakePtrObject(void);
|
|
||||||
class AppManagerMakePtrTest : public SixFrameMakePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerMakePtrTest();
|
|
||||||
virtual ~AppManagerMakePtrTest();
|
|
||||||
const StatusCode CreateAppManager(std::shared_ptr<IAppManager> &impl) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<AppManagerMock> mAppManagerMock;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,30 +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 "AppManagerMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
const StatusCode AppManagerTest::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogInfo("AppManagerTest::SetAppMonitor\n");
|
|
||||||
StatusCode code = SetAppMonitorTrace(monitor);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return AppManager::SetAppMonitor(monitor);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
const StatusCode AppManagerTest::SetAppMonitorTrace(std::shared_ptr<VAppMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogInfo("AppManagerTest::SetAppMonitorTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
|
@ -1,36 +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 APP_MANAGER_MOCK_H
|
|
||||||
#define APP_MANAGER_MOCK_H
|
|
||||||
#include "AppManager.h"
|
|
||||||
#include "AppManagerTestTool.h"
|
|
||||||
class AppManagerTest : public AppManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerTest() = default;
|
|
||||||
virtual ~AppManagerTest() = default;
|
|
||||||
const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual const StatusCode SetAppMonitorTrace(std::shared_ptr<VAppMonitor> &monitor);
|
|
||||||
};
|
|
||||||
class AppManagerMock : public AppManagerTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppManagerMock() = default;
|
|
||||||
virtual ~AppManagerMock() = default;
|
|
||||||
MOCK_METHOD1(SetAppMonitorTrace, const StatusCode(std::shared_ptr<VAppMonitor> &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,372 +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 "AppManagerTestTool.h"
|
|
||||||
#include "AppManagerMakePtrTest.h"
|
|
||||||
#include "AppManagerMock.h"
|
|
||||||
#include "AppMonitorMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "ServersMock.h"
|
|
||||||
#include "TcpModule.h"
|
|
||||||
constexpr int ONLY_BE_CALLED_ONCE = 1;
|
|
||||||
AppManagerTestTool::AppManagerTestTool()
|
|
||||||
{
|
|
||||||
mAppClientTool = nullptr;
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::Init(void)
|
|
||||||
{
|
|
||||||
ServersMock::GetInstance()->Init();
|
|
||||||
mAppManagerMock = std::make_shared<AppManagerMock>();
|
|
||||||
AppManagerMockInit(mAppManagerMock);
|
|
||||||
std::shared_ptr<AppManagerMock> mock = std::dynamic_pointer_cast<AppManagerMock>(mAppManagerMock);
|
|
||||||
OverrideAppManagerMakePtrObject(mock);
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
ServersMock::GetInstance()->UnInit();
|
|
||||||
mAppManagerMock.reset();
|
|
||||||
mAppMonitorMock.reset();
|
|
||||||
CancelOverrideAppManagerMakePtrObject();
|
|
||||||
if (nullptr != mAppClientTool) {
|
|
||||||
FreeTcpClient(mAppClientTool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetProductInfo(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetProductInfoTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetProductInfo();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetDeviceAttr(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetDeviceAttrTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetDeviceAttr();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetMediaInfo(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetMediaInfoTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetMediaInfo();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetSdCardInfo(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetSdCardInfoTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetSdCardInfo();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetBatteryInfo(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetBatteryInfoTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetBatteryInfo();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetDateTime(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), SetDateTimeTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockSetDateTime();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetTimeZone(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), SetTimeZoneTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockSetTimeZone();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockUploadFiles(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), UploadFileTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockUploadFiles();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetParamValue(const std::string ¶mName)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetParamValueTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetParamValue(paramName);
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetParamItems(const std::string ¶mName)
|
|
||||||
{
|
|
||||||
// std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
// if (mock) {
|
|
||||||
// EXPECT_CALL(*mock.get(), GetParamValueTrace(_)) // TODO:
|
|
||||||
// .Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
// .WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// }
|
|
||||||
ServersMock::GetInstance()->MockGetParamItems(paramName);
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetCapability(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetCapabilityTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetCapability();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetLockVideoStatus(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetLockVideoStatusTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetLockVideoStatus();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetStorageInfo(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetStorageInfoTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetStorageInfo();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockGetStorageFileList(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetStorageFileListTrace(_, _))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockGetStorageFileList();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetParamValue(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), SetParamValueTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockSetParamValue();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockEnterRecorder(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), EnterRecorderTrace())
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockEnterRecorder();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockAppPlayback(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), AppPlaybackTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
ServersMock::GetInstance()->MockAppPlayback();
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockMonitorSetFileList(std::vector<AppGetFileList> &files)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetStorageFileListTrace(_, _))
|
|
||||||
.WillRepeatedly(DoAll(SetArgReferee<1>(files), Return(CreateStatusCode(STATUS_CODE_OK))));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogError("MockMonitorSetFileList failed, mAppMonitorMock isn't mock object.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockAppClientConnect(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(mAppMonitorMock);
|
|
||||||
if (mock) {
|
|
||||||
auto appClientConnected = [=](std::shared_ptr<VAppClient> &cliient) {
|
|
||||||
LogInfo("appClientConnected.\n");
|
|
||||||
mAppClient = cliient;
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), AppClientConnectedTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(
|
|
||||||
DoAll(WithArgs<0>(Invoke(appClientConnected)), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
auto readFunc = [](const void *data, const ssize_t len, const void *context) -> void {
|
|
||||||
LogInfo("read data: %s", (char *)data);
|
|
||||||
};
|
|
||||||
auto closedFunc = [](const void *object) -> void {
|
|
||||||
LogInfo("tcp client closed.\n");
|
|
||||||
};
|
|
||||||
TcpClientParam param = {
|
|
||||||
.mIp = APP_MANAGER_DEVICE_IP,
|
|
||||||
.mPort = APP_MANAGER_TCP_SERVER_PORT,
|
|
||||||
.mReadFunc = readFunc,
|
|
||||||
.mClosedFunc = closedFunc,
|
|
||||||
};
|
|
||||||
mAppClientTool = CreateTcpClient(param);
|
|
||||||
if (nullptr == mAppClientTool) {
|
|
||||||
LogError("CreateTcpClient failed.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetRecordingStatus(const RecordingStatus &status)
|
|
||||||
{
|
|
||||||
if (mAppClient) {
|
|
||||||
mAppClient->SetRecordingStatus(status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogWarning("mAppClient is nullptr.\n");
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetMicrophoneStatus(const MicrophoneStatus &status)
|
|
||||||
{
|
|
||||||
if (mAppClient) {
|
|
||||||
mAppClient->SetMicrophoneStatus(status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogWarning("mAppClient is nullptr.\n");
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetBatteryStatus(const BatteryStatus &status, const int &batteryCapacity)
|
|
||||||
{
|
|
||||||
if (mAppClient) {
|
|
||||||
mAppClient->SetBatteryStatus(status, batteryCapacity);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogWarning("mAppClient is nullptr.\n");
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockSetSdCardStatus(const SdCardStatus &status)
|
|
||||||
{
|
|
||||||
if (mAppClient) {
|
|
||||||
mAppClient->SetSdCardStatus(status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogWarning("mAppClient is nullptr.\n");
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockDeletedFileMessage(const std::string &file, const StorageFileType &type)
|
|
||||||
{
|
|
||||||
if (mAppClient) {
|
|
||||||
mAppClient->DeletedFileMessage(file, type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogWarning("mAppClient is nullptr.\n");
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::MockCreatedFileMessage(const std::string &file, const StorageFileType &type)
|
|
||||||
{
|
|
||||||
if (mAppClient) {
|
|
||||||
mAppClient->CreatedFileMessage(file, type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogWarning("mAppClient is nullptr.\n");
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::AppManagerMockInit(std::shared_ptr<IAppManager> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppManagerMock> mock = std::dynamic_pointer_cast<AppManagerMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto getAppMonitor = [=](std::shared_ptr<VAppMonitor> &monitor) {
|
|
||||||
LogInfo("mAppMonitorMock get.\n");
|
|
||||||
mAppMonitorMock = monitor;
|
|
||||||
AppManagerTestTool::AppMonitorInit(mAppMonitorMock);
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), SetAppMonitorTrace(_))
|
|
||||||
.Times(testing::Between(0, 1))
|
|
||||||
.WillOnce(DoAll(WithArgs<0>(Invoke(getAppMonitor)), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
std::shared_ptr<VAppMonitor> AppManagerTestTool::MakeMonitorMock(void)
|
|
||||||
{
|
|
||||||
class Monitor : public AppMonitorMock, public AppMonitorTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Monitor() = default;
|
|
||||||
virtual ~Monitor() = default;
|
|
||||||
};
|
|
||||||
std::shared_ptr<VAppMonitor> monitor = std::make_shared<Monitor>();
|
|
||||||
return monitor;
|
|
||||||
}
|
|
||||||
void AppManagerTestTool::AppMonitorInit(std::shared_ptr<VAppMonitor> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AppMonitorMock> mock = std::dynamic_pointer_cast<AppMonitorMock>(vMock);
|
|
||||||
if (mock) {
|
|
||||||
EXPECT_CALL(*mock.get(), GetProductInfoTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetDeviceAttrTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetMediaInfoTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetSdCardInfoTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetParamValueTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetCapabilityTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetLockVideoStatusTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetStorageInfoTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetStorageFileListTrace(_, _))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetBatteryInfoTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), SetDateTimeTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), SetTimeZoneTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), SetParamValueTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), EnterRecorderTrace())
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), AppPlaybackTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), UploadFileTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), GetThumbnailTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
EXPECT_CALL(*mock.get(), AppClientConnectedTrace(_))
|
|
||||||
.WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,274 +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 "AppMonitorMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
StatusCode AppMonitorTest::GetProductInfo(AppGetProductInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetProductInfo\n");
|
|
||||||
StatusCode code = GetProductInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetProductInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetProductInfoTrace(AppGetProductInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetProductInfoTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetDeviceAttr(AppGetDeviceAttr ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetDeviceAttr\n");
|
|
||||||
StatusCode code = GetDeviceAttrTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetDeviceAttr(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetDeviceAttrTrace(AppGetDeviceAttr ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetDeviceAttrTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetMediaInfo(AppGetMediaInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetMediaInfo\n");
|
|
||||||
StatusCode code = GetMediaInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetMediaInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetMediaInfoTrace(AppGetMediaInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetMediaInfoTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetSdCardInfo\n");
|
|
||||||
StatusCode code = GetSdCardInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetSdCardInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetSdCardInfoTrace(AppGetSdCardInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetSdCardInfoTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetBatteryInfo(AppGetBatteryInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetBatteryInfo\n");
|
|
||||||
StatusCode code = GetBatteryInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetBatteryInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetBatteryInfoTrace(AppGetBatteryInfo ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetBatteryInfoTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetParamValue(AppParamValue ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetParamValue\n");
|
|
||||||
StatusCode code = GetParamValueTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetParamValue(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetParamValueTrace(AppParamValue ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetParamValueTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetCapability(AppGetCapability ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetCapability\n");
|
|
||||||
StatusCode code = GetCapabilityTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetCapability(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetCapabilityTrace(AppGetCapability ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetCapabilityTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetLockVideoStatus(LockVideoStatus ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetLockVideoStatus\n");
|
|
||||||
StatusCode code = GetLockVideoStatusTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetLockVideoStatus(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetLockVideoStatusTrace(LockVideoStatus ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetLockVideoStatusTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetStorageInfo(std::vector<AppGetStorageInfo> ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetStorageInfo\n");
|
|
||||||
StatusCode code = GetStorageInfoTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetStorageInfo(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetStorageInfoTrace(std::vector<AppGetStorageInfo> ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetStorageInfoTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetStorageFileList\n");
|
|
||||||
StatusCode code = GetStorageFileListTrace(fileInfo, param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetStorageFileList(fileInfo, param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetStorageFileListTrace(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::GetStorageFileListTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::SetDateTime(const AppSetDateTime ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::SetDateTime\n");
|
|
||||||
LogInfo("mYear = %u\n", param.mYear);
|
|
||||||
LogInfo("mMonth = %02u\n", param.mMonth);
|
|
||||||
LogInfo("mDay = %02u\n", param.mDay);
|
|
||||||
LogInfo("mHour = %02u\n", param.mHour);
|
|
||||||
LogInfo("mMinute = %02u\n", param.mMinute);
|
|
||||||
LogInfo("mSecond = %02u\n", param.mSecond);
|
|
||||||
StatusCode code = SetDateTimeTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::SetDateTime(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::SetDateTimeTrace(const AppSetDateTime ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::SetDateTimeTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::SetTimeZone(const unsigned int &zone)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::SetTimeZone = %u\n", zone);
|
|
||||||
StatusCode code = SetTimeZoneTrace(zone);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::SetTimeZone(zone);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::SetTimeZoneTrace(const unsigned int &zone)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::SetTimeZoneTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::SetParamValue(const AppSetParamValue ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::SetParamValue\n");
|
|
||||||
StatusCode code = SetParamValueTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::SetParamValue(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::SetParamValueTrace(const AppSetParamValue ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::SetParamValueTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::EnterRecorder(void)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::EnterRecorder\n");
|
|
||||||
StatusCode code = EnterRecorderTrace();
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::EnterRecorder();
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::EnterRecorderTrace(void)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::EnterRecorderTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::AppPlayback(const PlayBackEvent &event)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::AppPlayback\n");
|
|
||||||
StatusCode code = AppPlaybackTrace(event);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::AppPlayback(event);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::AppPlaybackTrace(const PlayBackEvent &event)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::AppPlaybackTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::UploadFile(AppUploadFile ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::UploadFile\n");
|
|
||||||
StatusCode code = UploadFileTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::UploadFile(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::UploadFileTrace(AppUploadFile ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::UploadFileTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::GetThumbnail(AppGetThumbnail ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::GetThumbnail\n");
|
|
||||||
StatusCode code = GetThumbnailTrace(param);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::GetThumbnail(param);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::GetThumbnailTrace(AppGetThumbnail ¶m)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::UploadFileTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTest::AppClientConnected(std::shared_ptr<VAppClient> &client)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTest::AppClientConnected\n");
|
|
||||||
StatusCode code = AppClientConnectedTrace(client);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return VAppMonitor::AppClientConnected(client);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
StatusCode AppMonitorTrace::AppClientConnectedTrace(std::shared_ptr<VAppClient> &client)
|
|
||||||
{
|
|
||||||
LogInfo("AppMonitorTrace::AppClientConnected\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
|
@ -1,93 +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 APP_MONITOR_MOCK_H
|
|
||||||
#define APP_MONITOR_MOCK_H
|
|
||||||
#include "GtestUsing.h"
|
|
||||||
#include "IAppManager.h"
|
|
||||||
class AppMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppMonitorTrace() = default;
|
|
||||||
virtual ~AppMonitorTrace() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual StatusCode GetProductInfoTrace(AppGetProductInfo ¶m);
|
|
||||||
virtual StatusCode GetDeviceAttrTrace(AppGetDeviceAttr ¶m);
|
|
||||||
virtual StatusCode GetMediaInfoTrace(AppGetMediaInfo ¶m);
|
|
||||||
virtual StatusCode GetSdCardInfoTrace(AppGetSdCardInfo ¶m);
|
|
||||||
virtual StatusCode GetBatteryInfoTrace(AppGetBatteryInfo ¶m);
|
|
||||||
virtual StatusCode GetParamValueTrace(AppParamValue ¶m);
|
|
||||||
virtual StatusCode GetCapabilityTrace(AppGetCapability ¶m);
|
|
||||||
virtual StatusCode GetLockVideoStatusTrace(LockVideoStatus ¶m);
|
|
||||||
virtual StatusCode GetStorageInfoTrace(std::vector<AppGetStorageInfo> ¶m);
|
|
||||||
virtual StatusCode GetStorageFileListTrace(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m);
|
|
||||||
virtual StatusCode SetDateTimeTrace(const AppSetDateTime ¶m);
|
|
||||||
virtual StatusCode SetTimeZoneTrace(const unsigned int &zone);
|
|
||||||
virtual StatusCode SetParamValueTrace(const AppSetParamValue ¶m);
|
|
||||||
virtual StatusCode EnterRecorderTrace(void);
|
|
||||||
virtual StatusCode AppPlaybackTrace(const PlayBackEvent &event);
|
|
||||||
virtual StatusCode UploadFileTrace(AppUploadFile ¶m);
|
|
||||||
virtual StatusCode GetThumbnailTrace(AppGetThumbnail ¶m);
|
|
||||||
virtual StatusCode AppClientConnectedTrace(std::shared_ptr<VAppClient> &client);
|
|
||||||
};
|
|
||||||
class AppMonitorTest : public VAppMonitor, virtual public AppMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppMonitorTest() = default;
|
|
||||||
virtual ~AppMonitorTest() = default;
|
|
||||||
StatusCode GetProductInfo(AppGetProductInfo ¶m) override;
|
|
||||||
StatusCode GetDeviceAttr(AppGetDeviceAttr ¶m) override;
|
|
||||||
StatusCode GetMediaInfo(AppGetMediaInfo ¶m) override;
|
|
||||||
StatusCode GetSdCardInfo(AppGetSdCardInfo ¶m) override;
|
|
||||||
StatusCode GetBatteryInfo(AppGetBatteryInfo ¶m) override;
|
|
||||||
StatusCode GetParamValue(AppParamValue ¶m) override;
|
|
||||||
StatusCode GetCapability(AppGetCapability ¶m) override;
|
|
||||||
StatusCode GetLockVideoStatus(LockVideoStatus ¶m) override;
|
|
||||||
StatusCode GetStorageInfo(std::vector<AppGetStorageInfo> ¶m) override;
|
|
||||||
StatusCode GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m) override;
|
|
||||||
StatusCode SetDateTime(const AppSetDateTime ¶m) override;
|
|
||||||
StatusCode SetTimeZone(const unsigned int &zone) override;
|
|
||||||
StatusCode SetParamValue(const AppSetParamValue ¶m) override;
|
|
||||||
StatusCode EnterRecorder(void) override;
|
|
||||||
StatusCode AppPlayback(const PlayBackEvent &event) override;
|
|
||||||
StatusCode UploadFile(AppUploadFile ¶m) override;
|
|
||||||
StatusCode GetThumbnail(AppGetThumbnail ¶m) override;
|
|
||||||
StatusCode AppClientConnected(std::shared_ptr<VAppClient> &client) override;
|
|
||||||
};
|
|
||||||
class AppMonitorMock : virtual public AppMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppMonitorMock() = default;
|
|
||||||
virtual ~AppMonitorMock() = default;
|
|
||||||
MOCK_METHOD1(GetProductInfoTrace, StatusCode(AppGetProductInfo &));
|
|
||||||
MOCK_METHOD1(GetDeviceAttrTrace, StatusCode(AppGetDeviceAttr &));
|
|
||||||
MOCK_METHOD1(GetMediaInfoTrace, StatusCode(AppGetMediaInfo &));
|
|
||||||
MOCK_METHOD1(GetSdCardInfoTrace, StatusCode(AppGetSdCardInfo &));
|
|
||||||
MOCK_METHOD1(GetBatteryInfoTrace, StatusCode(AppGetBatteryInfo &));
|
|
||||||
MOCK_METHOD1(GetParamValueTrace, StatusCode(AppParamValue &));
|
|
||||||
MOCK_METHOD1(GetCapabilityTrace, StatusCode(AppGetCapability &));
|
|
||||||
MOCK_METHOD1(GetLockVideoStatusTrace, StatusCode(LockVideoStatus &));
|
|
||||||
MOCK_METHOD1(GetStorageInfoTrace, StatusCode(std::vector<AppGetStorageInfo> &));
|
|
||||||
MOCK_METHOD2(GetStorageFileListTrace, StatusCode(const AppGetFileInfo &, std::vector<AppGetFileList> &));
|
|
||||||
MOCK_METHOD1(SetDateTimeTrace, StatusCode(const AppSetDateTime &));
|
|
||||||
MOCK_METHOD1(SetTimeZoneTrace, StatusCode(const unsigned int &));
|
|
||||||
MOCK_METHOD1(SetParamValueTrace, StatusCode(const AppSetParamValue &));
|
|
||||||
MOCK_METHOD0(EnterRecorderTrace, StatusCode(void));
|
|
||||||
MOCK_METHOD1(AppPlaybackTrace, StatusCode(const PlayBackEvent &));
|
|
||||||
MOCK_METHOD1(UploadFileTrace, StatusCode(AppUploadFile &));
|
|
||||||
MOCK_METHOD1(GetThumbnailTrace, StatusCode(AppGetThumbnail &));
|
|
||||||
MOCK_METHOD1(AppClientConnectedTrace, StatusCode(std::shared_ptr<VAppClient> &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,200 +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 "ServersMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "servers.h"
|
|
||||||
#include <cstring>
|
|
||||||
extern const char *APP_GET_PRODUCT_INFO;
|
|
||||||
extern const char *APP_GET_DEVICE_ATTR;
|
|
||||||
extern const char *APP_GET_MEDIA_INFO;
|
|
||||||
extern const char *APP_GET_SD_CARD_INFO;
|
|
||||||
extern const char *APP_GET_BATTERY_INFO;
|
|
||||||
extern const char *APP_GET_PARAM_VALUE;
|
|
||||||
extern const char *APP_GET_PARAM_ITEMS;
|
|
||||||
extern const char *APP_GET_CAPABILITY;
|
|
||||||
extern const char *APP_GET_LOCK_VIDEO_STATUS;
|
|
||||||
extern const char *APP_GET_STORAGE_INFO;
|
|
||||||
extern const char *APP_GET_FILE_LIST;
|
|
||||||
extern const char *APP_SET_DATE_TIME;
|
|
||||||
extern const char *APP_SET_TIME_ZONE;
|
|
||||||
extern const char *APP_SET_PARAM_VALUE;
|
|
||||||
extern const char *APP_ENTER_RECORDER;
|
|
||||||
extern const char *APP_PLAYBACK;
|
|
||||||
extern const char *APP_UPLOAD_FILE;
|
|
||||||
std::shared_ptr<ServersMock> &ServersMock::GetInstance(std::shared_ptr<ServersMock> *impl)
|
|
||||||
{
|
|
||||||
static auto instance = std::make_shared<ServersMock>();
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
ServersMock::ServersMock()
|
|
||||||
{
|
|
||||||
mServerUrl = APP_MANAGER_DEVICE_IP ":" + std::to_string(APP_MANAGER_HTTP_SERVER_PORT);
|
|
||||||
}
|
|
||||||
void ServersMock::Init(void)
|
|
||||||
{
|
|
||||||
ServerParam init = {
|
|
||||||
.logFlag = LOG_FLAG_ENABLE,
|
|
||||||
.sslVerifyFlag = SSL_VERIFY_DISABLE,
|
|
||||||
};
|
|
||||||
ServersInit(init);
|
|
||||||
}
|
|
||||||
void ServersMock::UnInit(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetProductInfo(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_PRODUCT_INFO test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_PRODUCT_INFO;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetDeviceAttr(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_DEVICE_ATTR test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_DEVICE_ATTR;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetMediaInfo(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_MEDIA_INFO test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_MEDIA_INFO;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetSdCardInfo(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_SD_CARD_INFO test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_SD_CARD_INFO;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetBatteryInfo(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_BATTERY_INFO test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_BATTERY_INFO;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetParamValue(const std::string ¶mName)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_PARAM_VALUE test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_PARAM_VALUE + "?param=" + paramName;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetParamItems(const std::string ¶mName)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_PARAM_ITEMS test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_PARAM_ITEMS + "?param=" + paramName;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetCapability(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_CAPABILITY test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_CAPABILITY;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetLockVideoStatus(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_LOCK_VIDEO_STATUS test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_LOCK_VIDEO_STATUS;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetStorageInfo(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_STORAGE_INFO test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_STORAGE_INFO;
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockGetStorageFileList(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_GET_FILE_LIST test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_GET_FILE_LIST + "?folder=loop&start=0&end=99";
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockSetDateTime(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_SET_DATE_TIME test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_SET_DATE_TIME + "?date=20240101010101";
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockSetTimeZone(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_SET_TIME_ZONE test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_SET_TIME_ZONE + "?timezone=8";
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockSetParamValue(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_SET_PARAM_VALUE test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_SET_PARAM_VALUE + "?param=switchcam&value=1";
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockEnterRecorder(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_ENTER_RECORDER test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_ENTER_RECORDER + "?timezone=8"; // TODO:
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
void ServersMock::MockAppPlayback(void)
|
|
||||||
{
|
|
||||||
LogInfo("APP_PLAYBACK test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_PLAYBACK + "?param=enter";
|
|
||||||
MockHttpGet(mockRequest);
|
|
||||||
}
|
|
||||||
#ifndef PLATFORM_PATH
|
|
||||||
#error Add the code in your linux.toolchain.cmake : add_definitions(-DPLATFORM_PATH="${PLATFORM_PATH}")
|
|
||||||
#endif
|
|
||||||
void ServersMock::MockUploadFiles(void)
|
|
||||||
{
|
|
||||||
LogInfo("servers test start.\n");
|
|
||||||
std::string mockRequest = mServerUrl + APP_UPLOAD_FILE;
|
|
||||||
ServerHttp *http = NewServersHttp(mockRequest.c_str());
|
|
||||||
if (http) {
|
|
||||||
http->filePath = (char *)PLATFORM_PATH "/output_files/test/bin/AppManagerTest";
|
|
||||||
LogInfo("http post file:%s\n", http->filePath);
|
|
||||||
HttpPostFile(http);
|
|
||||||
if (http->reply) {
|
|
||||||
char *replyStr = (char *)malloc(http->replyLength + 1);
|
|
||||||
memset(replyStr, 0, http->replyLength + 1);
|
|
||||||
memcpy(replyStr, http->reply, http->replyLength);
|
|
||||||
LogInfo("HttpPost response :\n%s\n", replyStr);
|
|
||||||
free(replyStr);
|
|
||||||
}
|
|
||||||
DeleteServersHttp(http);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ServersMock::MockHttpGet(const std::string &mockRequest)
|
|
||||||
{
|
|
||||||
ServerHttp *http = NewServersHttp(mockRequest.c_str());
|
|
||||||
if (http) {
|
|
||||||
HttpGet(http);
|
|
||||||
if (http->reply) {
|
|
||||||
char *replyStr = (char *)malloc(http->replyLength + 1);
|
|
||||||
memset(replyStr, 0, http->replyLength + 1);
|
|
||||||
memcpy(replyStr, http->reply, http->replyLength);
|
|
||||||
LogInfo("HttpGet response :\n%s\n", replyStr);
|
|
||||||
free(replyStr);
|
|
||||||
}
|
|
||||||
DeleteServersHttp(http);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("http is null.\n");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +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 SERVERS_MOCK_H
|
|
||||||
#define SERVERS_MOCK_H
|
|
||||||
#include "servers.h"
|
|
||||||
#include <memory>
|
|
||||||
class ServersMock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ServersMock();
|
|
||||||
virtual ~ServersMock() = default;
|
|
||||||
static std::shared_ptr<ServersMock> &GetInstance(std::shared_ptr<ServersMock> *impl = nullptr);
|
|
||||||
virtual void Init(void);
|
|
||||||
virtual void UnInit(void);
|
|
||||||
virtual void MockGetProductInfo(void);
|
|
||||||
virtual void MockGetDeviceAttr(void);
|
|
||||||
virtual void MockGetMediaInfo(void);
|
|
||||||
virtual void MockGetSdCardInfo(void);
|
|
||||||
virtual void MockGetBatteryInfo(void);
|
|
||||||
virtual void MockGetParamValue(const std::string ¶mName);
|
|
||||||
virtual void MockGetParamItems(const std::string ¶mName);
|
|
||||||
virtual void MockGetCapability(void);
|
|
||||||
virtual void MockGetLockVideoStatus(void);
|
|
||||||
virtual void MockGetStorageInfo(void);
|
|
||||||
virtual void MockGetStorageFileList(void);
|
|
||||||
virtual void MockSetDateTime(void);
|
|
||||||
virtual void MockSetTimeZone(void);
|
|
||||||
virtual void MockSetParamValue(void);
|
|
||||||
virtual void MockEnterRecorder(void);
|
|
||||||
virtual void MockAppPlayback(void);
|
|
||||||
virtual void MockUploadFiles(void);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void MockHttpGet(const std::string &mockRequest);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string mServerUrl;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,53 +0,0 @@
|
||||||
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}/LedControl/include
|
|
||||||
# ${UTILS_SOURCE_PATH}/McuProtocol/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/DeviceManager/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
|
|
||||||
# )
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET DeviceManagerTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} LedControl Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
DeviceManagerTestTool_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}/middleware/DeviceManager/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
DeviceManagerTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/DeviceManager/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make DeviceManagerTestTool_code_check
|
|
||||||
COMMAND make DeviceManagerTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,57 +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 "DeviceManagerMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
void OverrideDeviceMakePtrObject(std::shared_ptr<DeviceManagerMock> &halMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<DeviceManagerMakePtr> impl = std::make_shared<DeviceManagerMakePtrTest>();
|
|
||||||
std::shared_ptr<DeviceManagerMakePtrTest> test = std::dynamic_pointer_cast<DeviceManagerMakePtrTest>(impl);
|
|
||||||
if (test) {
|
|
||||||
test->mDeviceManagerMock = halMock;
|
|
||||||
}
|
|
||||||
DeviceManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
void CancelOverrideDeviceMakePtrObject(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<DeviceManagerMakePtr> tmp = DeviceManagerMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<DeviceManagerMakePtrTest> test = std::dynamic_pointer_cast<DeviceManagerMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mDeviceManagerMock.reset();
|
|
||||||
}
|
|
||||||
test.reset();
|
|
||||||
tmp.reset();
|
|
||||||
std::shared_ptr<DeviceManagerMakePtr> impl = std::make_shared<DeviceManagerMakePtrTest>();
|
|
||||||
DeviceManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
DeviceManagerMakePtrTest::DeviceManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
DeviceManagerMakePtrTest::~DeviceManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
mDeviceManagerMock.reset();
|
|
||||||
}
|
|
||||||
const StatusCode DeviceManagerMakePtrTest::CreateDeviceManager(std::shared_ptr<IDeviceManager> &impl)
|
|
||||||
{
|
|
||||||
if (mDeviceManagerMock) {
|
|
||||||
LogInfo("CreateDeviceManager mDeviceManagerMock\n");
|
|
||||||
impl = mDeviceManagerMock;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("CreateMcuManager failed:mDeviceManagerMock is nullptr.\n");
|
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
|
@ -1,31 +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 DEVICE_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#define DEVICE_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#include "DeviceManagerMakePtr.h"
|
|
||||||
#include "DeviceManagerTestTool.h"
|
|
||||||
void OverrideDeviceMakePtrObject(std::shared_ptr<DeviceManagerMock> &halMock);
|
|
||||||
void CancelOverrideDeviceMakePtrObject(void);
|
|
||||||
class DeviceManagerMakePtrTest : public DeviceManagerMakePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DeviceManagerMakePtrTest();
|
|
||||||
virtual ~DeviceManagerMakePtrTest();
|
|
||||||
const StatusCode CreateDeviceManager(std::shared_ptr<IDeviceManager> &impl) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<DeviceManagerMock> mDeviceManagerMock;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,93 +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 "DeviceManagerTestTool.h"
|
|
||||||
#include "DeviceManagerMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "KeyControl.h"
|
|
||||||
#include "SingleControlMock.h"
|
|
||||||
const StatusCode DeviceManagerTool::SetAllKeysMonitor(std::shared_ptr<VKeyMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogInfo("DeviceManagerTool::SetAllKeysMonitor\n");
|
|
||||||
StatusCode code = SetAllKeysMonitorTrace(monitor);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return DeviceManager::SetAllKeysMonitor(monitor);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
void DeviceManagerTestTool::Init(void)
|
|
||||||
{
|
|
||||||
mDeviceManagerMock = std::make_shared<DeviceManagerMock>();
|
|
||||||
DeviceManagerMockInit(mDeviceManagerMock);
|
|
||||||
OverrideDeviceMakePtrObject(mDeviceManagerMock);
|
|
||||||
}
|
|
||||||
void DeviceManagerTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
mDeviceManagerMock.reset();
|
|
||||||
mKeyMonitorMock.reset();
|
|
||||||
CancelOverrideDeviceMakePtrObject();
|
|
||||||
}
|
|
||||||
std::shared_ptr<VirtualLedControl> DeviceManagerTestTool::ControlLed(const std::string &ledName, const LedState &state,
|
|
||||||
const unsigned int &aliveTimeMs,
|
|
||||||
const unsigned int &blinkTimeMs)
|
|
||||||
{
|
|
||||||
HalTestTool::SetLedStateExpectations(ledName, state, aliveTimeMs, blinkTimeMs);
|
|
||||||
std::shared_ptr<VirtualLedControl> ledControl =
|
|
||||||
std::make_shared<SingleControlMock>(state, aliveTimeMs, blinkTimeMs);
|
|
||||||
IDeviceManager::GetInstance()->ControlLed(ledName, ledControl);
|
|
||||||
return ledControl;
|
|
||||||
}
|
|
||||||
void DeviceManagerTestTool::DeviceManagerNotice(const std::string &keyName, const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
LogInfo("DeviceManagerTestTool::DeviceManagerNotice\n");
|
|
||||||
if (mKeyMonitorMock) {
|
|
||||||
KeyMonitorInit(mKeyMonitorMock, keyName, pressingTimeMs);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("mKeyMonitorMock is nullptr.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void DeviceManagerTestTool::DeviceManagerMockInit(std::shared_ptr<DeviceManagerMock> &mock)
|
|
||||||
{
|
|
||||||
auto getKeyMonitor = [=](std::shared_ptr<VKeyMonitor> &monitor) {
|
|
||||||
LogInfo("mKeyMonitorMock get.\n");
|
|
||||||
mKeyMonitorMock = std::dynamic_pointer_cast<KeyMonitorMock>(monitor);
|
|
||||||
};
|
|
||||||
constexpr int ONLY_BE_CALLED_ONCE = 1;
|
|
||||||
EXPECT_CALL(*mock.get(), SetAllKeysMonitorTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(WithArgs<0>(Invoke(getKeyMonitor)), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
void DeviceManagerTestTool::KeyMonitorInit(std::shared_ptr<KeyMonitorMock> &mock, const std::string &keyName,
|
|
||||||
const unsigned int &pressingTimeMs)
|
|
||||||
{
|
|
||||||
// EXPECT_CALL(*mock.get(), KeyEventReport(_, _, _)).Times(100).WillRepeatedly(DoAll(Return()));
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventReport(_, _, _)).WillRepeatedly(DoAll(Return()));
|
|
||||||
constexpr int CLICK_EVENT_HAPPENED_ONLY_ONCE = 1;
|
|
||||||
constexpr int HOLD_UP_EVENT_HAPPENED_ONLY_ONCE = 1;
|
|
||||||
if (KEY_ACTION_SHORT_CLICK <= pressingTimeMs && pressingTimeMs < KEY_ACTION_HOLD_DWON) {
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventReport(keyName, static_cast<VirtualKeyEvent>(KeyEvent::SHORT_CLICK), _))
|
|
||||||
.Times(CLICK_EVENT_HAPPENED_ONLY_ONCE)
|
|
||||||
.WillRepeatedly(DoAll(Return()));
|
|
||||||
}
|
|
||||||
if (KEY_ACTION_HOLD_DWON <= pressingTimeMs) {
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventReport(keyName, static_cast<VirtualKeyEvent>(KeyEvent::HOLD_DOWN), _))
|
|
||||||
.Times(AtLeast(1))
|
|
||||||
.WillRepeatedly(DoAll(Return()));
|
|
||||||
EXPECT_CALL(*mock.get(), KeyEventReport(keyName, static_cast<VirtualKeyEvent>(KeyEvent::HOLD_UP), _))
|
|
||||||
.Times(HOLD_UP_EVENT_HAPPENED_ONLY_ONCE)
|
|
||||||
.WillOnce(DoAll(Return()));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +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 "SingleControlMock.h"
|
|
||||||
SingleControlTool::SingleControlTool(const LedState &state, const unsigned int aliveTimeMs,
|
|
||||||
const unsigned int &blinkTimeMs)
|
|
||||||
: mState(state), mAliveTimeMs(aliveTimeMs), mBlinkTimeMs(blinkTimeMs)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
StatusCode SingleControlTool::GetLedState(LedState &state)
|
|
||||||
{
|
|
||||||
state = mState;
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
||||||
SingleControlMock::SingleControlMock(const LedState &state, const unsigned int aliveTimeMs,
|
|
||||||
const unsigned int &blinkTimeMs)
|
|
||||||
: SingleControlTool(state, aliveTimeMs, blinkTimeMs)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -1,45 +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_CONTROL_MOCK_H
|
|
||||||
#define LED_CONTROL_MOCK_H
|
|
||||||
#include "IDeviceManager.h"
|
|
||||||
#include "LedControl.h"
|
|
||||||
class SingleControlTool : public VSingleControl, public VirtualLedControl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SingleControlTool(const LedState &state, const unsigned int aliveTimeMs, const unsigned int &blinkTimeMs);
|
|
||||||
virtual ~SingleControlTool() = default;
|
|
||||||
virtual StatusCode GetLedState(LedState &state);
|
|
||||||
virtual unsigned int GetKeepAliveTimeMs(void)
|
|
||||||
{
|
|
||||||
return mAliveTimeMs;
|
|
||||||
}
|
|
||||||
virtual unsigned int GetBlinkTimeMs(void)
|
|
||||||
{
|
|
||||||
return mBlinkTimeMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const LedState mState;
|
|
||||||
const unsigned int mAliveTimeMs;
|
|
||||||
const unsigned int mBlinkTimeMs;
|
|
||||||
};
|
|
||||||
class SingleControlMock : public SingleControlTool
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SingleControlMock(const LedState &state, const unsigned int aliveTimeMs, const unsigned int &blinkTimeMs);
|
|
||||||
virtual ~SingleControlMock() = default;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,56 +0,0 @@
|
||||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
|
||||||
include(${HAL_SOURCE_PATH}/build/hal.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}/LinuxApi/include
|
|
||||||
${UTILS_SOURCE_PATH}/UpgradeTool/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade/src
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${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
|
|
||||||
# )
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET HuntingUpgradeTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} UpgradeTool LinuxApi HuntingUpgrade Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
HuntingUpgradeTestTool_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}/middleware/HuntingUpgrade/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
HuntingUpgradeTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/HuntingUpgrade/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make HuntingUpgradeTestTool_code_check
|
|
||||||
COMMAND make HuntingUpgradeTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,82 +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 "HuntingUpgradeTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "LinuxApi.h"
|
|
||||||
#include "UpgradeTool.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
void HuntingUpgradeTestTool::Init(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void HuntingUpgradeTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
if (access(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test", F_OK) == 0) {
|
|
||||||
fx_system("rm -rf " SD_CARD_MOUNT_PATH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void HuntingUpgradeTestTool::CreateUpgradeFile(void)
|
|
||||||
{
|
|
||||||
CheckDirectory(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
|
||||||
fx_system("touch " SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test");
|
|
||||||
UpgradeTool::GetInstance()->PackFile(SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH "-test",
|
|
||||||
SD_CARD_MOUNT_PATH APPLICATION_CHECK_PATH,
|
|
||||||
"6.4.5.6",
|
|
||||||
"hunting",
|
|
||||||
"dgiot",
|
|
||||||
"app");
|
|
||||||
}
|
|
||||||
bool HuntingUpgradeTestTool::CheckDirectory(const char *filepath)
|
|
||||||
{
|
|
||||||
LogInfo("CheckDirectory:%s\n", filepath);
|
|
||||||
char *path = nullptr;
|
|
||||||
char *sep = nullptr;
|
|
||||||
struct stat st = {0};
|
|
||||||
|
|
||||||
path = strdup(filepath);
|
|
||||||
if (!path) {
|
|
||||||
LogError("strdup\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (sep = strchr(path, '/'); sep != NULL; sep = strchr(sep + 1, '/')) {
|
|
||||||
*sep = '\0';
|
|
||||||
if (strlen(path) == 0) {
|
|
||||||
*sep = '/';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (stat(path, &st) == -1) {
|
|
||||||
if (errno == ENOENT) {
|
|
||||||
if (mkdir(path, 0755) == -1) {
|
|
||||||
LogError("mkdir path failed:%s\n", path);
|
|
||||||
free(path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogError("stat\n");
|
|
||||||
free(path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*sep = '/';
|
|
||||||
}
|
|
||||||
free(path);
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
|
||||||
include(${MIDDLEWARE_SOURCE_PATH}/IpcConfig/build/ipc_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
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/IpcConfig/src
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${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
|
|
||||||
# )
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET IpcConfigTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} IpcConfig LinuxApiMock Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
IpcConfigTestTool_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}/middleware/IpcConfig/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
IpcConfigTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/IpcConfig/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make IpcConfigTestTool_code_check
|
|
||||||
COMMAND make IpcConfigTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,68 +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 "IpcConfigTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "LinuxApi.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
const char *MOUNTED_FILE = "./mount_info.txt";
|
|
||||||
extern const char *SYSTEM_MOUNTED_FILE;
|
|
||||||
void IpcConfigTestTool::Init(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
MockMountedFile();
|
|
||||||
auto api_fopen = [=](const char *pathname, const char *mode) {
|
|
||||||
LogInfo("Open mock mounted file.\n");
|
|
||||||
mFile = OpenMockMountedFile(mode);
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), fx_fopen(SYSTEM_MOUNTED_FILE, _))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0, 1>(Invoke(api_fopen)), (ReturnPointee(&mFile))));
|
|
||||||
}
|
|
||||||
void IpcConfigTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
constexpr int BUF_LENGTH = 256;
|
|
||||||
char cmd[BUF_LENGTH] = {0};
|
|
||||||
sprintf(cmd, "rm -rf %s", MOUNTED_FILE);
|
|
||||||
fx_system(cmd);
|
|
||||||
}
|
|
||||||
void IpcConfigTestTool::MockMountedFile(void)
|
|
||||||
{
|
|
||||||
FILE *file;
|
|
||||||
file = fopen(MOUNTED_FILE, "w");
|
|
||||||
if (file == NULL) {
|
|
||||||
perror("Error opening file");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(file, "devtmpfs /dev devtmpfs rw,relatime,size=10176k,nr_inodes=2544,mode=755 0 0\n");
|
|
||||||
fprintf(file, "proc /proc proc rw,relatime 0 0\n");
|
|
||||||
fprintf(file, "tmpfs /tmp tmpfs rw,relatime,size=14464k,nr_inodes=3616 0 0\n");
|
|
||||||
fprintf(file, "tmpfs /run tmpfs rw,nosuid,nodev,relatime,size=14464k,nr_inodes=3616,mode=755 0 0\n");
|
|
||||||
fprintf(file, "sysfs /sys sysfs rw,relatime 0 0\n");
|
|
||||||
fprintf(file, "/dev/block/by-name" USERDATA_MOUNT_PATH " " USERDATA_MOUNT_PATH " jffs2 rw,relatime 0 0\n");
|
|
||||||
fprintf(
|
|
||||||
file,
|
|
||||||
"/dev/mmcblk1p1 /mnt/sdcard vfat "
|
|
||||||
"rw,relatime,fmask=0022,dmask=0022,codepage=936,iocharset=cp936,shortname=mixed,utf8,errors=remount-ro 0 0\n");
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
fx_system("sync");
|
|
||||||
LogInfo("File written successfully.\n");
|
|
||||||
}
|
|
||||||
FILE *IpcConfigTestTool::OpenMockMountedFile(const char *mode)
|
|
||||||
{
|
|
||||||
FILE *fp = nullptr;
|
|
||||||
fp = fopen(MOUNTED_FILE, mode);
|
|
||||||
return fp;
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
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
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
|
|
||||||
# ${UTILS_SOURCE_PATH}/UartDevice/include
|
|
||||||
# ${UTILS_SOURCE_PATH}/ModBusCRC16/include
|
|
||||||
# ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include
|
|
||||||
# ${TEST_SOURCE_PATH}/utils/UartDevice/tool/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
|
|
||||||
)
|
|
||||||
# link_directories(
|
|
||||||
# ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET McuAskBaseTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} UartDeviceTestTool Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
McuAskBaseTestTool_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}/middleware/McuAskBase/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
McuAskBaseTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/McuAskBase/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make McuAskBaseTestTool_code_check
|
|
||||||
COMMAND make McuAskBaseTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,71 +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 "McuAskBaseTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
constexpr int CALL_ONLY_ONCE = 1;
|
|
||||||
constexpr int SHOULD_NOT_CALL = 0;
|
|
||||||
ASK_RESULT McuAskBaseTest::Blocking(void)
|
|
||||||
{
|
|
||||||
BlockingTrace();
|
|
||||||
return McuAskBase::Blocking();
|
|
||||||
}
|
|
||||||
bool McuAskBaseTest::NeedReply(void)
|
|
||||||
{
|
|
||||||
NeedReplyTrace();
|
|
||||||
return McuAskBase::NeedReply();
|
|
||||||
}
|
|
||||||
void McuAskBaseTest::ReplyFinished(const bool result)
|
|
||||||
{
|
|
||||||
ReplyFinishedTrace(result);
|
|
||||||
McuAskBase::ReplyFinished(result);
|
|
||||||
}
|
|
||||||
bool McuAskBaseTest::IfTimeout(const unsigned int &integrationTimeMs)
|
|
||||||
{
|
|
||||||
IfTimeoutTrace(integrationTimeMs);
|
|
||||||
return McuAskBase::IfTimeout(integrationTimeMs);
|
|
||||||
}
|
|
||||||
void McuAskBaseTestTool::McuAskDefaultFeatures(std::shared_ptr<McuAskBaseTestTool> &mock)
|
|
||||||
{
|
|
||||||
if (McuAskBlock::BLOCK == mIsBlock && McuAskReply::NEED_REPLY == mNeedReply) {
|
|
||||||
EXPECT_CALL(*mock.get(), BlockingTrace()).Times(CALL_ONLY_ONCE);
|
|
||||||
EXPECT_CALL(*mock.get(), NeedReplyTrace()).Times(AtLeast(1));
|
|
||||||
EXPECT_CALL(*mock.get(), ReplyFinishedTrace(_)).Times(CALL_ONLY_ONCE);
|
|
||||||
EXPECT_CALL(*mock.get(), IfTimeoutTrace(_)).Times(AnyNumber());
|
|
||||||
}
|
|
||||||
if (McuAskBlock::NOT_BLOCK == mIsBlock && McuAskReply::NEED_REPLY == mNeedReply) {
|
|
||||||
EXPECT_CALL(*mock.get(), BlockingTrace()).Times(CALL_ONLY_ONCE);
|
|
||||||
EXPECT_CALL(*mock.get(), NeedReplyTrace()).Times(AtLeast(1));
|
|
||||||
EXPECT_CALL(*mock.get(), ReplyFinishedTrace(_)).Times(CALL_ONLY_ONCE);
|
|
||||||
EXPECT_CALL(*mock.get(), IfTimeoutTrace(_)).Times(AnyNumber());
|
|
||||||
}
|
|
||||||
if (McuAskBlock::UNRELATED == mIsBlock && McuAskReply::NEED_NOT_REPLY == mNeedReply) {
|
|
||||||
EXPECT_CALL(*mock.get(), BlockingTrace()).Times(SHOULD_NOT_CALL);
|
|
||||||
EXPECT_CALL(*mock.get(), NeedReplyTrace()).Times(AtLeast(1));
|
|
||||||
EXPECT_CALL(*mock.get(), ReplyFinishedTrace(_)).Times(SHOULD_NOT_CALL);
|
|
||||||
EXPECT_CALL(*mock.get(), IfTimeoutTrace(_)).Times(SHOULD_NOT_CALL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void McuAskBaseTestTool::McuAskDoNothing(std::shared_ptr<McuAskBaseTestTool> &mock)
|
|
||||||
{
|
|
||||||
EXPECT_CALL(*mock.get(), BlockingTrace()).Times(AnyNumber());
|
|
||||||
EXPECT_CALL(*mock.get(), NeedReplyTrace()).Times(AnyNumber());
|
|
||||||
EXPECT_CALL(*mock.get(), ReplyFinishedTrace(_)).Times(AnyNumber());
|
|
||||||
EXPECT_CALL(*mock.get(), IfTimeoutTrace(_)).Times(AnyNumber());
|
|
||||||
}
|
|
||||||
void McuAskBaseTestTool::NoNeedToBlocking(std::shared_ptr<McuAskBaseTestTool> &mock)
|
|
||||||
{
|
|
||||||
// Mock::AllowLeak(mock.get());
|
|
||||||
EXPECT_CALL(*mock.get(), BlockingTrace()).Times(SHOULD_NOT_CALL);
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
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}/McuManager/src
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${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
|
|
||||||
# )
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET McuManagerTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} McuManager McuProtocolTestTool UartDeviceTestTool LinuxApiMock Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
McuManagerTestTool_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}/middleware/McuManager/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
McuManagerTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/McuManager/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make McuManagerTestTool_code_check
|
|
||||||
COMMAND make McuManagerTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,20 +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 "McuManagerTestTool.h"
|
|
||||||
bool McuManagerImplTest::CheckAskExist(const std::shared_ptr<VMcuAsk> &ask)
|
|
||||||
{
|
|
||||||
std::shared_ptr<VMcuAsk> result;
|
|
||||||
return SearchMcuAsk(ask->mSerialNumber, result);
|
|
||||||
}
|
|
|
@ -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.
|
|
||||||
*/
|
|
||||||
#include "McuManagerMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "McuManagerTestTool.h"
|
|
||||||
void OverrideMcuManagerMakePtrObject(std::shared_ptr<McuManagerImplTest> &mcuManagerMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<McuManagerMakePtr> impl = std::make_shared<McuManagerMakePtrTest>();
|
|
||||||
McuManagerMakePtr::GetInstance(&impl);
|
|
||||||
std::shared_ptr<McuManagerMakePtr> tmp = McuManagerMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<McuManagerMakePtrTest> test = std::dynamic_pointer_cast<McuManagerMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mMcuManagerMock = mcuManagerMock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void CancelOverrideMcuManagerMakePtrObject(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<McuManagerMakePtr> tmp = McuManagerMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<McuManagerMakePtrTest> test = std::dynamic_pointer_cast<McuManagerMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mMcuManagerMock.reset();
|
|
||||||
}
|
|
||||||
tmp.reset();
|
|
||||||
test.reset();
|
|
||||||
std::shared_ptr<McuManagerMakePtr> impl = std::make_shared<McuManagerMakePtr>();
|
|
||||||
McuManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
McuManagerMakePtrTest::McuManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
McuManagerMakePtrTest::~McuManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
mMcuManagerMock.reset();
|
|
||||||
}
|
|
||||||
const StatusCode McuManagerMakePtrTest::CreateMcuManager(std::shared_ptr<IMcuManager> &impl)
|
|
||||||
{
|
|
||||||
if (mMcuManagerMock) {
|
|
||||||
impl = mMcuManagerMock;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("CreateMcuManager failed:mMcuManagerMock is nullptr.\n");
|
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
|
@ -1,32 +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 MCU_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#define MCU_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#include "McuManagerMakePtr.h"
|
|
||||||
#include "McuManagerTestTool.h"
|
|
||||||
void OverrideMcuManagerMakePtrObject(std::shared_ptr<McuManagerImplTest> &mcuManagerMock);
|
|
||||||
void CancelOverrideMcuManagerMakePtrObject(void);
|
|
||||||
class McuManagerMakePtrTest : public McuManagerMakePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
McuManagerMakePtrTest();
|
|
||||||
virtual ~McuManagerMakePtrTest();
|
|
||||||
const StatusCode CreateMcuManager(std::shared_ptr<IMcuManager> &impl) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
public:
|
|
||||||
std::shared_ptr<McuManagerImplTest> mMcuManagerMock;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,85 +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 "McuManagerTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "McuManagerMakePtrTest.h"
|
|
||||||
extern const char *MCU_UART_DEVICE_PTR;
|
|
||||||
static UartInfo gUartDevice = {
|
|
||||||
MCU_UART_DEVICE_PTR,
|
|
||||||
1152000,
|
|
||||||
'N',
|
|
||||||
8,
|
|
||||||
1,
|
|
||||||
'N',
|
|
||||||
};
|
|
||||||
void McuManagerTestTool::Init(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
LogInfo("McuManagerTestTool::Init\n");
|
|
||||||
mMcuManagerMock = std::make_shared<McuManagerImplTest>();
|
|
||||||
OverrideMcuManagerMakePtrObject(mMcuManagerMock);
|
|
||||||
UartDeviceTestTool::RegisterUartDevice(mock, gUartDevice);
|
|
||||||
McuProtocolTestTool::Init(mock, gUartDevice);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
LogInfo("McuManagerTestTool::UnInit\n");
|
|
||||||
mMcuManagerMock.reset();
|
|
||||||
CancelOverrideMcuManagerMakePtrObject();
|
|
||||||
UartDeviceTestTool::UnregisterUartDevice(gUartDevice);
|
|
||||||
McuProtocolTestTool::UnInit();
|
|
||||||
}
|
|
||||||
bool McuManagerTestTool::CheckAskExist(const std::shared_ptr<VMcuAsk> &ask)
|
|
||||||
{
|
|
||||||
return mMcuManagerMock->CheckAskExist(ask);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideAskIpcMission(std::shared_ptr<LinuxTest> &mock, const unsigned int &serialNumber)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::MockOtherSideAskIpcMission(mock, serialNumber);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideAskHeartBeat(std::shared_ptr<LinuxTest> &mock, const unsigned int &serialNumber)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::MockOtherSideAskHeartBeat(mock, serialNumber);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideGetIntervalStart(std::shared_ptr<LinuxTest> &mock,
|
|
||||||
const unsigned int &serialNumber)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::MockOtherSideAskGetIntervalStart(mock, serialNumber);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideGetDateTime(std::shared_ptr<LinuxTest> &mock, const unsigned int &serialNumber)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::MockOtherSideAskGetDateTime(mock, serialNumber);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideGetPriSensitivity(std::shared_ptr<LinuxTest> &mock,
|
|
||||||
const unsigned int &serialNumber)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::MockOtherSideAskGetPirSensitivity(mock, serialNumber);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideSendData(std::shared_ptr<LinuxTest> &mock, const void *data, const size_t &size)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::MockOtherSideAskSendAnyData(mock, data, size);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockMcuDeviceOpenFailed(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
UartDeviceTestTool::SetUartDeviceOpenFailed(mock, gUartDevice);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockMcuDeviceOpenSuccessButReadNothing(std::shared_ptr<LinuxTest> &mock)
|
|
||||||
{
|
|
||||||
McuProtocolTestTool::ReadNothingAnyTime(mock);
|
|
||||||
}
|
|
||||||
void McuManagerTestTool::MockOtherSideIpcMissionReply(const IpcMission &replyIpcMission)
|
|
||||||
{
|
|
||||||
unsigned char reply = static_cast<unsigned char>(replyIpcMission);
|
|
||||||
McuProtocolTestTool::MockOtherSideIpcMissionReply(reply);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
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}/Servers/include
|
|
||||||
# ${UTILS_SOURCE_PATH}/TcpModule/include
|
|
||||||
${MIDDLEWARE_SOURCE_PATH}/MediaManager/src
|
|
||||||
${HAL_SOURCE_PATH}/include
|
|
||||||
${TEST_SOURCE_PATH}
|
|
||||||
${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
|
|
||||||
# )
|
|
||||||
|
|
||||||
aux_source_directory(./src TEST_TOOL_SRC_FILES)
|
|
||||||
set(TEST_TOOL_TARGET MediaManagerTestTool)
|
|
||||||
add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} MediaManager Servers Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
MediaManagerTestTool_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}/middleware/MediaManager/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
MediaManagerTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/MediaManager/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make MediaManagerTestTool_code_check
|
|
||||||
COMMAND make MediaManagerTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,15 +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 "MediaHandleMock.h"
|
|
|
@ -1,18 +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 MEDIA_HANDLE_MOCK_H
|
|
||||||
#define MEDIA_HANDLE_MOCK_H
|
|
||||||
#include "MediaHandle.h"
|
|
||||||
#endif
|
|
|
@ -1,55 +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 "MediaManagerMakePtrTest.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
void OverrideMediaManagerMakePtrObject(std::shared_ptr<MediaManagerMock> &appManagerMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MediaManagerMakePtr> impl = std::make_shared<MediaManagerMakePtrTest>();
|
|
||||||
std::shared_ptr<MediaManagerMakePtrTest> test = std::dynamic_pointer_cast<MediaManagerMakePtrTest>(impl);
|
|
||||||
if (test) {
|
|
||||||
test->mMediaManagerMock = appManagerMock;
|
|
||||||
}
|
|
||||||
MediaManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
void CancelOverrideMediaManagerMakePtrObject(void)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MediaManagerMakePtr> tmp = MediaManagerMakePtr::GetInstance();
|
|
||||||
std::shared_ptr<MediaManagerMakePtrTest> test = std::dynamic_pointer_cast<MediaManagerMakePtrTest>(tmp);
|
|
||||||
if (test) {
|
|
||||||
test->mMediaManagerMock.reset();
|
|
||||||
}
|
|
||||||
tmp.reset();
|
|
||||||
test.reset();
|
|
||||||
std::shared_ptr<MediaManagerMakePtr> impl = std::make_shared<MediaManagerMakePtrTest>();
|
|
||||||
MediaManagerMakePtr::GetInstance(&impl);
|
|
||||||
}
|
|
||||||
MediaManagerMakePtrTest::MediaManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
MediaManagerMakePtrTest::~MediaManagerMakePtrTest()
|
|
||||||
{
|
|
||||||
mMediaManagerMock.reset();
|
|
||||||
}
|
|
||||||
const StatusCode MediaManagerMakePtrTest::CreateMediaManagerModule(std::shared_ptr<IMediaManager> &impl)
|
|
||||||
{
|
|
||||||
if (mMediaManagerMock) {
|
|
||||||
LogInfo("CreateMediaManagerModule mMediaManagerMock\n");
|
|
||||||
impl = mMediaManagerMock;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("CreateMcuManager failed:mMediaManagerMock is nullptr.\n");
|
|
||||||
}
|
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
|
||||||
}
|
|
|
@ -1,32 +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 MEDIA_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#define MEDIA_MANAGER_MAKE_PTR_TEST_H
|
|
||||||
#include "MediaManagerMock.h"
|
|
||||||
#include "MediaManagerTestTool.h"
|
|
||||||
#include "MediaManagerMakePtr.h"
|
|
||||||
void OverrideMediaManagerMakePtrObject(std::shared_ptr<MediaManagerMock> &appManagerMock);
|
|
||||||
void CancelOverrideMediaManagerMakePtrObject(void);
|
|
||||||
class MediaManagerMakePtrTest : public MediaManagerMakePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaManagerMakePtrTest();
|
|
||||||
virtual ~MediaManagerMakePtrTest();
|
|
||||||
const StatusCode CreateMediaManagerModule(std::shared_ptr<IMediaManager> &impl) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<MediaManagerMock> mMediaManagerMock;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,30 +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 "MediaManagerMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
StatusCode MediaManagerTest::SetMediaMonitor(std::shared_ptr<VMediaMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogInfo("MediaManagerTest::SetMediaMonitor\n");
|
|
||||||
StatusCode code = SetMediaMonitorTrace(monitor);
|
|
||||||
if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
return MediaManagerImpl::SetMediaMonitor(monitor);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
const StatusCode MediaManagerTest::SetMediaMonitorTrace(std::shared_ptr<VMediaMonitor> &monitor)
|
|
||||||
{
|
|
||||||
LogInfo("SetMediaMonitorTrace::SetMediaMonitorTrace\n");
|
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
}
|
|
|
@ -1,37 +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 MEDIA_MANAGER_MOCK_H
|
|
||||||
#define MEDIA_MANAGER_MOCK_H
|
|
||||||
#include "MediaManagerImpl.h"
|
|
||||||
#include "MediaManagerTestTool.h"
|
|
||||||
class MediaManagerTest : public MediaManagerImpl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaManagerTest() = default;
|
|
||||||
virtual ~MediaManagerTest() = default;
|
|
||||||
// const StatusCode SetMediaMonitor(std::shared_ptr<VMediaMonitor> &monitor) override;
|
|
||||||
StatusCode SetMediaMonitor(std::shared_ptr<VMediaMonitor> &monitor) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual const StatusCode SetMediaMonitorTrace(std::shared_ptr<VMediaMonitor> &monitor);
|
|
||||||
};
|
|
||||||
class MediaManagerMock : public MediaManagerTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaManagerMock() = default;
|
|
||||||
virtual ~MediaManagerMock() = default;
|
|
||||||
MOCK_METHOD1(SetMediaMonitorTrace, const StatusCode(std::shared_ptr<VMediaMonitor> &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,102 +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 "MediaManagerTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include "MediaManagerMakePtrTest.h"
|
|
||||||
#include "MediaManagerMock.h"
|
|
||||||
#include "MediaMonitorMock.h"
|
|
||||||
constexpr int ONLY_BE_CALLED_ONCE = 1;
|
|
||||||
void MediaManagerTestTool::Init(void)
|
|
||||||
{
|
|
||||||
mMediaManagerMock = std::make_shared<MediaManagerMock>();
|
|
||||||
MediaManagerMockInit(mMediaManagerMock);
|
|
||||||
std::shared_ptr<MediaManagerMock> mock = std::dynamic_pointer_cast<MediaManagerMock>(mMediaManagerMock);
|
|
||||||
OverrideMediaManagerMakePtrObject(mock);
|
|
||||||
}
|
|
||||||
void MediaManagerTestTool::UnInit(void)
|
|
||||||
{
|
|
||||||
mMediaManagerMock.reset();
|
|
||||||
mMediaMonitorMock.reset();
|
|
||||||
CancelOverrideMediaManagerMakePtrObject();
|
|
||||||
}
|
|
||||||
void MediaManagerTestTool::MediaManagerMockInit(std::shared_ptr<IMediaManager> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MediaManagerMock> mock = std::dynamic_pointer_cast<MediaManagerMock>(vMock);
|
|
||||||
if (!mock) {
|
|
||||||
LogError("vMock error.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto getMediaMonitor = [=](std::shared_ptr<VMediaMonitor> &monitor) {
|
|
||||||
LogInfo("mMediaMonitorMock get.\n");
|
|
||||||
mMediaMonitorMock = monitor;
|
|
||||||
MediaManagerTestTool::MediaMonitorInit(mMediaMonitorMock);
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), SetMediaMonitorTrace(_))
|
|
||||||
.Times(ONLY_BE_CALLED_ONCE)
|
|
||||||
.WillOnce(DoAll(WithArgs<0>(Invoke(getMediaMonitor)), Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
void MediaManagerTestTool::MediaMonitorInit(std::shared_ptr<VMediaMonitor> &vMock)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MediaMonitorMock> mock = std::dynamic_pointer_cast<MediaMonitorMock>(vMock);
|
|
||||||
if (mock) {
|
|
||||||
// EXPECT_CALL(*mock.get(), GetProductInfoTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetDeviceAttrTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetMediaInfoTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetSdCardInfoTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetParamValueTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetCapabilityTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetLockVideoStatusTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetStorageInfoTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetStorageFileListTrace(_, _))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetBatteryInfoTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), SetDateTimeTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), SetTimeZoneTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), SetParamValueTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), EnterRecorderTrace())
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), MediaPlaybackTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), UploadFileTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), GetThumbnailTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
// EXPECT_CALL(*mock.get(), MediaClientConnectedTrace(_))
|
|
||||||
// .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::shared_ptr<VMediaMonitor> MediaManagerTestTool::MakeMonitorMock(void)
|
|
||||||
{
|
|
||||||
class Monitor : public MediaMonitorMock, public MediaMonitorTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Monitor() = default;
|
|
||||||
virtual ~Monitor() = default;
|
|
||||||
};
|
|
||||||
std::shared_ptr<VMediaMonitor> monitor = std::make_shared<Monitor>();
|
|
||||||
return monitor;
|
|
||||||
}
|
|
|
@ -1,274 +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 "MediaMonitorMock.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
// StatusCode MediaMonitorTest::GetProductInfo(AppGetProductInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetProductInfo\n");
|
|
||||||
// StatusCode code = GetProductInfoTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetProductInfo(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetProductInfoTrace(AppGetProductInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetProductInfoTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetDeviceAttr(AppGetDeviceAttr ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetDeviceAttr\n");
|
|
||||||
// StatusCode code = GetDeviceAttrTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetDeviceAttr(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetDeviceAttrTrace(AppGetDeviceAttr ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetDeviceAttrTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetMediaInfo(AppGetMediaInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetMediaInfo\n");
|
|
||||||
// StatusCode code = GetMediaInfoTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetMediaInfo(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetMediaInfoTrace(AppGetMediaInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetMediaInfoTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetSdCardInfo\n");
|
|
||||||
// StatusCode code = GetSdCardInfoTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetSdCardInfo(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetSdCardInfoTrace(AppGetSdCardInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetSdCardInfoTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetBatteryInfo(AppGetBatteryInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetBatteryInfo\n");
|
|
||||||
// StatusCode code = GetBatteryInfoTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetBatteryInfo(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetBatteryInfoTrace(AppGetBatteryInfo ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetBatteryInfoTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetParamValue(AppParamValue ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetParamValue\n");
|
|
||||||
// StatusCode code = GetParamValueTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetParamValue(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetParamValueTrace(AppParamValue ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetParamValueTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetCapability(AppGetCapability ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetCapability\n");
|
|
||||||
// StatusCode code = GetCapabilityTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetCapability(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetCapabilityTrace(AppGetCapability ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetCapabilityTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetLockVideoStatus(LockVideoStatus ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetLockVideoStatus\n");
|
|
||||||
// StatusCode code = GetLockVideoStatusTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetLockVideoStatus(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetLockVideoStatusTrace(LockVideoStatus ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetLockVideoStatusTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetStorageInfo(std::vector<AppGetStorageInfo> ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetStorageInfo\n");
|
|
||||||
// StatusCode code = GetStorageInfoTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetStorageInfo(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetStorageInfoTrace(std::vector<AppGetStorageInfo> ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetStorageInfoTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetStorageFileList\n");
|
|
||||||
// StatusCode code = GetStorageFileListTrace(fileInfo, param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetStorageFileList(fileInfo, param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetStorageFileListTrace(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::GetStorageFileListTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::SetDateTime(const AppSetDateTime ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::SetDateTime\n");
|
|
||||||
// LogInfo("mYear = %u\n", param.mYear);
|
|
||||||
// LogInfo("mMonth = %02u\n", param.mMonth);
|
|
||||||
// LogInfo("mDay = %02u\n", param.mDay);
|
|
||||||
// LogInfo("mHour = %02u\n", param.mHour);
|
|
||||||
// LogInfo("mMinute = %02u\n", param.mMinute);
|
|
||||||
// LogInfo("mSecond = %02u\n", param.mSecond);
|
|
||||||
// StatusCode code = SetDateTimeTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::SetDateTime(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::SetDateTimeTrace(const AppSetDateTime ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::SetDateTimeTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::SetTimeZone(const unsigned int &zone)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::SetTimeZone = %u\n", zone);
|
|
||||||
// StatusCode code = SetTimeZoneTrace(zone);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::SetTimeZone(zone);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::SetTimeZoneTrace(const unsigned int &zone)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::SetTimeZoneTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::SetParamValue(const AppSetParamValue ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::SetParamValue\n");
|
|
||||||
// StatusCode code = SetParamValueTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::SetParamValue(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::SetParamValueTrace(const AppSetParamValue ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::SetParamValueTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::EnterRecorder(void)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::EnterRecorder\n");
|
|
||||||
// StatusCode code = EnterRecorderTrace();
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::EnterRecorder();
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::EnterRecorderTrace(void)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::EnterRecorderTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::AppPlayback(const PlayBackEvent &event)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::AppPlayback\n");
|
|
||||||
// StatusCode code = AppPlaybackTrace(event);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::AppPlayback(event);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::AppPlaybackTrace(const PlayBackEvent &event)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::AppPlaybackTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::UploadFile(AppUploadFile ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::UploadFile\n");
|
|
||||||
// StatusCode code = UploadFileTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::UploadFile(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::UploadFileTrace(AppUploadFile ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::UploadFileTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::GetThumbnail(AppGetThumbnail ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::GetThumbnail\n");
|
|
||||||
// StatusCode code = GetThumbnailTrace(param);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::GetThumbnail(param);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::GetThumbnailTrace(AppGetThumbnail ¶m)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::UploadFileTrace\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTest::AppClientConnected(std::shared_ptr<VAppClient> &client)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTest::AppClientConnected\n");
|
|
||||||
// StatusCode code = AppClientConnectedTrace(client);
|
|
||||||
// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) {
|
|
||||||
// return VMediaMonitor::AppClientConnected(client);
|
|
||||||
// }
|
|
||||||
// return code;
|
|
||||||
// }
|
|
||||||
// StatusCode MediaMonitorTrace::AppClientConnectedTrace(std::shared_ptr<VAppClient> &client)
|
|
||||||
// {
|
|
||||||
// LogInfo("MediaMonitorTrace::AppClientConnected\n");
|
|
||||||
// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
||||||
// }
|
|
|
@ -1,93 +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 MEDIA_MONITOR_MOCK_H
|
|
||||||
#define MEDIA_MONITOR_MOCK_H
|
|
||||||
#include "GtestUsing.h"
|
|
||||||
#include "IMediaManager.h"
|
|
||||||
class MediaMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaMonitorTrace() = default;
|
|
||||||
virtual ~MediaMonitorTrace() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// virtual StatusCode GetProductInfoTrace(AppGetProductInfo ¶m);
|
|
||||||
// virtual StatusCode GetDeviceAttrTrace(AppGetDeviceAttr ¶m);
|
|
||||||
// virtual StatusCode GetMediaInfoTrace(AppGetMediaInfo ¶m);
|
|
||||||
// virtual StatusCode GetSdCardInfoTrace(AppGetSdCardInfo ¶m);
|
|
||||||
// virtual StatusCode GetBatteryInfoTrace(AppGetBatteryInfo ¶m);
|
|
||||||
// virtual StatusCode GetParamValueTrace(AppParamValue ¶m);
|
|
||||||
// virtual StatusCode GetCapabilityTrace(AppGetCapability ¶m);
|
|
||||||
// virtual StatusCode GetLockVideoStatusTrace(LockVideoStatus ¶m);
|
|
||||||
// virtual StatusCode GetStorageInfoTrace(std::vector<AppGetStorageInfo> ¶m);
|
|
||||||
// virtual StatusCode GetStorageFileListTrace(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m);
|
|
||||||
// virtual StatusCode SetDateTimeTrace(const AppSetDateTime ¶m);
|
|
||||||
// virtual StatusCode SetTimeZoneTrace(const unsigned int &zone);
|
|
||||||
// virtual StatusCode SetParamValueTrace(const AppSetParamValue ¶m);
|
|
||||||
// virtual StatusCode EnterRecorderTrace(void);
|
|
||||||
// virtual StatusCode AppPlaybackTrace(const PlayBackEvent &event);
|
|
||||||
// virtual StatusCode UploadFileTrace(AppUploadFile ¶m);
|
|
||||||
// virtual StatusCode GetThumbnailTrace(AppGetThumbnail ¶m);
|
|
||||||
// virtual StatusCode AppClientConnectedTrace(std::shared_ptr<VAppClient> &client);
|
|
||||||
};
|
|
||||||
class MediaMonitorTest : public VMediaMonitor, virtual public MediaMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaMonitorTest() = default;
|
|
||||||
virtual ~MediaMonitorTest() = default;
|
|
||||||
// StatusCode GetProductInfo(AppGetProductInfo ¶m) override;
|
|
||||||
// StatusCode GetDeviceAttr(AppGetDeviceAttr ¶m) override;
|
|
||||||
// StatusCode GetMediaInfo(AppGetMediaInfo ¶m) override;
|
|
||||||
// StatusCode GetSdCardInfo(AppGetSdCardInfo ¶m) override;
|
|
||||||
// StatusCode GetBatteryInfo(AppGetBatteryInfo ¶m) override;
|
|
||||||
// StatusCode GetParamValue(AppParamValue ¶m) override;
|
|
||||||
// StatusCode GetCapability(AppGetCapability ¶m) override;
|
|
||||||
// StatusCode GetLockVideoStatus(LockVideoStatus ¶m) override;
|
|
||||||
// StatusCode GetStorageInfo(std::vector<AppGetStorageInfo> ¶m) override;
|
|
||||||
// StatusCode GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m) override;
|
|
||||||
// StatusCode SetDateTime(const AppSetDateTime ¶m) override;
|
|
||||||
// StatusCode SetTimeZone(const unsigned int &zone) override;
|
|
||||||
// StatusCode SetParamValue(const AppSetParamValue ¶m) override;
|
|
||||||
// StatusCode EnterRecorder(void) override;
|
|
||||||
// StatusCode AppPlayback(const PlayBackEvent &event) override;
|
|
||||||
// StatusCode UploadFile(AppUploadFile ¶m) override;
|
|
||||||
// StatusCode GetThumbnail(AppGetThumbnail ¶m) override;
|
|
||||||
// StatusCode AppClientConnected(std::shared_ptr<VAppClient> &client) override;
|
|
||||||
};
|
|
||||||
class MediaMonitorMock : virtual public MediaMonitorTrace
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaMonitorMock() = default;
|
|
||||||
virtual ~MediaMonitorMock() = default;
|
|
||||||
// MOCK_METHOD1(GetProductInfoTrace, StatusCode(AppGetProductInfo &));
|
|
||||||
// MOCK_METHOD1(GetDeviceAttrTrace, StatusCode(AppGetDeviceAttr &));
|
|
||||||
// MOCK_METHOD1(GetMediaInfoTrace, StatusCode(AppGetMediaInfo &));
|
|
||||||
// MOCK_METHOD1(GetSdCardInfoTrace, StatusCode(AppGetSdCardInfo &));
|
|
||||||
// MOCK_METHOD1(GetBatteryInfoTrace, StatusCode(AppGetBatteryInfo &));
|
|
||||||
// MOCK_METHOD1(GetParamValueTrace, StatusCode(AppParamValue &));
|
|
||||||
// MOCK_METHOD1(GetCapabilityTrace, StatusCode(AppGetCapability &));
|
|
||||||
// MOCK_METHOD1(GetLockVideoStatusTrace, StatusCode(LockVideoStatus &));
|
|
||||||
// MOCK_METHOD1(GetStorageInfoTrace, StatusCode(std::vector<AppGetStorageInfo> &));
|
|
||||||
// MOCK_METHOD2(GetStorageFileListTrace, StatusCode(const AppGetFileInfo &, std::vector<AppGetFileList> &));
|
|
||||||
// MOCK_METHOD1(SetDateTimeTrace, StatusCode(const AppSetDateTime &));
|
|
||||||
// MOCK_METHOD1(SetTimeZoneTrace, StatusCode(const unsigned int &));
|
|
||||||
// MOCK_METHOD1(SetParamValueTrace, StatusCode(const AppSetParamValue &));
|
|
||||||
// MOCK_METHOD0(EnterRecorderTrace, StatusCode(void));
|
|
||||||
// MOCK_METHOD1(AppPlaybackTrace, StatusCode(const PlayBackEvent &));
|
|
||||||
// MOCK_METHOD1(UploadFileTrace, StatusCode(AppUploadFile &));
|
|
||||||
// MOCK_METHOD1(GetThumbnailTrace, StatusCode(AppGetThumbnail &));
|
|
||||||
// MOCK_METHOD1(AppClientConnectedTrace, StatusCode(std::shared_ptr<VAppClient> &));
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,57 +0,0 @@
|
||||||
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}/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
|
|
||||||
${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include
|
|
||||||
)
|
|
||||||
# link_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})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} UartDeviceTestTool Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
McuProtocolTestTool_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}/utils/McuProtocol/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
McuProtocolTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/utils/McuProtocol/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make McuProtocolTestTool_code_check
|
|
||||||
COMMAND make McuProtocolTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,76 +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 "ProtocolMonitor.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
static void PrintHexadecimalData(const void *buf, const size_t &bufLength, const char *log)
|
|
||||||
{
|
|
||||||
printf("%s { 0x%02X", log, *(unsigned char *)buf);
|
|
||||||
for (size_t i = 1; i < bufLength; i++) {
|
|
||||||
printf(", 0x%02X", *((unsigned char *)buf + i));
|
|
||||||
}
|
|
||||||
printf(" }\n");
|
|
||||||
}
|
|
||||||
std::shared_ptr<ProtocolMonitor> &ProtocolMonitor::GetInstance(std::shared_ptr<ProtocolMonitor> *impl)
|
|
||||||
{
|
|
||||||
static auto instance = std::make_shared<ProtocolMonitor>();
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
void ProtocolMonitor::MonitorWriteProtocolData(const short &head, const unsigned int &serialNumber,
|
|
||||||
const short &command, const void *data, const short &packetLength)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void ProtocolMonitorTest::Init(std::shared_ptr<ProtocolMonitorTest> &test)
|
|
||||||
{
|
|
||||||
auto printfParam = [=](const short &head,
|
|
||||||
const unsigned int &serialNumber,
|
|
||||||
const short &command,
|
|
||||||
const void *data,
|
|
||||||
const short &packetLength) {
|
|
||||||
LogInfo("MonitorWriteProtocolData called.\n");
|
|
||||||
PrintHexadecimalData(&head, sizeof(head), "MonitorWriteProtocolData(head):");
|
|
||||||
PrintHexadecimalData(&serialNumber, sizeof(serialNumber), "MonitorWriteProtocolData(serialNumber):");
|
|
||||||
PrintHexadecimalData(&command, sizeof(command), "MonitorWriteProtocolData(command):");
|
|
||||||
PrintHexadecimalData(&packetLength, sizeof(packetLength), "MonitorWriteProtocolData(packetLength):");
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*test.get(), MonitorWriteProtocolData(_, _, _, _, _))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(printfParam)), Return()));
|
|
||||||
}
|
|
||||||
void ProtocolMonitorTest::WriteDataOnce(std::shared_ptr<ProtocolMonitorTest> &test, const short &head,
|
|
||||||
const unsigned int &serialNumber, const short &command, const void *data,
|
|
||||||
const short &packetLength)
|
|
||||||
{
|
|
||||||
auto printfParam = [=](const short &head,
|
|
||||||
const unsigned int &serialNumber,
|
|
||||||
const short &command,
|
|
||||||
const void *data,
|
|
||||||
const short &packetLength) {
|
|
||||||
};
|
|
||||||
PrintHexadecimalData(&head, sizeof(head), "WriteDataOnce(head):");
|
|
||||||
PrintHexadecimalData(&serialNumber, sizeof(serialNumber), "WriteDataOnce(serialNumber):");
|
|
||||||
PrintHexadecimalData(&command, sizeof(command), "WriteDataOnce(command):");
|
|
||||||
PrintHexadecimalData(&packetLength, sizeof(packetLength), "WriteDataOnce(packetLength):");
|
|
||||||
EXPECT_CALL(*test.get(), MonitorWriteProtocolData(head, serialNumber, command, _, packetLength))
|
|
||||||
.Times(1)
|
|
||||||
.WillOnce(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(printfParam)), Return()));
|
|
||||||
}
|
|
|
@ -1,51 +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 PROTOCOL_MONITOR_H
|
|
||||||
#define PROTOCOL_MONITOR_H
|
|
||||||
#include "GtestUsing.h"
|
|
||||||
#include <memory>
|
|
||||||
class ProtocolMonitor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProtocolMonitor() = default;
|
|
||||||
virtual ~ProtocolMonitor() = default;
|
|
||||||
static std::shared_ptr<ProtocolMonitor> &GetInstance(std::shared_ptr<ProtocolMonitor> *impl = nullptr);
|
|
||||||
/**
|
|
||||||
* @brief This function is used to monitor whether the data written to the serial port matches the protocol and
|
|
||||||
* belongs to a piling function.
|
|
||||||
* @param head Whether to match the protocol header.
|
|
||||||
* @param serialNumber Whether to match the serial number.
|
|
||||||
* @param command Whether to match command words.
|
|
||||||
* @param data
|
|
||||||
* @param packetLength Whether to match the packet length.
|
|
||||||
*/
|
|
||||||
virtual void MonitorWriteProtocolData(const short &head, const unsigned int &serialNumber, const short &command,
|
|
||||||
const void *data, const short &packetLength);
|
|
||||||
};
|
|
||||||
class ProtocolMonitorTest : public ProtocolMonitor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProtocolMonitorTest() = default;
|
|
||||||
virtual ~ProtocolMonitorTest() = default;
|
|
||||||
MOCK_METHOD5(MonitorWriteProtocolData,
|
|
||||||
void(const short &, const unsigned int &, const short &, const void *, const short &));
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void Init(std::shared_ptr<ProtocolMonitorTest> &test);
|
|
||||||
static void WriteDataOnce(std::shared_ptr<ProtocolMonitorTest> &test, const short &head,
|
|
||||||
const unsigned int &serialNumber, const short &command, const void *data,
|
|
||||||
const short &packetLength);
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,51 +0,0 @@
|
||||||
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
|
|
||||||
${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})
|
|
||||||
target_link_libraries(${TEST_TOOL_TARGET} LinuxApiMock Log)
|
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
UartDeviceTestTool_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}/utils/UartDevice/tool
|
|
||||||
)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h)
|
|
||||||
add_custom_target(
|
|
||||||
UartDeviceTestTool_code_format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${TEST_TOOL_SRC_FILES} ${HEADER_FILES}
|
|
||||||
WORKING_DIRECTORY ${TEST_SOURCE_PATH}/utils/UartDevice/tool
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TEST_TOOL_TARGET}
|
|
||||||
PRE_BUILD
|
|
||||||
COMMAND make UartDeviceTestTool_code_check
|
|
||||||
COMMAND make UartDeviceTestTool_code_format
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_file_name(${TEST_TOOL_TARGET})
|
|
|
@ -1,130 +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 "UartDeviceTestTool.h"
|
|
||||||
#include "ILog.h"
|
|
||||||
#include <thread>
|
|
||||||
static size_t WRITE_COUNT = -1;
|
|
||||||
constexpr int INVALID_FD = -1;
|
|
||||||
int UartDeviceTestTool::RegisterUartDevice(std::shared_ptr<LinuxTest> &mock, const UartInfo &uart)
|
|
||||||
{
|
|
||||||
if (nullptr == uart.mDevice) {
|
|
||||||
LogError("Parament error, nullptr == uartInfo.mDevice\n");
|
|
||||||
return INVALID_FD;
|
|
||||||
}
|
|
||||||
constexpr int TCGETATTR_SUCCEED = 0;
|
|
||||||
constexpr int TCSETATTR_SUCCEED = 0;
|
|
||||||
int uartFd = mock->GetHandleForMock();
|
|
||||||
LogInfo("device = %s, uartFd = %d\n", uart.mDevice, uartFd);
|
|
||||||
EXPECT_CALL(*mock.get(), fx_open(uart.mDevice, _)).WillRepeatedly(DoAll((Return(uartFd))));
|
|
||||||
EXPECT_CALL(*mock.get(), fx_tcgetattr(uartFd, _)).WillRepeatedly(DoAll(Return(TCGETATTR_SUCCEED)));
|
|
||||||
EXPECT_CALL(*mock.get(), fx_tcsetattr(uartFd, _, _)).WillRepeatedly(DoAll(Return(TCSETATTR_SUCCEED)));
|
|
||||||
EXPECT_CALL(*mock.get(), fx_write(uartFd, _, _))
|
|
||||||
.WillRepeatedly(DoAll(SaveArg<2>(&WRITE_COUNT), ReturnPointee(&WRITE_COUNT)));
|
|
||||||
auto selectTimeOut =
|
|
||||||
[=, &mock](int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
|
|
||||||
long long timeMs = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeMs));
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), fx_select(uartFd + 1, _, _, _, _))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectTimeOut)), Return(MOCK_SELECT_TIME_OUT)));
|
|
||||||
EXPECT_CALL(*mock.get(), fx_read(uartFd, _, _)).WillRepeatedly(DoAll(Return(UART_DEVICE_READ_NOTHING)));
|
|
||||||
mDeviceMap[uart.mDevice] = uartFd;
|
|
||||||
return uartFd;
|
|
||||||
}
|
|
||||||
int UartDeviceTestTool::GetDeviceMockFd(const UartInfo &uart)
|
|
||||||
{
|
|
||||||
std::map<const char *, int>::iterator iter;
|
|
||||||
iter = mDeviceMap.find(uart.mDevice);
|
|
||||||
if (iter == mDeviceMap.end()) {
|
|
||||||
LogError("Can't found the uart device[%s].\n", uart.mDevice);
|
|
||||||
return INVALID_FD;
|
|
||||||
}
|
|
||||||
return mDeviceMap[uart.mDevice];
|
|
||||||
}
|
|
||||||
void UartDeviceTestTool::UnregisterUartDevice(const UartInfo &uart)
|
|
||||||
{
|
|
||||||
std::map<const char *, int>::iterator iter;
|
|
||||||
iter = mDeviceMap.find(uart.mDevice);
|
|
||||||
if (iter != mDeviceMap.end()) {
|
|
||||||
mDeviceMap.erase(iter);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LogError("Can't found the uart device[%s].\n", uart.mDevice);
|
|
||||||
}
|
|
||||||
void UartDeviceTestTool::SetSendApiOnce(std::shared_ptr<LinuxTest> &mock, const UartInfo &uart, const ssize_t &length)
|
|
||||||
{
|
|
||||||
std::map<const char *, int>::iterator iter;
|
|
||||||
iter = mDeviceMap.find(uart.mDevice);
|
|
||||||
if (iter == mDeviceMap.end()) {
|
|
||||||
LogError("Can't found the uart device[%s].\n", uart.mDevice);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EXPECT_CALL(*mock.get(), fx_write(mDeviceMap[uart.mDevice], _, _))
|
|
||||||
.WillOnce(DoAll(Return(length)))
|
|
||||||
.WillRepeatedly(DoAll(SaveArg<2>(&WRITE_COUNT), ReturnPointee(&WRITE_COUNT)));
|
|
||||||
}
|
|
||||||
void UartDeviceTestTool::SetRecvApiOnce(std::shared_ptr<LinuxTest> &mock, const UartInfo &uart, void *recvBuff,
|
|
||||||
const ssize_t &length)
|
|
||||||
{
|
|
||||||
std::map<const char *, int>::iterator iter;
|
|
||||||
iter = mDeviceMap.find(uart.mDevice);
|
|
||||||
if (iter == mDeviceMap.end()) {
|
|
||||||
LogError("Can't found the uart device[%s].\n", uart.mDevice);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int uartFd = mDeviceMap[uart.mDevice];
|
|
||||||
auto selectSucceed =
|
|
||||||
[=, &mock](int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
|
|
||||||
FD_ZERO(readfds);
|
|
||||||
FD_SET(uartFd, readfds);
|
|
||||||
};
|
|
||||||
auto selectTimeOut =
|
|
||||||
[=, &mock](int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
|
|
||||||
long long timeMs = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeMs));
|
|
||||||
};
|
|
||||||
constexpr int SELECT_READABLE = 1;
|
|
||||||
EXPECT_CALL(*mock.get(), fx_select(uartFd + 1, _, _, _, _))
|
|
||||||
.WillOnce(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectSucceed)), Return(SELECT_READABLE)))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectTimeOut)), Return(MOCK_SELECT_TIME_OUT)));
|
|
||||||
auto readBuf = [=, &mock](int fd, void *buf, size_t count) {
|
|
||||||
memcpy(buf, recvBuff, length);
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), fx_read(uartFd, _, _))
|
|
||||||
.WillOnce(DoAll(WithArgs<0, 1, 2>(Invoke(readBuf)), Return(length)))
|
|
||||||
.WillRepeatedly(DoAll(Return(UART_DEVICE_READ_NOTHING)));
|
|
||||||
}
|
|
||||||
void UartDeviceTestTool::SetUartDeviceOpenFailed(std::shared_ptr<LinuxTest> &mock, const UartInfo &uart)
|
|
||||||
{
|
|
||||||
LogInfo("SetUartDeviceOpenFailed[%s], will return -1\n", uart.mDevice);
|
|
||||||
EXPECT_CALL(*mock.get(), fx_open(uart.mDevice, _)).WillRepeatedly(DoAll((Return(-1))));
|
|
||||||
}
|
|
||||||
void UartDeviceTestTool::SetUartDeviceReadNothing(std::shared_ptr<LinuxTest> &mock, const UartInfo &uart)
|
|
||||||
{
|
|
||||||
SetUartDeviceTimeOut(mock, uart);
|
|
||||||
int uartFd = mDeviceMap[uart.mDevice];
|
|
||||||
EXPECT_CALL(*mock.get(), fx_read(uartFd, _, _)).WillRepeatedly(DoAll(Return(UART_DEVICE_READ_NOTHING)));
|
|
||||||
}
|
|
||||||
void UartDeviceTestTool::SetUartDeviceTimeOut(std::shared_ptr<LinuxTest> &mock, const UartInfo &uart)
|
|
||||||
{
|
|
||||||
int uartFd = mDeviceMap[uart.mDevice];
|
|
||||||
auto selectTimeOut =
|
|
||||||
[=, &mock](int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
|
|
||||||
long long timeMs = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeMs));
|
|
||||||
};
|
|
||||||
EXPECT_CALL(*mock.get(), fx_select(uartFd + 1, _, _, _, _))
|
|
||||||
.WillRepeatedly(DoAll(WithArgs<0, 1, 2, 3, 4>(Invoke(selectTimeOut)), Return(MOCK_SELECT_TIME_OUT)));
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user