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

Side by Side Diff: components/offline_pages/core/snapshot_controller_unittest.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: more rebase Created 4 years 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
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 "components/offline_pages/snapshot_controller.h" 5 #include "components/offline_pages/core/snapshot_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/test/test_mock_time_task_runner.h" 10 #include "base/test/test_mock_time_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace offline_pages { 15 namespace offline_pages {
16 16
17 class SnapshotControllerTest 17 class SnapshotControllerTest : public testing::Test,
18 : public testing::Test, 18 public SnapshotController::Client {
19 public SnapshotController::Client {
20 public: 19 public:
21 SnapshotControllerTest(); 20 SnapshotControllerTest();
22 ~SnapshotControllerTest() override; 21 ~SnapshotControllerTest() override;
23 22
24 SnapshotController* controller() { return controller_.get(); } 23 SnapshotController* controller() { return controller_.get(); }
25 int snapshot_count() { return snapshot_count_; } 24 int snapshot_count() { return snapshot_count_; }
26 25
27 // testing::Test 26 // testing::Test
28 void SetUp() override; 27 void SetUp() override;
29 void TearDown() override; 28 void TearDown() override;
(...skipping 12 matching lines...) Expand all
42 private: 41 private:
43 std::unique_ptr<SnapshotController> controller_; 42 std::unique_ptr<SnapshotController> controller_;
44 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; 43 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
45 bool snapshot_started_; 44 bool snapshot_started_;
46 int snapshot_count_; 45 int snapshot_count_;
47 }; 46 };
48 47
49 SnapshotControllerTest::SnapshotControllerTest() 48 SnapshotControllerTest::SnapshotControllerTest()
50 : task_runner_(new base::TestMockTimeTaskRunner), 49 : task_runner_(new base::TestMockTimeTaskRunner),
51 snapshot_started_(true), 50 snapshot_started_(true),
52 snapshot_count_(0) { 51 snapshot_count_(0) {}
53 }
54 52
55 SnapshotControllerTest::~SnapshotControllerTest() { 53 SnapshotControllerTest::~SnapshotControllerTest() {}
56 }
57 54
58 void SnapshotControllerTest::SetUp() { 55 void SnapshotControllerTest::SetUp() {
59 controller_.reset(new SnapshotController(task_runner_, this)); 56 controller_.reset(new SnapshotController(task_runner_, this));
60 snapshot_started_ = true; 57 snapshot_started_ = true;
61 } 58 }
62 59
63 void SnapshotControllerTest::TearDown() { 60 void SnapshotControllerTest::TearDown() {
64 controller_.reset(); 61 controller_.reset();
65 } 62 }
66 63
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 controller()->PendingSnapshotCompleted(); 181 controller()->PendingSnapshotCompleted();
185 // Next snapshot should be initiated when new document is loaded. 182 // Next snapshot should be initiated when new document is loaded.
186 controller()->DocumentAvailableInMainFrame(); 183 controller()->DocumentAvailableInMainFrame();
187 FastForwardBy(base::TimeDelta::FromMilliseconds( 184 FastForwardBy(base::TimeDelta::FromMilliseconds(
188 controller()->GetDelayAfterDocumentAvailableForTest())); 185 controller()->GetDelayAfterDocumentAvailableForTest()));
189 // No snapshot since session was reset. 186 // No snapshot since session was reset.
190 EXPECT_EQ(2, snapshot_count()); 187 EXPECT_EQ(2, snapshot_count());
191 } 188 }
192 189
193 } // namespace offline_pages 190 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698