chromium/ui/views/accessibility/ax_virtual_view_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/accessibility/ax_virtual_view.h"

#include <memory>
#include <utility>
#include <vector>

#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/ax_platform_for_test.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/accessibility/view_ax_platform_node_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"

#if BUILDFLAG(IS_WIN)
#include "ui/views/win/hwnd_util.h"
#endif

namespace views::test {

namespace {

class TestButton : public Button {};

BEGIN_METADATA()

}  // namespace

class AXVirtualViewTest : public ViewsTestBase {};

TEST_F(AXVirtualViewTest, AccessibilityRoleAndName) {}

// The focusable state of a virtual view should not depend on the focusable
// state of the real view ancestor, however the enabled state should.
TEST_F(AXVirtualViewTest, FocusableAndEnabledState) {}

TEST_F(AXVirtualViewTest, VirtualLabelIsChildOfButton) {}

TEST_F(AXVirtualViewTest, VirtualViewsPruned) {}

TEST_F(AXVirtualViewTest, RemoveFromParentView) {}

#if defined(USE_AURA)
TEST_F(AXVirtualViewTest, MultipleCaches) {}
#endif  // defined(USE_AURA)

TEST_F(AXVirtualViewTest, AddingAndRemovingVirtualChildren) {}

TEST_F(AXVirtualViewTest, ReorderingVirtualChildren) {}

TEST_F(AXVirtualViewTest, ContainsVirtualChild) {}

TEST_F(AXVirtualViewTest, GetIndexOfVirtualChild) {}

// Verify that virtual views with invisible ancestors inherit the
// ax::mojom::State::kInvisible state.
TEST_F(AXVirtualViewTest, InvisibleVirtualViews) {}

TEST_F(AXVirtualViewTest, OverrideFocus) {}

TEST_F(AXVirtualViewTest, TreeNavigation) {}

TEST_F(AXVirtualViewTest, TreeNavigationWithIgnoredVirtualViews) {}

TEST_F(AXVirtualViewTest, HitTesting) {}

// Test for GetTargetForNativeAccessibilityEvent().
#if BUILDFLAG(IS_WIN)
TEST_F(AXVirtualViewTest, GetTargetForEvents) {
  EXPECT_EQ(button_, virtual_label_->GetOwnerView());
  EXPECT_NE(nullptr, HWNDForView(virtual_label_->GetOwnerView()));
  EXPECT_EQ(HWNDForView(button_),
            virtual_label_->GetTargetForNativeAccessibilityEvent());
}
#endif  // BUILDFLAG(IS_WIN)

}  // namespace views::test