BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
customplotsceneadapter.test.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/tests/testview/customplotsceneadapter.test.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "google_test.h"
17 #include "qcustomplot.h"
18 
19 using namespace ModelView;
20 
21 //! Testing CustomPlotSceneAdapter.
22 
23 class CustomPlotSceneAdapterTest : public ::testing::Test {
24 public:
26 };
27 
29 
30 //! Scenario when QCustomPlot destroyed before adapter.
31 
32 TEST_F(CustomPlotSceneAdapterTest, customPlotBeforeAdapter)
33 {
34  auto custom_plot = std::make_unique<QCustomPlot>();
35  auto adapter = std::make_unique<CustomPlotSceneAdapter>(custom_plot.get());
36 
37  // destroying QCustomPlot
38  custom_plot.reset();
39 
40  EXPECT_EQ(42, adapter->toSceneX(42));
41  EXPECT_EQ(42, adapter->toSceneY(42));
42  EXPECT_EQ(42, adapter->fromSceneX(42));
43  EXPECT_EQ(42, adapter->fromSceneY(42));
44 }
45 
46 TEST_F(CustomPlotSceneAdapterTest, adapterBeforeCustomPlot)
47 {
48  auto custom_plot = std::make_unique<QCustomPlot>();
49  auto adapter = std::make_unique<CustomPlotSceneAdapter>(custom_plot.get());
50 
51  adapter.reset();
52  custom_plot.reset(); // would cause SEGFAULT if connection to adapter still exists
53 }
Testing CustomPlotSceneAdapter.
Defines class CLASS?
TEST_F(CustomPlotSceneAdapterTest, customPlotBeforeAdapter)
Scenario when QCustomPlot destroyed before adapter.
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.