Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: chrome/browser/sessions/tab_loader_unittest.cc

Issue 2466883002: Add TabLoaderTest (Closed)
Patch Set: Address on sky's review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sessions/tab_loader.h"
6
7 #include "base/memory/memory_coordinator_proxy.h"
8 #include "base/run_loop.h"
9 #include "base/time/time.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/browser/memory_coordinator_delegate.h"
12 #include "content/public/browser/render_widget_host_view.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/test_browser_thread.h"
15 #include "content/public/test/test_web_contents_factory.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 class TabLoaderTest : public testing::Test {
19 public:
20 using RestoredTab = SessionRestoreDelegate::RestoredTab;
21
22 TabLoaderTest()
23 : ui_thread_(content::BrowserThread::UI, &message_loop_) {}
24
25 // testing::Test:
26 void SetUp() override {
27 content::EnableFeaturesForTesting();
28 content::SetUpMemoryCoordinatorProxyForTesting();
29
30 test_web_contents_factory_.reset(new content::TestWebContentsFactory);
31 content::WebContents* contents =
32 test_web_contents_factory_->CreateWebContents(&testing_profile_);
33 restored_tabs_.push_back(RestoredTab(contents, false, false, false));
34 }
35
36 void TearDown() override {
37 restored_tabs_.clear();
38 test_web_contents_factory_.reset();
39 }
40
41 protected:
42 std::unique_ptr<content::TestWebContentsFactory> test_web_contents_factory_;
43 std::vector<RestoredTab> restored_tabs_;
44
45 base::MessageLoop message_loop_;
46 TestingProfile testing_profile_;
47 content::TestBrowserThread ui_thread_;
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(TabLoaderTest);
51 };
52
53 TEST_F(TabLoaderTest, OnMemoryStateChange) {
54 TabLoader::RestoreTabs(restored_tabs_, base::TimeTicks());
55 EXPECT_TRUE(TabLoader::shared_tab_loader_->loading_enabled_);
56 base::MemoryCoordinatorProxy::GetInstance()->SetCurrentMemoryStateForTesting(
57 base::MemoryState::THROTTLED);
58 base::RunLoop loop;
59 loop.RunUntilIdle();
60 EXPECT_FALSE(TabLoader::shared_tab_loader_->loading_enabled_);
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698