Flutter Engine
The Flutter Engine
ax_platform_node_win_unittest.h
Go to the documentation of this file.
1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
6#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
7
9// clang-format off
10#include "third_party/accessibility/base/win/atl.h" // Must be before UIAutomationCore.h
11// clang-format on
12
13#include <UIAutomationCore.h>
14#include <wrl.h>
15
16#include <memory>
17#include <string>
18#include <unordered_set>
19
21
22struct IAccessible;
23struct IAccessibleTableCell;
24struct IRawElementProviderFragment;
25struct IRawElementProviderFragmentRoot;
26struct IRawElementProviderSimple;
27struct IUnknown;
28
29namespace base {
30namespace win {
31class ScopedVariant;
32} // namespace win
33} // namespace base
34
35namespace ui {
36
37class AXFragmentRootWin;
38class AXPlatformNode;
39
41 public:
46 bool IsAXFragmentRootAControlElement() override;
50};
51
53 : public CComObjectRootEx<CComMultiThreadModel>,
54 public IRawElementProviderSimple {
55 public:
57 COM_INTERFACE_ENTRY(IRawElementProviderSimple)
58 END_COM_MAP()
59
62
64 IRawElementProviderSimple** provider);
65
66 //
67 // IRawElementProviderSimple methods.
68 //
69 IFACEMETHODIMP GetPatternProvider(PATTERNID pattern_id,
70 IUnknown** result) override;
71
72 IFACEMETHODIMP GetPropertyValue(PROPERTYID property_id,
73 VARIANT* result) override;
74
75 IFACEMETHODIMP
76 get_ProviderOptions(enum ProviderOptions* ret) override;
77
78 IFACEMETHODIMP
79 get_HostRawElementProvider(IRawElementProviderSimple** provider) override;
80};
81
83 public:
85 ~AXPlatformNodeWinTest() override;
86
87 void SetUp() override;
88
89 void TearDown() override;
90
91 protected:
92 static const std::u16string kEmbeddedCharacterAsString;
93
94 AXPlatformNode* AXPlatformNodeFromNode(AXNode* node);
95 template <typename T>
96 Microsoft::WRL::ComPtr<T> QueryInterfaceFromNodeId(AXNode::AXID id);
97 template <typename T>
98 Microsoft::WRL::ComPtr<T> QueryInterfaceFromNode(AXNode* node);
99 Microsoft::WRL::ComPtr<IRawElementProviderSimple>
100 GetRootIRawElementProviderSimple();
101 Microsoft::WRL::ComPtr<IRawElementProviderSimple>
102 GetIRawElementProviderSimpleFromChildIndex(int child_index);
103 Microsoft::WRL::ComPtr<IRawElementProviderSimple>
104 GetIRawElementProviderSimpleFromTree(const ui::AXTreeID tree_id,
105 const AXNode::AXID node_id);
106 Microsoft::WRL::ComPtr<IRawElementProviderFragment>
107 GetRootIRawElementProviderFragment();
108 Microsoft::WRL::ComPtr<IRawElementProviderFragment>
109 IRawElementProviderFragmentFromNode(AXNode* node);
110 Microsoft::WRL::ComPtr<IAccessible> IAccessibleFromNode(AXNode* node);
111 Microsoft::WRL::ComPtr<IAccessible> GetRootIAccessible();
112 void CheckVariantHasName(const base::win::ScopedVariant& variant,
113 const wchar_t* expected_name);
114 void CheckIUnknownHasName(Microsoft::WRL::ComPtr<IUnknown> unknown,
115 const wchar_t* expected_name);
116 Microsoft::WRL::ComPtr<IAccessibleTableCell> GetCellInTable();
117
118 void InitFragmentRoot();
119 AXFragmentRootWin* InitNodeAsFragmentRoot(AXNode* node,
120 TestFragmentRootDelegate* delegate);
121 Microsoft::WRL::ComPtr<IRawElementProviderFragmentRoot> GetFragmentRoot();
122
123 using PatternSet = std::unordered_set<LONG>;
124 PatternSet GetSupportedPatternsFromNodeId(AXNode::AXID id);
125
126 std::unique_ptr<AXFragmentRootWin> ax_fragment_root_;
127
128 std::unique_ptr<TestFragmentRootDelegate> test_fragment_root_delegate_;
129};
130
131} // namespace ui
132
133#endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
int32_t AXID
Definition: ax_node.h:36
Microsoft::WRL::ComPtr< T > QueryInterfaceFromNode(AXNode *node)
std::unique_ptr< AXFragmentRootWin > ax_fragment_root_
static const std::u16string kEmbeddedCharacterAsString
Microsoft::WRL::ComPtr< T > QueryInterfaceFromNodeId(AXNode::AXID id)
std::unordered_set< LONG > PatternSet
Microsoft::WRL::ComPtr< IAccessibleTableCell > GetCellInTable()
void CheckIUnknownHasName(Microsoft::WRL::ComPtr< IUnknown > unknown, const wchar_t *expected_name)
std::unique_ptr< TestFragmentRootDelegate > test_fragment_root_delegate_
IFACEMETHODIMP GetPatternProvider(PATTERNID pattern_id, IUnknown **result) override
IFACEMETHODIMP GetPropertyValue(PROPERTYID property_id, VARIANT *result) override
static HRESULT CreateMockIRawElementProviderSimple(IRawElementProviderSimple **provider)
IFACEMETHODIMP get_ProviderOptions(enum ProviderOptions *ret) override
IFACEMETHODIMP get_HostRawElementProvider(IRawElementProviderSimple **provider) override
gfx::NativeViewAccessible GetParentOfAXFragmentRoot() override
gfx::NativeViewAccessible GetChildOfAXFragmentRoot() override
GAsyncResult * result
UnimplementedNativeViewAccessible * NativeViewAccessible