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

Implements class CLASS? More...

Include dependency graph for projectchangecontroller.test.cpp:

Go to the source code of this file.

Classes

class  ProjectChangeControllerTest
 Tests for ProjectChangeController class. More...
 

Functions

 TEST_F (ProjectChangeControllerTest, callback)
 
 TEST_F (ProjectChangeControllerTest, initialState)
 
 TEST_F (ProjectChangeControllerTest, twoModelsChange)
 

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

Function Documentation

◆ TEST_F() [1/3]

TEST_F ( ProjectChangeControllerTest  ,
callback   
)

Definition at line 58 of file projectchangecontroller.test.cpp.

59 {
60  int model_changed_count{0};
61 
62  SessionModel sample_model("SampleModel");
63  SessionModel material_model("MaterialModel");
64  std::vector<SessionModel*> models = {&sample_model, &material_model};
65 
66  auto on_model_changed = [&model_changed_count]() { ++model_changed_count; };
67  ProjectChangedController controller(models, on_model_changed);
68 
69  // changing first model
70  sample_model.insertItem<PropertyItem>();
71  EXPECT_TRUE(controller.hasChanged());
72  EXPECT_EQ(model_changed_count, 1);
73 
74  // changing second model
75  material_model.insertItem<PropertyItem>();
76  EXPECT_TRUE(controller.hasChanged());
77  EXPECT_EQ(model_changed_count, 1); // controller reports only once
78 
79  controller.resetChanged();
80  EXPECT_FALSE(controller.hasChanged());
81 }
Item to carry concrete editable entity (e.g.
Definition: propertyitem.h:27
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37

References ModelView::ProjectChangedController::hasChanged(), ModelView::SessionModel::insertItem(), and ModelView::ProjectChangedController::resetChanged().

Here is the call graph for this function:

◆ TEST_F() [2/3]

TEST_F ( ProjectChangeControllerTest  ,
initialState   
)

Definition at line 31 of file projectchangecontroller.test.cpp.

32 {
33  SessionModel sample_model("SampleModel");
34  SessionModel material_model("MaterialModel");
35  std::vector<SessionModel*> models = {&sample_model, &material_model};
36 
37  ProjectChangedController controller(models);
38  EXPECT_FALSE(controller.hasChanged());
39 }

References ModelView::ProjectChangedController::hasChanged().

Here is the call graph for this function:

◆ TEST_F() [3/3]

TEST_F ( ProjectChangeControllerTest  ,
twoModelsChange   
)

Definition at line 41 of file projectchangecontroller.test.cpp.

42 {
43  SessionModel sample_model("SampleModel");
44  SessionModel material_model("MaterialModel");
45  std::vector<SessionModel*> models = {&sample_model, &material_model};
46 
47  ProjectChangedController controller(models);
48 
49  sample_model.insertItem<PropertyItem>();
50  material_model.insertItem<PropertyItem>();
51 
52  EXPECT_TRUE(controller.hasChanged());
53 
54  controller.resetChanged();
55  EXPECT_FALSE(controller.hasChanged());
56 }
bool insertItem(SessionItem *item, const TagRow &tagrow)
Insert item into given tag under the given row.

References ModelView::ProjectChangedController::hasChanged(), ModelView::SessionModel::insertItem(), and ModelView::ProjectChangedController::resetChanged().

Here is the call graph for this function: