TEST(FilePersistence, SaveList) { QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests"; Model::Model model; FileStore store; store.setBaseFolder(testDir); TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.createRoot("PartialList")); model.beginModification(root, "create "); Model::Text* one = new Model::Text(); one->set("one"); root->list()->append(one); Model::Text* two = new Model::Text(); two->set("two"); root->list()->append(two); Model::Text* three = new Model::Text(); three->set("three"); root->list()->append(three); Model::Text* four = new Model::Text(); four->set("four"); root->list()->append(four); model.endModification(); model.setName("partial"); model.save(&store); CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/partial/partial", testDir + "/partial/partial"); }
TEST(FilePersistence, SavingTypedList) { QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests"; Model::Model model; FileStore store; store.setBaseFolder(testDir); Model::TypedList<Model::Text>* list = dynamic_cast<Model::TypedList<Model::Text>*> (model.createRoot("TypedListOfText")); model.beginModification(list, "create"); Model::Text* one = new Model::Text(); one->set("one"); list->append(one); Model::Text* two = new Model::Text(); two->set("two"); list->append(two); model.endModification(); model.setName("typedList"); model.save(&store); CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/typedList/typedList", testDir + "/typedList/typedList"); }
TEST(VisualizationBase, ExtendableTest) { Model::Model* model = new Model::Model(); Model::List* list = static_cast<Model::List*> (model->createRoot("List")); model->beginModification(list, "set"); TestNodes::BinaryNode* first = new TestNodes::BinaryNode(); list->append(first); TestNodes::BinaryNode* second = new TestNodes::BinaryNode(); list->append(second); Model::Text* third = new Model::Text(); list->append(third); first->name()->set("First node"); TestNodes::BinaryNode* left = new TestNodes::BinaryNode(); first->setLeft(left); TestNodes::BinaryNode* right = new TestNodes::BinaryNode(); first->setRight(right); left->name()->set("left node"); right->name()->set("right node"); second->name()->set("Empty node"); third->set("Some independent text"); list->append(new TestBoxNode("someText")); list->append(new TestBoxNode("stretch", true)); model->endModification(); auto top = new RootItem(list); auto scene = VisualizationManager::instance().mainScene(); scene->addTopLevelItem( top ); QApplication::processEvents(); VList* l = dynamic_cast<VList*> (top->item()); l->itemAt<VExtendable>(1)->setExpanded(false); scene->scheduleUpdate(); scene->listenToModel(model); CHECK_CONDITION(scene); }
TEST(InteractionBase, TextSelect) { Scene* scene = new Scene(); Model::Model* model = new Model::Model(); Model::List* list = static_cast<Model::List*> (model->createRoot("List")); model->beginModification(list, "set"); TestNodes::BinaryNode* first = new TestNodes::BinaryNode(); list->append(first); TestNodes::BinaryNode* second = new TestNodes::BinaryNode(); list->append(second); Model::Text* third = new Model::Text(); list->append(third); first->name()->set("First node"); TestNodes::BinaryNode* left = new TestNodes::BinaryNode(); first->setLeft(left); TestNodes::BinaryNode* right = new TestNodes::BinaryNode(); first->setRight(right); left->name()->set("left node"); right->name()->set("right node"); second->name()->set("Empty node"); third->set("Some independent text"); model->endModification(); VList* l = dynamic_cast<VList*> (scene->renderer()->render(nullptr, list)); scene->addTopLevelItem(l); scene->scheduleUpdate(); QApplication::processEvents(); l->at<VExtendable>(0)->setExpanded(); scene->scheduleUpdate(); scene->listenToModel(model); // Create view MainView* view = new MainView(scene); CHECK_CONDITION(view != nullptr); }