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

Side by Side Diff: ui/accessibility/ax_tree_unittest.cc

Issue 1978373002: Correctly ignore AXTree event creation change state for reparented nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add subtree and node reparented. Created 4 years, 7 months 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 unified diff | Download patch
« no previous file with comments | « ui/accessibility/ax_tree.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 5 #include "ui/accessibility/ax_tree.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 for (size_t i = 0; i < changes.size(); ++i) { 56 for (size_t i = 0; i < changes.size(); ++i) {
57 int id = changes[i].node->id(); 57 int id = changes[i].node->id();
58 switch (changes[i].type) { 58 switch (changes[i].type) {
59 case NODE_CREATED: 59 case NODE_CREATED:
60 node_creation_finished_ids_.push_back(id); 60 node_creation_finished_ids_.push_back(id);
61 break; 61 break;
62 case SUBTREE_CREATED: 62 case SUBTREE_CREATED:
63 subtree_creation_finished_ids_.push_back(id); 63 subtree_creation_finished_ids_.push_back(id);
64 break; 64 break;
65 case NODE_REPARENTED:
66 node_reparented_finished_ids_.push_back(id);
67 break;
68 case SUBTREE_REPARENTED:
69 subtree_reparented_finished_ids_.push_back(id);
70 break;
65 case NODE_CHANGED: 71 case NODE_CHANGED:
66 change_finished_ids_.push_back(id); 72 change_finished_ids_.push_back(id);
67 break; 73 break;
68 } 74 }
69 } 75 }
70 } 76 }
71 77
72 bool tree_data_changed() const { return tree_data_changed_; } 78 bool tree_data_changed() const { return tree_data_changed_; }
73 bool root_changed() const { return root_changed_; } 79 bool root_changed() const { return root_changed_; }
74 const std::vector<int32_t>& deleted_ids() { return deleted_ids_; } 80 const std::vector<int32_t>& deleted_ids() { return deleted_ids_; }
75 const std::vector<int32_t>& subtree_deleted_ids() { 81 const std::vector<int32_t>& subtree_deleted_ids() {
76 return subtree_deleted_ids_; 82 return subtree_deleted_ids_;
77 } 83 }
78 const std::vector<int32_t>& created_ids() { return created_ids_; } 84 const std::vector<int32_t>& created_ids() { return created_ids_; }
79 const std::vector<int32_t>& node_creation_finished_ids() { 85 const std::vector<int32_t>& node_creation_finished_ids() {
80 return node_creation_finished_ids_; 86 return node_creation_finished_ids_;
81 } 87 }
82 const std::vector<int32_t>& subtree_creation_finished_ids() { 88 const std::vector<int32_t>& subtree_creation_finished_ids() {
83 return subtree_creation_finished_ids_; 89 return subtree_creation_finished_ids_;
84 } 90 }
91 const std::vector<int32_t>& node_reparented_finished_ids() {
92 return node_reparented_finished_ids_;
93 }
94 const std::vector<int32_t>& subtree_reparented_finished_ids() {
95 return subtree_reparented_finished_ids_;
96 }
85 const std::vector<int32_t>& change_finished_ids() { 97 const std::vector<int32_t>& change_finished_ids() {
86 return change_finished_ids_; 98 return change_finished_ids_;
87 } 99 }
88 100
89 private: 101 private:
90 bool tree_data_changed_; 102 bool tree_data_changed_;
91 bool root_changed_; 103 bool root_changed_;
92 std::vector<int32_t> deleted_ids_; 104 std::vector<int32_t> deleted_ids_;
93 std::vector<int32_t> subtree_deleted_ids_; 105 std::vector<int32_t> subtree_deleted_ids_;
94 std::vector<int32_t> created_ids_; 106 std::vector<int32_t> created_ids_;
95 std::vector<int32_t> changed_ids_; 107 std::vector<int32_t> changed_ids_;
96 std::vector<int32_t> node_creation_finished_ids_; 108 std::vector<int32_t> node_creation_finished_ids_;
97 std::vector<int32_t> subtree_creation_finished_ids_; 109 std::vector<int32_t> subtree_creation_finished_ids_;
110 std::vector<int32_t> node_reparented_finished_ids_;
111 std::vector<int32_t> subtree_reparented_finished_ids_;
98 std::vector<int32_t> change_finished_ids_; 112 std::vector<int32_t> change_finished_ids_;
99 }; 113 };
100 114
101 } // namespace 115 } // namespace
102 116
103 TEST(AXTreeTest, SerializeSimpleAXTree) { 117 TEST(AXTreeTest, SerializeSimpleAXTree) {
104 AXNodeData root; 118 AXNodeData root;
105 root.id = 1; 119 root.id = 1;
106 root.role = AX_ROLE_DIALOG; 120 root.role = AX_ROLE_DIALOG;
107 root.state = 1 << AX_STATE_FOCUSABLE; 121 root.state = 1 << AX_STATE_FOCUSABLE;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 AXTreeUpdate tree_data_update; 391 AXTreeUpdate tree_data_update;
378 tree_data_update.has_tree_data = true; 392 tree_data_update.has_tree_data = true;
379 tree_data_update.tree_data.title = "New Title"; 393 tree_data_update.tree_data.title = "New Title";
380 EXPECT_TRUE(tree.Unserialize(tree_data_update)); 394 EXPECT_TRUE(tree.Unserialize(tree_data_update));
381 EXPECT_TRUE(fake_delegate.tree_data_changed()); 395 EXPECT_TRUE(fake_delegate.tree_data_changed());
382 EXPECT_EQ("New Title", tree.data().title); 396 EXPECT_EQ("New Title", tree.data().title);
383 397
384 tree.SetDelegate(NULL); 398 tree.SetDelegate(NULL);
385 } 399 }
386 400
401 TEST(AXTreeTest, ReparentingDoesNotTriggerNodeCreated) {
402 AXTreeUpdate initial_state;
403 initial_state.root_id = 1;
404 initial_state.nodes.resize(3);
405 initial_state.nodes[0].id = 1;
406 initial_state.nodes[0].child_ids.push_back(2);
407 initial_state.nodes[1].id = 2;
408 initial_state.nodes[1].child_ids.push_back(3);
409 initial_state.nodes[2].id = 3;
410
411 FakeAXTreeDelegate fake_delegate;
412 AXTree tree(initial_state);
413 tree.SetDelegate(&fake_delegate);
414
415 AXTreeUpdate update;
416 update.nodes.resize(2);
417 update.node_id_to_clear = 2;
418 update.root_id = 1;
419 update.nodes[0].id = 1;
420 update.nodes[0].child_ids.push_back(3);
421 update.nodes[1].id = 3;
422 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
423 std::vector<int> created = fake_delegate.node_creation_finished_ids();
424 std::vector<int> subtree_reparented =
425 fake_delegate.subtree_reparented_finished_ids();
426 std::vector<int> node_reparented =
427 fake_delegate.node_reparented_finished_ids();
428 ASSERT_EQ(std::find(created.begin(), created.end(), 3), created.end());
429 ASSERT_NE(std::find(subtree_reparented.begin(), subtree_reparented.end(), 3),
430 subtree_reparented.end());
431 ASSERT_EQ(std::find(node_reparented.begin(), node_reparented.end(), 3),
432 node_reparented.end());
433 }
434
387 } // namespace ui 435 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/ax_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698