File indexing completed on 2024-05-19 05:42:26

0001 // ct_lvtqtw_exportmanager.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_graphicsview.h>
0021 #include <ct_lvtqtc_testing_utils.h>
0022 
0023 #include <ct_lvtclr_colormanagement.h>
0024 #include <ct_lvtldr_nodestorage.h>
0025 #include <ct_lvtqtc_lakosrelation.h>
0026 #include <ct_lvtqtw_exportmanager.h>
0027 #include <ct_lvttst_fixture_qt.h>
0028 
0029 #include <catch2-local-includes.h>
0030 
0031 #include <QFileInfo>
0032 #include <QTemporaryDir>
0033 
0034 using namespace Codethink::lvtqtc;
0035 using namespace Codethink::lvtqtw;
0036 using namespace Codethink::lvtclr;
0037 using namespace Codethink::lvtshr;
0038 using namespace Codethink::lvtprj;
0039 
0040 TEST_CASE_METHOD(QTApplicationFixture, "Export graphicsview contents to image files")
0041 {
0042     Codethink::lvtldr::NodeStorage storage;
0043     auto projectFile = ProjectFileForTesting{};
0044     auto *view = new Codethink::lvtqtc::GraphicsView(storage, projectFile);
0045 
0046     view->show();
0047     QApplication::processEvents();
0048 
0049     Codethink::lvtqtw::ExportManager manager(view);
0050 
0051     QTemporaryDir dir;
0052     QString filename = dir.path() + "/file.svg";
0053 
0054     auto ret = manager.exportSvg(filename);
0055     REQUIRE(ret.has_value());
0056 
0057     QFileInfo info(filename);
0058     REQUIRE(info.exists());
0059 }