BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
plottableitems.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/plottableitems.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"
18 #include <QColor>
19 
20 using namespace ModelView;
21 
22 //! Testing PlottableItemsTest.
23 
24 class PlottableItemsTest : public ::testing::Test {
25 public:
27 };
28 
30 
31 //! Initial state.
32 
33 TEST_F(PlottableItemsTest, penItem_initialState)
34 {
35  PenItem item;
36  EXPECT_EQ(item.property<QColor>(PenItem::P_COLOR), QColor(Qt::black));
37  EXPECT_EQ(item.property<int>(PenItem::P_WIDTH), 1);
38  EXPECT_EQ(item.property<ComboProperty>(PenItem::P_STYLE).currentIndex(), Qt::SolidLine);
39 }
40 
41 TEST_F(PlottableItemsTest, penItem_setSelected)
42 {
43  PenItem item;
44 
45  item.setSelected(true);
46  EXPECT_EQ(item.property<ComboProperty>(PenItem::P_STYLE).currentIndex(), Qt::DashLine);
47 
48  item.setSelected(false);
49  EXPECT_EQ(item.property<ComboProperty>(PenItem::P_STYLE).currentIndex(), Qt::SolidLine);
50 }
51 
52 TEST_F(PlottableItemsTest, penItem_setNamedColor)
53 {
54  PenItem item;
55  item.setNamedColor("mediumaquamarine");
56  EXPECT_EQ(item.colorName(), std::string("#66cdaa"));
57 }
Custom property to define list of string values with multiple selections.
Definition: comboproperty.h:27
Represents basics settings of QPen.
static const std::string P_STYLE
static const std::string P_COLOR
static const std::string P_WIDTH
void setSelected(bool is_selected)
Sets style of the pen to represent selected object (dash line).
std::string colorName() const
Returns color name in #RRGGBB format.
void setNamedColor(const std::string &named_color)
Sets named color following schema from https://www.w3.org/TR/css-color-3/#svg-color.
T property(const std::string &tag) const
Returns data stored in property item.
Definition: sessionitem.h:181
Testing PlottableItemsTest.
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?
TEST_F(PlottableItemsTest, penItem_initialState)
Initial state.