Flutter Engine
The Flutter Engine
ax_platform_node_mac_unittest.mm
Go to the documentation of this file.
1// Copyright 2015 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
6
8#include "gtest/gtest.h"
11
12namespace ui {
13
15
17
19
21 // Destroy the tree and make sure we're not leaking any objects.
25}
26
29 return wrapper ? wrapper->ax_platform_node() : nullptr;
30}
31
32// Verify that we can get an AXPlatformNodeMac and AXPlatformNodeCocoa from the tree.
33TEST_F(AXPlatformNodeMacTest, CanGetCocoaPlatformNodeFromTree) {
35 root.id = 1;
36 root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
37
38 Init(root);
39 AXNode* root_node = GetRootAsAXNode();
40 ASSERT_TRUE(root_node != nullptr);
41
42 AXPlatformNode* platform_node = AXPlatformNodeFromNode(root_node);
43 ASSERT_TRUE(platform_node != nullptr);
44
45 AXPlatformNodeCocoa* native_root = platform_node->GetNativeViewAccessible();
46 EXPECT_TRUE(native_root != nullptr);
47}
48
49// Test that [AXPlatformNodeCocoa accessbilityRangeForPosition:] doesn't crash.
50// https://github.com/flutter/flutter/issues/102416
51TEST_F(AXPlatformNodeMacTest, AccessibilityRangeForPositionDoesntCrash) {
53 root.id = 1;
54 root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
55
56 Init(root);
57 AXNode* root_node = GetRootAsAXNode();
58 ASSERT_TRUE(root_node != nullptr);
59
60 AXPlatformNode* platform_node = AXPlatformNodeFromNode(root_node);
61 ASSERT_TRUE(platform_node != nullptr);
62
63 NSPoint point = NSMakePoint(0, 0);
64 AXPlatformNodeCocoa* native_root = platform_node->GetNativeViewAccessible();
65 ASSERT_TRUE(native_root != nullptr);
66
67 [native_root accessibilityRangeForPosition:(NSPoint)point];
68}
69
70} // namespace ui
static size_t GetInstanceCountForTesting()
~AXPlatformNodeMacTest() override
AXPlatformNode * AXPlatformNodeFromNode(AXNode *node)
virtual gfx::NativeViewAccessible GetNativeViewAccessible()=0
static void SetGlobalIsWebContent(bool is_web_content)
static TestAXNodeWrapper * GetOrCreate(AXTree *tree, AXNode *node)
AXPlatformNode * ax_platform_node() const
void Init()
string root
Definition: scale_cpu.py:20
TEST_F(AXPositionTest, Clone)
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678