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

Implements class CLASS? More...

Include dependency graph for projectutils.test.cpp:

Go to the source code of this file.

Classes

class  ProjectUtilsTest
 Tests of ProjectUtils namespace functions. More...
 

Functions

 TEST_F (ProjectUtilsTest, CreateUntitledProject)
 
 TEST_F (ProjectUtilsTest, IsPossibleProjectDir)
 
 TEST_F (ProjectUtilsTest, ProjectWindowTitle)
 
 TEST_F (ProjectUtilsTest, SuggestFileName)
 Testing helper structure. 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 projectutils.test.cpp.

Function Documentation

◆ TEST_F() [1/4]

TEST_F ( ProjectUtilsTest  ,
CreateUntitledProject   
)

Definition at line 62 of file projectutils.test.cpp.

63 {
64  auto project = ProjectUtils::CreateUntitledProject(createContext());
65  EXPECT_TRUE(project->projectDir().empty());
66 }
MVVM_MODEL_EXPORT std::unique_ptr< ProjectInterface > CreateUntitledProject(const ProjectContext &context)
Creates new untitled project.
@ project
selective copying for saving/loading the project (tags and data created by item, updated from JSON)

References ModelView::ProjectUtils::CreateUntitledProject(), and ModelView::project.

Here is the call graph for this function:

◆ TEST_F() [2/4]

TEST_F ( ProjectUtilsTest  ,
IsPossibleProjectDir   
)

Definition at line 87 of file projectutils.test.cpp.

88 {
89  auto project = ProjectUtils::CreateUntitledProject(createContext());
90 
91  // empty directory can't be a project directory
92  auto dirname = createEmptyDir("test_IsPossibleProjectDir");
93  EXPECT_FALSE(ProjectUtils::IsPossibleProjectDir(dirname));
94 
95  project->save(dirname);
96  EXPECT_TRUE(ProjectUtils::IsPossibleProjectDir(dirname));
97 }
MVVM_MODEL_EXPORT bool IsPossibleProjectDir(const std::string &project_dir)
Returns 'true' if given directory might be a project directory.

References ModelView::ProjectUtils::CreateUntitledProject(), ModelView::ProjectUtils::IsPossibleProjectDir(), and ModelView::project.

Here is the call graph for this function:

◆ TEST_F() [3/4]

TEST_F ( ProjectUtilsTest  ,
ProjectWindowTitle   
)

Definition at line 68 of file projectutils.test.cpp.

69 {
70  auto project = ProjectUtils::CreateUntitledProject(createContext());
71 
72  // unmodified project without projectDir
73  EXPECT_EQ(ProjectUtils::ProjectWindowTitle(*project), "Untitled");
74 
75  sample_model->insertItem<PropertyItem>();
76  EXPECT_EQ(ProjectUtils::ProjectWindowTitle(*project), "*Untitled");
77 
78  // saving in a project directory
79  project->save(testPath());
80  EXPECT_EQ(ProjectUtils::ProjectWindowTitle(*project), testDir());
81 
82  // modifying
83  sample_model->insertItem<PropertyItem>();
84  EXPECT_EQ(ProjectUtils::ProjectWindowTitle(*project), "*" + testDir());
85 }
Item to carry concrete editable entity (e.g.
Definition: propertyitem.h:27
MVVM_MODEL_EXPORT std::string ProjectWindowTitle(const ProjectInterface &project)
Returns a MainWindow title for given project.

References ModelView::ProjectUtils::CreateUntitledProject(), ModelView::project, and ModelView::ProjectUtils::ProjectWindowTitle().

Here is the call graph for this function:

◆ TEST_F() [4/4]

TEST_F ( ProjectUtilsTest  ,
SuggestFileName   
)

Testing helper structure.

Definition at line 56 of file projectutils.test.cpp.

57 {
58  SessionModel model("TestModel");
59  EXPECT_EQ(std::string("testmodel.json"), ProjectUtils::SuggestFileName(model));
60 }
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
MVVM_MODEL_EXPORT std::string SuggestFileName(const SessionModel &model)
Suggests file name which can be used to store json content of given model.

References ModelView::ProjectUtils::SuggestFileName().

Here is the call graph for this function: