Rebase of facebook flexbox to yoga
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-third-party / yoga / YGTraversalTest.cpp
1 /**
2  * Copyright (c) 2014-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7
8 #include <gtest/gtest.h>
9 #include <yoga/Yoga.h>
10
11 TEST(YogaTest, pre_order_traversal) {
12   YGNodeRef const root = YGNodeNew();
13   YGNodeRef const root_child0 = YGNodeNew();
14   YGNodeRef const root_child1 = YGNodeNew();
15   YGNodeRef const root_child0_child0 = YGNodeNew();
16   
17   YGNodeSetChildren(root, {root_child0, root_child1});
18   YGNodeInsertChild(root_child0, root_child0_child0, 0);
19   
20   std::vector<YGNodeRef> visited;
21   YGTraversePreOrder(root, [&visited](YGNodeRef node) {
22     visited.push_back(node);
23   });
24   
25   const std::vector<YGNodeRef> expected = {
26     root,
27     root_child0,
28     root_child0_child0,
29     root_child1
30   };
31   ASSERT_EQ(visited, expected);
32
33   YGNodeFreeRecursive(root);
34 }