1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41

ash / quick_insert / views / quick_insert_pseudo_focus_unittest.cc [blame]

// 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 "ash/quick_insert/views/quick_insert_pseudo_focus.h"

#include "ash/quick_insert/views/quick_insert_badge_view.h"
#include "ash/quick_insert/views/quick_insert_list_item_view.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/test/views_test_base.h"

namespace ash {
namespace {

using QuickInsertPseudoFocusTest = views::ViewsTestBase;

TEST_F(QuickInsertPseudoFocusTest,
       ApplyPseudoFocusToListItemUpdatesItemStateAndBadge) {
  QuickInsertListItemView item_view(base::DoNothing());

  ApplyQuickInsertPseudoFocusToView(&item_view);

  EXPECT_EQ(item_view.GetItemState(),
            QuickInsertItemView::ItemState::kPseudoFocused);
  EXPECT_TRUE(item_view.trailing_badge_for_testing().GetVisible());
}

TEST_F(QuickInsertPseudoFocusTest,
       RemovePseudoFocusFromListItemUpdatesItemStateAndBadge) {
  QuickInsertListItemView item_view(base::DoNothing());
  ApplyQuickInsertPseudoFocusToView(&item_view);

  RemoveQuickInsertPseudoFocusFromView(&item_view);

  EXPECT_EQ(item_view.GetItemState(), QuickInsertItemView::ItemState::kNormal);
  EXPECT_FALSE(item_view.trailing_badge_for_testing().GetVisible());
}

}  // namespace
}  // namespace ash