aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testgitstorage.cpp
AgeCommit message (Collapse)Author
2019-06-19Cleanup: move trip-related functions into own translation unitGravatar Berthold Stoeger
These functions were spread out over dive.c and divelist.c. Move them into their own file to make all this a bit less monolithic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: prepare for dive site ref-countingGravatar Berthold Stoeger
Add a dive site table to each dive site to keep track of dives that have been added to a dive site. Add two functions to add dives to / remove dives from dive sites. Since dive sites now contain a dive table, the order of includes had to be changed: "divesite.h" now includes "dive.h" and not vice-versa. This caused some include churn. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Parser: parse into custom dive site tableGravatar Berthold Stoeger
To extend the undo system to dive sites, the importers and downloaders must not parse directly into the global dive site table. Instead, pass a dive_site_table argument to parse into. For now, always pass the global dive_site_table so that this commit should not cause any functional change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: split process_imported_dives() functionGravatar Berthold Stoeger
Split the process_imported_dives() function in two: 1) process_imported_dives() processes the dives and generates a list of dives and trips to be added and removed. 2) add_imported_dives() calls process_imported_dives() and does the actual removal / addition of dives and trips. The goal is to split preparation and actual work, to make dive import undo-able. The code adds extra checks to never merge into the same dive twice, as this would lead to a double-free() bug. This should in principle never happen, as dives that compare equal according to is_same_dive() are merged in the imported-dives list, but perhaps in some pathologival corner-cases is_same_dive() turns out to be non-transitive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Parser: add trip_table parameter to parsing functionsGravatar Berthold Stoeger
To allow parsing into arbitrary trip_tables, add the corresponding parameter to the parsing functions and the parser state. Currently, all callers pass the global trip_table so there should be no change in functionality. These arguments will be replaced in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-23Core: split process_dives() in post-import and post-load versionsGravatar Berthold Stoeger
process_dives() is used to post-process the dive table after loading or importing. The first parameter states whether this was after load or import. Especially in the light of undo, load and import are fundamentally different things. Notably, that latter should be undo-able, whereas the former is not. Therefore, as a first step to make import undo-able, split the function in two versions and remove the first parameter. It turns out the the load-version is very light. It only sets the DC nicknames and sorts the dive-table. There seems to be no reason to merge dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-25core/tests: remove QSettings from testgitstorageGravatar jan Iversen
update testgitstorage.cpp to use qPrefProxy and qPrefCloudStorage remove core/prefs-macros.h since it is unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-23Parse: pass dive_table argument to parse_file()Gravatar Berthold Stoeger
To enable undo of divelog-importing it is crucial that parse_file() can parse into arbitrary dive tables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: introduce copy_qstring() functionGravatar Berthold Stoeger
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common occurrences that they seem worthy of a short helper-function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06Remove cloud_background_sync preferences optionGravatar Berthold Stoeger
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>
2017-12-03Fix typo in TestGitStorage: SapleDives -> SampleDivesGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-03Add tests to read/write "file://..." style local git repositoriesGravatar Berthold Stoeger
Requested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-04-29Add SPDX header to testsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04Use QTest cleanup method for proper test shutdownGravatar Jeremie Guichard
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-04Use proper QTest initialization method in TestGitStorageGravatar Jeremie Guichard
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-02-24Fix "Load/Save to cloudstorage" for non-ASCII user namesGravatar Jeremie Guichard
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-24Make TestGitStorage::testGitStorageLocal parametrizableGravatar Jeremie Guichard
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-24Replace pPrintable with qUtf8Printable in TestGitStorageGravatar Jeremie Guichard
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-24Use SUBSURFACE_TEST_DATA definition to point to test data dirGravatar Jeremie Guichard
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-05Our tests are actually GUILESSGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05Fix compilation with the new folder architectureGravatar Tomaz Canabrava
A few more fixes for things that broke in commit 7be962bfc287 ("Move subsurface-core to core and qt-mobile to mobile-widgets"). [Dirk Hohndel: slightly edited and overlap with Linus' patch removed] Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23Prevent possible SIGSEGV in testGravatar Dirk Hohndel
If the load fails the get_dive(1) could return NULL. Let's catch that as an error instead of having the test crash. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-07Remove unnecessary call from testsGravatar Dirk Hohndel
Now that the WindowTitleUpdater is fixed we don't need to create an instance in the tests, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06Correctly copy preferencesGravatar Dirk Hohndel
When just assigning one structure to the other we copy the string pointers. If we then modify those strings in the copy, we happily free the strings of the original. And then resetting the preferences equally happily reused those strings, pointing to long since freed memory. I think what I did now is excessive for the current use case in that it copies a ton of strings that are unset in the default_prefs. But I figured this is a rarely used function and I might as well do it correctly. Also, once we implement multi user support with per user preferences we will be copying completely populated preferences around (at least that's my guess). Fixes #940 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18Git storage test: need to instantiate the window title updater classGravatar Dirk Hohndel
Otherwise calling the static function can cause a crash in mark_divelist_changed() Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-02Prevent tests from hanging when offlineGravatar Robert C. Helling
From 31e324797c06d366f49db453a67a119819ca8012 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <helling@atdotde.de> Date: Wed, 2 Sep 2015 17:28:12 +0200 Subject: [PATCH] Test that there is a dive so that the TestGitStorage does not hang when offline. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-30Add test case for multi line dive notes mergingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: second merge test, delete dive on one side, modify on otherGravatar Dirk Hohndel
Delete a dive while offline, modify it from a different system while online. Then resync. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: first test case for a very simple mergeGravatar Dirk Hohndel
- We add a dive while offline. - On a different computer (here simulated by a different local cache) we add a different file. - Now we go back to the previous local cache (the one where we added a different dive in the first step) and take that online (i.e., connect to cloud storage). Now both of the new dives should have been added to our data file. This is a rather trivial test with no conflict and a straight forward merge. We need to add a lot more test cases to make sure this works as expected and doesn't leave the user with a corrupt state. Ideally whatever happens, the user should never see an error... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: test offline operationGravatar Dirk Hohndel
All this really does is make sure that the fast forward works if the local cache has received updates that haven't made it to the server, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: add test for simple save / load from our test accountGravatar Dirk Hohndel
This will fail if the proxy settings of the user running the test are incorrect. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Add simple test for git storageGravatar Dirk Hohndel
This just makes sure that writing data to git storage and reading it back gives you the same result. Without the fixed generation of initial dive site UUIDs this fails. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>