Skip to content
Snippets Groups Projects
Commit a2858a88 authored by Ming Rui Zhang's avatar Ming Rui Zhang
Browse files

test: change the location of local storage files when running tests

Change-Id: I6ee537ee1ee3928c93b9a579e2b55b6ef97af779
parent 70c520e8
No related branches found
No related tags found
No related merge requests found
...@@ -127,8 +127,8 @@ Only 64-bit MSVC build can be compiled. ...@@ -127,8 +127,8 @@ Only 64-bit MSVC build can be compiled.
```sh ```sh
git clone https://review.jami.net/ring-project git clone https://review.jami.net/ring-project
cd ring-project/ cd ring-project/
git submodule update --init daemon lrc client-windows git submodule update --init daemon lrc client-qt
git submodule update --recursive --remote daemon lrc client-windows git submodule update --recursive --remote daemon lrc client-qt
``` ```
- Using **Elevated Command Prompt** - Using **Elevated Command Prompt**
```sh ```sh
...@@ -212,7 +212,7 @@ Only 64-bit MSVC build can be compiled. ...@@ -212,7 +212,7 @@ Only 64-bit MSVC build can be compiled.
- In Visual Studio, download WiX Toolset Visual Studio Extension. - In Visual Studio, download WiX Toolset Visual Studio Extension.
- Build client-windows project first, then the JamiInstaller project, msi package should be stored in ring-project\client-windows\JamiInstaller\bin\Release - Build client-windows project first, then the JamiInstaller project, msi package should be stored in ring-project\client-windows\JamiInstaller\bin\Release
## Testing For Client-qt ## Testing for Client-qt on Windows
- We currently use [GoogleTest](https://github.com/google/googletest) and [Qt Quick Test](https://doc.qt.io/qt-5/qtquicktest-index.html#introduction) in our product. To build and run tests, you could use the following command. - We currently use [GoogleTest](https://github.com/google/googletest) and [Qt Quick Test](https://doc.qt.io/qt-5/qtquicktest-index.html#introduction) in our product. To build and run tests, you could use the following command.
...@@ -221,6 +221,16 @@ Only 64-bit MSVC build can be compiled. ...@@ -221,6 +221,16 @@ Only 64-bit MSVC build can be compiled.
python make-client.py runtests python make-client.py runtests
``` ```
- Note that, for tests, the path of local storage files for jami will be changed based on following environment variables.
```
%JAMI_DATA_HOME% = %TEMP% + '\\jami_test\\jami'
%JAMI_CONFIG_HOME% = %TEMP% + '\\jami_test\\.config'
%JAMI_CACHE_HOME% = %TEMP% + '\\jami_test\\.cache'
```
- These environment variables will be temporarily set when using make-client.py to run tests.
## Debugging ## Debugging
Compile the client with `BUILD=Debug` and compile LibRingClient with Compile the client with `BUILD=Debug` and compile LibRingClient with
......
...@@ -21,6 +21,7 @@ vs_where_path = os.path.join( ...@@ -21,6 +21,7 @@ vs_where_path = os.path.join(
host_is_64bit = (False, True)[platform.machine().endswith('64')] host_is_64bit = (False, True)[platform.machine().endswith('64')]
this_dir = os.path.dirname(os.path.realpath(__file__)) this_dir = os.path.dirname(os.path.realpath(__file__))
build_dir = this_dir + '\\build' build_dir = this_dir + '\\build'
temp_path = os.environ['TEMP']
# project path # project path
jami_qt_project = build_dir + '\\jami-qt.vcxproj' jami_qt_project = build_dir + '\\jami-qt.vcxproj'
...@@ -31,6 +32,11 @@ qml_test_project = build_dir + '\\tests\\qml_tests.vcxproj' ...@@ -31,6 +32,11 @@ qml_test_project = build_dir + '\\tests\\qml_tests.vcxproj'
qml_test_exe = this_dir + '\\x64\\test\\qml_tests.exe -input ' + this_dir + '\\tests\\qml' qml_test_exe = this_dir + '\\x64\\test\\qml_tests.exe -input ' + this_dir + '\\tests\\qml'
unit_test_exe = this_dir + '\\x64\\test\\unittests.exe' unit_test_exe = this_dir + '\\x64\\test\\unittests.exe'
# test env path
test_data_dir = temp_path + '\\jami_test\\jami'
test_config_dir = temp_path + '\\jami_test\\.config'
test_cache_dir = temp_path + '\\jami_test\\.cache'
class QtVerison(Enum): class QtVerison(Enum):
Major = 0 Major = 0
Minor = 1 Minor = 1
...@@ -308,6 +314,12 @@ def run_tests(mute_dring, output_to_files): ...@@ -308,6 +314,12 @@ def run_tests(mute_dring, output_to_files):
# make sure that the tests are rendered offscreen # make sure that the tests are rendered offscreen
os.environ["QT_QPA_PLATFORM"] = 'offscreen' os.environ["QT_QPA_PLATFORM"] = 'offscreen'
os.environ["QT_QUICK_BACKEND"] = 'software' os.environ["QT_QUICK_BACKEND"] = 'software'
# set test env variables
os.environ["JAMI_DATA_HOME"] = test_data_dir
os.environ["JAMI_CONFIG_HOME"] = test_config_dir
os.environ["JAMI_CACHE_HOME"] = test_cache_dir
for test_exe_command in test_exe_command_list: for test_exe_command in test_exe_command_list:
if (execute_cmd(test_exe_command, True)): if (execute_cmd(test_exe_command, True)):
test_result_code = 1 test_result_code = 1
......
...@@ -195,6 +195,8 @@ main(int argc, char** argv) ...@@ -195,6 +195,8 @@ main(int argc, char** argv)
argc = std::distance(argv, end); argc = std::distance(argv, end);
} }
QStandardPaths::setTestModeEnabled(true);
QTEST_SET_MAIN_SOURCE_PATH QTEST_SET_MAIN_SOURCE_PATH
Setup setup(muteDring); Setup setup(muteDring);
return quick_test_main_with_setup(argc, argv, "qml_test", nullptr, &setup); return quick_test_main_with_setup(argc, argv, "qml_test", nullptr, &setup);
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "globaltestenvironment.h" #include "globaltestenvironment.h"
#include <QApplication> #include <QApplication>
#include <QStandardPaths>
#include <gtest/gtest.h> #include <gtest/gtest.h>
bool muteDring; bool muteDring;
...@@ -40,6 +42,8 @@ main(int argc, char* argv[]) ...@@ -40,6 +42,8 @@ main(int argc, char* argv[])
argc = std::distance(argv, end); argc = std::distance(argv, end);
} }
QStandardPaths::setTestModeEnabled(true);
QApplication a(argc, argv); QApplication a(argc, argv);
a.processEvents(); a.processEvents();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment