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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
7 #include "components/precache/core/precache_session_table.h" | 7 #include "components/precache/core/precache_session_table.h" |
8 #include "components/precache/core/proto/unfinished_work.pb.h" | 8 #include "components/precache/core/proto/unfinished_work.pb.h" |
9 #include "sql/connection.h" | 9 #include "sql/connection.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 precache_session_table_.reset(new PrecacheSessionTable()); | 24 precache_session_table_.reset(new PrecacheSessionTable()); |
25 db_.reset(new sql::Connection()); | 25 db_.reset(new sql::Connection()); |
26 ASSERT_TRUE(db_->OpenInMemory()); | 26 ASSERT_TRUE(db_->OpenInMemory()); |
27 precache_session_table_->Init(db_.get()); | 27 precache_session_table_->Init(db_.get()); |
28 } | 28 } |
29 | 29 |
30 std::unique_ptr<PrecacheSessionTable> precache_session_table_; | 30 std::unique_ptr<PrecacheSessionTable> precache_session_table_; |
31 std::unique_ptr<sql::Connection> db_; | 31 std::unique_ptr<sql::Connection> db_; |
32 }; | 32 }; |
33 | 33 |
| 34 TEST_F(PrecacheSessionTableTest, LastPrecacheTimestamp) { |
| 35 const base::Time sometime = base::Time::FromDoubleT(42); |
| 36 |
| 37 precache_session_table_->SetLastPrecacheTimestamp(sometime); |
| 38 |
| 39 EXPECT_EQ(sometime, precache_session_table_->GetLastPrecacheTimestamp()); |
| 40 |
| 41 precache_session_table_->DeleteLastPrecacheTimestamp(); |
| 42 |
| 43 EXPECT_EQ(base::Time(), precache_session_table_->GetLastPrecacheTimestamp()); |
| 44 } |
| 45 |
34 TEST_F(PrecacheSessionTableTest, SaveAndGetUnfinishedWork) { | 46 TEST_F(PrecacheSessionTableTest, SaveAndGetUnfinishedWork) { |
35 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work( | 47 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work( |
36 new PrecacheUnfinishedWork()); | 48 new PrecacheUnfinishedWork()); |
37 unfinished_work->add_top_host()->set_hostname("foo.com"); | 49 unfinished_work->add_top_host()->set_hostname("foo.com"); |
38 unfinished_work->add_top_host()->set_hostname("bar.com"); | 50 unfinished_work->add_top_host()->set_hostname("bar.com"); |
39 auto s = unfinished_work->mutable_config_settings(); | 51 auto s = unfinished_work->mutable_config_settings(); |
40 s->set_top_sites_count(11); | 52 s->set_top_sites_count(11); |
41 s->add_forced_site("baz.com"); | 53 s->add_forced_site("baz.com"); |
42 s->set_top_resources_count(12); | 54 s->set_top_resources_count(12); |
43 s->set_max_bytes_per_resource(501); | 55 s->set_max_bytes_per_resource(501); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 153 |
142 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work2 = | 154 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work2 = |
143 precache_session_table_->GetUnfinishedWork(); | 155 precache_session_table_->GetUnfinishedWork(); |
144 | 156 |
145 EXPECT_EQ(0, unfinished_work2->manifest_size()); | 157 EXPECT_EQ(0, unfinished_work2->manifest_size()); |
146 } | 158 } |
147 | 159 |
148 } // namespace | 160 } // namespace |
149 | 161 |
150 } // namespace precache | 162 } // namespace precache |
OLD | NEW |