File indexing completed on 2024-05-19 05:41:56

0001 // mainwindow.t.cpp                                      -*-C++-*-
0002 
0003 /*
0004  * // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk>
0005  * // SPDX-License-Identifier: Apache-2.0
0006  * //
0007  * // Licensed under the Apache License, Version 2.0 (the "License");
0008  * // you may not use this file except in compliance with the License.
0009  * // You may obtain a copy of the License at
0010  * //
0011  * //     http://www.apache.org/licenses/LICENSE-2.0
0012  * //
0013  * // Unless required by applicable law or agreed to in writing, software
0014  * // distributed under the License is distributed on an "AS IS" BASIS,
0015  * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016  * // See the License for the specific language governing permissions and
0017  * // limitations under the License.
0018  */
0019 
0020 #include <ct_lvtqtc_graphicsscene.h>
0021 #include <ct_lvtqtc_graphicsview.h>
0022 #include <ct_lvtqtc_lakosrelation.h>
0023 #include <ct_lvttst_fixture_qt.h>
0024 
0025 #include <apptesting_fixture.h>
0026 #include <catch2-local-includes.h>
0027 #include <variant>
0028 
0029 #include <preferences.h>
0030 
0031 // in a header
0032 Q_DECLARE_LOGGING_CATEGORY(LogTest)
0033 
0034 // in one source file
0035 Q_LOGGING_CATEGORY(LogTest, "log.test")
0036 
0037 using namespace Codethink::lvtldr;
0038 
0039 TEST_CASE_METHOD(CodeVisApplicationTestFixture, "Test Auto Save")
0040 {
0041     Preferences::setAutoSaveBackupIntervalMsecs(0);
0042 
0043     clickOn(Menubar::File::NewProject{});
0044 
0045     // first, let's delete any possible backup file from pre-existing runs.
0046     auto backupPath = window().projectFile().backupPath();
0047     std::filesystem::remove(backupPath);
0048     REQUIRE_FALSE(std::filesystem::exists(backupPath));
0049 
0050     clickOn(Sidebar::ManipulationTool::NewPackage{"abc"});
0051     clickOn(CurrentGraph{100, 400});
0052 
0053     REQUIRE(std::filesystem::exists(backupPath.string()));
0054 
0055     // let's clean our trash.
0056     std::filesystem::remove(backupPath);
0057 }