| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/win/scoped_comptr.h" | 6 #include "base/win/scoped_comptr.h" |
| 7 #include "content/browser/accessibility/browser_accessibility_manager.h" | 7 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 8 #include "content/browser/accessibility/browser_accessibility_win.h" | 8 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/base/win/atl_module.h" | 11 #include "ui/base/win/atl_module.h" |
| 12 | 12 |
| 13 using webkit_glue::WebAccessibility; | 13 using content::AccessibilityNodeData; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Subclass of BrowserAccessibilityWin that counts the number of instances. | 17 // Subclass of BrowserAccessibilityWin that counts the number of instances. |
| 18 class CountedBrowserAccessibility : public BrowserAccessibilityWin { | 18 class CountedBrowserAccessibility : public BrowserAccessibilityWin { |
| 19 public: | 19 public: |
| 20 CountedBrowserAccessibility() { global_obj_count_++; } | 20 CountedBrowserAccessibility() { global_obj_count_++; } |
| 21 virtual ~CountedBrowserAccessibility() { global_obj_count_--; } | 21 virtual ~CountedBrowserAccessibility() { global_obj_count_--; } |
| 22 static int global_obj_count_; | 22 static int global_obj_count_; |
| 23 }; | 23 }; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual void TearDown() { | 60 virtual void TearDown() { |
| 61 ::CoUninitialize(); | 61 ::CoUninitialize(); |
| 62 } | 62 } |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Test that BrowserAccessibilityManager correctly releases the tree of | 65 // Test that BrowserAccessibilityManager correctly releases the tree of |
| 66 // BrowserAccessibility instances upon delete. | 66 // BrowserAccessibility instances upon delete. |
| 67 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { | 67 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { |
| 68 // Create WebAccessibility objects for a simple document tree, | 68 // Create AccessibilityNodeData objects for a simple document tree, |
| 69 // representing the accessibility information used to initialize | 69 // representing the accessibility information used to initialize |
| 70 // BrowserAccessibilityManager. | 70 // BrowserAccessibilityManager. |
| 71 WebAccessibility button; | 71 AccessibilityNodeData button; |
| 72 button.id = 2; | 72 button.id = 2; |
| 73 button.name = L"Button"; | 73 button.name = L"Button"; |
| 74 button.role = WebAccessibility::ROLE_BUTTON; | 74 button.role = AccessibilityNodeData::ROLE_BUTTON; |
| 75 button.state = 0; | 75 button.state = 0; |
| 76 | 76 |
| 77 WebAccessibility checkbox; | 77 AccessibilityNodeData checkbox; |
| 78 checkbox.id = 3; | 78 checkbox.id = 3; |
| 79 checkbox.name = L"Checkbox"; | 79 checkbox.name = L"Checkbox"; |
| 80 checkbox.role = WebAccessibility::ROLE_CHECKBOX; | 80 checkbox.role = AccessibilityNodeData::ROLE_CHECKBOX; |
| 81 checkbox.state = 0; | 81 checkbox.state = 0; |
| 82 | 82 |
| 83 WebAccessibility root; | 83 AccessibilityNodeData root; |
| 84 root.id = 1; | 84 root.id = 1; |
| 85 root.name = L"Document"; | 85 root.name = L"Document"; |
| 86 root.role = WebAccessibility::ROLE_DOCUMENT; | 86 root.role = AccessibilityNodeData::ROLE_DOCUMENT; |
| 87 root.state = 0; | 87 root.state = 0; |
| 88 root.children.push_back(button); | 88 root.children.push_back(button); |
| 89 root.children.push_back(checkbox); | 89 root.children.push_back(checkbox); |
| 90 | 90 |
| 91 // Construct a BrowserAccessibilityManager with this WebAccessibility tree | 91 // Construct a BrowserAccessibilityManager with this |
| 92 // and a factory for an instance-counting BrowserAccessibility, and ensure | 92 // AccessibilityNodeData tree and a factory for an instance-counting |
| 93 // that exactly 3 instances were created. Note that the manager takes | 93 // BrowserAccessibility, and ensure that exactly 3 instances were |
| 94 // ownership of the factory. | 94 // created. Note that the manager takes ownership of the factory. |
| 95 CountedBrowserAccessibility::global_obj_count_ = 0; | 95 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 96 BrowserAccessibilityManager* manager = | 96 BrowserAccessibilityManager* manager = |
| 97 BrowserAccessibilityManager::Create( | 97 BrowserAccessibilityManager::Create( |
| 98 GetDesktopWindow(), | 98 GetDesktopWindow(), |
| 99 root, | 99 root, |
| 100 NULL, | 100 NULL, |
| 101 new CountedBrowserAccessibilityFactory()); | 101 new CountedBrowserAccessibilityFactory()); |
| 102 ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); | 102 ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); |
| 103 | 103 |
| 104 // Delete the manager and test that all 3 instances are deleted. | 104 // Delete the manager and test that all 3 instances are deleted. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 134 | 134 |
| 135 // Release each of our references and make sure that each one results in | 135 // Release each of our references and make sure that each one results in |
| 136 // the instance being deleted as its reference count hits zero. | 136 // the instance being deleted as its reference count hits zero. |
| 137 root_iaccessible->Release(); | 137 root_iaccessible->Release(); |
| 138 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); | 138 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); |
| 139 child1_iaccessible->Release(); | 139 child1_iaccessible->Release(); |
| 140 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 140 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 141 } | 141 } |
| 142 | 142 |
| 143 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { | 143 TEST_F(BrowserAccessibilityTest, TestChildrenChange) { |
| 144 // Create WebAccessibility objects for a simple document tree, | 144 // Create AccessibilityNodeData objects for a simple document tree, |
| 145 // representing the accessibility information used to initialize | 145 // representing the accessibility information used to initialize |
| 146 // BrowserAccessibilityManager. | 146 // BrowserAccessibilityManager. |
| 147 WebAccessibility text; | 147 AccessibilityNodeData text; |
| 148 text.id = 2; | 148 text.id = 2; |
| 149 text.role = WebAccessibility::ROLE_STATIC_TEXT; | 149 text.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 150 text.name = L"old text"; | 150 text.name = L"old text"; |
| 151 text.state = 0; | 151 text.state = 0; |
| 152 | 152 |
| 153 WebAccessibility root; | 153 AccessibilityNodeData root; |
| 154 root.id = 1; | 154 root.id = 1; |
| 155 root.name = L"Document"; | 155 root.name = L"Document"; |
| 156 root.role = WebAccessibility::ROLE_DOCUMENT; | 156 root.role = AccessibilityNodeData::ROLE_DOCUMENT; |
| 157 root.state = 0; | 157 root.state = 0; |
| 158 root.children.push_back(text); | 158 root.children.push_back(text); |
| 159 | 159 |
| 160 // Construct a BrowserAccessibilityManager with this WebAccessibility tree | 160 // Construct a BrowserAccessibilityManager with this |
| 161 // and a factory for an instance-counting BrowserAccessibility. | 161 // AccessibilityNodeData tree and a factory for an instance-counting |
| 162 // BrowserAccessibility. |
| 162 CountedBrowserAccessibility::global_obj_count_ = 0; | 163 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 163 BrowserAccessibilityManager* manager = | 164 BrowserAccessibilityManager* manager = |
| 164 BrowserAccessibilityManager::Create( | 165 BrowserAccessibilityManager::Create( |
| 165 GetDesktopWindow(), | 166 GetDesktopWindow(), |
| 166 root, | 167 root, |
| 167 NULL, | 168 NULL, |
| 168 new CountedBrowserAccessibilityFactory()); | 169 new CountedBrowserAccessibilityFactory()); |
| 169 | 170 |
| 170 // Query for the text IAccessible and verify that it returns "old text" as its | 171 // Query for the text IAccessible and verify that it returns "old text" as its |
| 171 // value. | 172 // value. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 text_dispatch.Release(); | 215 text_dispatch.Release(); |
| 215 text_accessible.Release(); | 216 text_accessible.Release(); |
| 216 | 217 |
| 217 // Delete the manager and test that all BrowserAccessibility instances are | 218 // Delete the manager and test that all BrowserAccessibility instances are |
| 218 // deleted. | 219 // deleted. |
| 219 delete manager; | 220 delete manager; |
| 220 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 221 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 221 } | 222 } |
| 222 | 223 |
| 223 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { | 224 TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { |
| 224 // Create WebAccessibility objects for a simple document tree, | 225 // Create AccessibilityNodeData objects for a simple document tree, |
| 225 // representing the accessibility information used to initialize | 226 // representing the accessibility information used to initialize |
| 226 // BrowserAccessibilityManager. | 227 // BrowserAccessibilityManager. |
| 227 WebAccessibility text; | 228 AccessibilityNodeData text; |
| 228 text.id = 3; | 229 text.id = 3; |
| 229 text.role = WebAccessibility::ROLE_STATIC_TEXT; | 230 text.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 230 text.state = 0; | 231 text.state = 0; |
| 231 | 232 |
| 232 WebAccessibility div; | 233 AccessibilityNodeData div; |
| 233 div.id = 2; | 234 div.id = 2; |
| 234 div.role = WebAccessibility::ROLE_GROUP; | 235 div.role = AccessibilityNodeData::ROLE_GROUP; |
| 235 div.state = 0; | 236 div.state = 0; |
| 236 | 237 |
| 237 div.children.push_back(text); | 238 div.children.push_back(text); |
| 238 text.id = 4; | 239 text.id = 4; |
| 239 div.children.push_back(text); | 240 div.children.push_back(text); |
| 240 | 241 |
| 241 WebAccessibility root; | 242 AccessibilityNodeData root; |
| 242 root.id = 1; | 243 root.id = 1; |
| 243 root.role = WebAccessibility::ROLE_DOCUMENT; | 244 root.role = AccessibilityNodeData::ROLE_DOCUMENT; |
| 244 root.state = 0; | 245 root.state = 0; |
| 245 root.children.push_back(div); | 246 root.children.push_back(div); |
| 246 | 247 |
| 247 // Construct a BrowserAccessibilityManager with this WebAccessibility tree | 248 // Construct a BrowserAccessibilityManager with this |
| 248 // and a factory for an instance-counting BrowserAccessibility and ensure | 249 // AccessibilityNodeData tree and a factory for an instance-counting |
| 249 // that exactly 4 instances were created. Note that the manager takes | 250 // BrowserAccessibility and ensure that exactly 4 instances were |
| 250 // ownership of the factory. | 251 // created. Note that the manager takes ownership of the factory. |
| 251 CountedBrowserAccessibility::global_obj_count_ = 0; | 252 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 252 BrowserAccessibilityManager* manager = | 253 BrowserAccessibilityManager* manager = |
| 253 BrowserAccessibilityManager::Create( | 254 BrowserAccessibilityManager::Create( |
| 254 GetDesktopWindow(), | 255 GetDesktopWindow(), |
| 255 root, | 256 root, |
| 256 NULL, | 257 NULL, |
| 257 new CountedBrowserAccessibilityFactory()); | 258 new CountedBrowserAccessibilityFactory()); |
| 258 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); | 259 ASSERT_EQ(4, CountedBrowserAccessibility::global_obj_count_); |
| 259 | 260 |
| 260 // Notify the BrowserAccessibilityManager that the div node and its children | 261 // Notify the BrowserAccessibilityManager that the div node and its children |
| 261 // were removed and ensure that only one BrowserAccessibility instance exists. | 262 // were removed and ensure that only one BrowserAccessibility instance exists. |
| 262 root.children.clear(); | 263 root.children.clear(); |
| 263 AccessibilityHostMsg_NotificationParams param; | 264 AccessibilityHostMsg_NotificationParams param; |
| 264 param.notification_type = AccessibilityNotificationChildrenChanged; | 265 param.notification_type = AccessibilityNotificationChildrenChanged; |
| 265 param.acc_tree = root; | 266 param.acc_tree = root; |
| 266 param.includes_children = true; | 267 param.includes_children = true; |
| 267 param.id = root.id; | 268 param.id = root.id; |
| 268 std::vector<AccessibilityHostMsg_NotificationParams> notifications; | 269 std::vector<AccessibilityHostMsg_NotificationParams> notifications; |
| 269 notifications.push_back(param); | 270 notifications.push_back(param); |
| 270 manager->OnAccessibilityNotifications(notifications); | 271 manager->OnAccessibilityNotifications(notifications); |
| 271 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); | 272 ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); |
| 272 | 273 |
| 273 // Delete the manager and test that all BrowserAccessibility instances are | 274 // Delete the manager and test that all BrowserAccessibility instances are |
| 274 // deleted. | 275 // deleted. |
| 275 delete manager; | 276 delete manager; |
| 276 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 277 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 277 } | 278 } |
| 278 | 279 |
| 279 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { | 280 TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { |
| 280 WebAccessibility text1; | 281 AccessibilityNodeData text1; |
| 281 text1.id = 11; | 282 text1.id = 11; |
| 282 text1.role = WebAccessibility::ROLE_TEXT_FIELD; | 283 text1.role = AccessibilityNodeData::ROLE_TEXT_FIELD; |
| 283 text1.state = 0; | 284 text1.state = 0; |
| 284 text1.value = L"One two three.\nFour five six."; | 285 text1.value = L"One two three.\nFour five six."; |
| 285 text1.line_breaks.push_back(15); | 286 text1.line_breaks.push_back(15); |
| 286 | 287 |
| 287 WebAccessibility root; | 288 AccessibilityNodeData root; |
| 288 root.id = 1; | 289 root.id = 1; |
| 289 root.role = WebAccessibility::ROLE_DOCUMENT; | 290 root.role = AccessibilityNodeData::ROLE_DOCUMENT; |
| 290 root.state = 0; | 291 root.state = 0; |
| 291 root.children.push_back(text1); | 292 root.children.push_back(text1); |
| 292 | 293 |
| 293 CountedBrowserAccessibility::global_obj_count_ = 0; | 294 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 294 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( | 295 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( |
| 295 GetDesktopWindow(), root, NULL, | 296 GetDesktopWindow(), root, NULL, |
| 296 new CountedBrowserAccessibilityFactory()); | 297 new CountedBrowserAccessibilityFactory()); |
| 297 ASSERT_EQ(2, CountedBrowserAccessibility::global_obj_count_); | 298 ASSERT_EQ(2, CountedBrowserAccessibility::global_obj_count_); |
| 298 | 299 |
| 299 BrowserAccessibilityWin* root_obj = | 300 BrowserAccessibilityWin* root_obj = |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 ASSERT_EQ(text, string16(L"One two three.\nFour five six.")); | 361 ASSERT_EQ(text, string16(L"One two three.\nFour five six.")); |
| 361 SysFreeString(text); | 362 SysFreeString(text); |
| 362 | 363 |
| 363 // Delete the manager and test that all BrowserAccessibility instances are | 364 // Delete the manager and test that all BrowserAccessibility instances are |
| 364 // deleted. | 365 // deleted. |
| 365 delete manager; | 366 delete manager; |
| 366 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 367 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 367 } | 368 } |
| 368 | 369 |
| 369 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { | 370 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { |
| 370 WebAccessibility text1; | 371 AccessibilityNodeData text1; |
| 371 text1.id = 11; | 372 text1.id = 11; |
| 372 text1.role = WebAccessibility::ROLE_STATIC_TEXT; | 373 text1.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 373 text1.state = 1 << WebAccessibility::STATE_READONLY; | 374 text1.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 374 text1.name = L"One two three."; | 375 text1.name = L"One two three."; |
| 375 | 376 |
| 376 WebAccessibility text2; | 377 AccessibilityNodeData text2; |
| 377 text2.id = 12; | 378 text2.id = 12; |
| 378 text2.role = WebAccessibility::ROLE_STATIC_TEXT; | 379 text2.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 379 text2.state = 1 << WebAccessibility::STATE_READONLY; | 380 text2.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 380 text2.name = L" Four five six."; | 381 text2.name = L" Four five six."; |
| 381 | 382 |
| 382 WebAccessibility root; | 383 AccessibilityNodeData root; |
| 383 root.id = 1; | 384 root.id = 1; |
| 384 root.role = WebAccessibility::ROLE_DOCUMENT; | 385 root.role = AccessibilityNodeData::ROLE_DOCUMENT; |
| 385 root.state = 1 << WebAccessibility::STATE_READONLY; | 386 root.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 386 root.children.push_back(text1); | 387 root.children.push_back(text1); |
| 387 root.children.push_back(text2); | 388 root.children.push_back(text2); |
| 388 | 389 |
| 389 CountedBrowserAccessibility::global_obj_count_ = 0; | 390 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 390 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( | 391 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( |
| 391 GetDesktopWindow(), root, NULL, | 392 GetDesktopWindow(), root, NULL, |
| 392 new CountedBrowserAccessibilityFactory()); | 393 new CountedBrowserAccessibilityFactory()); |
| 393 ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); | 394 ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); |
| 394 | 395 |
| 395 BrowserAccessibilityWin* root_obj = | 396 BrowserAccessibilityWin* root_obj = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 424 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlinkIndex(29, &hyperlink_index)); | 425 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlinkIndex(29, &hyperlink_index)); |
| 425 EXPECT_EQ(-1, hyperlink_index); | 426 EXPECT_EQ(-1, hyperlink_index); |
| 426 | 427 |
| 427 // Delete the manager and test that all BrowserAccessibility instances are | 428 // Delete the manager and test that all BrowserAccessibility instances are |
| 428 // deleted. | 429 // deleted. |
| 429 delete manager; | 430 delete manager; |
| 430 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 431 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 431 } | 432 } |
| 432 | 433 |
| 433 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { | 434 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { |
| 434 WebAccessibility text1; | 435 AccessibilityNodeData text1; |
| 435 text1.id = 11; | 436 text1.id = 11; |
| 436 text1.role = WebAccessibility::ROLE_STATIC_TEXT; | 437 text1.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 437 text1.state = 1 << WebAccessibility::STATE_READONLY; | 438 text1.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 438 text1.name = L"One two three."; | 439 text1.name = L"One two three."; |
| 439 | 440 |
| 440 WebAccessibility text2; | 441 AccessibilityNodeData text2; |
| 441 text2.id = 12; | 442 text2.id = 12; |
| 442 text2.role = WebAccessibility::ROLE_STATIC_TEXT; | 443 text2.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 443 text2.state = 1 << WebAccessibility::STATE_READONLY; | 444 text2.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 444 text2.name = L" Four five six."; | 445 text2.name = L" Four five six."; |
| 445 | 446 |
| 446 WebAccessibility button1, button1_text; | 447 AccessibilityNodeData button1, button1_text; |
| 447 button1.id = 13; | 448 button1.id = 13; |
| 448 button1_text.id = 15; | 449 button1_text.id = 15; |
| 449 button1_text.name = L"red"; | 450 button1_text.name = L"red"; |
| 450 button1.role = WebAccessibility::ROLE_BUTTON; | 451 button1.role = AccessibilityNodeData::ROLE_BUTTON; |
| 451 button1_text.role = WebAccessibility::ROLE_STATIC_TEXT; | 452 button1_text.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 452 button1.state = 1 << WebAccessibility::STATE_READONLY; | 453 button1.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 453 button1_text.state = 1 << WebAccessibility::STATE_READONLY; | 454 button1_text.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 454 button1.children.push_back(button1_text); | 455 button1.children.push_back(button1_text); |
| 455 | 456 |
| 456 WebAccessibility link1, link1_text; | 457 AccessibilityNodeData link1, link1_text; |
| 457 link1.id = 14; | 458 link1.id = 14; |
| 458 link1_text.id = 16; | 459 link1_text.id = 16; |
| 459 link1_text.name = L"blue"; | 460 link1_text.name = L"blue"; |
| 460 link1.role = WebAccessibility::ROLE_LINK; | 461 link1.role = AccessibilityNodeData::ROLE_LINK; |
| 461 link1_text.role = WebAccessibility::ROLE_STATIC_TEXT; | 462 link1_text.role = AccessibilityNodeData::ROLE_STATIC_TEXT; |
| 462 link1.state = 1 << WebAccessibility::STATE_READONLY; | 463 link1.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 463 link1_text.state = 1 << WebAccessibility::STATE_READONLY; | 464 link1_text.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 464 link1.children.push_back(link1_text); | 465 link1.children.push_back(link1_text); |
| 465 | 466 |
| 466 WebAccessibility root; | 467 AccessibilityNodeData root; |
| 467 root.id = 1; | 468 root.id = 1; |
| 468 root.role = WebAccessibility::ROLE_DOCUMENT; | 469 root.role = AccessibilityNodeData::ROLE_DOCUMENT; |
| 469 root.state = 1 << WebAccessibility::STATE_READONLY; | 470 root.state = 1 << AccessibilityNodeData::STATE_READONLY; |
| 470 root.children.push_back(text1); | 471 root.children.push_back(text1); |
| 471 root.children.push_back(button1); | 472 root.children.push_back(button1); |
| 472 root.children.push_back(text2); | 473 root.children.push_back(text2); |
| 473 root.children.push_back(link1); | 474 root.children.push_back(link1); |
| 474 | 475 |
| 475 CountedBrowserAccessibility::global_obj_count_ = 0; | 476 CountedBrowserAccessibility::global_obj_count_ = 0; |
| 476 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( | 477 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( |
| 477 GetDesktopWindow(), root, NULL, | 478 GetDesktopWindow(), root, NULL, |
| 478 new CountedBrowserAccessibilityFactory()); | 479 new CountedBrowserAccessibilityFactory()); |
| 479 ASSERT_EQ(7, CountedBrowserAccessibility::global_obj_count_); | 480 ASSERT_EQ(7, CountedBrowserAccessibility::global_obj_count_); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index)); | 528 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index)); |
| 528 EXPECT_EQ(0, hyperlink_index); | 529 EXPECT_EQ(0, hyperlink_index); |
| 529 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(30, &hyperlink_index)); | 530 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(30, &hyperlink_index)); |
| 530 EXPECT_EQ(1, hyperlink_index); | 531 EXPECT_EQ(1, hyperlink_index); |
| 531 | 532 |
| 532 // Delete the manager and test that all BrowserAccessibility instances are | 533 // Delete the manager and test that all BrowserAccessibility instances are |
| 533 // deleted. | 534 // deleted. |
| 534 delete manager; | 535 delete manager; |
| 535 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 536 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
| 536 } | 537 } |
| OLD | NEW |