chromium/ui/message_center/views/message_view_unittest.cc

// Copyright 2024 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/message_center/views/message_view.h"

#include <memory>

#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/test/event_generator.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notification.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_utils.h"

namespace message_center {

class NotificationControlButtonsView;

class TestMessageView : public MessageView {};

class MessageViewTest : public views::ViewsTestBase {};

// Updating control buttons visibility is a ChromeOS only feature.
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Make sure UpdateControlButtonsVisibility is called when their is a mouse
// enter or exit on a MessageView.
TEST_F(MessageViewTest, UpdateControlButtonsVisibilityCalled) {
  ui::test::EventGenerator event_generator(
      GetRootWindow(message_view()->GetWidget()));

  // Expect a call on the mouse entering the message view.
  EXPECT_CALL(*message_view(), UpdateControlButtonsVisibility);
  event_generator.MoveMouseTo(message_view()->GetBoundsInScreen().CenterPoint(),
                              10);

  // Expect a call on the mouse exiting the message view.
  EXPECT_CALL(*message_view(), UpdateControlButtonsVisibility);
  event_generator.MoveMouseTo(
      message_view()->GetBoundsInScreen().origin() - gfx::Vector2d(10, 10), 10);
}
#endif  // IS_CHROMEOS_ASH

TEST_F(MessageViewTest, AccessibleAttributes) {}

}  // namespace message_center