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

Implements class CLASS? More...

Include dependency graph for propertyflatview.test.cpp:

Go to the source code of this file.

Classes

class  PropertyFlatViewTest
 Tests of PropertyFlatView class. More...
 

Functions

 TEST_F (PropertyFlatViewTest, appearanceForItem)
 
 TEST_F (PropertyFlatViewTest, layoutForVector)
 

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 propertyflatview.test.cpp.

Function Documentation

◆ TEST_F() [1/2]

TEST_F ( PropertyFlatViewTest  ,
appearanceForItem   
)

Definition at line 63 of file propertyflatview.test.cpp.

64 {
65  SessionModel model;
66  auto vector_item = model.insertItem<VectorItem>();
67  auto x_item = vector_item->getItem(VectorItem::P_X);
68 
69  x_item->setEnabled(false);
70 
71  PropertyFlatView flat_view;
72  flat_view.setItem(vector_item);
73 
74  auto layout = flat_view.findChild<QGridLayout*>();
75  ASSERT_TRUE(layout != nullptr);
76 
77  EXPECT_EQ(layout->rowCount(), 3);
78  EXPECT_EQ(layout->columnCount(), 2);
79  std::vector<int> expected_enabled = {0, 0, 1, 1, 1, 1};
80  EXPECT_EQ(enable_status(flat_view), expected_enabled);
81 
82  // enabling x item
83  x_item->setEnabled(true);
84  expected_enabled = {1, 1, 1, 1, 1, 1};
85  EXPECT_EQ(enable_status(flat_view), expected_enabled);
86 }
Widget holding grid layout with editors and intended for displaying all properties of given SessionIt...
void setItem(SessionItem *item)
SessionItem * setEnabled(bool value)
Sets enabled flag to given value (fluent interface).
SessionItem * getItem(const std::string &tag, int row=0) const
Returns item at given row of given tag.
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
Vector item with three x,y,z property items.
Definition: vectoritem.h:24
static const QString P_X
Definition: VectorItem.h:24

References ModelView::SessionItem::getItem(), ModelView::SessionModel::insertItem(), ModelView::VectorItem::P_X, ModelView::SessionItem::setEnabled(), and ModelView::PropertyFlatView::setItem().

Here is the call graph for this function:

◆ TEST_F() [2/2]

TEST_F ( PropertyFlatViewTest  ,
layoutForVector   
)

Definition at line 47 of file propertyflatview.test.cpp.

48 {
49  SessionModel model;
50  auto vector_item = model.insertItem<VectorItem>();
51 
52  PropertyFlatView flat_view;
53  flat_view.setItem(vector_item);
54 
55  auto layout = flat_view.findChild<QGridLayout*>();
56  ASSERT_TRUE(layout != nullptr);
57 
58  EXPECT_EQ(layout->rowCount(), 3);
59  EXPECT_EQ(layout->columnCount(), 2);
60  std::vector<int> expected_enabled = {1, 1, 1, 1, 1, 1};
61 }

References ModelView::SessionModel::insertItem(), and ModelView::PropertyFlatView::setItem().

Here is the call graph for this function: