BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
defaulteditorfactory.test.cpp File Reference

Implements class CLASS? More...

Include dependency graph for defaulteditorfactory.test.cpp:

Go to the source code of this file.

Classes

class  DefaultEditorFactoryTest
 

Functions

 TEST_F (DefaultEditorFactoryTest, boolProperty)
 Tests editor creation on bool property. More...
 
 TEST_F (DefaultEditorFactoryTest, colorProperty)
 Tests editor creation on color property. More...
 
 TEST_F (DefaultEditorFactoryTest, comboProperty)
 Tests editor creation on combo property. More...
 
 TEST_F (DefaultEditorFactoryTest, comboPropertyInStandardModel)
 Tests editor creation on combo property in QStandardItemModel with our variant. More...
 
 TEST_F (DefaultEditorFactoryTest, doubleProperty)
 Tests editor creation on double property. More...
 
 TEST_F (DefaultEditorFactoryTest, doublePropertyWithLimits)
 Tests editor creation on double property with limits. More...
 
 TEST_F (DefaultEditorFactoryTest, editorType)
 Create test editor using EDITOR role. More...
 
 TEST_F (DefaultEditorFactoryTest, externalProperty)
 Tests editor creation on combo property. More...
 
 TEST_F (DefaultEditorFactoryTest, integerProperty)
 Tests editor creation on integer property. More...
 
 TEST_F (DefaultEditorFactoryTest, integerPropertyWithLimits)
 Tests editor creation on integer property with limits. More...
 
 TEST_F (DefaultEditorFactoryTest, unsupportedProperty)
 Tests editor creation on some unsupported property. More...
 

Detailed Description

Implements class CLASS?

Homepage:\n http://www.bornagainproject.org
License:\n GNU General Public License v3 or higher (see COPYING)
Authors
Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)

Definition in file defaulteditorfactory.test.cpp.

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( DefaultEditorFactoryTest  ,
boolProperty   
)

Tests editor creation on bool property.

Definition at line 74 of file defaulteditorfactory.test.cpp.

75 {
76  auto editor = createEditor(QVariant::fromValue(true));
77  EXPECT_TRUE(dynamic_cast<BoolEditor*>(editor.get()));
78 }
Custom editor for QVariant based on bool values.
Definition: booleditor.h:26

◆ TEST_F() [2/11]

TEST_F ( DefaultEditorFactoryTest  ,
colorProperty   
)

Tests editor creation on color property.

Definition at line 135 of file defaulteditorfactory.test.cpp.

136 {
137  auto editor = createEditor(QVariant::fromValue(QColor(Qt::green)));
138  EXPECT_TRUE(dynamic_cast<ColorEditor*>(editor.get()));
139 }
Custom editor for QVariant based on QColor.
Definition: coloreditor.h:28

◆ TEST_F() [3/11]

TEST_F ( DefaultEditorFactoryTest  ,
comboProperty   
)

Tests editor creation on combo property.

Definition at line 143 of file defaulteditorfactory.test.cpp.

144 {
145  auto editor = createEditor(QVariant::fromValue(ComboProperty()));
146  EXPECT_TRUE(dynamic_cast<ComboPropertyEditor*>(editor.get()));
147 }
Custom editor for QVariant based on ComboProperty.
Custom property to define list of string values with multiple selections.
Definition: comboproperty.h:27

◆ TEST_F() [4/11]

TEST_F ( DefaultEditorFactoryTest  ,
comboPropertyInStandardModel   
)

Tests editor creation on combo property in QStandardItemModel with our variant.

Definition at line 188 of file defaulteditorfactory.test.cpp.

189 {
190  QStandardItemModel model;
191  auto parent = model.invisibleRootItem();
192  QList<QStandardItem*> children{new QStandardItem};
193  parent->appendRow(children);
194 
195  auto item = model.item(0, 0);
196  item->setData(QVariant::fromValue(ComboProperty()), Qt::EditRole);
197 
198  auto editor = m_factory->createEditor(model.index(0, 0));
199  EXPECT_TRUE(dynamic_cast<ComboPropertyEditor*>(editor.get()));
200 }

References ModelView::SessionModel::setData().

Here is the call graph for this function:

◆ TEST_F() [5/11]

TEST_F ( DefaultEditorFactoryTest  ,
doubleProperty   
)

Tests editor creation on double property.

Definition at line 109 of file defaulteditorfactory.test.cpp.

110 {
111  auto editor = createEditor(QVariant::fromValue(42.42));
112  EXPECT_TRUE(dynamic_cast<ScientificSpinBoxEditor*>(editor.get()));
113 
114  auto spin_box = editor->findChild<ScientificSpinBox*>();
115  ASSERT_TRUE(spin_box != nullptr);
116  EXPECT_FLOAT_EQ(spin_box->minimum(), -std::numeric_limits<double>::max());
117  EXPECT_FLOAT_EQ(spin_box->maximum(), std::numeric_limits<double>::max());
118 }
Custom editor for QVariant based on double with scientific notation support.

◆ TEST_F() [6/11]

TEST_F ( DefaultEditorFactoryTest  ,
doublePropertyWithLimits   
)

Tests editor creation on double property with limits.

Definition at line 122 of file defaulteditorfactory.test.cpp.

123 {
124  auto editor = createEditor(QVariant::fromValue(42.42), RealLimits::limited(41, 43));
125  EXPECT_TRUE(dynamic_cast<ScientificSpinBoxEditor*>(editor.get()));
126 
127  auto spin_box = editor->findChild<ScientificSpinBox*>();
128  ASSERT_TRUE(spin_box != nullptr);
129  EXPECT_FLOAT_EQ(spin_box->minimum(), 41);
130  EXPECT_FLOAT_EQ(spin_box->maximum(), 43);
131 }
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:125

References ModelView::RealLimits::limited().

Here is the call graph for this function:

◆ TEST_F() [7/11]

TEST_F ( DefaultEditorFactoryTest  ,
editorType   
)

Create test editor using EDITOR role.

Definition at line 179 of file defaulteditorfactory.test.cpp.

180 {
181  auto editor = createEditor(QVariant::fromValue(ComboProperty()), RealLimits(),
183  EXPECT_TRUE(dynamic_cast<SelectableComboBoxEditor*>(editor.get()));
184 }
Limits for double.
Definition: reallimits.h:25
Adds multi-selection capabilities to QComboBox.
const std::string SelectableComboPropertyEditorType

References ModelView::Constants::SelectableComboPropertyEditorType.

◆ TEST_F() [8/11]

TEST_F ( DefaultEditorFactoryTest  ,
externalProperty   
)

Tests editor creation on combo property.

Definition at line 151 of file defaulteditorfactory.test.cpp.

152 {
153  auto editor = createEditor(QVariant::fromValue(ExternalProperty()));
154  EXPECT_TRUE(dynamic_cast<ExternalPropertyEditor*>(editor.get()));
155 }
Custom editor for QVariant based on ExternalProperty.
Property to carry text, color and identifier.

◆ TEST_F() [9/11]

TEST_F ( DefaultEditorFactoryTest  ,
integerProperty   
)

Tests editor creation on integer property.

Definition at line 82 of file defaulteditorfactory.test.cpp.

83 {
84  auto editor = createEditor(QVariant::fromValue(42));
85  EXPECT_TRUE(dynamic_cast<IntegerEditor*>(editor.get()));
86 
87  auto spin_box = editor->findChild<QSpinBox*>();
88 
89  ASSERT_TRUE(spin_box != nullptr);
90  EXPECT_EQ(spin_box->minimum(), -65536);
91  EXPECT_EQ(spin_box->maximum(), 65536);
92 }
Custom editor for QVariant based on integer with possibility to set limits.
Definition: integereditor.h:26

◆ TEST_F() [10/11]

TEST_F ( DefaultEditorFactoryTest  ,
integerPropertyWithLimits   
)

Tests editor creation on integer property with limits.

Definition at line 96 of file defaulteditorfactory.test.cpp.

97 {
98  auto editor = createEditor(QVariant::fromValue(42), RealLimits::limited(-1, 1));
99  EXPECT_TRUE(dynamic_cast<IntegerEditor*>(editor.get()));
100 
101  auto spin_box = editor->findChild<QSpinBox*>();
102  ASSERT_TRUE(spin_box != nullptr);
103  EXPECT_EQ(spin_box->minimum(), -1);
104  EXPECT_EQ(spin_box->maximum(), 1);
105 }

References ModelView::RealLimits::limited().

Here is the call graph for this function:

◆ TEST_F() [11/11]

TEST_F ( DefaultEditorFactoryTest  ,
unsupportedProperty   
)

Tests editor creation on some unsupported property.

Definition at line 159 of file defaulteditorfactory.test.cpp.

160 {
161  // no dedicated editor for std::string yet
162  auto editor = createEditor(QVariant::fromValue(std::string("text")));
163  EXPECT_EQ(editor.get(), nullptr);
164 
165  // no editor for RealLimits
166  editor = createEditor(QVariant::fromValue(RealLimits::limited(1.0, 2.0)));
167  EXPECT_EQ(editor.get(), nullptr);
168 
169  // no editor for invalid variant
170  editor = createEditor(QVariant());
171  EXPECT_EQ(editor.get(), nullptr);
172 
173  // special case of invalid index
174  EXPECT_EQ(m_factory->createEditor(QModelIndex()), nullptr);
175 }

References ModelView::RealLimits::limited().

Here is the call graph for this function: