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

0001 // mainwindow_auto_add_edges_from_components.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, "Show Error On Add Edge Failure")
0040 {
0041     Preferences::self()->useDefaults(true);
0042 
0043     clickOn(Menubar::File::NewProject{});
0044 
0045     clickOn(Sidebar::ManipulationTool::NewPackage{"abc"});
0046     clickOn(CurrentGraph{100, 400});
0047     QTest::qWait(1000);
0048 
0049     clickOn(Sidebar::VisualizationTool::ResetZoom{});
0050 
0051     auto point = findElementTopLeftPosition("abc");
0052     clickOn(Sidebar::ManipulationTool::NewPackage{"abcxyz"});
0053     clickOn(CurrentGraph{point});
0054     QTest::qWait(1000);
0055 
0056     point = findElementTopLeftPosition("abc/abcxyz");
0057 
0058     clickOn(Sidebar::ManipulationTool::NewPackage{"def"});
0059     clickOn(CurrentGraph{450, 450});
0060     QTest::qWait(1000);
0061     point = findElementTopLeftPosition("def");
0062 
0063     clickOn(Sidebar::ManipulationTool::AddDependency{});
0064     auto element1 = findElementTopLeftPosition("abc/abcxyz");
0065 
0066     clickOn(CurrentGraph{element1});
0067     auto element2 = findElementTopLeftPosition("def");
0068 
0069     clickOn(CurrentGraph{element2});
0070     REQUIRE(window().currentMessage() == "Cannot create dependency on different hierarchy levels");
0071 }