[Mac] Add test for AXPlatformNodeCocoa (flutter/engine#35437)
Adds an initial test of looking up the macOS-specific AXPlatformNodeMac C++ node wrapper and the AXPlatformNodeCocoa Objective-C wrapper, in addition to the existing platform-agnostic accessibility tests that run on macOS today. This is initial test infrastructure to support authoring tests for an upcoming fix to the issue below. Issue: https://github.com/flutter/flutter/issues/102416
This commit is contained in:
@@ -3258,6 +3258,8 @@ ORIGIN: ../../../third_party/icu/scripts/LICENSE
|
||||
TYPE: LicenseType.bsd
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/ax_tree_data.cc
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/ax_tree_data.h
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/platform/ax_platform_node_mac_unittest.h
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/platform/ax_platform_node_mac_unittest.mm
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/platform/ax_platform_node_win.cc
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/platform/ax_platform_node_win.h
|
||||
FILE: ../../../flutter/third_party/accessibility/ax/platform/ax_platform_node_win_unittest.cc
|
||||
|
||||
@@ -75,6 +75,19 @@ if (enable_unittests) {
|
||||
"ax/platform/test_ax_node_wrapper.h",
|
||||
]
|
||||
|
||||
if (is_mac) {
|
||||
sources += [ "ax/platform/ax_platform_node_mac_unittest.mm" ]
|
||||
frameworks = [
|
||||
"AppKit.framework",
|
||||
"CoreFoundation.framework",
|
||||
"CoreGraphics.framework",
|
||||
"CoreText.framework",
|
||||
"IOSurface.framework",
|
||||
]
|
||||
|
||||
cflags_objcc = flutter_cflags_objcc
|
||||
ldflags = [ "-ObjC" ]
|
||||
}
|
||||
if (is_win) {
|
||||
sources += [
|
||||
"ax/platform/ax_fragment_root_win_unittest.cc",
|
||||
|
||||
29
engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_mac_unittest.h
vendored
Normal file
29
engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_mac_unittest.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_MAC_UNITTEST_H_
|
||||
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_MAC_UNITTEST_H_
|
||||
|
||||
#include "ax_platform_node_mac.h"
|
||||
#include "ax_platform_node_unittest.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
// A test fixture that supports accessing the macOS-specific node
|
||||
// implementations for the AXTree under test.
|
||||
class AXPlatformNodeMacTest : public AXPlatformNodeTest {
|
||||
public:
|
||||
AXPlatformNodeMacTest();
|
||||
~AXPlatformNodeMacTest() override;
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
protected:
|
||||
AXPlatformNode* AXPlatformNodeFromNode(AXNode* node);
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_MAC_UNITTEST_H_
|
||||
49
engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_mac_unittest.mm
vendored
Normal file
49
engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_mac_unittest.mm
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ax_platform_node_mac_unittest.h"
|
||||
|
||||
#include "ax_platform_node_mac.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test_ax_node_wrapper.h"
|
||||
#include "third_party/accessibility/ax/ax_node_data.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
AXPlatformNodeMacTest::AXPlatformNodeMacTest() = default;
|
||||
|
||||
AXPlatformNodeMacTest::~AXPlatformNodeMacTest() = default;
|
||||
|
||||
void AXPlatformNodeMacTest::SetUp() {}
|
||||
|
||||
void AXPlatformNodeMacTest::TearDown() {
|
||||
// Destroy the tree and make sure we're not leaking any objects.
|
||||
DestroyTree();
|
||||
TestAXNodeWrapper::SetGlobalIsWebContent(false);
|
||||
ASSERT_EQ(0U, AXPlatformNodeBase::GetInstanceCountForTesting());
|
||||
}
|
||||
|
||||
AXPlatformNode* AXPlatformNodeMacTest::AXPlatformNodeFromNode(AXNode* node) {
|
||||
const TestAXNodeWrapper* wrapper = TestAXNodeWrapper::GetOrCreate(GetTree(), node);
|
||||
return wrapper ? wrapper->ax_platform_node() : nullptr;
|
||||
}
|
||||
|
||||
// Verify that we can get an AXPlatformNodeMac and AXPlatformNodeCocoa from the tree.
|
||||
TEST_F(AXPlatformNodeMacTest, CanGetCocoaPlatformNodeFromTree) {
|
||||
AXNodeData root;
|
||||
root.id = 1;
|
||||
root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
|
||||
|
||||
Init(root);
|
||||
AXNode* root_node = GetRootAsAXNode();
|
||||
ASSERT_TRUE(root_node != nullptr);
|
||||
|
||||
AXPlatformNode* platform_node = AXPlatformNodeFromNode(root_node);
|
||||
ASSERT_TRUE(platform_node != nullptr);
|
||||
|
||||
AXPlatformNodeCocoa* native_root = platform_node->GetNativeViewAccessible();
|
||||
EXPECT_TRUE(native_root != nullptr);
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
Reference in New Issue
Block a user