Esempio n. 1
0
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);
}
Esempio n. 2
0
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");
	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->at<VExtendable>(0)->setExpanded();
	scene->scheduleUpdate();
	scene->listenToModel(model);

	CHECK_CONDITION(scene);
}
Esempio n. 3
0
TEST(FilePersistence, LoadingList)
{
	QString testDir = ":/FilePersistence/test/persisted";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	model.load(&store, "partial");
	TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.root());
	CHECK_CONDITION(root != nullptr);

	Model::List* list = root->list();

	CHECK_CONDITION(list != nullptr);
	CHECK_STR_EQUAL("List", list->typeName() );
	CHECK_CONDITION(list->isFullyLoaded() == false);
	CHECK_INT_EQUAL(1, list->id());

	list->loadFully(store);

	CHECK_CONDITION(list->isFullyLoaded());
	CHECK_INT_EQUAL(4, list->size());

	Model::Text* one = list->at<Model::Text>(0);
	Model::Text* two = list->at<Model::Text>(1);
	Model::Text* three = list->at<Model::Text>(2);
	Model::Text* four = list->at<Model::Text>(3);

	CHECK_CONDITION(one != nullptr);
	CHECK_STR_EQUAL("one", one->get());
	CHECK_INT_EQUAL(2, one->id());

	CHECK_CONDITION(two != nullptr);
	CHECK_STR_EQUAL("two", two->get());
	CHECK_INT_EQUAL(3, two->id())

	CHECK_CONDITION(three != nullptr);
	CHECK_STR_EQUAL("three", three->get());
	CHECK_INT_EQUAL(4, three->id())

	CHECK_CONDITION(four != nullptr);
	CHECK_STR_EQUAL("four", four->get());
	CHECK_INT_EQUAL(5, four->id());

}