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

Implements class CLASS? More...

Include dependency graph for TestToyParticleItem.cpp:

Go to the source code of this file.

Classes

class  ToyParticleItemTest
 Tests of toy MultiLayer in the context of model and viewmodel. More...
 

Functions

 TEST_F (ToyParticleItemTest, initialState)
 Initial state. More...
 
 TEST_F (ToyParticleItemTest, SinglePropertyItems)
 
 TEST_F (ToyParticleItemTest, TopLevelItems)
 

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 TestToyParticleItem.cpp.

Function Documentation

◆ TEST_F() [1/3]

TEST_F ( ToyParticleItemTest  ,
initialState   
)

Initial state.

Definition at line 36 of file TestToyParticleItem.cpp.

37 {
41 }
Represents a particle, with a position, and a selection of possible shapes.
Definition: toyitems.h:62
static const std::string P_SHAPES
Definition: toyitems.h:65
static const std::string P_POSITION
Definition: toyitems.h:64
MVVM_MODEL_EXPORT bool IsSinglePropertyTag(const SessionItem &item, const std::string &tag)
Returns true if given item has registered tag, and it belongs to single property.
Definition: itemutils.cpp:91

References ModelView::Utils::IsSinglePropertyTag(), ToyItems::ParticleItem::P_POSITION, and ToyItems::ParticleItem::P_SHAPES.

Here is the call graph for this function:

◆ TEST_F() [2/3]

TEST_F ( ToyParticleItemTest  ,
SinglePropertyItems   
)

Definition at line 52 of file TestToyParticleItem.cpp.

53 {
55  auto particle = model.insertItem<ToyItems::ParticleItem>();
56 
57  EXPECT_EQ(Utils::TopLevelItems(*model.rootItem()), std::vector<SessionItem*>({particle}));
58 
59  EXPECT_EQ(Utils::SinglePropertyItems(*model.rootItem()), std::vector<SessionItem*>{});
60  std::vector<SessionItem*> expected = {particle->getItem(ToyItems::ParticleItem::P_POSITION),
61  particle->getItem(ToyItems::ParticleItem::P_SHAPES)};
62  EXPECT_EQ(Utils::SinglePropertyItems(*particle), expected);
63 }
SessionItem * rootItem() const
Returns root item of the model.
T * insertItem(SessionItem *parent=nullptr, const TagRow &tagrow={})
Inserts item into given parent under given tagrow.
Definition: sessionmodel.h:104
MVVM_MODEL_EXPORT std::vector< SessionItem * > SinglePropertyItems(const SessionItem &item)
Returns vector of children representing property items.
Definition: itemutils.cpp:122
MVVM_MODEL_EXPORT std::vector< SessionItem * > TopLevelItems(const SessionItem &item)
Returns vector of children representing top level items.
Definition: itemutils.cpp:113

References ModelView::SessionModel::insertItem(), ToyItems::ParticleItem::P_POSITION, ToyItems::ParticleItem::P_SHAPES, ModelView::SessionModel::rootItem(), ModelView::Utils::SinglePropertyItems(), and ModelView::Utils::TopLevelItems().

Here is the call graph for this function:

◆ TEST_F() [3/3]

TEST_F ( ToyParticleItemTest  ,
TopLevelItems   
)

Definition at line 43 of file TestToyParticleItem.cpp.

44 {
46  auto particle = model.insertItem<ToyItems::ParticleItem>();
47 
48  EXPECT_EQ(Utils::TopLevelItems(*model.rootItem()), std::vector<SessionItem*>({particle}));
49  EXPECT_EQ(Utils::TopLevelItems(*particle), std::vector<SessionItem*>{});
50 }

References ModelView::SessionModel::insertItem(), ModelView::SessionModel::rootItem(), and ModelView::Utils::TopLevelItems().

Here is the call graph for this function: