Commit 85ab6eee authored by Kai Koehne's avatar Kai Koehne
Browse files

Add autotest for ModelNode::isAncestorOf

parent fe4e5117
......@@ -4229,6 +4229,45 @@ void TestCore::testModelNodeInHierarchy()
QVERIFY(node2.isInHierarchy());
}
void TestCore::testModelNodeIsAncestorOf()
{
QScopedPointer<Model> model(Model::create("Qt/Item"));
QVERIFY(model.data());
//
// import Qt 4.6
// Item {
// Item {
// id: item2
// }
// Item {
// id: item3
// Item {
// id: item4
// }
// }
// }
//
QScopedPointer<TestView> view(new TestView);
QVERIFY(view.data());
model->attachView(view.data());
view->rootModelNode().setId("item1");
ModelNode item2 = view->rootModelNode().addChildNode("Qt/Item", 4, 6, "data");
item2.setId("item2");
ModelNode item3 = view->rootModelNode().addChildNode("Qt/Item", 4, 6, "data");
item3.setId("item3");
ModelNode item4 = item3.addChildNode("Qt/Item", 4, 6, "data");
item4.setId("item4");
QVERIFY(view->rootModelNode().isAncestorOf(item2));
QVERIFY(view->rootModelNode().isAncestorOf(item3));
QVERIFY(view->rootModelNode().isAncestorOf(item4));
QVERIFY(!item2.isAncestorOf(view->rootModelNode()));
QVERIFY(!item2.isAncestorOf(item4));
QVERIFY(item3.isAncestorOf(item4));
}
void TestCore::testModelDefaultProperties()
{
QScopedPointer<Model> model(Model::create("Qt/Rectangle"));
......
......@@ -66,6 +66,7 @@ private slots:
void testModelNodeListProperty();
void testModelPropertyValueTypes();
void testModelNodeInHierarchy();
void testModelNodeIsAncestorOf();
//
// unit tests MetaInfo, NodeMetaInfo, PropertyMetaInfo
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment