Commit graph

156 commits

Author SHA1 Message Date
Berthold Stoeger
b750a48f0f Cleanup: Don't store hash in picture struct in learnHash()
learnHash() is called either on a local picture structure
[DiveListView::loadImageFromURL()] or on a cloned picture structure
[ImageDownloader::saveImage()]. In neither case the picture structure
is passed to the frontend. Therefore, storing the new hash in the
picture struct is not necessary.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Miika Turkia
f2beeb4078 Parameter size needs to be increased for test
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
4a5b40c144 Update DL7 tests to current import
As we now parse dives without profile, we get 2 more dives from the
sample log import (3 in total). And naturally also the resulting XML to
compare against needs to be updated.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
e2197a56a4 Compare DL7 import to saved conversion
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
fbbca93d53 Add test for DL7 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Berthold Stoeger
59526e948a Remove cloud_background_sync preferences option
The preferences flag cloud_background_sync used to be used heavily in
the mobile code, but is not used there anymore. Now, it is accessed
only in one place, but does not do what it actually says: If it is off,
the remote storage is not synced on save (but will be synced on next
load).

Syncing on save can also be prevented by unchecking the "Cloud online"
menu checkbox. Since the latter seems more logical and general
(support for non-cloud remote git repositories), remove the cloud_background_sync
option.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
cab0699d4c Fix typo in TestGitStorage: SapleDives -> SampleDives
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-03 19:07:03 -08:00
Berthold Stoeger
d775adfb29 Add tests to read/write "file://..." style local git repositories
Requested-by: Dirk Hohndel <dirk@hohndel.org>

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-03 08:26:43 -08:00
Miika Turkia
02c80a60b0 Refactore parse-xml.c into parse.c and parse-xml.c
This should help us to move parsing that is not XML related to other
files, hopefully making the code cleaner.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
e17ad1b0e0 Add test for DM5 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Robert C. Helling
8e21a65653 Localize global planner state
For UI responsiveness, we need to be able to run the planner in the background. This needs the
planner state to be localized (and we need to pass a pointer around).

In order to not let too many lines overrun (and to save typing in the future)
I have renamed instances of struct deco_state to ds. Yes this should have gone
to a separate commit but I accidentally commit --amend'ed it.

Computing of planner variations is temporarily disabled.

Unlock the planner when returning early

So we don't deadlock in add dive and recreational mode (which
use the planner without actually planning).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Berthold Stoeger
dd8e4fae2a Make handling of booleans consistent on the C++-side of preferences
In general, the C++-side of the preferences code consistently uses
the bool data type for boolean settings. There are five exceptions,
which use short instead:
  showPo2
  showPn2
  showPhe
  saveUserIdLocal
  displayInvalidDives
This patch attempts to make the code more consistent by turning
these into bools as well.

Tests showed that writing as short and reading as bool is handled
gracefully by the Qt variant code. Therefore, an upgrade should not
cause user-visible changes to their settings.

As a bonus, two extern declarations of the set_save_userid_local()
function, which is not defined anywhere, were removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
b32251a5a8 Typo: modp02 -> modpO2
Fixes two function names, where O2 was written as 02.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-12 15:11:30 +01:00
Stefan Fuchs
4e320cca5b Remove three obsolete preferences options for geocoding
These options are not used any longer/were never used and can be
removed to not confuse the users.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-29 11:07:52 -07:00
Robert C. Helling
1f50485732 More VPMB state in special structure
... and reset deco information in profile ceiling computation.

The planner test then needs to know about the struct holding the deco
state.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-01 23:58:55 +03:00
Robert C. Helling
5b080bedde Remove option to apply GFlow at maxdepth
This option should have never been there. This is not how
gradient factors are supposed to work. It would only trick
users to use the wrong value..

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Robert C. Helling
e6545a7b0f Store a table of deco stops in planner
... in addition to struct diveplan which combines all kinds
of information

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
82aac4efff Make plan take dive and decotimestep as arguments
...rather than use a global variable and a macro.

This should be a no-op in preparation to allow planning
several versions of a dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Seamus Boyle
252dfaf6d1 TestPreferences: Fix update manager test date
QDate::addDays() returns a copy with the changed date, calling it and
ignoring the return value does nothing.

Signed-off-by: Seamus Boyle <seamus@beantrader.com.au>
2017-07-04 11:54:54 +09:00
Dirk Hohndel
c6bc88b50d Fix some warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:21:37 -07:00
Robert C. Helling
7b18be2a50 Adopt planner state caching to new struct
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00
Miika Turkia
726c9e859c Test case for CSV profile export to imperial and back
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-12 14:05:33 -07:00
Dirk Hohndel
d7cf3408e5 Merge branch 'seabear-refactor'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-07 07:52:55 -07:00
Miika Turkia
0829d601c6 Change test case to use new Seabear parsing function
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 16:32:11 +03:00
Miika Turkia
ab1813a445 Move intdup to qthelper
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 09:41:27 +03:00
Stefan Fuchs
67fbf6009a Test for adding a picture with data after JFIF EOI to a dive
Add one more picture to the already existing test.
This new picture is a JPEG and has data after JFIF EOI tag.

Suggested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-06 10:31:09 -07:00
Miika Turkia
b7c6998cf7 Enable test mode in UDDF export test
Using the units parameter to indicate test mode on UDDF export.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-06 08:06:42 -07:00
Miika Turkia
e52d9c2846 Add UDDF export-import test
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-06 08:06:42 -07:00
Miika Turkia
52426b8585 Fix memory leak
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-06 08:06:42 -07:00
Dirk Hohndel
ee1bf18189 Add SPDX header to tests
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Miika Turkia
2b2df88e87 Cleanup for CSV testing
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Miika Turkia
8bb9eb501b Enable CSV import-export unit conversion test
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Miika Turkia
acd791b7c1 Export-import test for manual CSV
Note that the actual validation of the result is currently disabled, so
the tests will pass even though there are some bugs and rounding errors
present.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Miika Turkia
a0ed0ff823 Change parseCSV to support unit and file selection
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-04-01 08:06:09 -07:00
Jan Mulder
622ab2286a minimal pO2 threshold: corrected testpreferences
Adapt the testpreferences procedure for the new min/max pO2 preference.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-03-28 11:17:03 -07:00
Jeremie Guichard
597539ce39 Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint

Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.

Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-24 09:39:25 -07:00
Stefan Fuchs
6f21d2749e Tests for minimum gas
Add automatic tests in TestPlan for minimum gas:
- Copy minimum gas result (pressure) to diveplan.
- Add cylinder size and working pressure for bottom gas to every dive in TestPlan
  Hint: Unrealistic cylinder sizes (100l, 200l) have to be used for the very long and deep dives in TestPlan
- Add minimum gas check for every dive
- Add two additional test dives in TestPlan which produce sane minimum gas results with 24l tank
  Hint: Deco check for these new dives is commented out at the moment

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-19 17:11:52 -07:00
Jeremie Guichard
1ff0aeed4c Fix error in install target for tests on Windows
The rule was working when called from the fake test
used as preparation step in check target on Windows,
but did not work for the normal install target.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-11 08:05:22 -08:00
Jeremie Guichard
ea4df67b32 Fix failures in TestPreferences for Windows run
QSettings needs OrganizationName and ApplicationName
to be set to work properly under Windows.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-11 08:05:22 -08:00
Jeremie Guichard
b9a3dfb86b Rework TestParse to make tests independent from each other
In the original version, parsing and comparing output was
done in separate test methods. This was forbidding use of
QTest cleanup to call clear_dive_file_data().
As a side effect a failure in one test would make other tests
failing too (since call to clear_dive_file_data was skipped
by QCOMPARE failure).

Added a FILE_COMPARE macro to avoid code duplication.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-04 12:03:33 -08:00
Jeremie Guichard
5caa9b23fe Use QTest cleanup method for proper test shutdown
In case of QCOMPARE failure, code following the comparison
is not executed, this results in application state not being
properly resorted and often gives several test failures,
when only one test really fails.
Using QTest cleanup method allows restoring proper state,
before next test is executed.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-04 12:03:33 -08:00
Jeremie Guichard
16a321d43b Use proper QTest initialization method in TestGitStorage
Method originally called testSetup is more a precondition
to test execution rather than an actual test.
QTest recommends to use initTestCase for that purpose.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-04 12:03:33 -08:00
Jeremie Guichard
7329629b6e Use proper order in QCOMPARE arguments
Expected value is the second argument of QCOMPARE,
having the arguments in the right order avoid confusion
when looking at error message in case of test failure.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-04 12:03:33 -08:00
Jeremie Guichard
f28aab7bd9 Fix trailing '\r' test failure on Windows
Windows implementation of fwrite changes \n to \r\n
for files opened in text mode.
It caused failures in TestMerge and TestParse when
comparing written files against reference data.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-25 09:24:23 -08:00
Jeremie Guichard
08bc1edc81 Improve install and test rules for Windows test execution
Update install rules to create a staging_tests folder
for easy deployment to test target.

Update test rules for compile time testing
when wine is available on build machine.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-25 09:24:23 -08:00
Jeremie Guichard
7b08f8d23c Move CMake variables printing into a utility macro
Added cmake_variables_helper.cmake providing 2 helpers
 - print_variable
 - print_all_variables

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-25 09:24:23 -08:00
Jeremie Guichard
5ed93a9d9e Fix "Load/Save to cloudstorage" for non-ASCII user names
On Windows that would fail because stat() doesn't deal well with our
utf8 strings.

Added new subsurface_stat() portability function to replace stat().
Added Windows implementation of subsurface_stat() using wstat(),
with conversion to ut16 of the inputed path.
Other platform implementations (linux, android) make use of the normal stat().

Added non ASCII test case in TestGitStorage::testGitStorageLocal()

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-24 01:10:22 -08:00
Jeremie Guichard
5640a6a839 Make TestGitStorage::testGitStorageLocal parametrizable
Make use of QTest "Data Driven Testing",
allowing to test multiple repo base path values.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-24 01:10:22 -08:00
Jeremie Guichard
56d31c9c1b Replace pPrintable with qUtf8Printable in TestGitStorage
Update TestGitStorage to use qUtf8Printable instead of pPrintable.
This ensures that non-ASCII chars are utf8 encoded before calling internal functions.
In windows case pPrintable returns other codepoint that depends on system settings.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-24 01:10:22 -08:00
Jeremie Guichard
1e2580c3fd Use SUBSURFACE_TEST_DATA definition to point to test data dir
Update tests with a (compile time) option SUBSURFACE_TEST_DATA,
pointing to test data base path. It is needed for cross compilation cases.
SUBSURFACE_TEST_DATA is set to SUBSURFACE_SOURCE by default,
or configurable via cmake option -DSUBSURFACE_TEST_DATA="...".

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-24 01:10:22 -08:00