27 const std::string samplemodel_name =
"samplemodel";
42 std::vector<SessionModel*>
models()
const {
return {sample_model.get()}; };
52 const std::string& select_dir = {})
78 const auto project_dir = createEmptyDir(
"Project_untitledEmptyCreateNew");
90 auto model_json =
Utils::join(project_dir, samplemodel_name +
".json");
99 const auto project_dir = createEmptyDir(
"Project_untitledEmptySaveCurrentProject");
111 auto model_json =
Utils::join(project_dir, samplemodel_name +
".json");
120 const auto project_dir = createEmptyDir(
"Project_untitledEmptySaveAs");
132 auto model_json =
Utils::join(project_dir, samplemodel_name +
".json");
167 const auto existing_project_dir = createEmptyDir(
"Project_untitledModifiedOpenExisting1");
168 const auto unsaved_project_dir = createEmptyDir(
"Project_untitledModifiedOpenExisting2");
177 auto open_dir = [&existing_project_dir]() -> std::string {
return existing_project_dir; };
178 auto create_dir = [&unsaved_project_dir]() -> std::string {
return unsaved_project_dir; };
180 auto ask_create = [&result]() {
184 auto user_context = userContext({}, {});
185 user_context.m_create_dir_callback = create_dir;
186 user_context.m_select_dir_callback = open_dir;
187 user_context.m_answer_callback = ask_create;
202 auto model_json =
Utils::join(unsaved_project_dir, samplemodel_name +
".json");
Convenience class which creates a directory on disk for test content.
Decorator for ProjectManager to provide interaction with the user on open/save-as requests.
bool createNewProject(const std::string &dirname={}) override
Creates a new project in the directory 'dirname', returns 'true' in the case of success.
bool saveProjectAs(const std::string &dirname={}) override
Saves the project under a given directory, returns true in the case of success.
std::string currentProjectDir() const override
Returns current project directory.
bool saveCurrentProject() override
Saves current project, returns 'true' in the case of success.
bool isModified() const override
Returns true if project was modified since last save.
bool openExistingProject(const std::string &dirname={}) override
Opens existing project, returns 'true' in the case of success.
Item to carry concrete editable entity (e.g.
Main class to hold hierarchy of SessionItem objects.
Tests for ProjectManager class.
ProjectContext projectContext()
UserInteractionContext userContext(const std::string &create_dir={}, const std::string &select_dir={})
std::unique_ptr< SessionModel > sample_model
~ProjectManagerDecoratorTest()
std::vector< SessionModel * > models() const
ProjectManagerDecoratorTest()
MVVM_MODEL_EXPORT std::string join(const std::string &part1, const std::string &part2)
Joins two path elements into the path.
MVVM_MODEL_EXPORT bool exists(const std::string &fileName)
Returns true if file exists.
materialitems.h Collection of materials to populate MaterialModel.
TEST_F(ProjectManagerDecoratorTest, initialState)
Initial state of ProjectManager. Project created, and not-saved.
Provides necessary information for Project construction.
models_callback_t m_models_callback
Defines the context to interact with the user regarding save/save-as/create-new project scenarious.
select_dir_callback_t m_select_dir_callback
create_dir_callback_t m_create_dir_callback