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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
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 <stddef.h>
6 #include <stdint.h>
7
5 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
6 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h"
7 #include "content/browser/accessibility/browser_accessibility.h" 11 #include "content/browser/accessibility/browser_accessibility.h"
8 #include "content/browser/accessibility/browser_accessibility_manager.h" 12 #include "content/browser/accessibility/browser_accessibility_manager.h"
9 #if defined(OS_WIN) 13 #if defined(OS_WIN)
10 #include "content/browser/accessibility/browser_accessibility_win.h" 14 #include "content/browser/accessibility/browser_accessibility_win.h"
11 #endif 15 #endif
12 #include "content/public/browser/ax_event_notification_details.h" 16 #include "content/public/browser/ax_event_notification_details.h"
13 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
14 18
15 namespace content { 19 namespace content {
16 namespace { 20 namespace {
(...skipping 17 matching lines...) Expand all
34 38
35 int native_ref_count_; 39 int native_ref_count_;
36 static int global_obj_count_; 40 static int global_obj_count_;
37 41
38 #if defined(OS_WIN) 42 #if defined(OS_WIN)
39 // Adds some padding to prevent a heap-buffer-overflow when an instance of 43 // Adds some padding to prevent a heap-buffer-overflow when an instance of
40 // this class is casted into a BrowserAccessibilityWin pointer. 44 // this class is casted into a BrowserAccessibilityWin pointer.
41 // http://crbug.com/235508 45 // http://crbug.com/235508
42 // TODO(dmazzoni): Fix this properly. 46 // TODO(dmazzoni): Fix this properly.
43 static const size_t kDataSize = sizeof(int) + sizeof(BrowserAccessibility); 47 static const size_t kDataSize = sizeof(int) + sizeof(BrowserAccessibility);
44 uint8 padding_[sizeof(BrowserAccessibilityWin) - kDataSize]; 48 uint8_t padding_[sizeof(BrowserAccessibilityWin) - kDataSize];
45 #endif 49 #endif
46 }; 50 };
47 51
48 int CountedBrowserAccessibility::global_obj_count_ = 0; 52 int CountedBrowserAccessibility::global_obj_count_ = 0;
49 53
50 // Factory that creates a CountedBrowserAccessibility. 54 // Factory that creates a CountedBrowserAccessibility.
51 class CountedBrowserAccessibilityFactory 55 class CountedBrowserAccessibilityFactory
52 : public BrowserAccessibilityFactory { 56 : public BrowserAccessibilityFactory {
53 public: 57 public:
54 ~CountedBrowserAccessibilityFactory() override {} 58 ~CountedBrowserAccessibilityFactory() override {}
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 static_text.location = gfx::Rect(100, 100, 29, 18); 642 static_text.location = gfx::Rect(100, 100, 29, 18);
639 root.child_ids.push_back(2); 643 root.child_ids.push_back(2);
640 644
641 ui::AXNodeData inline_text1; 645 ui::AXNodeData inline_text1;
642 inline_text1.id = 3; 646 inline_text1.id = 3;
643 inline_text1.SetName("Hello, "); 647 inline_text1.SetName("Hello, ");
644 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; 648 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX;
645 inline_text1.location = gfx::Rect(100, 100, 29, 9); 649 inline_text1.location = gfx::Rect(100, 100, 29, 9);
646 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 650 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
647 ui::AX_TEXT_DIRECTION_LTR); 651 ui::AX_TEXT_DIRECTION_LTR);
648 std::vector<int32> character_offsets1; 652 std::vector<int32_t> character_offsets1;
649 character_offsets1.push_back(6); // 0 653 character_offsets1.push_back(6); // 0
650 character_offsets1.push_back(11); // 1 654 character_offsets1.push_back(11); // 1
651 character_offsets1.push_back(16); // 2 655 character_offsets1.push_back(16); // 2
652 character_offsets1.push_back(21); // 3 656 character_offsets1.push_back(21); // 3
653 character_offsets1.push_back(26); // 4 657 character_offsets1.push_back(26); // 4
654 character_offsets1.push_back(29); // 5 658 character_offsets1.push_back(29); // 5
655 character_offsets1.push_back(29); // 6 (note that the space has no width) 659 character_offsets1.push_back(29); // 6 (note that the space has no width)
656 inline_text1.AddIntListAttribute( 660 inline_text1.AddIntListAttribute(
657 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); 661 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1);
658 static_text.child_ids.push_back(3); 662 static_text.child_ids.push_back(3);
659 663
660 ui::AXNodeData inline_text2; 664 ui::AXNodeData inline_text2;
661 inline_text2.id = 4; 665 inline_text2.id = 4;
662 inline_text2.SetName("world."); 666 inline_text2.SetName("world.");
663 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; 667 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX;
664 inline_text2.location = gfx::Rect(100, 109, 28, 9); 668 inline_text2.location = gfx::Rect(100, 109, 28, 9);
665 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 669 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
666 ui::AX_TEXT_DIRECTION_LTR); 670 ui::AX_TEXT_DIRECTION_LTR);
667 std::vector<int32> character_offsets2; 671 std::vector<int32_t> character_offsets2;
668 character_offsets2.push_back(5); 672 character_offsets2.push_back(5);
669 character_offsets2.push_back(10); 673 character_offsets2.push_back(10);
670 character_offsets2.push_back(15); 674 character_offsets2.push_back(15);
671 character_offsets2.push_back(20); 675 character_offsets2.push_back(20);
672 character_offsets2.push_back(25); 676 character_offsets2.push_back(25);
673 character_offsets2.push_back(28); 677 character_offsets2.push_back(28);
674 inline_text2.AddIntListAttribute( 678 inline_text2.AddIntListAttribute(
675 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); 679 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2);
676 static_text.child_ids.push_back(4); 680 static_text.child_ids.push_back(4);
677 681
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 static_text.location = gfx::Rect(100, 100, 60, 20); 737 static_text.location = gfx::Rect(100, 100, 60, 20);
734 root.child_ids.push_back(2); 738 root.child_ids.push_back(2);
735 739
736 ui::AXNodeData inline_text1; 740 ui::AXNodeData inline_text1;
737 inline_text1.id = 3; 741 inline_text1.id = 3;
738 inline_text1.SetName("123"); 742 inline_text1.SetName("123");
739 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; 743 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX;
740 inline_text1.location = gfx::Rect(100, 100, 30, 20); 744 inline_text1.location = gfx::Rect(100, 100, 30, 20);
741 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 745 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
742 ui::AX_TEXT_DIRECTION_LTR); 746 ui::AX_TEXT_DIRECTION_LTR);
743 std::vector<int32> character_offsets1; 747 std::vector<int32_t> character_offsets1;
744 character_offsets1.push_back(10); // 0 748 character_offsets1.push_back(10); // 0
745 character_offsets1.push_back(20); // 1 749 character_offsets1.push_back(20); // 1
746 character_offsets1.push_back(30); // 2 750 character_offsets1.push_back(30); // 2
747 inline_text1.AddIntListAttribute( 751 inline_text1.AddIntListAttribute(
748 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); 752 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1);
749 static_text.child_ids.push_back(3); 753 static_text.child_ids.push_back(3);
750 754
751 ui::AXNodeData inline_text2; 755 ui::AXNodeData inline_text2;
752 inline_text2.id = 4; 756 inline_text2.id = 4;
753 inline_text2.SetName("abc"); 757 inline_text2.SetName("abc");
754 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; 758 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX;
755 inline_text2.location = gfx::Rect(130, 100, 30, 20); 759 inline_text2.location = gfx::Rect(130, 100, 30, 20);
756 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 760 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
757 ui::AX_TEXT_DIRECTION_RTL); 761 ui::AX_TEXT_DIRECTION_RTL);
758 std::vector<int32> character_offsets2; 762 std::vector<int32_t> character_offsets2;
759 character_offsets2.push_back(10); 763 character_offsets2.push_back(10);
760 character_offsets2.push_back(20); 764 character_offsets2.push_back(20);
761 character_offsets2.push_back(30); 765 character_offsets2.push_back(30);
762 inline_text2.AddIntListAttribute( 766 inline_text2.AddIntListAttribute(
763 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); 767 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2);
764 static_text.child_ids.push_back(4); 768 static_text.child_ids.push_back(4);
765 769
766 scoped_ptr<BrowserAccessibilityManager> manager( 770 scoped_ptr<BrowserAccessibilityManager> manager(
767 BrowserAccessibilityManager::Create( 771 BrowserAccessibilityManager::Create(
768 MakeAXTreeUpdate(root, static_text, inline_text1, inline_text2), 772 MakeAXTreeUpdate(root, static_text, inline_text1, inline_text2),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 static_text.location = gfx::Rect(100, 100, 16, 9); 812 static_text.location = gfx::Rect(100, 100, 16, 9);
809 root.child_ids.push_back(2); 813 root.child_ids.push_back(2);
810 814
811 ui::AXNodeData inline_text; 815 ui::AXNodeData inline_text;
812 inline_text.id = 3; 816 inline_text.id = 3;
813 inline_text.SetName("ABC"); 817 inline_text.SetName("ABC");
814 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; 818 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX;
815 inline_text.location = gfx::Rect(100, 100, 16, 9); 819 inline_text.location = gfx::Rect(100, 100, 16, 9);
816 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 820 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
817 ui::AX_TEXT_DIRECTION_LTR); 821 ui::AX_TEXT_DIRECTION_LTR);
818 std::vector<int32> character_offsets1; 822 std::vector<int32_t> character_offsets1;
819 character_offsets1.push_back(6); // 0 823 character_offsets1.push_back(6); // 0
820 character_offsets1.push_back(11); // 1 824 character_offsets1.push_back(11); // 1
821 character_offsets1.push_back(16); // 2 825 character_offsets1.push_back(16); // 2
822 inline_text.AddIntListAttribute( 826 inline_text.AddIntListAttribute(
823 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); 827 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1);
824 static_text.child_ids.push_back(3); 828 static_text.child_ids.push_back(3);
825 829
826 scoped_ptr<BrowserAccessibilityManager> manager( 830 scoped_ptr<BrowserAccessibilityManager> manager(
827 BrowserAccessibilityManager::Create( 831 BrowserAccessibilityManager::Create(
828 MakeAXTreeUpdate(root, static_text, inline_text), 832 MakeAXTreeUpdate(root, static_text, inline_text),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 static_text2.location = gfx::Rect(160, 100, 40, 20); 885 static_text2.location = gfx::Rect(160, 100, 40, 20);
882 static_text2.child_ids.push_back(7); 886 static_text2.child_ids.push_back(7);
883 887
884 ui::AXNodeData inline_text1; 888 ui::AXNodeData inline_text1;
885 inline_text1.id = 6; 889 inline_text1.id = 6;
886 inline_text1.SetName("AB"); 890 inline_text1.SetName("AB");
887 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; 891 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX;
888 inline_text1.location = gfx::Rect(100, 100, 40, 20); 892 inline_text1.location = gfx::Rect(100, 100, 40, 20);
889 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 893 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
890 ui::AX_TEXT_DIRECTION_LTR); 894 ui::AX_TEXT_DIRECTION_LTR);
891 std::vector<int32> character_offsets1; 895 std::vector<int32_t> character_offsets1;
892 character_offsets1.push_back(20); // 0 896 character_offsets1.push_back(20); // 0
893 character_offsets1.push_back(40); // 1 897 character_offsets1.push_back(40); // 1
894 inline_text1.AddIntListAttribute( 898 inline_text1.AddIntListAttribute(
895 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); 899 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1);
896 900
897 ui::AXNodeData inline_text2; 901 ui::AXNodeData inline_text2;
898 inline_text2.id = 7; 902 inline_text2.id = 7;
899 inline_text2.SetName("CD"); 903 inline_text2.SetName("CD");
900 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; 904 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX;
901 inline_text2.location = gfx::Rect(160, 100, 40, 20); 905 inline_text2.location = gfx::Rect(160, 100, 40, 20);
902 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, 906 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION,
903 ui::AX_TEXT_DIRECTION_LTR); 907 ui::AX_TEXT_DIRECTION_LTR);
904 std::vector<int32> character_offsets2; 908 std::vector<int32_t> character_offsets2;
905 character_offsets2.push_back(20); // 0 909 character_offsets2.push_back(20); // 0
906 character_offsets2.push_back(40); // 1 910 character_offsets2.push_back(40); // 1
907 inline_text2.AddIntListAttribute( 911 inline_text2.AddIntListAttribute(
908 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); 912 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2);
909 913
910 scoped_ptr<BrowserAccessibilityManager> manager( 914 scoped_ptr<BrowserAccessibilityManager> manager(
911 BrowserAccessibilityManager::Create( 915 BrowserAccessibilityManager::Create(
912 MakeAXTreeUpdate( 916 MakeAXTreeUpdate(
913 root, div, static_text1, img, 917 root, div, static_text1, img,
914 static_text2, inline_text1, inline_text2), 918 static_text2, inline_text1, inline_text2),
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 events2[0].event_type = ui::AX_EVENT_NONE; 1199 events2[0].event_type = ui::AX_EVENT_NONE;
1196 manager->OnAccessibilityEvents(events2); 1200 manager->OnAccessibilityEvents(events2);
1197 1201
1198 // Make sure that the focused node was updated to the new root and 1202 // Make sure that the focused node was updated to the new root and
1199 // that this doesn't crash. 1203 // that this doesn't crash.
1200 ASSERT_EQ(3, manager->GetRoot()->GetId()); 1204 ASSERT_EQ(3, manager->GetRoot()->GetId());
1201 ASSERT_EQ(3, manager->GetFocus(manager->GetRoot())->GetId()); 1205 ASSERT_EQ(3, manager->GetFocus(manager->GetRoot())->GetId());
1202 } 1206 }
1203 1207
1204 } // namespace content 1208 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698