| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sessions/tab_loader.h" | 5 #include "chrome/browser/sessions/tab_loader.h" |
| 6 | 6 |
| 7 #include "base/base_features.h" |
| 7 #include "base/memory/memory_coordinator_client_registry.h" | 8 #include "base/memory/memory_coordinator_client_registry.h" |
| 8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 9 #include "base/test/scoped_feature_list.h" | 10 #include "base/test/scoped_feature_list.h" |
| 10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 12 #include "content/public/browser/memory_coordinator_delegate.h" | 13 #include "content/public/browser/memory_coordinator_delegate.h" |
| 13 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/content_features.h" | |
| 16 #include "content/public/test/memory_coordinator_test_utils.h" | 16 #include "content/public/test/memory_coordinator_test_utils.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "content/public/test/test_web_contents_factory.h" | 18 #include "content/public/test/test_web_contents_factory.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 class TabLoaderTest : public testing::Test { | 21 class TabLoaderTest : public testing::Test { |
| 22 public: | 22 public: |
| 23 using RestoredTab = SessionRestoreDelegate::RestoredTab; | 23 using RestoredTab = SessionRestoreDelegate::RestoredTab; |
| 24 | 24 |
| 25 TabLoaderTest() = default; | 25 TabLoaderTest() = default; |
| 26 | 26 |
| 27 // testing::Test: | 27 // testing::Test: |
| 28 void SetUp() override { | 28 void SetUp() override { |
| 29 scoped_feature_list_.InitAndEnableFeature(features::kMemoryCoordinator); | 29 scoped_feature_list_.InitAndEnableFeature( |
| 30 base::features::kMemoryCoordinator); |
| 30 content::SetUpMemoryCoordinatorProxyForTesting(); | 31 content::SetUpMemoryCoordinatorProxyForTesting(); |
| 31 | 32 |
| 32 test_web_contents_factory_.reset(new content::TestWebContentsFactory); | 33 test_web_contents_factory_.reset(new content::TestWebContentsFactory); |
| 33 content::WebContents* contents = | 34 content::WebContents* contents = |
| 34 test_web_contents_factory_->CreateWebContents(&testing_profile_); | 35 test_web_contents_factory_->CreateWebContents(&testing_profile_); |
| 35 restored_tabs_.push_back(RestoredTab(contents, false, false, false)); | 36 restored_tabs_.push_back(RestoredTab(contents, false, false, false)); |
| 36 } | 37 } |
| 37 | 38 |
| 38 void TearDown() override { | 39 void TearDown() override { |
| 39 restored_tabs_.clear(); | 40 restored_tabs_.clear(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 TabLoader::RestoreTabs(restored_tabs_, base::TimeTicks()); | 64 TabLoader::RestoreTabs(restored_tabs_, base::TimeTicks()); |
| 64 EXPECT_TRUE(TabLoader::shared_tab_loader_->loading_enabled_); | 65 EXPECT_TRUE(TabLoader::shared_tab_loader_->loading_enabled_); |
| 65 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( | 66 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( |
| 66 base::MemoryState::THROTTLED); | 67 base::MemoryState::THROTTLED); |
| 67 // ObserverListThreadsafe is used to notify the state to clients, so running | 68 // ObserverListThreadsafe is used to notify the state to clients, so running |
| 68 // the loop is necessary here. | 69 // the loop is necessary here. |
| 69 base::RunLoop loop; | 70 base::RunLoop loop; |
| 70 loop.RunUntilIdle(); | 71 loop.RunUntilIdle(); |
| 71 EXPECT_FALSE(TabLoader::shared_tab_loader_->loading_enabled_); | 72 EXPECT_FALSE(TabLoader::shared_tab_loader_->loading_enabled_); |
| 72 } | 73 } |
| OLD | NEW |