BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
colormapitem.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/testmodel/colormapitem.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"
16 #include "mockwidgets.h"
23 
24 using namespace ModelView;
25 using ::testing::_;
26 
27 //! Testing ColorMapItem.
28 
29 class ColorMapItemTest : public ::testing::Test {
30 public:
32 };
33 
35 
36 //! Initial state.
37 
38 TEST_F(ColorMapItemTest, initialState)
39 {
40  ColorMapItem item;
41  EXPECT_TRUE(item.dataItem() == nullptr);
42  EXPECT_TRUE(item.property<bool>(ColorMapItem::P_INTERPOLATION));
43  EXPECT_EQ(item.property<ComboProperty>(ColorMapItem::P_GRADIENT).value(), "Polar");
44 }
45 
46 //! Setting dataItem in model context.
47 
48 TEST_F(ColorMapItemTest, setDataItem)
49 {
50  SessionModel model;
51  auto data_item = model.insertItem<Data2DItem>();
52  auto colormap_item = model.insertItem<ColorMapItem>();
53 
54  colormap_item->setDataItem(data_item);
55 
56  EXPECT_EQ(colormap_item->dataItem(), data_item);
57 }
58 
59 //! Check signaling on set data item.
60 
61 TEST_F(ColorMapItemTest, onSetDataItem)
62 {
63  SessionModel model;
64  auto data_item = model.insertItem<Data2DItem>();
65  auto colormap_item = model.insertItem<ColorMapItem>();
66 
67  MockWidgetForItem widget(colormap_item);
68 
69  EXPECT_CALL(widget, onDataChange(_, _)).Times(0);
70  EXPECT_CALL(widget, onPropertyChange(colormap_item, ColorMapItem::P_LINK)).Times(1);
71  EXPECT_CALL(widget, onChildPropertyChange(_, _)).Times(0);
72  EXPECT_CALL(widget, onItemInserted(_, _)).Times(0);
73  EXPECT_CALL(widget, onAboutToRemoveItem(_, _)).Times(0);
74 
75  // performing action
76  colormap_item->setDataItem(data_item);
77 }
Defines class CLASS?
Testing ColorMapItem.
Mock widget to test ItemMapper functionality.
Definition: mockwidgets.h:36
Two-dimensional color map representation of Data2DItem.
Definition: colormapitem.h:28
static const std::string P_INTERPOLATION
Definition: colormapitem.h:33
static const std::string P_LINK
Definition: colormapitem.h:30
static const std::string P_GRADIENT
Definition: colormapitem.h:32
Data2DItem * dataItem() const
Returns data item linked to the given ColorMapItem.
Custom property to define list of string values with multiple selections.
Definition: comboproperty.h:27
std::string value() const
Represents two-dimensional data (axes definition and 2d array of values).
Definition: data2ditem.h:29
T property(const std::string &tag) const
Returns data stored in property item.
Definition: sessionitem.h:181
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
T * insertItem(SessionItem *parent=nullptr, const TagRow &tagrow={})
Inserts item into given parent under given tagrow.
Definition: sessionmodel.h:104
Defines class CLASS?
TEST_F(ColorMapItemTest, initialState)
Initial state.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?