test_instance_placeholder.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. /**************************************************************************/
  2. /* test_instance_placeholder.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef TEST_INSTANCE_PLACEHOLDER_H
  31. #define TEST_INSTANCE_PLACEHOLDER_H
  32. #include "scene/main/instance_placeholder.h"
  33. #include "scene/resources/packed_scene.h"
  34. #include "tests/test_macros.h"
  35. class _TestInstancePlaceholderNode : public Node {
  36. GDCLASS(_TestInstancePlaceholderNode, Node);
  37. protected:
  38. static void _bind_methods() {
  39. ClassDB::bind_method(D_METHOD("set_int_property", "int_property"), &_TestInstancePlaceholderNode::set_int_property);
  40. ClassDB::bind_method(D_METHOD("get_int_property"), &_TestInstancePlaceholderNode::get_int_property);
  41. ADD_PROPERTY(PropertyInfo(Variant::INT, "int_property"), "set_int_property", "get_int_property");
  42. ClassDB::bind_method(D_METHOD("set_reference_property", "reference_property"), &_TestInstancePlaceholderNode::set_reference_property);
  43. ClassDB::bind_method(D_METHOD("get_reference_property"), &_TestInstancePlaceholderNode::get_reference_property);
  44. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "reference_property", PROPERTY_HINT_NODE_TYPE), "set_reference_property", "get_reference_property");
  45. ClassDB::bind_method(D_METHOD("set_reference_array_property", "reference_array_property"), &_TestInstancePlaceholderNode::set_reference_array_property);
  46. ClassDB::bind_method(D_METHOD("get_reference_array_property"), &_TestInstancePlaceholderNode::get_reference_array_property);
  47. // The hint string value "24/34:Node" is determined from existing PackedScenes with typed Array properties.
  48. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "reference_array_property", PROPERTY_HINT_TYPE_STRING, "24/34:Node"), "set_reference_array_property", "get_reference_array_property");
  49. }
  50. public:
  51. int int_property = 0;
  52. void set_int_property(int p_int) {
  53. int_property = p_int;
  54. }
  55. int get_int_property() const {
  56. return int_property;
  57. }
  58. Variant reference_property;
  59. void set_reference_property(const Variant &p_node) {
  60. reference_property = p_node;
  61. }
  62. Variant get_reference_property() const {
  63. return reference_property;
  64. }
  65. Array reference_array_property;
  66. void set_reference_array_property(const Array &p_array) {
  67. reference_array_property = p_array;
  68. }
  69. Array get_reference_array_property() const {
  70. return reference_array_property;
  71. }
  72. _TestInstancePlaceholderNode() {
  73. reference_array_property.set_typed(Variant::OBJECT, "Node", Variant());
  74. }
  75. };
  76. namespace TestInstancePlaceholder {
  77. TEST_CASE("[SceneTree][InstancePlaceholder] Instantiate from placeholder with no overrides") {
  78. GDREGISTER_CLASS(_TestInstancePlaceholderNode);
  79. SUBCASE("with non-node values") {
  80. InstancePlaceholder *ip = memnew(InstancePlaceholder);
  81. ip->set_name("TestScene");
  82. Node *root = memnew(Node);
  83. SceneTree::get_singleton()->get_root()->add_child(root);
  84. root->add_child(ip);
  85. // Create a scene to instance.
  86. _TestInstancePlaceholderNode *scene = memnew(_TestInstancePlaceholderNode);
  87. scene->set_int_property(12);
  88. // Pack the scene.
  89. PackedScene *packed_scene = memnew(PackedScene);
  90. const Error err = packed_scene->pack(scene);
  91. REQUIRE(err == OK);
  92. // Instantiate the scene.
  93. _TestInstancePlaceholderNode *created = Object::cast_to<_TestInstancePlaceholderNode>(ip->create_instance(true, packed_scene));
  94. REQUIRE(created != nullptr);
  95. CHECK(created->get_name() == "TestScene");
  96. CHECK(created->get_int_property() == 12);
  97. root->queue_free();
  98. memdelete(scene);
  99. }
  100. SUBCASE("with node value") {
  101. InstancePlaceholder *ip = memnew(InstancePlaceholder);
  102. ip->set_name("TestScene");
  103. Node *root = memnew(Node);
  104. SceneTree::get_singleton()->get_root()->add_child(root);
  105. root->add_child(ip);
  106. // Create a scene to instance.
  107. _TestInstancePlaceholderNode *scene = memnew(_TestInstancePlaceholderNode);
  108. Node *referenced = memnew(Node);
  109. scene->add_child(referenced);
  110. referenced->set_owner(scene);
  111. scene->set_reference_property(referenced);
  112. // Pack the scene.
  113. PackedScene *packed_scene = memnew(PackedScene);
  114. const Error err = packed_scene->pack(scene);
  115. REQUIRE(err == OK);
  116. // Instantiate the scene.
  117. _TestInstancePlaceholderNode *created = Object::cast_to<_TestInstancePlaceholderNode>(ip->create_instance(true, packed_scene));
  118. REQUIRE(created != nullptr);
  119. CHECK(created->get_name() == "TestScene");
  120. CHECK(created->get_child_count() == 1);
  121. CHECK(created->get_reference_property().identity_compare(created->get_child(0, false)));
  122. CHECK_FALSE(created->get_reference_property().identity_compare(referenced));
  123. root->queue_free();
  124. memdelete(scene);
  125. }
  126. SUBCASE("with node-array value") {
  127. InstancePlaceholder *ip = memnew(InstancePlaceholder);
  128. ip->set_name("TestScene");
  129. Node *root = memnew(Node);
  130. SceneTree::get_singleton()->get_root()->add_child(root);
  131. root->add_child(ip);
  132. // Create a scene to instance.
  133. _TestInstancePlaceholderNode *scene = memnew(_TestInstancePlaceholderNode);
  134. Node *referenced1 = memnew(Node);
  135. Node *referenced2 = memnew(Node);
  136. scene->add_child(referenced1);
  137. scene->add_child(referenced2);
  138. referenced1->set_owner(scene);
  139. referenced2->set_owner(scene);
  140. Array node_array;
  141. node_array.set_typed(Variant::OBJECT, "Node", Variant());
  142. node_array.push_back(referenced1);
  143. node_array.push_back(referenced2);
  144. scene->set_reference_array_property(node_array);
  145. // Pack the scene.
  146. PackedScene *packed_scene = memnew(PackedScene);
  147. const Error err = packed_scene->pack(scene);
  148. REQUIRE(err == OK);
  149. // Instantiate the scene.
  150. _TestInstancePlaceholderNode *created = Object::cast_to<_TestInstancePlaceholderNode>(ip->create_instance(true, packed_scene));
  151. REQUIRE(created != nullptr);
  152. CHECK(created->get_name() == "TestScene");
  153. CHECK(created->get_child_count() == 2);
  154. Array created_array = created->get_reference_array_property();
  155. REQUIRE(created_array.size() == node_array.size());
  156. REQUIRE(created_array.size() == created->get_child_count());
  157. // Iterate over all nodes, since the ordering is not guaranteed.
  158. for (int i = 0; i < node_array.size(); i++) {
  159. bool node_found = false;
  160. for (int j = 0; j < created->get_child_count(); j++) {
  161. if (created_array[i].identity_compare(created->get_child(j, true))) {
  162. node_found = true;
  163. }
  164. }
  165. CHECK(node_found);
  166. }
  167. root->queue_free();
  168. memdelete(scene);
  169. }
  170. }
  171. TEST_CASE("[SceneTree][InstancePlaceholder] Instantiate from placeholder with overrides") {
  172. GDREGISTER_CLASS(_TestInstancePlaceholderNode);
  173. SUBCASE("with non-node values") {
  174. InstancePlaceholder *ip = memnew(InstancePlaceholder);
  175. Node *root = memnew(Node);
  176. SceneTree::get_singleton()->get_root()->add_child(root);
  177. root->add_child(ip);
  178. ip->set_name("TestScene");
  179. ip->set("int_property", 45);
  180. // Create a scene to pack.
  181. _TestInstancePlaceholderNode *scene = memnew(_TestInstancePlaceholderNode);
  182. scene->set_int_property(12);
  183. // Pack the scene.
  184. PackedScene *packed_scene = memnew(PackedScene);
  185. packed_scene->pack(scene);
  186. // Instantiate the scene.
  187. _TestInstancePlaceholderNode *created = Object::cast_to<_TestInstancePlaceholderNode>(ip->create_instance(true, packed_scene));
  188. REQUIRE(created != nullptr);
  189. CHECK(created->get_int_property() == 45);
  190. root->queue_free();
  191. memdelete(scene);
  192. }
  193. SUBCASE("with node values") {
  194. InstancePlaceholder *ip = memnew(InstancePlaceholder);
  195. ip->set_name("TestScene");
  196. Node *root = memnew(Node);
  197. Node *overriding = memnew(Node);
  198. SceneTree::get_singleton()->get_root()->add_child(root);
  199. root->add_child(ip);
  200. root->add_child(overriding);
  201. ip->set("reference_property", overriding);
  202. // Create a scene to instance.
  203. _TestInstancePlaceholderNode *scene = memnew(_TestInstancePlaceholderNode);
  204. Node *referenced = memnew(Node);
  205. scene->add_child(referenced);
  206. referenced->set_owner(scene);
  207. scene->set_reference_property(referenced);
  208. // Pack the scene.
  209. PackedScene *packed_scene = memnew(PackedScene);
  210. const Error err = packed_scene->pack(scene);
  211. REQUIRE(err == OK);
  212. // Instantiate the scene.
  213. _TestInstancePlaceholderNode *created = Object::cast_to<_TestInstancePlaceholderNode>(ip->create_instance(true, packed_scene));
  214. REQUIRE(created != nullptr);
  215. CHECK(created->get_name() == "TestScene");
  216. CHECK(created->get_child_count() == 1);
  217. CHECK(created->get_reference_property().identity_compare(overriding));
  218. CHECK_FALSE(created->get_reference_property().identity_compare(referenced));
  219. root->queue_free();
  220. memdelete(scene);
  221. }
  222. SUBCASE("with node-array value") {
  223. InstancePlaceholder *ip = memnew(InstancePlaceholder);
  224. ip->set_name("TestScene");
  225. Node *root = memnew(Node);
  226. SceneTree::get_singleton()->get_root()->add_child(root);
  227. Node *override1 = memnew(Node);
  228. Node *override2 = memnew(Node);
  229. Node *override3 = memnew(Node);
  230. root->add_child(ip);
  231. root->add_child(override1);
  232. root->add_child(override2);
  233. root->add_child(override3);
  234. Array override_node_array;
  235. override_node_array.set_typed(Variant::OBJECT, "Node", Variant());
  236. override_node_array.push_back(override1);
  237. override_node_array.push_back(override2);
  238. override_node_array.push_back(override3);
  239. ip->set("reference_array_property", override_node_array);
  240. // Create a scene to instance.
  241. _TestInstancePlaceholderNode *scene = memnew(_TestInstancePlaceholderNode);
  242. Node *referenced1 = memnew(Node);
  243. Node *referenced2 = memnew(Node);
  244. scene->add_child(referenced1);
  245. scene->add_child(referenced2);
  246. referenced1->set_owner(scene);
  247. referenced2->set_owner(scene);
  248. Array referenced_array;
  249. referenced_array.set_typed(Variant::OBJECT, "Node", Variant());
  250. referenced_array.push_back(referenced1);
  251. referenced_array.push_back(referenced2);
  252. scene->set_reference_array_property(referenced_array);
  253. // Pack the scene.
  254. PackedScene *packed_scene = memnew(PackedScene);
  255. const Error err = packed_scene->pack(scene);
  256. REQUIRE(err == OK);
  257. // Instantiate the scene.
  258. _TestInstancePlaceholderNode *created = Object::cast_to<_TestInstancePlaceholderNode>(ip->create_instance(true, packed_scene));
  259. REQUIRE(created != nullptr);
  260. CHECK(created->get_name() == "TestScene");
  261. CHECK(created->get_child_count() == 2);
  262. Array created_array = created->get_reference_array_property();
  263. REQUIRE_FALSE(created_array.size() == referenced_array.size());
  264. REQUIRE(created_array.size() == override_node_array.size());
  265. REQUIRE_FALSE(created_array.size() == created->get_child_count());
  266. // Iterate over all nodes, since the ordering is not guaranteed.
  267. for (int i = 0; i < override_node_array.size(); i++) {
  268. bool node_found = false;
  269. for (int j = 0; j < created_array.size(); j++) {
  270. if (override_node_array[i].identity_compare(created_array[j])) {
  271. node_found = true;
  272. }
  273. }
  274. CHECK(node_found);
  275. }
  276. root->queue_free();
  277. memdelete(scene);
  278. }
  279. }
  280. #ifdef TOOLS_ENABLED
  281. TEST_CASE("[SceneTree][InstancePlaceholder] Instance a PackedScene containing an InstancePlaceholder with no overrides") {
  282. GDREGISTER_CLASS(_TestInstancePlaceholderNode);
  283. // Create the internal scene.
  284. _TestInstancePlaceholderNode *internal = memnew(_TestInstancePlaceholderNode);
  285. internal->set_name("InternalNode");
  286. Node *referenced = memnew(Node);
  287. referenced->set_name("OriginalReference");
  288. internal->add_child(referenced);
  289. referenced->set_owner(internal);
  290. internal->set_reference_property(referenced);
  291. // Pack the internal scene.
  292. PackedScene *internal_scene = memnew(PackedScene);
  293. Error err = internal_scene->pack(internal);
  294. REQUIRE(err == OK);
  295. const String internal_path = TestUtils::get_temp_path("instance_placeholder_test_internal.tscn");
  296. err = ResourceSaver::save(internal_scene, internal_path);
  297. REQUIRE(err == OK);
  298. Ref<PackedScene> internal_scene_loaded = ResourceLoader::load(internal_path, "PackedScene", ResourceFormatLoader::CacheMode::CACHE_MODE_IGNORE, &err);
  299. REQUIRE(err == OK);
  300. // Create the main scene.
  301. Node *root = memnew(Node);
  302. root->set_name("MainNode");
  303. Node *overriding = memnew(Node);
  304. overriding->set_name("OverridingReference");
  305. _TestInstancePlaceholderNode *internal_created = Object::cast_to<_TestInstancePlaceholderNode>(internal_scene_loaded->instantiate(PackedScene::GEN_EDIT_STATE_MAIN_INHERITED));
  306. internal_created->set_scene_instance_load_placeholder(true);
  307. root->add_child(internal_created);
  308. internal_created->set_owner(root);
  309. root->add_child(overriding);
  310. overriding->set_owner(root);
  311. // Here we introduce an error, we override the property with an internal node to the instance placeholder.
  312. // The InstancePlaceholder is now forced to properly resolve the Node.
  313. internal_created->set("reference_property", NodePath("OriginalReference"));
  314. // Pack the main scene.
  315. PackedScene *main_scene = memnew(PackedScene);
  316. err = main_scene->pack(root);
  317. REQUIRE(err == OK);
  318. const String main_path = TestUtils::get_temp_path("instance_placeholder_test_main.tscn");
  319. err = ResourceSaver::save(main_scene, main_path);
  320. REQUIRE(err == OK);
  321. // // Instantiate the scene.
  322. Ref<PackedScene> main_scene_loaded = ResourceLoader::load(main_path, "PackedScene", ResourceFormatLoader::CacheMode::CACHE_MODE_IGNORE, &err);
  323. REQUIRE(err == OK);
  324. Node *instanced_main_node = main_scene_loaded->instantiate();
  325. REQUIRE(instanced_main_node != nullptr);
  326. SceneTree::get_singleton()->get_root()->add_child(instanced_main_node);
  327. CHECK(instanced_main_node->get_name() == "MainNode");
  328. REQUIRE(instanced_main_node->get_child_count() == 2);
  329. InstancePlaceholder *instanced_placeholder = Object::cast_to<InstancePlaceholder>(instanced_main_node->get_child(0, true));
  330. REQUIRE(instanced_placeholder != nullptr);
  331. _TestInstancePlaceholderNode *final_node = Object::cast_to<_TestInstancePlaceholderNode>(instanced_placeholder->create_instance(true));
  332. REQUIRE(final_node != nullptr);
  333. REQUIRE(final_node->get_child_count() == 1);
  334. REQUIRE(final_node->get_reference_property().identity_compare(final_node->get_child(0, true)));
  335. instanced_main_node->queue_free();
  336. memdelete(overriding);
  337. memdelete(root);
  338. memdelete(internal);
  339. DirAccess::remove_file_or_error(internal_path);
  340. DirAccess::remove_file_or_error(main_path);
  341. }
  342. TEST_CASE("[SceneTree][InstancePlaceholder] Instance a PackedScene containing an InstancePlaceholder with overrides") {
  343. GDREGISTER_CLASS(_TestInstancePlaceholderNode);
  344. // Create the internal scene.
  345. _TestInstancePlaceholderNode *internal = memnew(_TestInstancePlaceholderNode);
  346. internal->set_name("InternalNode");
  347. Node *referenced = memnew(Node);
  348. referenced->set_name("OriginalReference");
  349. internal->add_child(referenced);
  350. referenced->set_owner(internal);
  351. internal->set_reference_property(referenced);
  352. Node *array_ref1 = memnew(Node);
  353. array_ref1->set_name("ArrayRef1");
  354. internal->add_child(array_ref1);
  355. array_ref1->set_owner(internal);
  356. Node *array_ref2 = memnew(Node);
  357. array_ref2->set_name("ArrayRef2");
  358. internal->add_child(array_ref2);
  359. array_ref2->set_owner(internal);
  360. Array referenced_array;
  361. referenced_array.set_typed(Variant::OBJECT, "Node", Variant());
  362. referenced_array.push_back(array_ref1);
  363. referenced_array.push_back(array_ref2);
  364. internal->set_reference_array_property(referenced_array);
  365. // Pack the internal scene.
  366. PackedScene *internal_scene = memnew(PackedScene);
  367. Error err = internal_scene->pack(internal);
  368. REQUIRE(err == OK);
  369. const String internal_path = TestUtils::get_temp_path("instance_placeholder_test_internal_override.tscn");
  370. err = ResourceSaver::save(internal_scene, internal_path);
  371. REQUIRE(err == OK);
  372. Ref<PackedScene> internal_scene_loaded = ResourceLoader::load(internal_path, "PackedScene", ResourceFormatLoader::CacheMode::CACHE_MODE_IGNORE, &err);
  373. REQUIRE(err == OK);
  374. // Create the main scene.
  375. Node *root = memnew(Node);
  376. root->set_name("MainNode");
  377. Node *overriding = memnew(Node);
  378. overriding->set_name("OverridingReference");
  379. Node *array_ext = memnew(Node);
  380. array_ext->set_name("ExternalArrayMember");
  381. _TestInstancePlaceholderNode *internal_created = Object::cast_to<_TestInstancePlaceholderNode>(internal_scene_loaded->instantiate(PackedScene::GEN_EDIT_STATE_MAIN_INHERITED));
  382. internal_created->set_scene_instance_load_placeholder(true);
  383. root->add_child(internal_created);
  384. internal_created->set_owner(root);
  385. root->add_child(overriding);
  386. overriding->set_owner(root);
  387. root->add_child(array_ext);
  388. array_ext->set_owner(root);
  389. // Here we introduce an error, we override the property with an internal node to the instance placeholder.
  390. // The InstancePlaceholder is now forced to properly resolve the Node.
  391. internal_created->set_reference_property(overriding);
  392. Array internal_array = internal_created->get_reference_array_property();
  393. Array override_array;
  394. override_array.set_typed(Variant::OBJECT, "Node", Variant());
  395. for (int i = 0; i < internal_array.size(); i++) {
  396. override_array.push_back(internal_array[i]);
  397. }
  398. override_array.push_back(array_ext);
  399. internal_created->set_reference_array_property(override_array);
  400. // Pack the main scene.
  401. PackedScene *main_scene = memnew(PackedScene);
  402. err = main_scene->pack(root);
  403. REQUIRE(err == OK);
  404. const String main_path = TestUtils::get_temp_path("instance_placeholder_test_main_override.tscn");
  405. err = ResourceSaver::save(main_scene, main_path);
  406. REQUIRE(err == OK);
  407. // // Instantiate the scene.
  408. Ref<PackedScene> main_scene_loaded = ResourceLoader::load(main_path, "PackedScene", ResourceFormatLoader::CacheMode::CACHE_MODE_IGNORE, &err);
  409. REQUIRE(err == OK);
  410. Node *instanced_main_node = main_scene_loaded->instantiate();
  411. REQUIRE(instanced_main_node != nullptr);
  412. SceneTree::get_singleton()->get_root()->add_child(instanced_main_node);
  413. CHECK(instanced_main_node->get_name() == "MainNode");
  414. REQUIRE(instanced_main_node->get_child_count() == 3);
  415. InstancePlaceholder *instanced_placeholder = Object::cast_to<InstancePlaceholder>(instanced_main_node->get_child(0, true));
  416. REQUIRE(instanced_placeholder != nullptr);
  417. _TestInstancePlaceholderNode *final_node = Object::cast_to<_TestInstancePlaceholderNode>(instanced_placeholder->create_instance(true));
  418. REQUIRE(final_node != nullptr);
  419. REQUIRE(final_node->get_child_count() == 3);
  420. REQUIRE(final_node->get_reference_property().identity_compare(instanced_main_node->get_child(1, true)));
  421. Array final_array = final_node->get_reference_array_property();
  422. REQUIRE(final_array.size() == 3);
  423. Array wanted_node_array;
  424. wanted_node_array.push_back(instanced_main_node->get_child(2, true)); // ExternalArrayMember
  425. wanted_node_array.push_back(final_node->get_child(1, true)); // ArrayRef1
  426. wanted_node_array.push_back(final_node->get_child(2, true)); // ArrayRef2
  427. // Iterate over all nodes, since the ordering is not guaranteed.
  428. for (int i = 0; i < wanted_node_array.size(); i++) {
  429. bool node_found = false;
  430. for (int j = 0; j < final_array.size(); j++) {
  431. if (wanted_node_array[i].identity_compare(final_array[j])) {
  432. node_found = true;
  433. }
  434. }
  435. CHECK(node_found);
  436. }
  437. instanced_main_node->queue_free();
  438. memdelete(array_ext);
  439. memdelete(overriding);
  440. memdelete(root);
  441. memdelete(internal);
  442. DirAccess::remove_file_or_error(internal_path);
  443. DirAccess::remove_file_or_error(main_path);
  444. }
  445. #endif // TOOLS_ENABLED
  446. } //namespace TestInstancePlaceholder
  447. #endif // TEST_INSTANCE_PLACEHOLDER_H