Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: ui/accessibility/ax_tree_unittest.cc

Issue 67283004: First step to move common accessibility code out of content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Git rid of AX_EXPORT from templatized function Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/ax_tree_source.h ('k') | ui/accessibility/ax_tree_update.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_tree_unittest.cc
diff --git a/ui/accessibility/ax_tree_unittest.cc b/ui/accessibility/ax_tree_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db802f59bdfff9f6a60a76294bb9ddb969a61ba0
--- /dev/null
+++ b/ui/accessibility/ax_tree_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/accessibility/ax_node.h"
+#include "ui/accessibility/ax_serializable_tree.h"
+#include "ui/accessibility/ax_tree.h"
+#include "ui/accessibility/ax_tree_serializer.h"
+
+namespace ui {
+
+TEST(AXTreeTest, TestSerialize) {
+ AXNodeData root;
+ root.id = 1;
+ root.role = AX_ROLE_ROOT_WEB_AREA;
+ root.child_ids.push_back(2);
+ root.child_ids.push_back(3);
+
+ AXNodeData button;
+ button.id = 2;
+ button.role = AX_ROLE_BUTTON;
+ button.state = 0;
+
+ AXNodeData checkbox;
+ checkbox.id = 3;
+ checkbox.role = AX_ROLE_CHECK_BOX;
+
+ AXTreeUpdate initial_state;
+ initial_state.nodes.push_back(root);
+ initial_state.nodes.push_back(button);
+ initial_state.nodes.push_back(checkbox);
+ AXSerializableTree src_tree(initial_state);
+
+ scoped_ptr<AXTreeSource<AXNode> > tree_source(
+ src_tree.CreateTreeSource());
+ AXTreeSerializer<AXNode> serializer(tree_source.get());
+ AXTreeUpdate update;
+ serializer.SerializeChanges(src_tree.GetRoot(), &update);
+
+ AXTree dst_tree;
+ ASSERT_TRUE(dst_tree.Unserialize(update));
+
+ AXNode* root_node = dst_tree.GetRoot();
+ ASSERT_TRUE(root_node != NULL);
+ EXPECT_EQ(root.id, root_node->id());
+ EXPECT_EQ(root.role, root_node->data().role);
+
+ ASSERT_EQ(2, root_node->child_count());
+
+ AXNode* button_node = root_node->ChildAtIndex(0);
+ EXPECT_EQ(button.id, button_node->id());
+ EXPECT_EQ(button.role, button_node->data().role);
+
+ AXNode* checkbox_node = root_node->ChildAtIndex(1);
+ EXPECT_EQ(checkbox.id, checkbox_node->id());
+ EXPECT_EQ(checkbox.role, checkbox_node->data().role);
+}
+
+} // namespace ui
« no previous file with comments | « ui/accessibility/ax_tree_source.h ('k') | ui/accessibility/ax_tree_update.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698