#include "chrome/browser/ui/views/performance_controls/memory_saver_chip_view.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/performance_manager/test_support/test_user_performance_tuning_manager_environment.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/browser_window/public/browser_window_features.h"
#include "chrome/browser/ui/performance_controls/memory_saver_chip_tab_helper.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_bubble_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/browser/ui/views/side_panel/side_panel.h"
#include "chrome/browser/ui/views/side_panel/side_panel_coordinator.h"
#include "chrome/browser/ui/views/side_panel/side_panel_entry.h"
#include "chrome/browser/ui/views/side_panel/side_panel_ui.h"
#include "chrome/common/pref_names.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 "ui/base/interaction/element_identifier.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/label.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/test/button_test_api.h"
namespace {
constexpr int64_t kMemorySavingsKilobytes = …;
constexpr int64_t kHighMemorySavingsKilobytes = …;
constexpr int64_t kVeryHighMemorySavingsKilobytes = …;
}
class MemorySaverChipViewTest
: public MemorySaverUnitTestMixin<TestWithBrowserView> { … };
TEST_F(MemorySaverChipViewTest, ShouldShowChipForProactivelyDiscardedPage) { … }
TEST_F(MemorySaverChipViewTest,
ShouldNotShowChipWhenNonProactivelyDiscardPage) { … }
TEST_F(MemorySaverChipViewTest, ShouldNotShowWhenPrefIsFalse) { … }
TEST_F(MemorySaverChipViewTest, ShouldLogMetricsForCollapsedChip) { … }
TEST_F(MemorySaverChipViewTest, ShouldLogMetricsForInformationalExpandedChip) { … }
TEST_F(MemorySaverChipViewTest, ShouldNotShowForRegularPage) { … }
TEST_F(MemorySaverChipViewTest, ShouldHideLabelAfterMultipleDiscards) { … }
TEST_F(MemorySaverChipViewTest, ShouldCollapseChipAfterNavigatingTabs) { … }
TEST_F(MemorySaverChipViewTest, ShouldExpandChipWhenConditionsAreMet) { … }
TEST_F(MemorySaverChipViewTest, ShouldNotExpandForSavingsBelowThreshold) { … }
TEST_F(MemorySaverChipViewTest, ShouldNotExpandWhenChipHasExpandedRecently) { … }
TEST_F(MemorySaverChipViewTest, ShouldNotExpandWhenTabWasDiscardedRecently) { … }
TEST_F(MemorySaverChipViewTest, ShouldLogMetricsForCelebratoryExpandedChip) { … }
TEST_F(MemorySaverChipViewTest, MoreThan2GbMemorySavings) { … }