Commit 1a0facfa authored by Victor Fei's avatar Victor Fei Committed by Commit Bot

Move custom end of uia test event to UiaRegistrarWin

CL:2242046 introduced ui::UiaRegistrarWin for registering custom UIA
property and event. This change moves the custom UIA event used for
signaling test end to ui::UiaRegistrarWin.

There is no functionality change.

AX-Relnotes:n/a

Bug: 847971
Change-Id: Id1b8852d788d5533e14bc63588fd26669ae78eb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261876Reviewed-by: default avatarIan Prest <iapres@microsoft.com>
Commit-Queue: Victor Fei <vicfei@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#782061}
parent 6fe356f6
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "content/browser/accessibility/browser_accessibility_com_win.h" #include "content/browser/accessibility/browser_accessibility_com_win.h"
#include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/accessibility/browser_accessibility_manager_win.h" #include "content/browser/accessibility/browser_accessibility_manager_win.h"
#include "ui/accessibility/platform/uia_registrar_win.h"
#include "ui/base/win/atl_module.h" #include "ui/base/win/atl_module.h"
namespace content { namespace content {
...@@ -110,14 +111,8 @@ void AccessibilityEventRecorderUia::Thread::ThreadMain() { ...@@ -110,14 +111,8 @@ void AccessibilityEventRecorderUia::Thread::ThreadMain() {
CHECK(uia_.Get()); CHECK(uia_.Get());
// Register the custom event to mark the end of the test. // Register the custom event to mark the end of the test.
Microsoft::WRL::ComPtr<IUIAutomationRegistrar> registrar; shutdown_sentinel_ =
CoCreateInstance(CLSID_CUIAutomationRegistrar, NULL, CLSCTX_INPROC_SERVER, ui::UiaRegistrarWin::GetInstance().GetUiaTestCompleteEventId();
IID_IUIAutomationRegistrar, &registrar);
CHECK(registrar.Get());
UIAutomationEventInfo custom_event = {kUiaTestCompleteSentinelGuid,
kUiaTestCompleteSentinel};
CHECK(
SUCCEEDED(registrar->RegisterEvent(&custom_event, &shutdown_sentinel_)));
// Find the IUIAutomationElement for the root content window // Find the IUIAutomationElement for the root content window
uia_->ElementFromHandle(hwnd_, &root_); uia_->ElementFromHandle(hwnd_, &root_);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "ui/accessibility/ax_role_properties.h" #include "ui/accessibility/ax_role_properties.h"
#include "ui/accessibility/platform/ax_fragment_root_win.h" #include "ui/accessibility/platform/ax_fragment_root_win.h"
#include "ui/accessibility/platform/ax_platform_node_delegate_utils_win.h" #include "ui/accessibility/platform/ax_platform_node_delegate_utils_win.h"
#include "ui/accessibility/platform/uia_registrar_win.h"
#include "ui/base/win/atl_module.h" #include "ui/base/win/atl_module.h"
namespace content { namespace content {
...@@ -95,24 +96,11 @@ void BrowserAccessibilityManagerWin::FireBlinkEvent( ...@@ -95,24 +96,11 @@ void BrowserAccessibilityManagerWin::FireBlinkEvent(
if (node->GetData().IsInvocable()) if (node->GetData().IsInvocable())
FireUiaAccessibilityEvent(UIA_Invoke_InvokedEventId, node); FireUiaAccessibilityEvent(UIA_Invoke_InvokedEventId, node);
break; break;
case ax::mojom::Event::kEndOfTest: { case ax::mojom::Event::kEndOfTest:
if (::switches::IsExperimentalAccessibilityPlatformUIAEnabled()) { // Event tests use kEndOfTest as a sentinel to mark the end of the test.
// Event tests use kEndOfTest as a sentinel to mark the end of the test. FireUiaAccessibilityEvent(
Microsoft::WRL::ComPtr<IUIAutomationRegistrar> registrar; ui::UiaRegistrarWin::GetInstance().GetUiaTestCompleteEventId(), node);
CoCreateInstance(CLSID_CUIAutomationRegistrar, NULL,
CLSCTX_INPROC_SERVER, IID_IUIAutomationRegistrar,
&registrar);
CHECK(registrar.Get());
UIAutomationEventInfo custom_event = {kUiaTestCompleteSentinelGuid,
kUiaTestCompleteSentinel};
EVENTID custom_event_id = 0;
CHECK(SUCCEEDED(
registrar->RegisterEvent(&custom_event, &custom_event_id)));
FireUiaAccessibilityEvent(custom_event_id, node);
}
break; break;
}
case ax::mojom::Event::kLocationChanged: case ax::mojom::Event::kLocationChanged:
FireWinAccessibilityEvent(IA2_EVENT_VISIBLE_DATA_CHANGED, node); FireWinAccessibilityEvent(IA2_EVENT_VISIBLE_DATA_CHANGED, node);
break; break;
......
...@@ -19,14 +19,6 @@ ...@@ -19,14 +19,6 @@
namespace content { namespace content {
class BrowserAccessibilityWin; class BrowserAccessibilityWin;
// {3761326A-34B2-465A-835D-7A3D8F4EFB92}
static const GUID kUiaTestCompleteSentinelGuid = {
0x3761326a,
0x34b2,
0x465a,
{0x83, 0x5d, 0x7a, 0x3d, 0x8f, 0x4e, 0xfb, 0x92}};
static const wchar_t kUiaTestCompleteSentinel[] = L"kUiaTestCompleteSentinel";
// Manages a tree of BrowserAccessibilityWin objects. // Manages a tree of BrowserAccessibilityWin objects.
class CONTENT_EXPORT BrowserAccessibilityManagerWin class CONTENT_EXPORT BrowserAccessibilityManagerWin
: public BrowserAccessibilityManager { : public BrowserAccessibilityManager {
......
...@@ -23,6 +23,13 @@ UiaRegistrarWin::UiaRegistrarWin() { ...@@ -23,6 +23,13 @@ UiaRegistrarWin::UiaRegistrarWin() {
kUiaPropertyUniqueIdGuid, L"UniqueId", UIAutomationType_String}; kUiaPropertyUniqueIdGuid, L"UniqueId", UIAutomationType_String};
registrar->RegisterProperty(&unique_id_property_info, registrar->RegisterProperty(&unique_id_property_info,
&uia_unique_id_property_id_); &uia_unique_id_property_id_);
// Register the custom UIA event that represents the test end event for the
// UIA test suite.
UIAutomationEventInfo test_complete_event_info = {
kUiaEventTestCompleteSentinelGuid, L"kUiaTestCompleteSentinel"};
registrar->RegisterEvent(&test_complete_event_info,
&uia_test_complete_event_id_);
} }
UiaRegistrarWin::~UiaRegistrarWin() = default; UiaRegistrarWin::~UiaRegistrarWin() = default;
...@@ -31,6 +38,10 @@ PROPERTYID UiaRegistrarWin::GetUiaUniqueIdPropertyId() const { ...@@ -31,6 +38,10 @@ PROPERTYID UiaRegistrarWin::GetUiaUniqueIdPropertyId() const {
return uia_unique_id_property_id_; return uia_unique_id_property_id_;
} }
EVENTID UiaRegistrarWin::GetUiaTestCompleteEventId() const {
return uia_test_complete_event_id_;
}
const UiaRegistrarWin& UiaRegistrarWin::GetInstance() { const UiaRegistrarWin& UiaRegistrarWin::GetInstance() {
static base::NoDestructor<UiaRegistrarWin> instance; static base::NoDestructor<UiaRegistrarWin> instance;
return *instance; return *instance;
......
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
#include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_export.h"
namespace ui { namespace ui {
// {3761326A-34B2-465A-835D-7A3D8F4EFB92}
static const GUID kUiaEventTestCompleteSentinelGuid = {
0x3761326a,
0x34b2,
0x465a,
{0x83, 0x5d, 0x7a, 0x3d, 0x8f, 0x4e, 0xfb, 0x92}};
// {cc7eeb32-4b62-4f4c-aff6-1c2e5752ad8e} // {cc7eeb32-4b62-4f4c-aff6-1c2e5752ad8e}
static const GUID kUiaPropertyUniqueIdGuid = { static const GUID kUiaPropertyUniqueIdGuid = {
0xcc7eeb32, 0xcc7eeb32,
...@@ -24,11 +31,13 @@ class AX_EXPORT UiaRegistrarWin { ...@@ -24,11 +31,13 @@ class AX_EXPORT UiaRegistrarWin {
UiaRegistrarWin(); UiaRegistrarWin();
~UiaRegistrarWin(); ~UiaRegistrarWin();
PROPERTYID GetUiaUniqueIdPropertyId() const; PROPERTYID GetUiaUniqueIdPropertyId() const;
EVENTID GetUiaTestCompleteEventId() const;
static const UiaRegistrarWin& GetInstance(); static const UiaRegistrarWin& GetInstance();
private: private:
PROPERTYID uia_unique_id_property_id_ = 0; PROPERTYID uia_unique_id_property_id_ = 0;
EVENTID uia_test_complete_event_id_ = 0;
}; };
} // namespace ui } // namespace ui
......
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