| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/accessibility/browser_accessibility.h" | 7 #include "content/browser/accessibility/browser_accessibility.h" |
| 8 #include "content/browser/accessibility/browser_accessibility_manager.h" | 8 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
| 10 #include "content/common/accessibility_node_data.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 namespace { | 13 namespace { |
| 15 | 14 |
| 16 // Subclass of BrowserAccessibility that counts the number of instances. | 15 // Subclass of BrowserAccessibility that counts the number of instances. |
| 17 class CountedBrowserAccessibility : public BrowserAccessibility { | 16 class CountedBrowserAccessibility : public BrowserAccessibility { |
| 18 public: | 17 public: |
| 19 CountedBrowserAccessibility() { | 18 CountedBrowserAccessibility() { |
| 20 global_obj_count_++; | 19 global_obj_count_++; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool got_fatal_error() const { return got_fatal_error_; } | 79 bool got_fatal_error() const { return got_fatal_error_; } |
| 81 void reset_got_fatal_error() { got_fatal_error_ = false; } | 80 void reset_got_fatal_error() { got_fatal_error_ = false; } |
| 82 | 81 |
| 83 private: | 82 private: |
| 84 bool got_fatal_error_; | 83 bool got_fatal_error_; |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 } // anonymous namespace | 86 } // anonymous namespace |
| 88 | 87 |
| 89 TEST(BrowserAccessibilityManagerTest, TestNoLeaks) { | 88 TEST(BrowserAccessibilityManagerTest, TestNoLeaks) { |
| 90 // Create AccessibilityNodeData objects for a simple document tree, | 89 // Create ui::AXNodeData objects for a simple document tree, |
| 91 // representing the accessibility information used to initialize | 90 // representing the accessibility information used to initialize |
| 92 // BrowserAccessibilityManager. | 91 // BrowserAccessibilityManager. |
| 93 AccessibilityNodeData button; | 92 ui::AXNodeData button; |
| 94 button.id = 2; | 93 button.id = 2; |
| 95 button.SetName("Button"); | 94 button.SetName("Button"); |
| 96 button.role = blink::WebAXRoleButton; | 95 button.role = ui::AX_ROLE_BUTTON; |
| 97 button.state = 0; | 96 button.state = 0; |
| 98 | 97 |
| 99 AccessibilityNodeData checkbox; | 98 ui::AXNodeData checkbox; |
| 100 checkbox.id = 3; | 99 checkbox.id = 3; |
| 101 checkbox.SetName("Checkbox"); | 100 checkbox.SetName("Checkbox"); |
| 102 checkbox.role = blink::WebAXRoleCheckBox; | 101 checkbox.role = ui::AX_ROLE_CHECK_BOX; |
| 103 checkbox.state = 0; | 102 checkbox.state = 0; |
| 104 | 103 |
| 105 AccessibilityNodeData root; | 104 ui::AXNodeData root; |
| 106 root.id = 1; | 105 root.id = 1; |
| 107 root.SetName("Document"); | 106 root.SetName("Document"); |
| 108 root.role = blink::WebAXRoleRootWebArea; | 107 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 109 root.state = 0; | 108 root.state = 0; |
| 110 root.child_ids.push_back(2); | 109 root.child_ids.push_back(2); |
| 111 root.child_ids.push_back(3); | 110 root.child_ids.push_back(3); |
| 112 | 111 |
| 113 // Construct a BrowserAccessibilityManager with this | 112 // Construct a BrowserAccessibilityManager with this |
| 114 // AccessibilityNodeData tree and a factory for an instance-counting | 113 // ui::AXNodeData tree and a factory for an instance-counting |
| 115 // BrowserAccessibility, and ensure that exactly 3 instances were | 114 // BrowserAccessibility, and ensure that exactly 3 instances were |
| 116 // created. Note that the manager takes ownership of the factory. | 115 // created. Note that the manager takes ownership of the factory. |
| 117 CountedBrowserAccessibility::global_obj_count_ = 0; | 116 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 118 BrowserAccessibilityManager* manager = | 117 BrowserAccessibilityManager* manager = |
| 119 BrowserAccessibilityManager::Create( | 118 BrowserAccessibilityManager::Create( |
| 120 root, | 119 root, |
| 121 NULL, | 120 NULL, |
| 122 new CountedBrowserAccessibilityFactory()); | 121 new CountedBrowserAccessibilityFactory()); |
| 123 manager->UpdateNodesForTesting(button, checkbox); | 122 manager->UpdateNodesForTesting(button, checkbox); |
| 124 | 123 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { | 161 TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { |
| 163 // Make sure that changes to a subtree reuse as many objects as possible. | 162 // Make sure that changes to a subtree reuse as many objects as possible. |
| 164 | 163 |
| 165 // Tree 1: | 164 // Tree 1: |
| 166 // | 165 // |
| 167 // root | 166 // root |
| 168 // child1 | 167 // child1 |
| 169 // child2 | 168 // child2 |
| 170 // child3 | 169 // child3 |
| 171 | 170 |
| 172 AccessibilityNodeData tree1_child1; | 171 ui::AXNodeData tree1_child1; |
| 173 tree1_child1.id = 2; | 172 tree1_child1.id = 2; |
| 174 tree1_child1.SetName("Child1"); | 173 tree1_child1.SetName("Child1"); |
| 175 tree1_child1.role = blink::WebAXRoleButton; | 174 tree1_child1.role = ui::AX_ROLE_BUTTON; |
| 176 tree1_child1.state = 0; | 175 tree1_child1.state = 0; |
| 177 | 176 |
| 178 AccessibilityNodeData tree1_child2; | 177 ui::AXNodeData tree1_child2; |
| 179 tree1_child2.id = 3; | 178 tree1_child2.id = 3; |
| 180 tree1_child2.SetName("Child2"); | 179 tree1_child2.SetName("Child2"); |
| 181 tree1_child2.role = blink::WebAXRoleButton; | 180 tree1_child2.role = ui::AX_ROLE_BUTTON; |
| 182 tree1_child2.state = 0; | 181 tree1_child2.state = 0; |
| 183 | 182 |
| 184 AccessibilityNodeData tree1_child3; | 183 ui::AXNodeData tree1_child3; |
| 185 tree1_child3.id = 4; | 184 tree1_child3.id = 4; |
| 186 tree1_child3.SetName("Child3"); | 185 tree1_child3.SetName("Child3"); |
| 187 tree1_child3.role = blink::WebAXRoleButton; | 186 tree1_child3.role = ui::AX_ROLE_BUTTON; |
| 188 tree1_child3.state = 0; | 187 tree1_child3.state = 0; |
| 189 | 188 |
| 190 AccessibilityNodeData tree1_root; | 189 ui::AXNodeData tree1_root; |
| 191 tree1_root.id = 1; | 190 tree1_root.id = 1; |
| 192 tree1_root.SetName("Document"); | 191 tree1_root.SetName("Document"); |
| 193 tree1_root.role = blink::WebAXRoleRootWebArea; | 192 tree1_root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 194 tree1_root.state = 0; | 193 tree1_root.state = 0; |
| 195 tree1_root.child_ids.push_back(2); | 194 tree1_root.child_ids.push_back(2); |
| 196 tree1_root.child_ids.push_back(3); | 195 tree1_root.child_ids.push_back(3); |
| 197 tree1_root.child_ids.push_back(4); | 196 tree1_root.child_ids.push_back(4); |
| 198 | 197 |
| 199 // Tree 2: | 198 // Tree 2: |
| 200 // | 199 // |
| 201 // root | 200 // root |
| 202 // child0 <-- inserted | 201 // child0 <-- inserted |
| 203 // child1 | 202 // child1 |
| 204 // child2 | 203 // child2 |
| 205 // <-- child3 deleted | 204 // <-- child3 deleted |
| 206 | 205 |
| 207 AccessibilityNodeData tree2_child0; | 206 ui::AXNodeData tree2_child0; |
| 208 tree2_child0.id = 5; | 207 tree2_child0.id = 5; |
| 209 tree2_child0.SetName("Child0"); | 208 tree2_child0.SetName("Child0"); |
| 210 tree2_child0.role = blink::WebAXRoleButton; | 209 tree2_child0.role = ui::AX_ROLE_BUTTON; |
| 211 tree2_child0.state = 0; | 210 tree2_child0.state = 0; |
| 212 | 211 |
| 213 AccessibilityNodeData tree2_root; | 212 ui::AXNodeData tree2_root; |
| 214 tree2_root.id = 1; | 213 tree2_root.id = 1; |
| 215 tree2_root.SetName("DocumentChanged"); | 214 tree2_root.SetName("DocumentChanged"); |
| 216 tree2_root.role = blink::WebAXRoleRootWebArea; | 215 tree2_root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 217 tree2_root.state = 0; | 216 tree2_root.state = 0; |
| 218 tree2_root.child_ids.push_back(5); | 217 tree2_root.child_ids.push_back(5); |
| 219 tree2_root.child_ids.push_back(2); | 218 tree2_root.child_ids.push_back(2); |
| 220 tree2_root.child_ids.push_back(3); | 219 tree2_root.child_ids.push_back(3); |
| 221 | 220 |
| 222 // Construct a BrowserAccessibilityManager with tree1. | 221 // Construct a BrowserAccessibilityManager with tree1. |
| 223 CountedBrowserAccessibility::global_obj_count_ = 0; | 222 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 224 BrowserAccessibilityManager* manager = | 223 BrowserAccessibilityManager* manager = |
| 225 BrowserAccessibilityManager::Create( | 224 BrowserAccessibilityManager::Create( |
| 226 tree1_root, | 225 tree1_root, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 248 | 247 |
| 249 // Check the index in parent. | 248 // Check the index in parent. |
| 250 EXPECT_EQ(0, child1_accessible->index_in_parent()); | 249 EXPECT_EQ(0, child1_accessible->index_in_parent()); |
| 251 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 250 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
| 252 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 251 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
| 253 | 252 |
| 254 // Process a notification containing the changed subtree. | 253 // Process a notification containing the changed subtree. |
| 255 std::vector<AccessibilityHostMsg_EventParams> params; | 254 std::vector<AccessibilityHostMsg_EventParams> params; |
| 256 params.push_back(AccessibilityHostMsg_EventParams()); | 255 params.push_back(AccessibilityHostMsg_EventParams()); |
| 257 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 256 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 258 msg->event_type = blink::WebAXEventChildrenChanged; | 257 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 259 msg->nodes.push_back(tree2_root); | 258 msg->nodes.push_back(tree2_root); |
| 260 msg->nodes.push_back(tree2_child0); | 259 msg->nodes.push_back(tree2_child0); |
| 261 msg->id = tree2_root.id; | 260 msg->id = tree2_root.id; |
| 262 manager->OnAccessibilityEvents(params); | 261 manager->OnAccessibilityEvents(params); |
| 263 | 262 |
| 264 // There should be 5 objects now: the 4 from the new tree, plus the | 263 // There should be 5 objects now: the 4 from the new tree, plus the |
| 265 // reference to child3 we kept. | 264 // reference to child3 we kept. |
| 266 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); | 265 EXPECT_EQ(5, CountedBrowserAccessibility::global_obj_count_); |
| 267 | 266 |
| 268 // Check that our references to the root, child1, and child2 are still valid, | 267 // Check that our references to the root, child1, and child2 are still valid, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 297 // | 296 // |
| 298 // root | 297 // root |
| 299 // container | 298 // container |
| 300 // child1 | 299 // child1 |
| 301 // grandchild1 | 300 // grandchild1 |
| 302 // child2 | 301 // child2 |
| 303 // grandchild2 | 302 // grandchild2 |
| 304 // child3 | 303 // child3 |
| 305 // grandchild3 | 304 // grandchild3 |
| 306 | 305 |
| 307 AccessibilityNodeData tree1_grandchild1; | 306 ui::AXNodeData tree1_grandchild1; |
| 308 tree1_grandchild1.id = 4; | 307 tree1_grandchild1.id = 4; |
| 309 tree1_grandchild1.SetName("GrandChild1"); | 308 tree1_grandchild1.SetName("GrandChild1"); |
| 310 tree1_grandchild1.role = blink::WebAXRoleButton; | 309 tree1_grandchild1.role = ui::AX_ROLE_BUTTON; |
| 311 tree1_grandchild1.state = 0; | 310 tree1_grandchild1.state = 0; |
| 312 | 311 |
| 313 AccessibilityNodeData tree1_child1; | 312 ui::AXNodeData tree1_child1; |
| 314 tree1_child1.id = 3; | 313 tree1_child1.id = 3; |
| 315 tree1_child1.SetName("Child1"); | 314 tree1_child1.SetName("Child1"); |
| 316 tree1_child1.role = blink::WebAXRoleButton; | 315 tree1_child1.role = ui::AX_ROLE_BUTTON; |
| 317 tree1_child1.state = 0; | 316 tree1_child1.state = 0; |
| 318 tree1_child1.child_ids.push_back(4); | 317 tree1_child1.child_ids.push_back(4); |
| 319 | 318 |
| 320 AccessibilityNodeData tree1_grandchild2; | 319 ui::AXNodeData tree1_grandchild2; |
| 321 tree1_grandchild2.id = 6; | 320 tree1_grandchild2.id = 6; |
| 322 tree1_grandchild2.SetName("GrandChild1"); | 321 tree1_grandchild2.SetName("GrandChild1"); |
| 323 tree1_grandchild2.role = blink::WebAXRoleButton; | 322 tree1_grandchild2.role = ui::AX_ROLE_BUTTON; |
| 324 tree1_grandchild2.state = 0; | 323 tree1_grandchild2.state = 0; |
| 325 | 324 |
| 326 AccessibilityNodeData tree1_child2; | 325 ui::AXNodeData tree1_child2; |
| 327 tree1_child2.id = 5; | 326 tree1_child2.id = 5; |
| 328 tree1_child2.SetName("Child2"); | 327 tree1_child2.SetName("Child2"); |
| 329 tree1_child2.role = blink::WebAXRoleButton; | 328 tree1_child2.role = ui::AX_ROLE_BUTTON; |
| 330 tree1_child2.state = 0; | 329 tree1_child2.state = 0; |
| 331 tree1_child2.child_ids.push_back(6); | 330 tree1_child2.child_ids.push_back(6); |
| 332 | 331 |
| 333 AccessibilityNodeData tree1_grandchild3; | 332 ui::AXNodeData tree1_grandchild3; |
| 334 tree1_grandchild3.id = 8; | 333 tree1_grandchild3.id = 8; |
| 335 tree1_grandchild3.SetName("GrandChild3"); | 334 tree1_grandchild3.SetName("GrandChild3"); |
| 336 tree1_grandchild3.role = blink::WebAXRoleButton; | 335 tree1_grandchild3.role = ui::AX_ROLE_BUTTON; |
| 337 tree1_grandchild3.state = 0; | 336 tree1_grandchild3.state = 0; |
| 338 | 337 |
| 339 AccessibilityNodeData tree1_child3; | 338 ui::AXNodeData tree1_child3; |
| 340 tree1_child3.id = 7; | 339 tree1_child3.id = 7; |
| 341 tree1_child3.SetName("Child3"); | 340 tree1_child3.SetName("Child3"); |
| 342 tree1_child3.role = blink::WebAXRoleButton; | 341 tree1_child3.role = ui::AX_ROLE_BUTTON; |
| 343 tree1_child3.state = 0; | 342 tree1_child3.state = 0; |
| 344 tree1_child3.child_ids.push_back(8); | 343 tree1_child3.child_ids.push_back(8); |
| 345 | 344 |
| 346 AccessibilityNodeData tree1_container; | 345 ui::AXNodeData tree1_container; |
| 347 tree1_container.id = 2; | 346 tree1_container.id = 2; |
| 348 tree1_container.SetName("Container"); | 347 tree1_container.SetName("Container"); |
| 349 tree1_container.role = blink::WebAXRoleGroup; | 348 tree1_container.role = ui::AX_ROLE_GROUP; |
| 350 tree1_container.state = 0; | 349 tree1_container.state = 0; |
| 351 tree1_container.child_ids.push_back(3); | 350 tree1_container.child_ids.push_back(3); |
| 352 tree1_container.child_ids.push_back(5); | 351 tree1_container.child_ids.push_back(5); |
| 353 tree1_container.child_ids.push_back(7); | 352 tree1_container.child_ids.push_back(7); |
| 354 | 353 |
| 355 AccessibilityNodeData tree1_root; | 354 ui::AXNodeData tree1_root; |
| 356 tree1_root.id = 1; | 355 tree1_root.id = 1; |
| 357 tree1_root.SetName("Document"); | 356 tree1_root.SetName("Document"); |
| 358 tree1_root.role = blink::WebAXRoleRootWebArea; | 357 tree1_root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 359 tree1_root.state = 0; | 358 tree1_root.state = 0; |
| 360 tree1_root.child_ids.push_back(2); | 359 tree1_root.child_ids.push_back(2); |
| 361 | 360 |
| 362 // Tree 2: | 361 // Tree 2: |
| 363 // | 362 // |
| 364 // root | 363 // root |
| 365 // container | 364 // container |
| 366 // child0 <-- inserted | 365 // child0 <-- inserted |
| 367 // grandchild0 <-- | 366 // grandchild0 <-- |
| 368 // child1 | 367 // child1 |
| 369 // grandchild1 | 368 // grandchild1 |
| 370 // child2 | 369 // child2 |
| 371 // grandchild2 | 370 // grandchild2 |
| 372 // <-- child3 (and grandchild3) deleted | 371 // <-- child3 (and grandchild3) deleted |
| 373 | 372 |
| 374 AccessibilityNodeData tree2_grandchild0; | 373 ui::AXNodeData tree2_grandchild0; |
| 375 tree2_grandchild0.id = 9; | 374 tree2_grandchild0.id = 9; |
| 376 tree2_grandchild0.SetName("GrandChild0"); | 375 tree2_grandchild0.SetName("GrandChild0"); |
| 377 tree2_grandchild0.role = blink::WebAXRoleButton; | 376 tree2_grandchild0.role = ui::AX_ROLE_BUTTON; |
| 378 tree2_grandchild0.state = 0; | 377 tree2_grandchild0.state = 0; |
| 379 | 378 |
| 380 AccessibilityNodeData tree2_child0; | 379 ui::AXNodeData tree2_child0; |
| 381 tree2_child0.id = 10; | 380 tree2_child0.id = 10; |
| 382 tree2_child0.SetName("Child0"); | 381 tree2_child0.SetName("Child0"); |
| 383 tree2_child0.role = blink::WebAXRoleButton; | 382 tree2_child0.role = ui::AX_ROLE_BUTTON; |
| 384 tree2_child0.state = 0; | 383 tree2_child0.state = 0; |
| 385 tree2_child0.child_ids.push_back(9); | 384 tree2_child0.child_ids.push_back(9); |
| 386 | 385 |
| 387 AccessibilityNodeData tree2_container; | 386 ui::AXNodeData tree2_container; |
| 388 tree2_container.id = 2; | 387 tree2_container.id = 2; |
| 389 tree2_container.SetName("Container"); | 388 tree2_container.SetName("Container"); |
| 390 tree2_container.role = blink::WebAXRoleGroup; | 389 tree2_container.role = ui::AX_ROLE_GROUP; |
| 391 tree2_container.state = 0; | 390 tree2_container.state = 0; |
| 392 tree2_container.child_ids.push_back(10); | 391 tree2_container.child_ids.push_back(10); |
| 393 tree2_container.child_ids.push_back(3); | 392 tree2_container.child_ids.push_back(3); |
| 394 tree2_container.child_ids.push_back(5); | 393 tree2_container.child_ids.push_back(5); |
| 395 | 394 |
| 396 // Construct a BrowserAccessibilityManager with tree1. | 395 // Construct a BrowserAccessibilityManager with tree1. |
| 397 CountedBrowserAccessibility::global_obj_count_ = 0; | 396 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 398 BrowserAccessibilityManager* manager = | 397 BrowserAccessibilityManager* manager = |
| 399 BrowserAccessibilityManager::Create( | 398 BrowserAccessibilityManager::Create( |
| 400 tree1_root, | 399 tree1_root, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 425 | 424 |
| 426 // Check the index in parent. | 425 // Check the index in parent. |
| 427 EXPECT_EQ(1, child2_accessible->index_in_parent()); | 426 EXPECT_EQ(1, child2_accessible->index_in_parent()); |
| 428 EXPECT_EQ(2, child3_accessible->index_in_parent()); | 427 EXPECT_EQ(2, child3_accessible->index_in_parent()); |
| 429 | 428 |
| 430 // Process a notification containing the changed subtree rooted at | 429 // Process a notification containing the changed subtree rooted at |
| 431 // the container. | 430 // the container. |
| 432 std::vector<AccessibilityHostMsg_EventParams> params; | 431 std::vector<AccessibilityHostMsg_EventParams> params; |
| 433 params.push_back(AccessibilityHostMsg_EventParams()); | 432 params.push_back(AccessibilityHostMsg_EventParams()); |
| 434 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 433 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 435 msg->event_type = blink::WebAXEventChildrenChanged; | 434 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 436 msg->nodes.push_back(tree2_container); | 435 msg->nodes.push_back(tree2_container); |
| 437 msg->nodes.push_back(tree2_child0); | 436 msg->nodes.push_back(tree2_child0); |
| 438 msg->nodes.push_back(tree2_grandchild0); | 437 msg->nodes.push_back(tree2_grandchild0); |
| 439 msg->id = tree2_container.id; | 438 msg->id = tree2_container.id; |
| 440 manager->OnAccessibilityEvents(params); | 439 manager->OnAccessibilityEvents(params); |
| 441 | 440 |
| 442 // There should be 9 objects now: the 8 from the new tree, plus the | 441 // There should be 9 objects now: the 8 from the new tree, plus the |
| 443 // reference to child3 we kept. | 442 // reference to child3 we kept. |
| 444 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); | 443 EXPECT_EQ(9, CountedBrowserAccessibility::global_obj_count_); |
| 445 | 444 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 472 } | 471 } |
| 473 | 472 |
| 474 TEST(BrowserAccessibilityManagerTest, TestMoveChildUp) { | 473 TEST(BrowserAccessibilityManagerTest, TestMoveChildUp) { |
| 475 // Tree 1: | 474 // Tree 1: |
| 476 // | 475 // |
| 477 // 1 | 476 // 1 |
| 478 // 2 | 477 // 2 |
| 479 // 3 | 478 // 3 |
| 480 // 4 | 479 // 4 |
| 481 | 480 |
| 482 AccessibilityNodeData tree1_4; | 481 ui::AXNodeData tree1_4; |
| 483 tree1_4.id = 4; | 482 tree1_4.id = 4; |
| 484 tree1_4.state = 0; | 483 tree1_4.state = 0; |
| 485 | 484 |
| 486 AccessibilityNodeData tree1_3; | 485 ui::AXNodeData tree1_3; |
| 487 tree1_3.id = 3; | 486 tree1_3.id = 3; |
| 488 tree1_3.state = 0; | 487 tree1_3.state = 0; |
| 489 tree1_3.child_ids.push_back(4); | 488 tree1_3.child_ids.push_back(4); |
| 490 | 489 |
| 491 AccessibilityNodeData tree1_2; | 490 ui::AXNodeData tree1_2; |
| 492 tree1_2.id = 2; | 491 tree1_2.id = 2; |
| 493 tree1_2.state = 0; | 492 tree1_2.state = 0; |
| 494 | 493 |
| 495 AccessibilityNodeData tree1_1; | 494 ui::AXNodeData tree1_1; |
| 496 tree1_1.id = 1; | 495 tree1_1.id = 1; |
| 497 tree1_1.role = blink::WebAXRoleRootWebArea; | 496 tree1_1.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 498 tree1_1.state = 0; | 497 tree1_1.state = 0; |
| 499 tree1_1.child_ids.push_back(2); | 498 tree1_1.child_ids.push_back(2); |
| 500 tree1_1.child_ids.push_back(3); | 499 tree1_1.child_ids.push_back(3); |
| 501 | 500 |
| 502 // Tree 2: | 501 // Tree 2: |
| 503 // | 502 // |
| 504 // 1 | 503 // 1 |
| 505 // 4 <-- moves up a level and gains child | 504 // 4 <-- moves up a level and gains child |
| 506 // 6 <-- new | 505 // 6 <-- new |
| 507 // 5 <-- new | 506 // 5 <-- new |
| 508 | 507 |
| 509 AccessibilityNodeData tree2_6; | 508 ui::AXNodeData tree2_6; |
| 510 tree2_6.id = 6; | 509 tree2_6.id = 6; |
| 511 tree2_6.state = 0; | 510 tree2_6.state = 0; |
| 512 | 511 |
| 513 AccessibilityNodeData tree2_5; | 512 ui::AXNodeData tree2_5; |
| 514 tree2_5.id = 5; | 513 tree2_5.id = 5; |
| 515 tree2_5.state = 0; | 514 tree2_5.state = 0; |
| 516 | 515 |
| 517 AccessibilityNodeData tree2_4; | 516 ui::AXNodeData tree2_4; |
| 518 tree2_4.id = 4; | 517 tree2_4.id = 4; |
| 519 tree2_4.state = 0; | 518 tree2_4.state = 0; |
| 520 tree2_4.child_ids.push_back(6); | 519 tree2_4.child_ids.push_back(6); |
| 521 | 520 |
| 522 AccessibilityNodeData tree2_1; | 521 ui::AXNodeData tree2_1; |
| 523 tree2_1.id = 1; | 522 tree2_1.id = 1; |
| 524 tree2_1.state = 0; | 523 tree2_1.state = 0; |
| 525 tree2_1.child_ids.push_back(4); | 524 tree2_1.child_ids.push_back(4); |
| 526 tree2_1.child_ids.push_back(5); | 525 tree2_1.child_ids.push_back(5); |
| 527 | 526 |
| 528 // Construct a BrowserAccessibilityManager with tree1. | 527 // Construct a BrowserAccessibilityManager with tree1. |
| 529 CountedBrowserAccessibility::global_obj_count_ = 0; | 528 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 530 BrowserAccessibilityManager* manager = | 529 BrowserAccessibilityManager* manager = |
| 531 BrowserAccessibilityManager::Create( | 530 BrowserAccessibilityManager::Create( |
| 532 tree1_1, | 531 tree1_1, |
| 533 NULL, | 532 NULL, |
| 534 new CountedBrowserAccessibilityFactory()); | 533 new CountedBrowserAccessibilityFactory()); |
| 535 manager->UpdateNodesForTesting(tree1_2, tree1_3, tree1_4); | 534 manager->UpdateNodesForTesting(tree1_2, tree1_3, tree1_4); |
| 536 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 535 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 537 | 536 |
| 538 // Process a notification containing the changed subtree. | 537 // Process a notification containing the changed subtree. |
| 539 std::vector<AccessibilityHostMsg_EventParams> params; | 538 std::vector<AccessibilityHostMsg_EventParams> params; |
| 540 params.push_back(AccessibilityHostMsg_EventParams()); | 539 params.push_back(AccessibilityHostMsg_EventParams()); |
| 541 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; | 540 AccessibilityHostMsg_EventParams* msg = ¶ms[0]; |
| 542 msg->event_type = blink::WebAXEventChildrenChanged; | 541 msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; |
| 543 msg->nodes.push_back(tree2_1); | 542 msg->nodes.push_back(tree2_1); |
| 544 msg->nodes.push_back(tree2_4); | 543 msg->nodes.push_back(tree2_4); |
| 545 msg->nodes.push_back(tree2_5); | 544 msg->nodes.push_back(tree2_5); |
| 546 msg->nodes.push_back(tree2_6); | 545 msg->nodes.push_back(tree2_6); |
| 547 msg->id = tree2_1.id; | 546 msg->id = tree2_1.id; |
| 548 manager->OnAccessibilityEvents(params); | 547 manager->OnAccessibilityEvents(params); |
| 549 | 548 |
| 550 // There should be 4 objects now. | 549 // There should be 4 objects now. |
| 551 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 550 EXPECT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 552 | 551 |
| 553 // Delete the manager and make sure all memory is cleaned up. | 552 // Delete the manager and make sure all memory is cleaned up. |
| 554 delete manager; | 553 delete manager; |
| 555 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 554 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 556 } | 555 } |
| 557 | 556 |
| 558 // Crashes on Windows. http://crbug.com/304130 | 557 // Crashes on Windows. http://crbug.com/304130 |
| 559 #if defined(OS_WIN) | 558 #if defined(OS_WIN) |
| 560 #define MAYBE_TestFatalError DISABLED_TestFatalError | 559 #define MAYBE_TestFatalError DISABLED_TestFatalError |
| 561 #else | 560 #else |
| 562 #define MAYBE_TestFatalError TestFatalError | 561 #define MAYBE_TestFatalError TestFatalError |
| 563 #endif | 562 #endif |
| 564 TEST(BrowserAccessibilityManagerTest, MAYBE_TestFatalError) { | 563 TEST(BrowserAccessibilityManagerTest, MAYBE_TestFatalError) { |
| 565 // Test that BrowserAccessibilityManager raises a fatal error | 564 // Test that BrowserAccessibilityManager raises a fatal error |
| 566 // (which will crash the renderer) if the same id is used in | 565 // (which will crash the renderer) if the same id is used in |
| 567 // two places in the tree. | 566 // two places in the tree. |
| 568 | 567 |
| 569 AccessibilityNodeData root; | 568 ui::AXNodeData root; |
| 570 root.id = 1; | 569 root.id = 1; |
| 571 root.role = blink::WebAXRoleRootWebArea; | 570 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 572 root.child_ids.push_back(2); | 571 root.child_ids.push_back(2); |
| 573 root.child_ids.push_back(2); | 572 root.child_ids.push_back(2); |
| 574 | 573 |
| 575 CountedBrowserAccessibilityFactory* factory = | 574 CountedBrowserAccessibilityFactory* factory = |
| 576 new CountedBrowserAccessibilityFactory(); | 575 new CountedBrowserAccessibilityFactory(); |
| 577 scoped_ptr<TestBrowserAccessibilityDelegate> delegate( | 576 scoped_ptr<TestBrowserAccessibilityDelegate> delegate( |
| 578 new TestBrowserAccessibilityDelegate()); | 577 new TestBrowserAccessibilityDelegate()); |
| 579 scoped_ptr<BrowserAccessibilityManager> manager; | 578 scoped_ptr<BrowserAccessibilityManager> manager; |
| 580 ASSERT_FALSE(delegate->got_fatal_error()); | 579 ASSERT_FALSE(delegate->got_fatal_error()); |
| 581 manager.reset(BrowserAccessibilityManager::Create( | 580 manager.reset(BrowserAccessibilityManager::Create( |
| 582 root, | 581 root, |
| 583 delegate.get(), | 582 delegate.get(), |
| 584 factory)); | 583 factory)); |
| 585 ASSERT_TRUE(delegate->got_fatal_error()); | 584 ASSERT_TRUE(delegate->got_fatal_error()); |
| 586 | 585 |
| 587 AccessibilityNodeData root2; | 586 ui::AXNodeData root2; |
| 588 root2.id = 1; | 587 root2.id = 1; |
| 589 root2.role = blink::WebAXRoleRootWebArea; | 588 root2.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 590 root2.child_ids.push_back(2); | 589 root2.child_ids.push_back(2); |
| 591 root2.child_ids.push_back(3); | 590 root2.child_ids.push_back(3); |
| 592 | 591 |
| 593 AccessibilityNodeData child1; | 592 ui::AXNodeData child1; |
| 594 child1.id = 2; | 593 child1.id = 2; |
| 595 child1.child_ids.push_back(4); | 594 child1.child_ids.push_back(4); |
| 596 child1.child_ids.push_back(5); | 595 child1.child_ids.push_back(5); |
| 597 | 596 |
| 598 AccessibilityNodeData child2; | 597 ui::AXNodeData child2; |
| 599 child2.id = 3; | 598 child2.id = 3; |
| 600 child2.child_ids.push_back(6); | 599 child2.child_ids.push_back(6); |
| 601 child2.child_ids.push_back(5); // Duplicate | 600 child2.child_ids.push_back(5); // Duplicate |
| 602 | 601 |
| 603 delegate->reset_got_fatal_error(); | 602 delegate->reset_got_fatal_error(); |
| 604 factory = new CountedBrowserAccessibilityFactory(); | 603 factory = new CountedBrowserAccessibilityFactory(); |
| 605 manager.reset(BrowserAccessibilityManager::Create( | 604 manager.reset(BrowserAccessibilityManager::Create( |
| 606 root2, | 605 root2, |
| 607 delegate.get(), | 606 delegate.get(), |
| 608 factory)); | 607 factory)); |
| 609 ASSERT_FALSE(delegate->got_fatal_error()); | 608 ASSERT_FALSE(delegate->got_fatal_error()); |
| 610 manager->UpdateNodesForTesting(child1, child2); | 609 manager->UpdateNodesForTesting(child1, child2); |
| 611 ASSERT_TRUE(delegate->got_fatal_error()); | 610 ASSERT_TRUE(delegate->got_fatal_error()); |
| 612 } | 611 } |
| 613 | 612 |
| 614 TEST(BrowserAccessibilityManagerTest, BoundsForRange) { | 613 TEST(BrowserAccessibilityManagerTest, BoundsForRange) { |
| 615 AccessibilityNodeData root; | 614 ui::AXNodeData root; |
| 616 root.id = 1; | 615 root.id = 1; |
| 617 root.role = blink::WebAXRoleRootWebArea; | 616 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 618 | 617 |
| 619 AccessibilityNodeData static_text; | 618 ui::AXNodeData static_text; |
| 620 static_text.id = 2; | 619 static_text.id = 2; |
| 621 static_text.SetValue("Hello, world."); | 620 static_text.SetValue("Hello, world."); |
| 622 static_text.role = blink::WebAXRoleStaticText; | 621 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 623 static_text.location = gfx::Rect(100, 100, 29, 18); | 622 static_text.location = gfx::Rect(100, 100, 29, 18); |
| 624 root.child_ids.push_back(2); | 623 root.child_ids.push_back(2); |
| 625 | 624 |
| 626 AccessibilityNodeData inline_text1; | 625 ui::AXNodeData inline_text1; |
| 627 inline_text1.id = 3; | 626 inline_text1.id = 3; |
| 628 inline_text1.SetValue("Hello, "); | 627 inline_text1.SetValue("Hello, "); |
| 629 inline_text1.role = blink::WebAXRoleInlineTextBox; | 628 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 630 inline_text1.location = gfx::Rect(100, 100, 29, 9); | 629 inline_text1.location = gfx::Rect(100, 100, 29, 9); |
| 631 inline_text1.AddIntAttribute(AccessibilityNodeData::ATTR_TEXT_DIRECTION, | 630 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 632 blink::WebAXTextDirectionLR); | 631 blink::WebAXTextDirectionLR); |
| 633 std::vector<int32> character_offsets1; | 632 std::vector<int32> character_offsets1; |
| 634 character_offsets1.push_back(6); // 0 | 633 character_offsets1.push_back(6); // 0 |
| 635 character_offsets1.push_back(11); // 1 | 634 character_offsets1.push_back(11); // 1 |
| 636 character_offsets1.push_back(16); // 2 | 635 character_offsets1.push_back(16); // 2 |
| 637 character_offsets1.push_back(21); // 3 | 636 character_offsets1.push_back(21); // 3 |
| 638 character_offsets1.push_back(26); // 4 | 637 character_offsets1.push_back(26); // 4 |
| 639 character_offsets1.push_back(29); // 5 | 638 character_offsets1.push_back(29); // 5 |
| 640 character_offsets1.push_back(29); // 6 (note that the space has no width) | 639 character_offsets1.push_back(29); // 6 (note that the space has no width) |
| 641 inline_text1.AddIntListAttribute( | 640 inline_text1.AddIntListAttribute( |
| 642 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS, character_offsets1); | 641 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 643 static_text.child_ids.push_back(3); | 642 static_text.child_ids.push_back(3); |
| 644 | 643 |
| 645 AccessibilityNodeData inline_text2; | 644 ui::AXNodeData inline_text2; |
| 646 inline_text2.id = 4; | 645 inline_text2.id = 4; |
| 647 inline_text2.SetValue("world."); | 646 inline_text2.SetValue("world."); |
| 648 inline_text2.role = blink::WebAXRoleInlineTextBox; | 647 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 649 inline_text2.location = gfx::Rect(100, 109, 28, 9); | 648 inline_text2.location = gfx::Rect(100, 109, 28, 9); |
| 650 inline_text2.AddIntAttribute(AccessibilityNodeData::ATTR_TEXT_DIRECTION, | 649 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 651 blink::WebAXTextDirectionLR); | 650 blink::WebAXTextDirectionLR); |
| 652 std::vector<int32> character_offsets2; | 651 std::vector<int32> character_offsets2; |
| 653 character_offsets2.push_back(5); | 652 character_offsets2.push_back(5); |
| 654 character_offsets2.push_back(10); | 653 character_offsets2.push_back(10); |
| 655 character_offsets2.push_back(15); | 654 character_offsets2.push_back(15); |
| 656 character_offsets2.push_back(20); | 655 character_offsets2.push_back(20); |
| 657 character_offsets2.push_back(25); | 656 character_offsets2.push_back(25); |
| 658 character_offsets2.push_back(28); | 657 character_offsets2.push_back(28); |
| 659 inline_text2.AddIntListAttribute( | 658 inline_text2.AddIntListAttribute( |
| 660 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS, character_offsets2); | 659 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| 661 static_text.child_ids.push_back(4); | 660 static_text.child_ids.push_back(4); |
| 662 | 661 |
| 663 scoped_ptr<BrowserAccessibilityManager> manager( | 662 scoped_ptr<BrowserAccessibilityManager> manager( |
| 664 BrowserAccessibilityManager::Create( | 663 BrowserAccessibilityManager::Create( |
| 665 root, | 664 root, |
| 666 NULL, | 665 NULL, |
| 667 new CountedBrowserAccessibilityFactory())); | 666 new CountedBrowserAccessibilityFactory())); |
| 668 manager->UpdateNodesForTesting(static_text, inline_text1, inline_text2); | 667 manager->UpdateNodesForTesting(static_text, inline_text1, inline_text2); |
| 669 | 668 |
| 670 BrowserAccessibility* root_accessible = manager->GetRoot(); | 669 BrowserAccessibility* root_accessible = manager->GetRoot(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 701 | 700 |
| 702 TEST(BrowserAccessibilityManagerTest, BoundsForRangeBiDi) { | 701 TEST(BrowserAccessibilityManagerTest, BoundsForRangeBiDi) { |
| 703 // In this example, we assume that the string "123abc" is rendered with | 702 // In this example, we assume that the string "123abc" is rendered with |
| 704 // "123" going left-to-right and "abc" going right-to-left. In other | 703 // "123" going left-to-right and "abc" going right-to-left. In other |
| 705 // words, on-screen it would look like "123cba". This is possible to | 704 // words, on-screen it would look like "123cba". This is possible to |
| 706 // acheive if the source string had unicode control characters | 705 // acheive if the source string had unicode control characters |
| 707 // to switch directions. This test doesn't worry about how, though - it just | 706 // to switch directions. This test doesn't worry about how, though - it just |
| 708 // tests that if something like that were to occur, GetLocalBoundsForRange | 707 // tests that if something like that were to occur, GetLocalBoundsForRange |
| 709 // returns the correct bounds for different ranges. | 708 // returns the correct bounds for different ranges. |
| 710 | 709 |
| 711 AccessibilityNodeData root; | 710 ui::AXNodeData root; |
| 712 root.id = 1; | 711 root.id = 1; |
| 713 root.role = blink::WebAXRoleRootWebArea; | 712 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 714 | 713 |
| 715 AccessibilityNodeData static_text; | 714 ui::AXNodeData static_text; |
| 716 static_text.id = 2; | 715 static_text.id = 2; |
| 717 static_text.SetValue("123abc"); | 716 static_text.SetValue("123abc"); |
| 718 static_text.role = blink::WebAXRoleStaticText; | 717 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
| 719 static_text.location = gfx::Rect(100, 100, 60, 20); | 718 static_text.location = gfx::Rect(100, 100, 60, 20); |
| 720 root.child_ids.push_back(2); | 719 root.child_ids.push_back(2); |
| 721 | 720 |
| 722 AccessibilityNodeData inline_text1; | 721 ui::AXNodeData inline_text1; |
| 723 inline_text1.id = 3; | 722 inline_text1.id = 3; |
| 724 inline_text1.SetValue("123"); | 723 inline_text1.SetValue("123"); |
| 725 inline_text1.role = blink::WebAXRoleInlineTextBox; | 724 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 726 inline_text1.location = gfx::Rect(100, 100, 30, 20); | 725 inline_text1.location = gfx::Rect(100, 100, 30, 20); |
| 727 inline_text1.AddIntAttribute(AccessibilityNodeData::ATTR_TEXT_DIRECTION, | 726 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 728 blink::WebAXTextDirectionLR); | 727 blink::WebAXTextDirectionLR); |
| 729 std::vector<int32> character_offsets1; | 728 std::vector<int32> character_offsets1; |
| 730 character_offsets1.push_back(10); // 0 | 729 character_offsets1.push_back(10); // 0 |
| 731 character_offsets1.push_back(20); // 1 | 730 character_offsets1.push_back(20); // 1 |
| 732 character_offsets1.push_back(30); // 2 | 731 character_offsets1.push_back(30); // 2 |
| 733 inline_text1.AddIntListAttribute( | 732 inline_text1.AddIntListAttribute( |
| 734 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS, character_offsets1); | 733 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 735 static_text.child_ids.push_back(3); | 734 static_text.child_ids.push_back(3); |
| 736 | 735 |
| 737 AccessibilityNodeData inline_text2; | 736 ui::AXNodeData inline_text2; |
| 738 inline_text2.id = 4; | 737 inline_text2.id = 4; |
| 739 inline_text2.SetValue("abc"); | 738 inline_text2.SetValue("abc"); |
| 740 inline_text2.role = blink::WebAXRoleInlineTextBox; | 739 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 741 inline_text2.location = gfx::Rect(130, 100, 30, 20); | 740 inline_text2.location = gfx::Rect(130, 100, 30, 20); |
| 742 inline_text2.AddIntAttribute(AccessibilityNodeData::ATTR_TEXT_DIRECTION, | 741 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 743 blink::WebAXTextDirectionRL); | 742 blink::WebAXTextDirectionRL); |
| 744 std::vector<int32> character_offsets2; | 743 std::vector<int32> character_offsets2; |
| 745 character_offsets2.push_back(10); | 744 character_offsets2.push_back(10); |
| 746 character_offsets2.push_back(20); | 745 character_offsets2.push_back(20); |
| 747 character_offsets2.push_back(30); | 746 character_offsets2.push_back(30); |
| 748 inline_text2.AddIntListAttribute( | 747 inline_text2.AddIntListAttribute( |
| 749 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS, character_offsets2); | 748 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| 750 static_text.child_ids.push_back(4); | 749 static_text.child_ids.push_back(4); |
| 751 | 750 |
| 752 scoped_ptr<BrowserAccessibilityManager> manager( | 751 scoped_ptr<BrowserAccessibilityManager> manager( |
| 753 BrowserAccessibilityManager::Create( | 752 BrowserAccessibilityManager::Create( |
| 754 root, | 753 root, |
| 755 NULL, | 754 NULL, |
| 756 new CountedBrowserAccessibilityFactory())); | 755 new CountedBrowserAccessibilityFactory())); |
| 757 manager->UpdateNodesForTesting(static_text, inline_text1, inline_text2); | 756 manager->UpdateNodesForTesting(static_text, inline_text1, inline_text2); |
| 758 | 757 |
| 759 BrowserAccessibility* root_accessible = manager->GetRoot(); | 758 BrowserAccessibility* root_accessible = manager->GetRoot(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 781 static_text_accessible->GetLocalBoundsForRange(2, 2).ToString()); | 780 static_text_accessible->GetLocalBoundsForRange(2, 2).ToString()); |
| 782 } | 781 } |
| 783 | 782 |
| 784 #if defined(OS_WIN) | 783 #if defined(OS_WIN) |
| 785 #define MAYBE_BoundsForRangeOnParentElement \ | 784 #define MAYBE_BoundsForRangeOnParentElement \ |
| 786 DISABLED_BoundsForRangeOnParentElement | 785 DISABLED_BoundsForRangeOnParentElement |
| 787 #else | 786 #else |
| 788 #define MAYBE_BoundsForRangeOnParentElement BoundsForRangeOnParentElement | 787 #define MAYBE_BoundsForRangeOnParentElement BoundsForRangeOnParentElement |
| 789 #endif | 788 #endif |
| 790 TEST(BrowserAccessibilityManagerTest, MAYBE_BoundsForRangeOnParentElement) { | 789 TEST(BrowserAccessibilityManagerTest, MAYBE_BoundsForRangeOnParentElement) { |
| 791 AccessibilityNodeData root; | 790 ui::AXNodeData root; |
| 792 root.id = 1; | 791 root.id = 1; |
| 793 root.role = blink::WebAXRoleRootWebArea; | 792 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 794 root.child_ids.push_back(2); | 793 root.child_ids.push_back(2); |
| 795 | 794 |
| 796 AccessibilityNodeData div; | 795 ui::AXNodeData div; |
| 797 div.id = 2; | 796 div.id = 2; |
| 798 div.role = blink::WebAXRoleDiv; | 797 div.role = ui::AX_ROLE_DIV; |
| 799 div.location = gfx::Rect(100, 100, 100, 20); | 798 div.location = gfx::Rect(100, 100, 100, 20); |
| 800 div.child_ids.push_back(3); | 799 div.child_ids.push_back(3); |
| 801 div.child_ids.push_back(4); | 800 div.child_ids.push_back(4); |
| 802 div.child_ids.push_back(5); | 801 div.child_ids.push_back(5); |
| 803 | 802 |
| 804 AccessibilityNodeData static_text1; | 803 ui::AXNodeData static_text1; |
| 805 static_text1.id = 3; | 804 static_text1.id = 3; |
| 806 static_text1.SetValue("AB"); | 805 static_text1.SetValue("AB"); |
| 807 static_text1.role = blink::WebAXRoleStaticText; | 806 static_text1.role = ui::AX_ROLE_STATIC_TEXT; |
| 808 static_text1.location = gfx::Rect(100, 100, 40, 20); | 807 static_text1.location = gfx::Rect(100, 100, 40, 20); |
| 809 static_text1.child_ids.push_back(6); | 808 static_text1.child_ids.push_back(6); |
| 810 | 809 |
| 811 AccessibilityNodeData img; | 810 ui::AXNodeData img; |
| 812 img.id = 4; | 811 img.id = 4; |
| 813 img.role = blink::WebAXRoleImage; | 812 img.role = ui::AX_ROLE_IMAGE; |
| 814 img.location = gfx::Rect(140, 100, 20, 20); | 813 img.location = gfx::Rect(140, 100, 20, 20); |
| 815 | 814 |
| 816 AccessibilityNodeData static_text2; | 815 ui::AXNodeData static_text2; |
| 817 static_text2.id = 5; | 816 static_text2.id = 5; |
| 818 static_text2.SetValue("CD"); | 817 static_text2.SetValue("CD"); |
| 819 static_text2.role = blink::WebAXRoleStaticText; | 818 static_text2.role = ui::AX_ROLE_STATIC_TEXT; |
| 820 static_text2.location = gfx::Rect(160, 100, 40, 20); | 819 static_text2.location = gfx::Rect(160, 100, 40, 20); |
| 821 static_text2.child_ids.push_back(7); | 820 static_text2.child_ids.push_back(7); |
| 822 | 821 |
| 823 AccessibilityNodeData inline_text1; | 822 ui::AXNodeData inline_text1; |
| 824 inline_text1.id = 6; | 823 inline_text1.id = 6; |
| 825 inline_text1.SetValue("AB"); | 824 inline_text1.SetValue("AB"); |
| 826 inline_text1.role = blink::WebAXRoleInlineTextBox; | 825 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 827 inline_text1.location = gfx::Rect(100, 100, 40, 20); | 826 inline_text1.location = gfx::Rect(100, 100, 40, 20); |
| 828 inline_text1.AddIntAttribute(AccessibilityNodeData::ATTR_TEXT_DIRECTION, | 827 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 829 blink::WebAXTextDirectionLR); | 828 blink::WebAXTextDirectionLR); |
| 830 std::vector<int32> character_offsets1; | 829 std::vector<int32> character_offsets1; |
| 831 character_offsets1.push_back(20); // 0 | 830 character_offsets1.push_back(20); // 0 |
| 832 character_offsets1.push_back(40); // 1 | 831 character_offsets1.push_back(40); // 1 |
| 833 inline_text1.AddIntListAttribute( | 832 inline_text1.AddIntListAttribute( |
| 834 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS, character_offsets1); | 833 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
| 835 | 834 |
| 836 AccessibilityNodeData inline_text2; | 835 ui::AXNodeData inline_text2; |
| 837 inline_text2.id = 7; | 836 inline_text2.id = 7; |
| 838 inline_text2.SetValue("CD"); | 837 inline_text2.SetValue("CD"); |
| 839 inline_text2.role = blink::WebAXRoleInlineTextBox; | 838 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
| 840 inline_text2.location = gfx::Rect(160, 100, 40, 20); | 839 inline_text2.location = gfx::Rect(160, 100, 40, 20); |
| 841 inline_text2.AddIntAttribute(AccessibilityNodeData::ATTR_TEXT_DIRECTION, | 840 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 842 blink::WebAXTextDirectionLR); | 841 blink::WebAXTextDirectionLR); |
| 843 std::vector<int32> character_offsets2; | 842 std::vector<int32> character_offsets2; |
| 844 character_offsets2.push_back(20); // 0 | 843 character_offsets2.push_back(20); // 0 |
| 845 character_offsets2.push_back(40); // 1 | 844 character_offsets2.push_back(40); // 1 |
| 846 inline_text2.AddIntListAttribute( | 845 inline_text2.AddIntListAttribute( |
| 847 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS, character_offsets2); | 846 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
| 848 | 847 |
| 849 scoped_ptr<BrowserAccessibilityManager> manager( | 848 scoped_ptr<BrowserAccessibilityManager> manager( |
| 850 BrowserAccessibilityManager::Create( | 849 BrowserAccessibilityManager::Create( |
| 851 root, | 850 root, |
| 852 NULL, | 851 NULL, |
| 853 new CountedBrowserAccessibilityFactory())); | 852 new CountedBrowserAccessibilityFactory())); |
| 854 manager->UpdateNodesForTesting( | 853 manager->UpdateNodesForTesting( |
| 855 div, static_text1, img, static_text2, inline_text1, inline_text2); | 854 div, static_text1, img, static_text2, inline_text1, inline_text2); |
| 856 | 855 |
| 857 BrowserAccessibility* root_accessible = manager->GetRoot(); | 856 BrowserAccessibility* root_accessible = manager->GetRoot(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 869 root_accessible->GetLocalBoundsForRange(1, 2).ToString()); | 868 root_accessible->GetLocalBoundsForRange(1, 2).ToString()); |
| 870 | 869 |
| 871 EXPECT_EQ(gfx::Rect(120, 100, 80, 20).ToString(), | 870 EXPECT_EQ(gfx::Rect(120, 100, 80, 20).ToString(), |
| 872 root_accessible->GetLocalBoundsForRange(1, 3).ToString()); | 871 root_accessible->GetLocalBoundsForRange(1, 3).ToString()); |
| 873 | 872 |
| 874 EXPECT_EQ(gfx::Rect(100, 100, 100, 20).ToString(), | 873 EXPECT_EQ(gfx::Rect(100, 100, 100, 20).ToString(), |
| 875 root_accessible->GetLocalBoundsForRange(0, 4).ToString()); | 874 root_accessible->GetLocalBoundsForRange(0, 4).ToString()); |
| 876 } | 875 } |
| 877 | 876 |
| 878 } // namespace content | 877 } // namespace content |
| OLD | NEW |