OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include "ui/accessibility/ax_tree.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 #include <stdint.h> | 8 #include <stdint.h> |
7 | 9 |
8 #include "base/memory/scoped_ptr.h" | 10 #include <memory> |
| 11 |
9 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/accessibility/ax_node.h" | 14 #include "ui/accessibility/ax_node.h" |
12 #include "ui/accessibility/ax_serializable_tree.h" | 15 #include "ui/accessibility/ax_serializable_tree.h" |
13 #include "ui/accessibility/ax_tree.h" | |
14 #include "ui/accessibility/ax_tree_serializer.h" | 16 #include "ui/accessibility/ax_tree_serializer.h" |
15 | 17 |
16 namespace ui { | 18 namespace ui { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 class FakeAXTreeDelegate : public AXTreeDelegate { | 22 class FakeAXTreeDelegate : public AXTreeDelegate { |
21 public: | 23 public: |
22 FakeAXTreeDelegate() | 24 FakeAXTreeDelegate() |
23 : tree_data_changed_(false), | 25 : tree_data_changed_(false), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 checkbox.location = gfx::Rect(20, 50, 200, 30); | 122 checkbox.location = gfx::Rect(20, 50, 200, 30); |
121 | 123 |
122 AXTreeUpdate initial_state; | 124 AXTreeUpdate initial_state; |
123 initial_state.nodes.push_back(root); | 125 initial_state.nodes.push_back(root); |
124 initial_state.nodes.push_back(button); | 126 initial_state.nodes.push_back(button); |
125 initial_state.nodes.push_back(checkbox); | 127 initial_state.nodes.push_back(checkbox); |
126 initial_state.has_tree_data = true; | 128 initial_state.has_tree_data = true; |
127 initial_state.tree_data.title = "Title"; | 129 initial_state.tree_data.title = "Title"; |
128 AXSerializableTree src_tree(initial_state); | 130 AXSerializableTree src_tree(initial_state); |
129 | 131 |
130 scoped_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData> > tree_source( | 132 std::unique_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData>> |
131 src_tree.CreateTreeSource()); | 133 tree_source(src_tree.CreateTreeSource()); |
132 AXTreeSerializer<const AXNode*, AXNodeData, AXTreeData> serializer( | 134 AXTreeSerializer<const AXNode*, AXNodeData, AXTreeData> serializer( |
133 tree_source.get()); | 135 tree_source.get()); |
134 AXTreeUpdate update; | 136 AXTreeUpdate update; |
135 serializer.SerializeChanges(src_tree.root(), &update); | 137 serializer.SerializeChanges(src_tree.root(), &update); |
136 | 138 |
137 AXTree dst_tree; | 139 AXTree dst_tree; |
138 ASSERT_TRUE(dst_tree.Unserialize(update)); | 140 ASSERT_TRUE(dst_tree.Unserialize(update)); |
139 | 141 |
140 const AXNode* root_node = dst_tree.root(); | 142 const AXNode* root_node = dst_tree.root(); |
141 ASSERT_TRUE(root_node != NULL); | 143 ASSERT_TRUE(root_node != NULL); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 tree_data_update.has_tree_data = true; | 397 tree_data_update.has_tree_data = true; |
396 tree_data_update.tree_data.title = "New Title"; | 398 tree_data_update.tree_data.title = "New Title"; |
397 EXPECT_TRUE(tree.Unserialize(tree_data_update)); | 399 EXPECT_TRUE(tree.Unserialize(tree_data_update)); |
398 EXPECT_TRUE(fake_delegate.tree_data_changed()); | 400 EXPECT_TRUE(fake_delegate.tree_data_changed()); |
399 EXPECT_EQ("New Title", tree.data().title); | 401 EXPECT_EQ("New Title", tree.data().title); |
400 | 402 |
401 tree.SetDelegate(NULL); | 403 tree.SetDelegate(NULL); |
402 } | 404 } |
403 | 405 |
404 } // namespace ui | 406 } // namespace ui |
OLD | NEW |