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

Side by Side Diff: content/browser/accessibility/browser_accessibility_win_unittest.cc

Issue 143473003: Generate ax enums from idl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Caught Blink enum conversion bug! Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/accessibility/browser_accessibility_win.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/win/scoped_bstr.h" 7 #include "base/win/scoped_bstr.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/scoped_variant.h" 9 #include "base/win/scoped_variant.h"
10 #include "content/browser/accessibility/browser_accessibility_manager.h" 10 #include "content/browser/accessibility/browser_accessibility_manager.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 416 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
417 } 417 }
418 418
419 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { 419 TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) {
420 const std::string text1_name = "One two three."; 420 const std::string text1_name = "One two three.";
421 const std::string text2_name = " Four five six."; 421 const std::string text2_name = " Four five six.";
422 422
423 ui::AXNodeData text1; 423 ui::AXNodeData text1;
424 text1.id = 11; 424 text1.id = 11;
425 text1.role = ui::AX_ROLE_STATIC_TEXT; 425 text1.role = ui::AX_ROLE_STATIC_TEXT;
426 text1.state = 1 << ui::AX_STATE_READONLY; 426 text1.state = 1 << ui::AX_STATE_READ_ONLY;
427 text1.SetName(text1_name); 427 text1.SetName(text1_name);
428 428
429 ui::AXNodeData text2; 429 ui::AXNodeData text2;
430 text2.id = 12; 430 text2.id = 12;
431 text2.role = ui::AX_ROLE_STATIC_TEXT; 431 text2.role = ui::AX_ROLE_STATIC_TEXT;
432 text2.state = 1 << ui::AX_STATE_READONLY; 432 text2.state = 1 << ui::AX_STATE_READ_ONLY;
433 text2.SetName(text2_name); 433 text2.SetName(text2_name);
434 434
435 ui::AXNodeData root; 435 ui::AXNodeData root;
436 root.id = 1; 436 root.id = 1;
437 root.role = ui::AX_ROLE_ROOT_WEB_AREA; 437 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
438 root.state = 1 << ui::AX_STATE_READONLY; 438 root.state = 1 << ui::AX_STATE_READ_ONLY;
439 root.child_ids.push_back(11); 439 root.child_ids.push_back(11);
440 root.child_ids.push_back(12); 440 root.child_ids.push_back(12);
441 441
442 CountedBrowserAccessibility::reset(); 442 CountedBrowserAccessibility::reset();
443 scoped_ptr<BrowserAccessibilityManager> manager( 443 scoped_ptr<BrowserAccessibilityManager> manager(
444 BrowserAccessibilityManager::Create( 444 BrowserAccessibilityManager::Create(
445 root, NULL, new CountedBrowserAccessibilityFactory())); 445 root, NULL, new CountedBrowserAccessibilityFactory()));
446 manager->UpdateNodesForTesting(root, text1, text2); 446 manager->UpdateNodesForTesting(root, text1, text2);
447 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); 447 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances());
448 448
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { 485 TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
486 const std::string text1_name = "One two three."; 486 const std::string text1_name = "One two three.";
487 const std::string text2_name = " Four five six."; 487 const std::string text2_name = " Four five six.";
488 const std::string button1_text_name = "red"; 488 const std::string button1_text_name = "red";
489 const std::string link1_text_name = "blue"; 489 const std::string link1_text_name = "blue";
490 490
491 ui::AXNodeData text1; 491 ui::AXNodeData text1;
492 text1.id = 11; 492 text1.id = 11;
493 text1.role = ui::AX_ROLE_STATIC_TEXT; 493 text1.role = ui::AX_ROLE_STATIC_TEXT;
494 text1.state = 1 << ui::AX_STATE_READONLY; 494 text1.state = 1 << ui::AX_STATE_READ_ONLY;
495 text1.SetName(text1_name); 495 text1.SetName(text1_name);
496 496
497 ui::AXNodeData text2; 497 ui::AXNodeData text2;
498 text2.id = 12; 498 text2.id = 12;
499 text2.role = ui::AX_ROLE_STATIC_TEXT; 499 text2.role = ui::AX_ROLE_STATIC_TEXT;
500 text2.state = 1 << ui::AX_STATE_READONLY; 500 text2.state = 1 << ui::AX_STATE_READ_ONLY;
501 text2.SetName(text2_name); 501 text2.SetName(text2_name);
502 502
503 ui::AXNodeData button1, button1_text; 503 ui::AXNodeData button1, button1_text;
504 button1.id = 13; 504 button1.id = 13;
505 button1_text.id = 15; 505 button1_text.id = 15;
506 button1_text.SetName(button1_text_name); 506 button1_text.SetName(button1_text_name);
507 button1.role = ui::AX_ROLE_BUTTON; 507 button1.role = ui::AX_ROLE_BUTTON;
508 button1_text.role = ui::AX_ROLE_STATIC_TEXT; 508 button1_text.role = ui::AX_ROLE_STATIC_TEXT;
509 button1.state = 1 << ui::AX_STATE_READONLY; 509 button1.state = 1 << ui::AX_STATE_READ_ONLY;
510 button1_text.state = 1 << ui::AX_STATE_READONLY; 510 button1_text.state = 1 << ui::AX_STATE_READ_ONLY;
511 button1.child_ids.push_back(15); 511 button1.child_ids.push_back(15);
512 512
513 ui::AXNodeData link1, link1_text; 513 ui::AXNodeData link1, link1_text;
514 link1.id = 14; 514 link1.id = 14;
515 link1_text.id = 16; 515 link1_text.id = 16;
516 link1_text.SetName(link1_text_name); 516 link1_text.SetName(link1_text_name);
517 link1.role = ui::AX_ROLE_LINK; 517 link1.role = ui::AX_ROLE_LINK;
518 link1_text.role = ui::AX_ROLE_STATIC_TEXT; 518 link1_text.role = ui::AX_ROLE_STATIC_TEXT;
519 link1.state = 1 << ui::AX_STATE_READONLY; 519 link1.state = 1 << ui::AX_STATE_READ_ONLY;
520 link1_text.state = 1 << ui::AX_STATE_READONLY; 520 link1_text.state = 1 << ui::AX_STATE_READ_ONLY;
521 link1.child_ids.push_back(16); 521 link1.child_ids.push_back(16);
522 522
523 ui::AXNodeData root; 523 ui::AXNodeData root;
524 root.id = 1; 524 root.id = 1;
525 root.role = ui::AX_ROLE_ROOT_WEB_AREA; 525 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
526 root.state = 1 << ui::AX_STATE_READONLY; 526 root.state = 1 << ui::AX_STATE_READ_ONLY;
527 root.child_ids.push_back(11); 527 root.child_ids.push_back(11);
528 root.child_ids.push_back(13); 528 root.child_ids.push_back(13);
529 root.child_ids.push_back(12); 529 root.child_ids.push_back(12);
530 root.child_ids.push_back(14); 530 root.child_ids.push_back(14);
531 531
532 CountedBrowserAccessibility::reset(); 532 CountedBrowserAccessibility::reset();
533 scoped_ptr<BrowserAccessibilityManager> manager( 533 scoped_ptr<BrowserAccessibilityManager> manager(
534 BrowserAccessibilityManager::Create( 534 BrowserAccessibilityManager::Create(
535 root, NULL, new CountedBrowserAccessibilityFactory())); 535 root, NULL, new CountedBrowserAccessibilityFactory()));
536 manager->UpdateNodesForTesting(root, 536 manager->UpdateNodesForTesting(root,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // deleted. 597 // deleted.
598 manager.reset(); 598 manager.reset();
599 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 599 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
600 } 600 }
601 601
602 TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { 602 TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) {
603 // Try creating an empty document with busy state. Readonly is 603 // Try creating an empty document with busy state. Readonly is
604 // set automatically. 604 // set automatically.
605 CountedBrowserAccessibility::reset(); 605 CountedBrowserAccessibility::reset();
606 const int32 busy_state = 1 << ui::AX_STATE_BUSY; 606 const int32 busy_state = 1 << ui::AX_STATE_BUSY;
607 const int32 readonly_state = 1 << ui::AX_STATE_READONLY; 607 const int32 readonly_state = 1 << ui::AX_STATE_READ_ONLY;
608 const int32 enabled_state = 1 << blink::WebAXStateEnabled; 608 const int32 enabled_state = 1 << blink::WebAXStateEnabled;
609 scoped_ptr<content::LegacyRenderWidgetHostHWND> accessible_hwnd( 609 scoped_ptr<content::LegacyRenderWidgetHostHWND> accessible_hwnd(
610 content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow())); 610 content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow()));
611 scoped_ptr<BrowserAccessibilityManager> manager( 611 scoped_ptr<BrowserAccessibilityManager> manager(
612 new BrowserAccessibilityManagerWin( 612 new BrowserAccessibilityManagerWin(
613 accessible_hwnd.get(), 613 accessible_hwnd.get(),
614 NULL, 614 NULL,
615 BrowserAccessibilityManagerWin::GetEmptyDocument(), 615 BrowserAccessibilityManagerWin::GetEmptyDocument(),
616 NULL, 616 NULL,
617 new CountedBrowserAccessibilityFactory())); 617 new CountedBrowserAccessibilityFactory()));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 manager->MaybeCallNotifyWinEvent(0, 0); 731 manager->MaybeCallNotifyWinEvent(0, 0);
732 new_parent_hwnd = manager->parent_hwnd(); 732 new_parent_hwnd = manager->parent_hwnd();
733 ASSERT_FALSE(NULL == new_parent_hwnd); 733 ASSERT_FALSE(NULL == new_parent_hwnd);
734 734
735 // This time, destroy the manager first, make sure the AccessibleHWND doesn't 735 // This time, destroy the manager first, make sure the AccessibleHWND doesn't
736 // crash on destruction (to be caught by SyzyASAN or other tools). 736 // crash on destruction (to be caught by SyzyASAN or other tools).
737 manager.reset(NULL); 737 manager.reset(NULL);
738 } 738 }
739 739
740 } // namespace content 740 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility_win.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698