MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / loadFile

Method loadFile

test/editor_test.cpp:47–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void EditorTest::loadFile()
48{
49 QString file_xml = readFile(":/crossdoor_with_subtree.xml");
50 main_win->on_actionClear_triggered();
51 main_win->loadFromXML( file_xml );
52
53 QString saved_xml = main_win->saveToXML();
54
55 QFile qFile("crossdoor_EditorTest_loadFile.xml");
56 if (qFile.open(QIODevice::WriteOnly))
57 {
58 QTextStream out(&qFile); out << saved_xml;
59 qFile.close();
60 }
61
62 sleepAndRefresh( 500 );
63 //-------------------------------
64 // Compare AbsBehaviorTree
65 main_win->on_actionClear_triggered();
66 main_win->loadFromXML( file_xml );
67 auto tree_A1 = getAbstractTree("MainTree");
68 auto tree_A2 = getAbstractTree("DoorClosed");
69
70 main_win->loadFromXML( saved_xml );
71 auto tree_B1 = getAbstractTree("MainTree");
72 auto tree_B2 = getAbstractTree("DoorClosed");
73
74 bool same_maintree = (tree_A1 == tree_B1);
75 if( !same_maintree )
76 {
77 tree_A1.debugPrint();
78 tree_B1.debugPrint();
79 }
80 QVERIFY2( same_maintree, "AbsBehaviorTree comparison fails" );
81
82 QVERIFY2( file_xml.simplified() == saved_xml.simplified(),
83 "Loaded and saved XML are not the same" );
84
85
86 bool same_doorclosed = tree_A2 == tree_B2;
87 if( !same_doorclosed )
88 {
89 tree_A2.debugPrint();
90 tree_B2.debugPrint();
91 }
92
93 QVERIFY2( same_doorclosed, "AbsBehaviorTree comparison fails" );
94
95 //-------------------------------
96 // Next: expand the Subtree [DoorClosed]
97 auto tree = getAbstractTree("MainTree");
98
99 auto subtree_abs_node = tree.findFirstNode("DoorClosed");
100 QVERIFY2(subtree_abs_node, "Can't find node with ID [DoorClosed]");
101
102 {
103 auto data_model = subtree_abs_node->graphic_node->nodeDataModel();
104 auto subtree_model = dynamic_cast<SubtreeNodeModel*>(data_model);

Callers

nothing calls this directly

Calls 6

loadFromXMLMethod · 0.80
saveToXMLMethod · 0.80
debugPrintMethod · 0.80
findFirstNodeMethod · 0.80
expandButtonMethod · 0.80

Tested by

no test coverage detected