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

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

Issue 1768753003: Implemented the reporting of text style and language information on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test expectations. Created 4 years, 9 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/win/scoped_bstr.h" 10 #include "base/win/scoped_bstr.h"
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 EXPECT_EQ(nullptr, child2_child1_accessible->PlatformDeepestFirstChild()); 1786 EXPECT_EQ(nullptr, child2_child1_accessible->PlatformDeepestFirstChild());
1787 EXPECT_EQ(nullptr, child2_child1_accessible->InternalDeepestFirstChild()); 1787 EXPECT_EQ(nullptr, child2_child1_accessible->InternalDeepestFirstChild());
1788 EXPECT_EQ(nullptr, child2_child1_accessible->PlatformDeepestLastChild()); 1788 EXPECT_EQ(nullptr, child2_child1_accessible->PlatformDeepestLastChild());
1789 EXPECT_EQ(nullptr, child2_child1_accessible->InternalDeepestLastChild()); 1789 EXPECT_EQ(nullptr, child2_child1_accessible->InternalDeepestLastChild());
1790 EXPECT_EQ(nullptr, child2_child2_accessible->PlatformDeepestFirstChild()); 1790 EXPECT_EQ(nullptr, child2_child2_accessible->PlatformDeepestFirstChild());
1791 EXPECT_EQ(nullptr, child2_child2_accessible->InternalDeepestFirstChild()); 1791 EXPECT_EQ(nullptr, child2_child2_accessible->InternalDeepestFirstChild());
1792 EXPECT_EQ(nullptr, child2_child2_accessible->PlatformDeepestLastChild()); 1792 EXPECT_EQ(nullptr, child2_child2_accessible->PlatformDeepestLastChild());
1793 EXPECT_EQ(nullptr, child2_child2_accessible->InternalDeepestLastChild()); 1793 EXPECT_EQ(nullptr, child2_child2_accessible->InternalDeepestLastChild());
1794 } 1794 }
1795 1795
1796 TEST_F(BrowserAccessibilityTest, TestInheritedStringAttributes) {
1797 ui::AXNodeData root;
1798 root.id = 1;
1799 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
1800 root.AddStringAttribute(ui::AX_ATTR_LANGUAGE, "en-US");
1801 root.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Helvetica");
1802
1803 ui::AXNodeData child1;
1804 child1.id = 2;
1805 child1.role = ui::AX_ROLE_STATIC_TEXT;
1806 root.child_ids.push_back(2);
1807
1808 ui::AXNodeData child2;
1809 child2.id = 3;
1810 child2.role = ui::AX_ROLE_STATIC_TEXT;
1811 child2.AddStringAttribute(ui::AX_ATTR_LANGUAGE, "fr");
1812 child2.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Arial");
1813 root.child_ids.push_back(3);
1814
1815 ui::AXNodeData child2_child1;
1816 child2_child1.id = 4;
1817 child2_child1.role = ui::AX_ROLE_INLINE_TEXT_BOX;
1818 child2.child_ids.push_back(4);
1819
1820 ui::AXNodeData child2_child2;
1821 child2_child2.id = 5;
1822 child2_child2.role = ui::AX_ROLE_INLINE_TEXT_BOX;
1823 child2.child_ids.push_back(5);
1824
1825 scoped_ptr<BrowserAccessibilityManager> manager(
1826 BrowserAccessibilityManager::Create(
1827 MakeAXTreeUpdate(root, child1, child2, child2_child1, child2_child2),
1828 nullptr, new CountedBrowserAccessibilityFactory()));
1829
1830 BrowserAccessibility* root_accessible = manager->GetRoot();
1831 ASSERT_NE(nullptr, root_accessible);
1832 BrowserAccessibility* child1_accessible =
1833 root_accessible->PlatformGetChild(0);
1834 ASSERT_NE(nullptr, child1_accessible);
1835 BrowserAccessibility* child2_accessible =
1836 root_accessible->PlatformGetChild(1);
1837 ASSERT_NE(nullptr, child2_accessible);
1838 BrowserAccessibility* child2_child1_accessible =
1839 child2_accessible->InternalGetChild(0);
1840 ASSERT_NE(nullptr, child2_child1_accessible);
1841 BrowserAccessibility* child2_child2_accessible =
1842 child2_accessible->InternalGetChild(1);
1843 ASSERT_NE(nullptr, child2_child2_accessible);
1844
1845 // Test GetInheritedString16Attribute(attribute).
1846 EXPECT_EQ(
1847 base::UTF8ToUTF16("en-US"),
1848 root_accessible->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE));
1849 EXPECT_EQ(
1850 base::UTF8ToUTF16("en-US"),
1851 child1_accessible->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE));
1852 EXPECT_EQ(
1853 base::UTF8ToUTF16("fr"),
1854 child2_accessible->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE));
1855 EXPECT_EQ(base::UTF8ToUTF16("fr"),
1856 child2_child1_accessible->GetInheritedString16Attribute(
1857 ui::AX_ATTR_LANGUAGE));
1858 EXPECT_EQ(base::UTF8ToUTF16("fr"),
1859 child2_child2_accessible->GetInheritedString16Attribute(
1860 ui::AX_ATTR_LANGUAGE));
1861
1862 // Test GetInheritedString16Attribute(attribute, out_value).
1863 base::string16 value16;
1864 EXPECT_TRUE(root_accessible->GetInheritedString16Attribute(
1865 ui::AX_ATTR_LANGUAGE, &value16));
1866 EXPECT_EQ(base::UTF8ToUTF16("en-US"), value16);
1867 EXPECT_TRUE(child1_accessible->GetInheritedString16Attribute(
1868 ui::AX_ATTR_LANGUAGE, &value16));
1869 EXPECT_EQ(base::UTF8ToUTF16("en-US"), value16);
1870 EXPECT_TRUE(child2_accessible->GetInheritedString16Attribute(
1871 ui::AX_ATTR_LANGUAGE, &value16));
1872 EXPECT_EQ(base::UTF8ToUTF16("fr"), value16);
1873 EXPECT_TRUE(child2_child1_accessible->GetInheritedString16Attribute(
1874 ui::AX_ATTR_LANGUAGE, &value16));
1875 EXPECT_EQ(base::UTF8ToUTF16("fr"), value16);
1876 EXPECT_TRUE(child2_child2_accessible->GetInheritedString16Attribute(
1877 ui::AX_ATTR_LANGUAGE, &value16));
1878 EXPECT_EQ(base::UTF8ToUTF16("fr"), value16);
1879
1880 // Test GetInheritedStringAttribute(attribute).
1881 EXPECT_EQ("Helvetica", root_accessible->GetInheritedStringAttribute(
1882 ui::AX_ATTR_FONT_FAMILY));
1883 EXPECT_EQ("Helvetica", child1_accessible->GetInheritedStringAttribute(
1884 ui::AX_ATTR_FONT_FAMILY));
1885 EXPECT_EQ("Arial", child2_accessible->GetInheritedStringAttribute(
1886 ui::AX_ATTR_FONT_FAMILY));
1887 EXPECT_EQ("Arial", child2_child1_accessible->GetInheritedStringAttribute(
1888 ui::AX_ATTR_FONT_FAMILY));
1889 EXPECT_EQ("Arial", child2_child2_accessible->GetInheritedStringAttribute(
1890 ui::AX_ATTR_FONT_FAMILY));
1891
1892 // Test GetInheritedStringAttribute(attribute, out_value).
1893 std::string value;
1894 EXPECT_TRUE(root_accessible->GetInheritedStringAttribute(
1895 ui::AX_ATTR_FONT_FAMILY, &value));
1896 EXPECT_EQ("Helvetica", value);
1897 EXPECT_TRUE(child1_accessible->GetInheritedStringAttribute(
1898 ui::AX_ATTR_FONT_FAMILY, &value));
1899 EXPECT_EQ("Helvetica", value);
1900 EXPECT_TRUE(child2_accessible->GetInheritedStringAttribute(
1901 ui::AX_ATTR_FONT_FAMILY, &value));
1902 EXPECT_EQ("Arial", value);
1903 EXPECT_TRUE(child2_child1_accessible->GetInheritedStringAttribute(
1904 ui::AX_ATTR_FONT_FAMILY, &value));
1905 EXPECT_EQ("Arial", value);
1906 EXPECT_TRUE(child2_child2_accessible->GetInheritedStringAttribute(
1907 ui::AX_ATTR_FONT_FAMILY, &value));
1908 EXPECT_EQ("Arial", value);
1909 }
1910
1796 TEST_F(BrowserAccessibilityTest, TestSanitizeStringAttributeForIA2) { 1911 TEST_F(BrowserAccessibilityTest, TestSanitizeStringAttributeForIA2) {
1797 base::string16 input(L"\\:=,;"); 1912 base::string16 input(L"\\:=,;");
1798 base::string16 output; 1913 base::string16 output;
1799 BrowserAccessibilityWin::SanitizeStringAttributeForIA2(input, &output); 1914 BrowserAccessibilityWin::SanitizeStringAttributeForIA2(input, &output);
1800 EXPECT_EQ(L"\\\\\\:\\=\\,\\;", output); 1915 EXPECT_EQ(L"\\\\\\:\\=\\,\\;", output);
1801 } 1916 }
1802 1917
1803 TEST_F(BrowserAccessibilityTest, UniqueIdWinInvalidAfterDeletingTree) { 1918 TEST_F(BrowserAccessibilityTest, UniqueIdWinInvalidAfterDeletingTree) {
1804 ui::AXNodeData root_node; 1919 ui::AXNodeData root_node;
1805 root_node.id = 1; 1920 root_node.id = 1;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 EXPECT_EQ(S_OK, hr); 1971 EXPECT_EQ(S_OK, hr);
1857 1972
1858 base::win::ScopedVariant new_child_variant(-child_unique_id_2); 1973 base::win::ScopedVariant new_child_variant(-child_unique_id_2);
1859 base::win::ScopedComPtr<IDispatch> new_child_dispatch; 1974 base::win::ScopedComPtr<IDispatch> new_child_dispatch;
1860 hr = ToBrowserAccessibilityWin(root)->get_accChild( 1975 hr = ToBrowserAccessibilityWin(root)->get_accChild(
1861 new_child_variant, new_child_dispatch.Receive()); 1976 new_child_variant, new_child_dispatch.Receive());
1862 EXPECT_EQ(S_OK, hr); 1977 EXPECT_EQ(S_OK, hr);
1863 } 1978 }
1864 1979
1865 } // namespace content 1980 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698