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

Side by Side Diff: components/precache/core/precache_session_table_unittest.cc

Issue 2123813002: Report Precache.TimeSinceLastPrecache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gclient sync Created 4 years, 5 months 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 <stdint.h>
6
5 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
6 #include "base/time/time.h" 8 #include "base/time/time.h"
7 #include "components/precache/core/precache_session_table.h" 9 #include "components/precache/core/precache_session_table.h"
8 #include "components/precache/core/proto/unfinished_work.pb.h" 10 #include "components/precache/core/proto/unfinished_work.pb.h"
9 #include "sql/connection.h" 11 #include "sql/connection.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h" 13 #include "url/gurl.h"
12 14
13 namespace precache { 15 namespace precache {
14 16
15 namespace { 17 namespace {
16 18
17 class PrecacheSessionTableTest : public testing::Test { 19 class PrecacheSessionTableTest : public testing::Test {
18 public: 20 public:
19 PrecacheSessionTableTest() {} 21 PrecacheSessionTableTest() {}
20 ~PrecacheSessionTableTest() override {} 22 ~PrecacheSessionTableTest() override {}
21 23
22 protected: 24 protected:
23 void SetUp() override { 25 void SetUp() override {
24 precache_session_table_.reset(new PrecacheSessionTable()); 26 precache_session_table_.reset(new PrecacheSessionTable());
25 db_.reset(new sql::Connection()); 27 db_.reset(new sql::Connection());
26 ASSERT_TRUE(db_->OpenInMemory()); 28 ASSERT_TRUE(db_->OpenInMemory());
27 precache_session_table_->Init(db_.get()); 29 precache_session_table_->Init(db_.get());
28 } 30 }
29 31
30 std::unique_ptr<PrecacheSessionTable> precache_session_table_; 32 std::unique_ptr<PrecacheSessionTable> precache_session_table_;
31 std::unique_ptr<sql::Connection> db_; 33 std::unique_ptr<sql::Connection> db_;
32 }; 34 };
33 35
36 TEST_F(PrecacheSessionTableTest, LastPrecacheTimestamp) {
37 const base::Time sometime = base::Time::FromDoubleT(42);
38
39 precache_session_table_->SetLastPrecacheTimestamp(sometime);
40
41 EXPECT_EQ(sometime, precache_session_table_->GetLastPrecacheTimestamp());
42
43 precache_session_table_->DeleteLastPrecacheTimestamp();
44
45 EXPECT_EQ(base::Time(), precache_session_table_->GetLastPrecacheTimestamp());
46 }
47
34 TEST_F(PrecacheSessionTableTest, SaveAndGetUnfinishedWork) { 48 TEST_F(PrecacheSessionTableTest, SaveAndGetUnfinishedWork) {
35 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work( 49 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work(
36 new PrecacheUnfinishedWork()); 50 new PrecacheUnfinishedWork());
37 unfinished_work->add_top_host()->set_hostname("foo.com"); 51 unfinished_work->add_top_host()->set_hostname("foo.com");
38 unfinished_work->add_top_host()->set_hostname("bar.com"); 52 unfinished_work->add_top_host()->set_hostname("bar.com");
39 auto s = unfinished_work->mutable_config_settings(); 53 auto s = unfinished_work->mutable_config_settings();
40 s->set_top_sites_count(11); 54 s->set_top_sites_count(11);
41 s->add_forced_site("baz.com"); 55 s->add_forced_site("baz.com");
42 s->set_top_resources_count(12); 56 s->set_top_resources_count(12);
43 s->set_max_bytes_per_resource(501); 57 s->set_max_bytes_per_resource(501);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 155
142 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work2 = 156 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work2 =
143 precache_session_table_->GetUnfinishedWork(); 157 precache_session_table_->GetUnfinishedWork();
144 158
145 EXPECT_EQ(0, unfinished_work2->manifest_size()); 159 EXPECT_EQ(0, unfinished_work2->manifest_size());
146 } 160 }
147 161
148 } // namespace 162 } // namespace
149 163
150 } // namespace precache 164 } // namespace precache
OLDNEW
« no previous file with comments | « components/precache/core/precache_session_table.cc ('k') | components/precache/core/proto/timestamp.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698