chromium/chrome/browser/ui/views/performance_controls/memory_saver_bubble_view_unittest.cc

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

#include "chrome/browser/ui/views/performance_controls/memory_saver_bubble_view.h"

#include <tuple>

#include "base/test/metrics/histogram_tester.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom-shared.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/performance_controls/performance_controls_metrics.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_controller.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "chrome/browser/ui/views/performance_controls/memory_saver_chip_view.h"
#include "chrome/browser/ui/views/performance_controls/memory_saver_resource_view.h"
#include "chrome/browser/ui/views/performance_controls/test_support/memory_saver_unit_test_mixin.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/testing_profile.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/user_tuning/prefs.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/mock_navigation_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
#include "ui/events/event_utils.h"
#include "ui/events/types/event_type.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/label.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/widget/widget.h"

namespace {
constexpr int kMemorySavingsKilobytes =;
}  // namespace

class MemorySaverBubbleViewTest
    : public MemorySaverUnitTestMixin<TestWithBrowserView>,
      public testing::WithParamInterface<std::tuple<int, int>> {};

// When the page action chip is clicked, the dialog should open.
TEST_F(MemorySaverBubbleViewTest, ShouldOpenDialogOnClick) {}

// When the dialog is closed, UMA metrics should be logged.
TEST_F(MemorySaverBubbleViewTest, ShouldLogMetricsOnDialogDismiss) {}

// A the domain of the current site should be rendered as a subtitle.
TEST_F(MemorySaverBubbleViewTest, ShouldRenderDomainInDialogSubtitle) {}

TEST_F(MemorySaverBubbleViewTest,
       ShowDialogWithoutExcludeSiteButtonInGuestMode) {}

TEST_F(MemorySaverBubbleViewTest,
       ShouldCollapseChipAfterNavigatingTabsWithDialogOpen) {}

// The memory savings should be rendered within the resource view.
TEST_F(MemorySaverBubbleViewTest, ShouldRenderMemorySavingsInResourceView) {}

// The memory savings should not be rendered within the text above the resource
// view.
TEST_F(MemorySaverBubbleViewTest,
       ShouldNotRenderMemorySavingsInDialogBodyText) {}

// The correct label should be rendered for different memory savings amounts.
TEST_P(MemorySaverBubbleViewTest, ShowsCorrectLabelsForDifferentSavings) {}

INSTANTIATE_TEST_SUITE_P();