Commit 32ffd534 authored by Ethan Jimenez's avatar Ethan Jimenez Committed by Commit Bot

Implement UIA LandmarkType and LocalizedLandmarkType

1. Adding a method in `AXPlatformNodeDelegate` to provide a localized
   string for the Landmark Type property of an element.

   A cross-platform browser test to validate such method is created.

2. Introducing support in `AXPlatformNodeWin::GetPropertyValue` for UIA
   Landmark Type and Localized Landmark Type properties.

3. Adding unit tests for both properties in `AXPlatformNodeWinTest`.

4. Updating role mapping for Windows and Linux platforms to be more
   consistent with the CORE-AMM specification.

   See: https://www.w3.org/TR/html-aam-1.0/#html-element-role-mappings
        https://www.w3.org/TR/core-aam-1.2/#mapping_role_table

Bug: 844149
Change-Id: I7a2f47ff6b7b127907b8bfff63ae84852e153f1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1509907
Commit-Queue: Ethan Jimenez <ethavar@microsoft.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarMartin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#642362}
parent 179784a6
...@@ -1354,6 +1354,31 @@ BrowserAccessibility::GetLocalizedRoleDescriptionForUnlabeledImage() const { ...@@ -1354,6 +1354,31 @@ BrowserAccessibility::GetLocalizedRoleDescriptionForUnlabeledImage() const {
IDS_AX_UNLABELED_IMAGE_ROLE_DESCRIPTION); IDS_AX_UNLABELED_IMAGE_ROLE_DESCRIPTION);
} }
base::string16 BrowserAccessibility::GetLocalizedStringForLandmarkType() const {
const ContentClient* content_client = content::GetContentClient();
const ui::AXNodeData& data = GetData();
switch (data.role) {
case ax::mojom::Role::kBanner:
return content_client->GetLocalizedString(IDS_AX_ROLE_BANNER);
case ax::mojom::Role::kComplementary:
return content_client->GetLocalizedString(IDS_AX_ROLE_COMPLEMENTARY);
case ax::mojom::Role::kContentInfo:
case ax::mojom::Role::kFooter:
return content_client->GetLocalizedString(IDS_AX_ROLE_CONTENT_INFO);
case ax::mojom::Role::kRegion:
if (data.HasStringAttribute(ax::mojom::StringAttribute::kName))
return content_client->GetLocalizedString(IDS_AX_ROLE_REGION);
FALLTHROUGH;
default:
return {};
}
}
bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() { bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() {
BrowserAccessibilityStateImpl* accessibility_state = BrowserAccessibilityStateImpl* accessibility_state =
BrowserAccessibilityStateImpl::GetInstance(); BrowserAccessibilityStateImpl::GetInstance();
......
...@@ -403,6 +403,7 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { ...@@ -403,6 +403,7 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
base::string16 GetLocalizedStringForImageAnnotationStatus( base::string16 GetLocalizedStringForImageAnnotationStatus(
ax::mojom::ImageAnnotationStatus status) const override; ax::mojom::ImageAnnotationStatus status) const override;
base::string16 GetLocalizedRoleDescriptionForUnlabeledImage() const override; base::string16 GetLocalizedRoleDescriptionForUnlabeledImage() const override;
base::string16 GetLocalizedStringForLandmarkType() const override;
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
bool IsOffscreen() const override; bool IsOffscreen() const override;
bool IsWebContent() const override; bool IsWebContent() const override;
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/accessibility/browser_accessibility.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
...@@ -67,6 +70,12 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { ...@@ -67,6 +70,12 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
void TearDownOnMainThread() override; void TearDownOnMainThread() override;
protected: protected:
BrowserAccessibilityManager* GetManager() {
WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents());
return web_contents->GetRootBrowserAccessibilityManager();
}
std::string GetAttr(const ui::AXNode* node, std::string GetAttr(const ui::AXNode* node,
const ax::mojom::StringAttribute attr); const ax::mojom::StringAttribute attr);
int GetIntAttr(const ui::AXNode* node, const ax::mojom::IntAttribute attr); int GetIntAttr(const ui::AXNode* node, const ax::mojom::IntAttribute attr);
...@@ -457,4 +466,80 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ...@@ -457,4 +466,80 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
EXPECT_EQ(-1, GetIntAttr(header5, ax::mojom::IntAttribute::kSortDirection)); EXPECT_EQ(-1, GetIntAttr(header5, ax::mojom::IntAttribute::kSortDirection));
} }
IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest,
LocalizedLandmarkType) {
AccessibilityNotificationWaiter waiter(shell()->web_contents(),
ui::kAXModeComplete,
ax::mojom::Event::kLoadComplete);
GURL url(
"data:text/html,"
"<!doctype html>"
"<header aria-label='header'></header>"
"<aside aria-label='aside'></aside>"
"<footer aria-label='footer'></footer>"
"<form aria-label='form'></form>"
"<main aria-label='main'></main>"
"<nav aria-label='nav'></nav>"
"<section></section>"
"<section aria-label='section'></section>"
"<div role='banner' aria-label='banner'></div>"
"<div role='complementary' aria-label='complementary'></div>"
"<div role='contentinfo' aria-label='contentinfo'></div>"
"<div role='form' aria-label='role_form'></div>"
"<div role='main' aria-label='role_main'></div>"
"<div role='navigation' aria-label='role_nav'></div>"
"<div role='region'></div>"
"<div role='region' aria-label='region'></div>"
"<div role='search' aria-label='search'></div>");
NavigateToURL(shell(), url);
waiter.WaitForNotification();
BrowserAccessibility* root = GetManager()->GetRoot();
ASSERT_NE(nullptr, root);
ASSERT_EQ(17u, root->PlatformChildCount());
auto TestLocalizedLandmarkType =
[root](int child_index, ax::mojom::Role expected_role,
const std::string& expected_name,
const base::string16& expected_localized_landmark_type = {}) {
BrowserAccessibility* node = root->PlatformGetChild(child_index);
ASSERT_NE(nullptr, node);
EXPECT_EQ(expected_role, node->GetRole());
EXPECT_EQ(expected_name,
node->GetStringAttribute(ax::mojom::StringAttribute::kName));
EXPECT_EQ(expected_localized_landmark_type,
node->GetLocalizedStringForLandmarkType());
};
// For testing purposes, assume we get en-US localized strings.
TestLocalizedLandmarkType(0, ax::mojom::Role::kBanner, "header",
base::ASCIIToUTF16("banner"));
TestLocalizedLandmarkType(1, ax::mojom::Role::kComplementary, "aside",
base::ASCIIToUTF16("complementary"));
TestLocalizedLandmarkType(2, ax::mojom::Role::kFooter, "footer",
base::ASCIIToUTF16("content info"));
TestLocalizedLandmarkType(3, ax::mojom::Role::kForm, "form");
TestLocalizedLandmarkType(4, ax::mojom::Role::kMain, "main");
TestLocalizedLandmarkType(5, ax::mojom::Role::kNavigation, "nav");
TestLocalizedLandmarkType(6, ax::mojom::Role::kRegion, "");
TestLocalizedLandmarkType(7, ax::mojom::Role::kRegion, "section",
base::ASCIIToUTF16("region"));
TestLocalizedLandmarkType(8, ax::mojom::Role::kBanner, "banner",
base::ASCIIToUTF16("banner"));
TestLocalizedLandmarkType(9, ax::mojom::Role::kComplementary, "complementary",
base::ASCIIToUTF16("complementary"));
TestLocalizedLandmarkType(10, ax::mojom::Role::kContentInfo, "contentinfo",
base::ASCIIToUTF16("content info"));
TestLocalizedLandmarkType(11, ax::mojom::Role::kForm, "role_form");
TestLocalizedLandmarkType(12, ax::mojom::Role::kMain, "role_main");
TestLocalizedLandmarkType(13, ax::mojom::Role::kNavigation, "role_nav");
TestLocalizedLandmarkType(14, ax::mojom::Role::kRegion, "");
TestLocalizedLandmarkType(15, ax::mojom::Role::kRegion, "region",
base::ASCIIToUTF16("region"));
TestLocalizedLandmarkType(16, ax::mojom::Role::kSearch, "search");
}
} // namespace content } // namespace content
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_HEADER xml-roles:banner ++IA2_ROLE_LANDMARK xml-roles:banner
++++ROLE_SYSTEM_STATICTEXT name='Chromium Browser' ++++ROLE_SYSTEM_STATICTEXT name='Chromium Browser'
[document web] [document web]
++[footer] ++[landmark] xml-roles:contentinfo
++++[text] name='Footer element' ++++[text] name='Footer element'
AXWebArea AXWebArea AXRoleDescription='HTML content'
++AXGroup AXSubrole=AXLandmarkContentInfo AXRoleDescription='footer' ++AXGroup AXSubrole=AXLandmarkContentInfo AXRoleDescription='footer'
++++AXStaticText AXValue='Footer element' ++++AXStaticText AXRoleDescription='text' AXValue='Footer element'
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_FOOTER ++IA2_ROLE_LANDMARK xml-roles:contentinfo
++++ROLE_SYSTEM_STATICTEXT name='Footer element' ++++ROLE_SYSTEM_STATICTEXT name='Footer element'
<!-- <!--
@MAC-ALLOW:AXRoleDescription='footer' @MAC-ALLOW:AXRole*
@MAC-ALLOW:AXSubrole* @MAC-ALLOW:AXSubrole*
@WIN-ALLOW:xml-roles:*
@AURALINUX-ALLOW:xml-roles:*
--> -->
<html> <html>
<body> <body>
......
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_HEADER xml-roles:banner ++IA2_ROLE_LANDMARK xml-roles:banner
++++ROLE_SYSTEM_STATICTEXT name='Chromium Browser' ++++ROLE_SYSTEM_STATICTEXT name='Chromium Browser'
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
++++[text] name='This is an aside element.' ++++[text] name='This is an aside element.'
++[section] ++[section]
++++[text] name='This is an address element.' ++++[text] name='This is an address element.'
++[footer] xml-roles:contentinfo ++[landmark] xml-roles:contentinfo
++++[text] name='This is a footer element.' ++++[text] name='This is a footer element.'
++[form] ++[form]
++++[text] name='This is a form element.' ++++[text] name='This is a form element.'
......
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_HEADER xml-roles:banner ++IA2_ROLE_LANDMARK xml-roles:banner
++++ROLE_SYSTEM_STATICTEXT name='This is a header element.' ++++ROLE_SYSTEM_STATICTEXT name='This is a header element.'
++IA2_ROLE_LANDMARK xml-roles:complementary ++IA2_ROLE_LANDMARK xml-roles:complementary
++++ROLE_SYSTEM_STATICTEXT name='This is an aside element.' ++++ROLE_SYSTEM_STATICTEXT name='This is an aside element.'
++IA2_ROLE_SECTION ++IA2_ROLE_SECTION
++++ROLE_SYSTEM_STATICTEXT name='This is an address element.' ++++ROLE_SYSTEM_STATICTEXT name='This is an address element.'
++IA2_ROLE_FOOTER xml-roles:contentinfo ++IA2_ROLE_LANDMARK xml-roles:contentinfo
++++ROLE_SYSTEM_STATICTEXT name='This is a footer element.' ++++ROLE_SYSTEM_STATICTEXT name='This is a footer element.'
++IA2_ROLE_FORM ++IA2_ROLE_FORM
++++ROLE_SYSTEM_STATICTEXT name='This is a form element.' ++++ROLE_SYSTEM_STATICTEXT name='This is a form element.'
...@@ -15,7 +15,7 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ...@@ -15,7 +15,7 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++++ROLE_SYSTEM_STATICTEXT name='This is a nav element.' ++++ROLE_SYSTEM_STATICTEXT name='This is a nav element.'
++ROLE_SYSTEM_APPLICATION xml-roles:application ++ROLE_SYSTEM_APPLICATION xml-roles:application
++++ROLE_SYSTEM_STATICTEXT name='This is an ARIA application landmark.' ++++ROLE_SYSTEM_STATICTEXT name='This is an ARIA application landmark.'
++IA2_ROLE_HEADER xml-roles:banner ++IA2_ROLE_LANDMARK xml-roles:banner
++++ROLE_SYSTEM_STATICTEXT name='This is an ARIA banner landmark.' ++++ROLE_SYSTEM_STATICTEXT name='This is an ARIA banner landmark.'
++IA2_ROLE_LANDMARK xml-roles:complementary ++IA2_ROLE_LANDMARK xml-roles:complementary
++++ROLE_SYSTEM_STATICTEXT name='This is an ARIA complementary landmark.' ++++ROLE_SYSTEM_STATICTEXT name='This is an ARIA complementary landmark.'
......
...@@ -2047,6 +2047,7 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { ...@@ -2047,6 +2047,7 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() {
// TODO(accessibility) https://github.com/w3c/html-aam/issues/141 // TODO(accessibility) https://github.com/w3c/html-aam/issues/141
return ATK_ROLE_SECTION; return ATK_ROLE_SECTION;
case ax::mojom::Role::kContentInfo: case ax::mojom::Role::kContentInfo:
case ax::mojom::Role::kFooter:
return ATK_ROLE_LANDMARK; return ATK_ROLE_LANDMARK;
case ax::mojom::Role::kDate: case ax::mojom::Role::kDate:
return ATK_ROLE_DATE_EDITOR; return ATK_ROLE_DATE_EDITOR;
...@@ -2355,8 +2356,6 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { ...@@ -2355,8 +2356,6 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() {
return ATK_ROLE_PANEL; return ATK_ROLE_PANEL;
case ax::mojom::Role::kFigcaption: case ax::mojom::Role::kFigcaption:
return ATK_ROLE_CAPTION; return ATK_ROLE_CAPTION;
case ax::mojom::Role::kFooter:
return ATK_ROLE_FOOTER;
case ax::mojom::Role::kKeyboard: case ax::mojom::Role::kKeyboard:
case ax::mojom::Role::kNone: case ax::mojom::Role::kNone:
case ax::mojom::Role::kPresentational: case ax::mojom::Role::kPresentational:
......
...@@ -216,6 +216,7 @@ class AX_EXPORT AXPlatformNodeDelegate { ...@@ -216,6 +216,7 @@ class AX_EXPORT AXPlatformNodeDelegate {
const = 0; const = 0;
virtual base::string16 GetLocalizedStringForImageAnnotationStatus( virtual base::string16 GetLocalizedStringForImageAnnotationStatus(
ax::mojom::ImageAnnotationStatus status) const = 0; ax::mojom::ImageAnnotationStatus status) const = 0;
virtual base::string16 GetLocalizedStringForLandmarkType() const = 0;
// //
// Testing. // Testing.
......
...@@ -215,6 +215,11 @@ AXPlatformNodeDelegateBase::GetLocalizedRoleDescriptionForUnlabeledImage() ...@@ -215,6 +215,11 @@ AXPlatformNodeDelegateBase::GetLocalizedRoleDescriptionForUnlabeledImage()
return base::string16(); return base::string16();
} }
base::string16 AXPlatformNodeDelegateBase::GetLocalizedStringForLandmarkType()
const {
return base::string16();
}
bool AXPlatformNodeDelegateBase::ShouldIgnoreHoveredStateForTesting() { bool AXPlatformNodeDelegateBase::ShouldIgnoreHoveredStateForTesting() {
return true; return true;
} }
......
...@@ -186,6 +186,7 @@ class AX_EXPORT AXPlatformNodeDelegateBase : public AXPlatformNodeDelegate { ...@@ -186,6 +186,7 @@ class AX_EXPORT AXPlatformNodeDelegateBase : public AXPlatformNodeDelegate {
base::string16 GetLocalizedStringForImageAnnotationStatus( base::string16 GetLocalizedStringForImageAnnotationStatus(
ax::mojom::ImageAnnotationStatus status) const override; ax::mojom::ImageAnnotationStatus status) const override;
base::string16 GetLocalizedRoleDescriptionForUnlabeledImage() const override; base::string16 GetLocalizedRoleDescriptionForUnlabeledImage() const override;
base::string16 GetLocalizedStringForLandmarkType() const override;
// //
// Testing. // Testing.
......
...@@ -922,6 +922,8 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) ...@@ -922,6 +922,8 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
bool IsUIAControl() const; bool IsUIAControl() const;
base::Optional<LONG> ComputeUIALandmarkType() const;
// AXPlatformNodeBase overrides. // AXPlatformNodeBase overrides.
void Dispose() override; void Dispose() override;
......
...@@ -60,6 +60,14 @@ ScopedVariant SELF(CHILDID_SELF); ...@@ -60,6 +60,14 @@ ScopedVariant SELF(CHILDID_SELF);
// WARNING: These aren't intended to be generic EXPECT_BSTR_EQ macros // WARNING: These aren't intended to be generic EXPECT_BSTR_EQ macros
// as the logic is specific to extracting and comparing UIA property // as the logic is specific to extracting and comparing UIA property
// values. // values.
#define EXPECT_UIA_EMPTY(node, property_id) \
{ \
ScopedVariant actual; \
ASSERT_HRESULT_SUCCEEDED( \
node->GetPropertyValue(property_id, actual.Receive())); \
EXPECT_EQ(VT_EMPTY, actual.type()); \
}
#define EXPECT_UIA_VALUE_EQ(node, property_id, expectedVariant) \ #define EXPECT_UIA_VALUE_EQ(node, property_id, expectedVariant) \
{ \ { \
ScopedVariant actual; \ ScopedVariant actual; \
...@@ -4052,6 +4060,90 @@ TEST_F(AXPlatformNodeWinTest, TestComputeUIAControlType) { ...@@ -4052,6 +4060,90 @@ TEST_F(AXPlatformNodeWinTest, TestComputeUIAControlType) {
UIA_ControlTypePropertyId, int{UIA_TableControlTypeId}); UIA_ControlTypePropertyId, int{UIA_TableControlTypeId});
} }
TEST_F(AXPlatformNodeWinTest, TestUIALandmarkType) {
auto TestLandmarkType = [this](ax::mojom::Role node_role,
base::Optional<LONG> expected_landmark_type,
const std::string& node_name = {}) {
AXNodeData root_data;
root_data.id = 0;
root_data.role = node_role;
if (!node_name.empty())
root_data.SetName(node_name);
Init(root_data);
ComPtr<IRawElementProviderSimple> root_provider =
GetRootIRawElementProviderSimple();
if (expected_landmark_type) {
EXPECT_UIA_INT_EQ(root_provider, UIA_LandmarkTypePropertyId,
expected_landmark_type.value());
} else {
EXPECT_UIA_EMPTY(root_provider, UIA_LandmarkTypePropertyId);
}
};
TestLandmarkType(ax::mojom::Role::kBanner, UIA_CustomLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kComplementary, UIA_CustomLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kContentInfo, UIA_CustomLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kFooter, UIA_CustomLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kForm, UIA_FormLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kMain, UIA_MainLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kNavigation, UIA_NavigationLandmarkTypeId);
TestLandmarkType(ax::mojom::Role::kSearch, UIA_SearchLandmarkTypeId);
// Only named regions should be exposed as landmarks.
TestLandmarkType(ax::mojom::Role::kRegion, {});
TestLandmarkType(ax::mojom::Role::kRegion, UIA_CustomLandmarkTypeId, "name");
TestLandmarkType(ax::mojom::Role::kGroup, {});
TestLandmarkType(ax::mojom::Role::kHeading, {});
TestLandmarkType(ax::mojom::Role::kList, {});
TestLandmarkType(ax::mojom::Role::kTable, {});
}
TEST_F(AXPlatformNodeWinTest, TestUIALocalizedLandmarkType) {
auto TestLocalizedLandmarkType =
[this](ax::mojom::Role node_role,
const std::wstring& expected_localized_landmark,
const std::string& node_name = {}) {
AXNodeData root_data;
root_data.id = 0;
root_data.role = node_role;
if (!node_name.empty())
root_data.SetName(node_name);
Init(root_data);
ComPtr<IRawElementProviderSimple> root_provider =
GetRootIRawElementProviderSimple();
if (expected_localized_landmark.empty()) {
EXPECT_UIA_EMPTY(root_provider, UIA_LocalizedLandmarkTypePropertyId);
} else {
EXPECT_UIA_BSTR_EQ(root_provider, UIA_LocalizedLandmarkTypePropertyId,
expected_localized_landmark.c_str());
}
};
TestLocalizedLandmarkType(ax::mojom::Role::kBanner, L"banner");
TestLocalizedLandmarkType(ax::mojom::Role::kComplementary, L"complementary");
TestLocalizedLandmarkType(ax::mojom::Role::kContentInfo,
L"content information");
TestLocalizedLandmarkType(ax::mojom::Role::kFooter, L"content information");
// Only named regions should be exposed as landmarks.
TestLocalizedLandmarkType(ax::mojom::Role::kRegion, {});
TestLocalizedLandmarkType(ax::mojom::Role::kRegion, L"region", "name");
TestLocalizedLandmarkType(ax::mojom::Role::kForm, {});
TestLocalizedLandmarkType(ax::mojom::Role::kGroup, {});
TestLocalizedLandmarkType(ax::mojom::Role::kHeading, {});
TestLocalizedLandmarkType(ax::mojom::Role::kList, {});
TestLocalizedLandmarkType(ax::mojom::Role::kMain, {});
TestLocalizedLandmarkType(ax::mojom::Role::kNavigation, {});
TestLocalizedLandmarkType(ax::mojom::Role::kSearch, {});
TestLocalizedLandmarkType(ax::mojom::Role::kTable, {});
}
TEST_F(AXPlatformNodeWinTest, TestIRawElementProviderSimple2ShowContextMenu) { TEST_F(AXPlatformNodeWinTest, TestIRawElementProviderSimple2ShowContextMenu) {
AXNodeData root_data; AXNodeData root_data;
root_data.id = 0; root_data.id = 0;
......
...@@ -405,6 +405,29 @@ base::string16 TestAXNodeWrapper::GetLocalizedRoleDescriptionForUnlabeledImage() ...@@ -405,6 +405,29 @@ base::string16 TestAXNodeWrapper::GetLocalizedRoleDescriptionForUnlabeledImage()
return base::ASCIIToUTF16("Unlabeled image"); return base::ASCIIToUTF16("Unlabeled image");
} }
base::string16 TestAXNodeWrapper::GetLocalizedStringForLandmarkType() const {
const AXNodeData& data = GetData();
switch (data.role) {
case ax::mojom::Role::kBanner:
return base::ASCIIToUTF16("banner");
case ax::mojom::Role::kComplementary:
return base::ASCIIToUTF16("complementary");
case ax::mojom::Role::kContentInfo:
case ax::mojom::Role::kFooter:
return base::ASCIIToUTF16("content information");
case ax::mojom::Role::kRegion:
if (data.HasStringAttribute(ax::mojom::StringAttribute::kName))
return base::ASCIIToUTF16("region");
FALLTHROUGH;
default:
return {};
}
}
base::string16 TestAXNodeWrapper::GetLocalizedStringForImageAnnotationStatus( base::string16 TestAXNodeWrapper::GetLocalizedStringForImageAnnotationStatus(
ax::mojom::ImageAnnotationStatus status) const { ax::mojom::ImageAnnotationStatus status) const {
switch (status) { switch (status) {
......
...@@ -87,6 +87,7 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegateBase { ...@@ -87,6 +87,7 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegateBase {
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
bool AccessibilityPerformAction(const AXActionData& data) override; bool AccessibilityPerformAction(const AXActionData& data) override;
base::string16 GetLocalizedRoleDescriptionForUnlabeledImage() const override; base::string16 GetLocalizedRoleDescriptionForUnlabeledImage() const override;
base::string16 GetLocalizedStringForLandmarkType() const override;
base::string16 GetLocalizedStringForImageAnnotationStatus( base::string16 GetLocalizedStringForImageAnnotationStatus(
ax::mojom::ImageAnnotationStatus status) const override; ax::mojom::ImageAnnotationStatus status) const override;
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment