chromium/chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc

// Copyright 2017 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/resource_coordinator/tab_lifecycle_unit_source.h"

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

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit_observer.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit_source_observer.h"
#include "chrome/browser/resource_coordinator/tab_helper.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_observer.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/tab_load_tracker.h"
#include "chrome/browser/resource_coordinator/test_lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/time.h"
#include "chrome/browser/resource_coordinator/utils.h"
#include "chrome/browser/ui/recently_audible_helper.h"
#include "chrome/browser/ui/tabs/tab_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h"
#include "chrome/browser/ui/tabs/test_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/performance_manager/test_support/graph_impl.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace resource_coordinator {

namespace {

constexpr base::TimeDelta kShortDelay =;

class MockLifecycleUnitSourceObserver : public LifecycleUnitSourceObserver {};

class MockTabLifecycleObserver : public TabLifecycleObserver {};

class MockLifecycleUnitObserver : public LifecycleUnitObserver {};

bool IsFocused(LifecycleUnit* lifecycle_unit) {}

class TabLifecycleUnitSourceTest : public ChromeRenderViewHostTestHarness {};

}  // namespace

TEST_F(TabLifecycleUnitSourceTest, AppendTabsToFocusedTabStrip) {}

TEST_F(TabLifecycleUnitSourceTest, AppendTabsToNonFocusedTabStrip) {}

TEST_F(TabLifecycleUnitSourceTest, SwitchTabInFocusedTabStrip) {}

TEST_F(TabLifecycleUnitSourceTest, CloseTabInFocusedTabStrip) {}

TEST_F(TabLifecycleUnitSourceTest, DiscardWebContents) {}

TEST_F(TabLifecycleUnitSourceTest, DetachWebContents_Urgent) {}

TEST_F(TabLifecycleUnitSourceTest, DetachWebContents_External) {}

// Regression test for https://crbug.com/818454. Previously, TabLifecycleUnits
// were destroyed from TabStripModelObserver::TabClosingAt(). If a tab was
// detached (TabStripModel::DetachWebContentsAt) and its WebContents destroyed,
// the TabLifecycleUnit was never destroyed. This was solved by giving ownership
// of a tab lifecycleunit to a WebContentsUserData.
TEST_F(TabLifecycleUnitSourceTest, DetachAndDeleteWebContents) {}

// Tab discarding is tested here rather than in TabLifecycleUnitTest because
// collaboration from the TabLifecycleUnitSource is required to replace the
// WebContents in the TabLifecycleUnit.

TEST_F(TabLifecycleUnitSourceTest, Discard_Urgent) {}

TEST_F(TabLifecycleUnitSourceTest, Discard_External) {}

TEST_F(TabLifecycleUnitSourceTest, DiscardAndActivate_Urgent) {}

TEST_F(TabLifecycleUnitSourceTest, DiscardAndActivate_External) {}

TEST_F(TabLifecycleUnitSourceTest, DiscardAndExplicitlyReload_Urgent) {}

TEST_F(TabLifecycleUnitSourceTest, DiscardAndExplicitlyReload_External) {}

}  // namespace resource_coordinator