| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offline_page_metadata_store_impl.h" | 5 #include "components/offline_pages/offline_page_metadata_store_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/test_simple_task_runner.h" | 14 #include "base/test/test_simple_task_runner.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "components/leveldb_proto/proto_database_impl.h" | 16 #include "components/leveldb_proto/proto_database_impl.h" |
| 17 #include "components/offline_pages/offline_page_item.h" | 17 #include "components/offline_pages/offline_page_item.h" |
| 18 #include "components/offline_pages/offline_page_metadata_store_sql.h" |
| 18 #include "components/offline_pages/offline_page_model.h" | 19 #include "components/offline_pages/offline_page_model.h" |
| 19 #include "components/offline_pages/proto/offline_pages.pb.h" | 20 #include "components/offline_pages/proto/offline_pages.pb.h" |
| 21 #include "sql/connection.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 23 |
| 22 using leveldb_proto::ProtoDatabaseImpl; | 24 using leveldb_proto::ProtoDatabaseImpl; |
| 23 | 25 |
| 24 namespace offline_pages { | 26 namespace offline_pages { |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 const char kTestURL[] = "https://example.com"; | 30 const char kTestURL[] = "https://example.com"; |
| 29 const ClientId kTestBookmarkId(BOOKMARK_NAMESPACE, "1234"); | 31 const ClientId kTestBookmarkId(BOOKMARK_NAMESPACE, "1234"); |
| 30 const ClientId kTestBookmarkId2(BOOKMARK_NAMESPACE, "5678"); | 32 const ClientId kTestBookmarkId2(BOOKMARK_NAMESPACE, "5678"); |
| 31 const base::FilePath::CharType kFilePath[] = | 33 const base::FilePath::CharType kFilePath[] = |
| 32 FILE_PATH_LITERAL("/offline_pages/example_com.mhtml"); | 34 FILE_PATH_LITERAL("/offline_pages/example_com.mhtml"); |
| 33 int64_t kFileSize = 234567; | 35 int64_t kFileSize = 234567; |
| 34 | 36 |
| 35 class OfflinePageMetadataStoreImplTest : public testing::Test { | 37 class OfflinePageMetadataStoreFactory { |
| 36 public: | 38 public: |
| 37 enum CalledCallback { NONE, LOAD, ADD, REMOVE, DESTROY }; | 39 virtual OfflinePageMetadataStore* BuildStore(const base::FilePath& file) = 0; |
| 38 enum Status { STATUS_NONE, STATUS_TRUE, STATUS_FALSE }; | 40 }; |
| 39 | 41 |
| 40 OfflinePageMetadataStoreImplTest(); | 42 class OfflinePageMetadataStoreImplFactory |
| 41 ~OfflinePageMetadataStoreImplTest() override; | 43 : public OfflinePageMetadataStoreFactory { |
| 44 public: |
| 45 OfflinePageMetadataStore* BuildStore(const base::FilePath& file) { |
| 46 return new OfflinePageMetadataStoreImpl(base::ThreadTaskRunnerHandle::Get(), |
| 47 file); |
| 48 } |
| 49 }; |
| 50 |
| 51 class OfflinePageMetadataStoreSQLFactory |
| 52 : public OfflinePageMetadataStoreFactory { |
| 53 public: |
| 54 OfflinePageMetadataStore* BuildStore(const base::FilePath& file) { |
| 55 OfflinePageMetadataStoreSQL* store = new OfflinePageMetadataStoreSQL( |
| 56 base::ThreadTaskRunnerHandle::Get(), file); |
| 57 return store; |
| 58 } |
| 59 }; |
| 60 |
| 61 enum CalledCallback { NONE, LOAD, ADD, REMOVE, DESTROY }; |
| 62 enum Status { STATUS_NONE, STATUS_TRUE, STATUS_FALSE }; |
| 63 |
| 64 class OfflinePageMetadataStoreTestBase : public testing::Test { |
| 65 public: |
| 66 OfflinePageMetadataStoreTestBase(); |
| 67 ~OfflinePageMetadataStoreTestBase() override; |
| 42 | 68 |
| 43 void TearDown() override { | 69 void TearDown() override { |
| 44 // Wait for all the pieces of the store to delete itself properly. | 70 // Wait for all the pieces of the store to delete itself properly. |
| 45 PumpLoop(); | 71 PumpLoop(); |
| 46 } | 72 } |
| 47 | 73 |
| 48 scoped_ptr<OfflinePageMetadataStoreImpl> BuildStore(); | 74 virtual scoped_ptr<OfflinePageMetadataStore> BuildStore() = 0; |
| 49 void PumpLoop(); | 75 void PumpLoop(); |
| 50 | 76 |
| 51 void LoadCallback(OfflinePageMetadataStore::LoadStatus load_status, | 77 void LoadCallback(OfflinePageMetadataStore::LoadStatus load_status, |
| 52 const std::vector<OfflinePageItem>& offline_pages); | 78 const std::vector<OfflinePageItem>& offline_pages); |
| 53 void UpdateCallback(CalledCallback called_callback, bool success); | 79 void UpdateCallback(CalledCallback called_callback, bool success); |
| 54 | 80 |
| 55 void ClearResults(); | 81 void ClearResults(); |
| 56 | 82 |
| 57 protected: | 83 protected: |
| 58 CalledCallback last_called_callback_; | 84 CalledCallback last_called_callback_; |
| 59 Status last_status_; | 85 Status last_status_; |
| 60 std::vector<OfflinePageItem> offline_pages_; | 86 std::vector<OfflinePageItem> offline_pages_; |
| 61 | 87 |
| 62 base::ScopedTempDir temp_directory_; | 88 base::ScopedTempDir temp_directory_; |
| 63 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 89 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
| 64 base::ThreadTaskRunnerHandle task_runner_handle_; | 90 base::ThreadTaskRunnerHandle task_runner_handle_; |
| 65 }; | 91 }; |
| 66 | 92 |
| 67 OfflinePageMetadataStoreImplTest::OfflinePageMetadataStoreImplTest() | 93 OfflinePageMetadataStoreTestBase::OfflinePageMetadataStoreTestBase() |
| 68 : last_called_callback_(NONE), | 94 : last_called_callback_(NONE), |
| 69 last_status_(STATUS_NONE), | 95 last_status_(STATUS_NONE), |
| 70 task_runner_(new base::TestSimpleTaskRunner), | 96 task_runner_(new base::TestSimpleTaskRunner), |
| 71 task_runner_handle_(task_runner_) { | 97 task_runner_handle_(task_runner_) { |
| 72 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); | 98 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); |
| 73 } | 99 } |
| 74 | 100 |
| 75 OfflinePageMetadataStoreImplTest::~OfflinePageMetadataStoreImplTest() { | 101 OfflinePageMetadataStoreTestBase::~OfflinePageMetadataStoreTestBase() {} |
| 76 } | |
| 77 | 102 |
| 78 void OfflinePageMetadataStoreImplTest::PumpLoop() { | 103 void OfflinePageMetadataStoreTestBase::PumpLoop() { |
| 79 task_runner_->RunUntilIdle(); | 104 task_runner_->RunUntilIdle(); |
| 80 } | 105 } |
| 81 | 106 |
| 82 scoped_ptr<OfflinePageMetadataStoreImpl> | 107 void OfflinePageMetadataStoreTestBase::LoadCallback( |
| 83 OfflinePageMetadataStoreImplTest::BuildStore() { | |
| 84 scoped_ptr<OfflinePageMetadataStoreImpl> store( | |
| 85 new OfflinePageMetadataStoreImpl(base::ThreadTaskRunnerHandle::Get(), | |
| 86 temp_directory_.path())); | |
| 87 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | |
| 88 base::Unretained(this))); | |
| 89 PumpLoop(); | |
| 90 return store; | |
| 91 } | |
| 92 | |
| 93 void OfflinePageMetadataStoreImplTest::LoadCallback( | |
| 94 OfflinePageMetadataStore::LoadStatus load_status, | 108 OfflinePageMetadataStore::LoadStatus load_status, |
| 95 const std::vector<OfflinePageItem>& offline_pages) { | 109 const std::vector<OfflinePageItem>& offline_pages) { |
| 96 last_called_callback_ = LOAD; | 110 last_called_callback_ = LOAD; |
| 97 last_status_ = load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ? | 111 last_status_ = load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ? |
| 98 STATUS_TRUE : STATUS_FALSE; | 112 STATUS_TRUE : STATUS_FALSE; |
| 99 offline_pages_.swap(const_cast<std::vector<OfflinePageItem>&>(offline_pages)); | 113 offline_pages_.swap(const_cast<std::vector<OfflinePageItem>&>(offline_pages)); |
| 100 } | 114 } |
| 101 | 115 |
| 102 void OfflinePageMetadataStoreImplTest::UpdateCallback( | 116 void OfflinePageMetadataStoreTestBase::UpdateCallback( |
| 103 CalledCallback called_callback, | 117 CalledCallback called_callback, |
| 104 bool status) { | 118 bool status) { |
| 105 last_called_callback_ = called_callback; | 119 last_called_callback_ = called_callback; |
| 106 last_status_ = status ? STATUS_TRUE : STATUS_FALSE; | 120 last_status_ = status ? STATUS_TRUE : STATUS_FALSE; |
| 107 } | 121 } |
| 108 | 122 |
| 109 void OfflinePageMetadataStoreImplTest::ClearResults() { | 123 void OfflinePageMetadataStoreTestBase::ClearResults() { |
| 110 last_called_callback_ = NONE; | 124 last_called_callback_ = NONE; |
| 111 last_status_ = STATUS_NONE; | 125 last_status_ = STATUS_NONE; |
| 112 offline_pages_.clear(); | 126 offline_pages_.clear(); |
| 113 } | 127 } |
| 114 | 128 |
| 129 template <typename T> |
| 130 class OfflinePageMetadataStoreTest : public OfflinePageMetadataStoreTestBase { |
| 131 public: |
| 132 scoped_ptr<OfflinePageMetadataStore> BuildStore(); |
| 133 |
| 134 protected: |
| 135 T factory_; |
| 136 }; |
| 137 |
| 138 template <typename T> |
| 139 scoped_ptr<OfflinePageMetadataStore> |
| 140 OfflinePageMetadataStoreTest<T>::BuildStore() { |
| 141 scoped_ptr<OfflinePageMetadataStore> store( |
| 142 factory_.BuildStore(temp_directory_.path())); |
| 143 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 144 base::Unretained(this))); |
| 145 PumpLoop(); |
| 146 return store; |
| 147 } |
| 148 |
| 149 typedef testing::Types<OfflinePageMetadataStoreImplFactory, |
| 150 OfflinePageMetadataStoreSQLFactory> |
| 151 MyTypes; |
| 152 TYPED_TEST_CASE(OfflinePageMetadataStoreTest, MyTypes); |
| 153 |
| 115 // Loads empty store and makes sure that there are no offline pages stored in | 154 // Loads empty store and makes sure that there are no offline pages stored in |
| 116 // it. | 155 // it. |
| 117 TEST_F(OfflinePageMetadataStoreImplTest, LoadEmptyStore) { | 156 TYPED_TEST(OfflinePageMetadataStoreTest, LoadEmptyStore) { |
| 118 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 157 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 119 EXPECT_EQ(LOAD, last_called_callback_); | 158 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 120 EXPECT_EQ(STATUS_TRUE, last_status_); | 159 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 121 EXPECT_EQ(0U, offline_pages_.size()); | 160 EXPECT_EQ(0U, this->offline_pages_.size()); |
| 122 } | 161 } |
| 123 | 162 |
| 124 // Adds metadata of an offline page into a store and then opens the store | 163 // Adds metadata of an offline page into a store and then opens the store |
| 125 // again to make sure that stored metadata survives store restarts. | 164 // again to make sure that stored metadata survives store restarts. |
| 126 TEST_F(OfflinePageMetadataStoreImplTest, AddOfflinePage) { | 165 TYPED_TEST(OfflinePageMetadataStoreTest, AddOfflinePage) { |
| 127 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 166 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 128 | 167 |
| 129 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, | 168 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, |
| 130 base::FilePath(kFilePath), kFileSize); | 169 base::FilePath(kFilePath), kFileSize); |
| 131 store->AddOrUpdateOfflinePage( | 170 store->AddOrUpdateOfflinePage( |
| 132 offline_page, | 171 offline_page, |
| 133 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 172 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 134 base::Unretained(this), ADD)); | 173 base::Unretained(this), ADD)); |
| 135 PumpLoop(); | 174 this->PumpLoop(); |
| 136 EXPECT_EQ(ADD, last_called_callback_); | 175 EXPECT_EQ(ADD, this->last_called_callback_); |
| 137 EXPECT_EQ(STATUS_TRUE, last_status_); | 176 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 138 | 177 |
| 139 ClearResults(); | 178 this->ClearResults(); |
| 140 | 179 |
| 141 // Close the store first to ensure file lock is removed. | 180 // Close the store first to ensure file lock is removed. |
| 142 store.reset(); | 181 store.reset(); |
| 143 store = BuildStore(); | 182 store = this->BuildStore(); |
| 144 PumpLoop(); | 183 this->PumpLoop(); |
| 145 | 184 |
| 146 EXPECT_EQ(LOAD, last_called_callback_); | 185 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 147 EXPECT_EQ(STATUS_TRUE, last_status_); | 186 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 148 EXPECT_EQ(1U, offline_pages_.size()); | 187 EXPECT_EQ(1U, this->offline_pages_.size()); |
| 149 EXPECT_EQ(offline_page.url, offline_pages_[0].url); | 188 EXPECT_EQ(offline_page.url, this->offline_pages_[0].url); |
| 150 EXPECT_EQ(offline_page.offline_id, offline_pages_[0].offline_id); | 189 EXPECT_EQ(offline_page.offline_id, this->offline_pages_[0].offline_id); |
| 151 EXPECT_EQ(offline_page.version, offline_pages_[0].version); | 190 EXPECT_EQ(offline_page.version, this->offline_pages_[0].version); |
| 152 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | 191 EXPECT_EQ(offline_page.file_path, this->offline_pages_[0].file_path); |
| 153 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | 192 EXPECT_EQ(offline_page.file_size, this->offline_pages_[0].file_size); |
| 154 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | 193 EXPECT_EQ(offline_page.creation_time, this->offline_pages_[0].creation_time); |
| 155 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | 194 EXPECT_EQ(offline_page.last_access_time, |
| 156 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); | 195 this->offline_pages_[0].last_access_time); |
| 157 EXPECT_EQ(offline_page.client_id, offline_pages_[0].client_id); | 196 EXPECT_EQ(offline_page.access_count, this->offline_pages_[0].access_count); |
| 197 EXPECT_EQ(offline_page.client_id, this->offline_pages_[0].client_id); |
| 158 } | 198 } |
| 159 | 199 |
| 160 // Tests removing offline page metadata from the store, for which it first adds | 200 // Tests removing offline page metadata from the store, for which it first adds |
| 161 // metadata of an offline page. | 201 // metadata of an offline page. |
| 162 TEST_F(OfflinePageMetadataStoreImplTest, RemoveOfflinePage) { | 202 TYPED_TEST(OfflinePageMetadataStoreTest, RemoveOfflinePage) { |
| 163 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 203 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 164 | 204 |
| 165 // Add an offline page. | 205 // Add an offline page. |
| 166 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, | 206 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, |
| 167 base::FilePath(kFilePath), kFileSize); | 207 base::FilePath(kFilePath), kFileSize); |
| 168 store->AddOrUpdateOfflinePage( | 208 store->AddOrUpdateOfflinePage( |
| 169 offline_page, | 209 offline_page, |
| 170 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 210 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 171 base::Unretained(this), ADD)); | 211 base::Unretained(this), ADD)); |
| 172 PumpLoop(); | 212 this->PumpLoop(); |
| 173 EXPECT_EQ(ADD, last_called_callback_); | 213 EXPECT_EQ(ADD, this->last_called_callback_); |
| 174 EXPECT_EQ(STATUS_TRUE, last_status_); | 214 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 175 | 215 |
| 176 ClearResults(); | 216 this->ClearResults(); |
| 177 | 217 |
| 178 // Load the store. | 218 // Load the store. |
| 179 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 219 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 180 base::Unretained(this))); | 220 base::Unretained(this))); |
| 181 PumpLoop(); | 221 this->PumpLoop(); |
| 182 EXPECT_EQ(LOAD, last_called_callback_); | 222 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 183 EXPECT_EQ(1U, offline_pages_.size()); | 223 EXPECT_EQ(1U, this->offline_pages_.size()); |
| 184 | 224 |
| 185 // Remove the offline page. | 225 // Remove the offline page. |
| 186 std::vector<int64_t> ids_to_remove; | 226 std::vector<int64_t> ids_to_remove; |
| 187 ids_to_remove.push_back(offline_page.offline_id); | 227 ids_to_remove.push_back(offline_page.offline_id); |
| 188 store->RemoveOfflinePages( | 228 store->RemoveOfflinePages( |
| 189 ids_to_remove, | 229 ids_to_remove, |
| 190 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 230 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 191 base::Unretained(this), REMOVE)); | 231 base::Unretained(this), REMOVE)); |
| 192 PumpLoop(); | 232 this->PumpLoop(); |
| 193 EXPECT_EQ(REMOVE, last_called_callback_); | 233 EXPECT_EQ(REMOVE, this->last_called_callback_); |
| 194 EXPECT_EQ(STATUS_TRUE, last_status_); | 234 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 195 | 235 |
| 196 ClearResults(); | 236 this->ClearResults(); |
| 197 | 237 |
| 198 // Load the store. | 238 // Load the store. |
| 199 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 239 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 200 base::Unretained(this))); | 240 base::Unretained(this))); |
| 201 PumpLoop(); | 241 this->PumpLoop(); |
| 202 EXPECT_EQ(LOAD, last_called_callback_); | 242 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 203 EXPECT_EQ(0U, offline_pages_.size()); | 243 EXPECT_EQ(0U, this->offline_pages_.size()); |
| 204 | 244 |
| 205 ClearResults(); | 245 this->ClearResults(); |
| 206 | 246 |
| 207 // Close and reload the store. | 247 // Close and reload the store. |
| 208 store.reset(); | 248 store.reset(); |
| 209 store = BuildStore(); | 249 store = this->BuildStore(); |
| 210 EXPECT_EQ(LOAD, last_called_callback_); | 250 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 211 EXPECT_EQ(STATUS_TRUE, last_status_); | 251 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 212 EXPECT_EQ(0U, offline_pages_.size()); | 252 EXPECT_EQ(0U, this->offline_pages_.size()); |
| 213 } | 253 } |
| 214 | 254 |
| 215 // Adds metadata of multiple offline pages into a store and removes some. | 255 // Adds metadata of multiple offline pages into a store and removes some. |
| 216 TEST_F(OfflinePageMetadataStoreImplTest, AddRemoveMultipleOfflinePages) { | 256 TYPED_TEST(OfflinePageMetadataStoreTest, AddRemoveMultipleOfflinePages) { |
| 217 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 257 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 218 | 258 |
| 219 // Add an offline page. | 259 // Add an offline page. |
| 220 OfflinePageItem offline_page_1(GURL(kTestURL), 12345LL, kTestBookmarkId, | 260 OfflinePageItem offline_page_1(GURL(kTestURL), 12345LL, kTestBookmarkId, |
| 221 base::FilePath(kFilePath), kFileSize); | 261 base::FilePath(kFilePath), kFileSize); |
| 222 base::FilePath file_path_2 = | 262 base::FilePath file_path_2 = |
| 223 base::FilePath(FILE_PATH_LITERAL("//other.page.com.mhtml")); | 263 base::FilePath(FILE_PATH_LITERAL("//other.page.com.mhtml")); |
| 224 OfflinePageItem offline_page_2(GURL("https://other.page.com"), 5678LL, | 264 OfflinePageItem offline_page_2(GURL("https://other.page.com"), 5678LL, |
| 225 kTestBookmarkId2, file_path_2, 12345, | 265 kTestBookmarkId2, file_path_2, 12345, |
| 226 base::Time::Now()); | 266 base::Time::Now()); |
| 227 store->AddOrUpdateOfflinePage( | 267 store->AddOrUpdateOfflinePage( |
| 228 offline_page_1, | 268 offline_page_1, |
| 229 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 269 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 230 base::Unretained(this), ADD)); | 270 base::Unretained(this), ADD)); |
| 231 PumpLoop(); | 271 this->PumpLoop(); |
| 232 EXPECT_EQ(ADD, last_called_callback_); | 272 EXPECT_EQ(ADD, this->last_called_callback_); |
| 233 EXPECT_EQ(STATUS_TRUE, last_status_); | 273 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 234 | 274 |
| 235 ClearResults(); | 275 this->ClearResults(); |
| 236 | 276 |
| 237 // Add anther offline page. | 277 // Add anther offline page. |
| 238 store->AddOrUpdateOfflinePage( | 278 store->AddOrUpdateOfflinePage( |
| 239 offline_page_2, | 279 offline_page_2, |
| 240 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 280 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 241 base::Unretained(this), ADD)); | 281 base::Unretained(this), ADD)); |
| 242 PumpLoop(); | 282 this->PumpLoop(); |
| 243 EXPECT_EQ(ADD, last_called_callback_); | 283 EXPECT_EQ(ADD, this->last_called_callback_); |
| 244 EXPECT_EQ(STATUS_TRUE, last_status_); | 284 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 245 | 285 |
| 246 ClearResults(); | 286 this->ClearResults(); |
| 247 | 287 |
| 248 // Load the store. | 288 // Load the store. |
| 249 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 289 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 250 base::Unretained(this))); | 290 base::Unretained(this))); |
| 251 PumpLoop(); | 291 this->PumpLoop(); |
| 252 | 292 |
| 253 EXPECT_EQ(LOAD, last_called_callback_); | 293 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 254 EXPECT_EQ(STATUS_TRUE, last_status_); | 294 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 255 EXPECT_EQ(2U, offline_pages_.size()); | 295 EXPECT_EQ(2U, this->offline_pages_.size()); |
| 256 | 296 |
| 257 // Remove the offline page. | 297 // Remove the offline page. |
| 258 std::vector<int64_t> ids_to_remove; | 298 std::vector<int64_t> ids_to_remove; |
| 259 ids_to_remove.push_back(offline_page_1.offline_id); | 299 ids_to_remove.push_back(offline_page_1.offline_id); |
| 260 store->RemoveOfflinePages( | 300 store->RemoveOfflinePages( |
| 261 ids_to_remove, | 301 ids_to_remove, |
| 262 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 302 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 263 base::Unretained(this), REMOVE)); | 303 base::Unretained(this), REMOVE)); |
| 264 PumpLoop(); | 304 this->PumpLoop(); |
| 265 EXPECT_EQ(REMOVE, last_called_callback_); | 305 EXPECT_EQ(REMOVE, this->last_called_callback_); |
| 266 EXPECT_EQ(STATUS_TRUE, last_status_); | 306 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 267 | 307 |
| 268 ClearResults(); | 308 this->ClearResults(); |
| 269 | 309 |
| 270 // Close and reload the store. | 310 // Close and reload the store. |
| 271 store.reset(); | 311 store.reset(); |
| 272 store = BuildStore(); | 312 store = this->BuildStore(); |
| 273 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 313 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 274 base::Unretained(this))); | 314 base::Unretained(this))); |
| 275 PumpLoop(); | 315 this->PumpLoop(); |
| 276 | 316 |
| 277 EXPECT_EQ(LOAD, last_called_callback_); | 317 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 278 EXPECT_EQ(STATUS_TRUE, last_status_); | 318 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 279 EXPECT_EQ(1U, offline_pages_.size()); | 319 EXPECT_EQ(1U, this->offline_pages_.size()); |
| 280 EXPECT_EQ(offline_page_2.url, offline_pages_[0].url); | 320 EXPECT_EQ(offline_page_2.url, this->offline_pages_[0].url); |
| 281 EXPECT_EQ(offline_page_2.offline_id, offline_pages_[0].offline_id); | 321 EXPECT_EQ(offline_page_2.offline_id, this->offline_pages_[0].offline_id); |
| 282 EXPECT_EQ(offline_page_2.version, offline_pages_[0].version); | 322 EXPECT_EQ(offline_page_2.version, this->offline_pages_[0].version); |
| 283 EXPECT_EQ(offline_page_2.file_path, offline_pages_[0].file_path); | 323 EXPECT_EQ(offline_page_2.file_path, this->offline_pages_[0].file_path); |
| 284 EXPECT_EQ(offline_page_2.file_size, offline_pages_[0].file_size); | 324 EXPECT_EQ(offline_page_2.file_size, this->offline_pages_[0].file_size); |
| 285 EXPECT_EQ(offline_page_2.creation_time, offline_pages_[0].creation_time); | 325 EXPECT_EQ(offline_page_2.creation_time, |
| 326 this->offline_pages_[0].creation_time); |
| 286 EXPECT_EQ(offline_page_2.last_access_time, | 327 EXPECT_EQ(offline_page_2.last_access_time, |
| 287 offline_pages_[0].last_access_time); | 328 this->offline_pages_[0].last_access_time); |
| 288 EXPECT_EQ(offline_page_2.access_count, offline_pages_[0].access_count); | 329 EXPECT_EQ(offline_page_2.access_count, this->offline_pages_[0].access_count); |
| 289 EXPECT_EQ(offline_page_2.client_id, offline_pages_[0].client_id); | 330 EXPECT_EQ(offline_page_2.client_id, this->offline_pages_[0].client_id); |
| 290 } | 331 } |
| 291 | 332 |
| 292 // Tests updating offline page metadata from the store. | 333 // Tests updating offline page metadata from the store. |
| 293 TEST_F(OfflinePageMetadataStoreImplTest, UpdateOfflinePage) { | 334 TYPED_TEST(OfflinePageMetadataStoreTest, UpdateOfflinePage) { |
| 294 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 335 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 295 | 336 |
| 296 // First, adds a fresh page. | 337 // First, add a fresh page. |
| 297 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, | 338 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, |
| 298 base::FilePath(kFilePath), kFileSize); | 339 base::FilePath(kFilePath), kFileSize); |
| 299 store->AddOrUpdateOfflinePage( | 340 store->AddOrUpdateOfflinePage( |
| 300 offline_page, | 341 offline_page, |
| 301 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 342 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 302 base::Unretained(this), ADD)); | 343 base::Unretained(this), ADD)); |
| 303 PumpLoop(); | 344 this->PumpLoop(); |
| 304 EXPECT_EQ(ADD, last_called_callback_); | 345 EXPECT_EQ(ADD, this->last_called_callback_); |
| 305 EXPECT_EQ(STATUS_TRUE, last_status_); | 346 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 306 | 347 |
| 307 ClearResults(); | 348 this->ClearResults(); |
| 308 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 349 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 309 base::Unretained(this))); | 350 base::Unretained(this))); |
| 310 PumpLoop(); | 351 this->PumpLoop(); |
| 311 | 352 |
| 312 EXPECT_EQ(LOAD, last_called_callback_); | 353 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 313 EXPECT_EQ(STATUS_TRUE, last_status_); | 354 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 314 EXPECT_EQ(1U, offline_pages_.size()); | 355 EXPECT_EQ(1U, this->offline_pages_.size()); |
| 315 EXPECT_EQ(offline_page.url, offline_pages_[0].url); | 356 EXPECT_EQ(offline_page.url, this->offline_pages_[0].url); |
| 316 EXPECT_EQ(offline_page.offline_id, offline_pages_[0].offline_id); | 357 EXPECT_EQ(offline_page.offline_id, this->offline_pages_[0].offline_id); |
| 317 EXPECT_EQ(offline_page.version, offline_pages_[0].version); | 358 EXPECT_EQ(offline_page.version, this->offline_pages_[0].version); |
| 318 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | 359 EXPECT_EQ(offline_page.file_path, this->offline_pages_[0].file_path); |
| 319 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | 360 EXPECT_EQ(offline_page.file_size, this->offline_pages_[0].file_size); |
| 320 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | 361 EXPECT_EQ(offline_page.creation_time, this->offline_pages_[0].creation_time); |
| 321 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | 362 EXPECT_EQ(offline_page.last_access_time, |
| 322 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); | 363 this->offline_pages_[0].last_access_time); |
| 323 EXPECT_EQ(offline_page.client_id, offline_pages_[0].client_id); | 364 EXPECT_EQ(offline_page.access_count, this->offline_pages_[0].access_count); |
| 365 EXPECT_EQ(offline_page.client_id, this->offline_pages_[0].client_id); |
| 324 | 366 |
| 325 // Then updates some data. | 367 // Then update some data. |
| 326 offline_page.file_size = kFileSize + 1; | 368 offline_page.file_size = kFileSize + 1; |
| 327 offline_page.access_count++; | 369 offline_page.access_count++; |
| 328 store->AddOrUpdateOfflinePage( | 370 store->AddOrUpdateOfflinePage( |
| 329 offline_page, | 371 offline_page, |
| 330 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 372 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 331 base::Unretained(this), ADD)); | 373 base::Unretained(this), ADD)); |
| 332 PumpLoop(); | 374 this->PumpLoop(); |
| 333 EXPECT_EQ(ADD, last_called_callback_); | 375 EXPECT_EQ(ADD, this->last_called_callback_); |
| 334 EXPECT_EQ(STATUS_TRUE, last_status_); | 376 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 335 | 377 |
| 336 ClearResults(); | 378 this->ClearResults(); |
| 337 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 379 store->Load(base::Bind(&OfflinePageMetadataStoreTestBase::LoadCallback, |
| 338 base::Unretained(this))); | 380 base::Unretained(this))); |
| 339 PumpLoop(); | 381 this->PumpLoop(); |
| 340 | 382 |
| 341 EXPECT_EQ(LOAD, last_called_callback_); | 383 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 342 EXPECT_EQ(STATUS_TRUE, last_status_); | 384 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 343 EXPECT_EQ(1U, offline_pages_.size()); | 385 EXPECT_EQ(1U, this->offline_pages_.size()); |
| 344 EXPECT_EQ(offline_page.url, offline_pages_[0].url); | 386 EXPECT_EQ(offline_page.url, this->offline_pages_[0].url); |
| 345 EXPECT_EQ(offline_page.offline_id, offline_pages_[0].offline_id); | 387 EXPECT_EQ(offline_page.offline_id, this->offline_pages_[0].offline_id); |
| 346 EXPECT_EQ(offline_page.version, offline_pages_[0].version); | 388 EXPECT_EQ(offline_page.version, this->offline_pages_[0].version); |
| 347 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | 389 EXPECT_EQ(offline_page.file_path, this->offline_pages_[0].file_path); |
| 348 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | 390 EXPECT_EQ(offline_page.file_size, this->offline_pages_[0].file_size); |
| 349 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | 391 EXPECT_EQ(offline_page.creation_time, this->offline_pages_[0].creation_time); |
| 350 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | 392 EXPECT_EQ(offline_page.last_access_time, |
| 351 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); | 393 this->offline_pages_[0].last_access_time); |
| 352 EXPECT_EQ(offline_page.client_id, offline_pages_[0].client_id); | 394 EXPECT_EQ(offline_page.access_count, this->offline_pages_[0].access_count); |
| 395 EXPECT_EQ(offline_page.client_id, this->offline_pages_[0].client_id); |
| 353 } | 396 } |
| 354 | 397 |
| 355 } // namespace | 398 } // namespace |
| 356 | 399 |
| 400 class OfflinePageMetadataStoreImplTest |
| 401 : public OfflinePageMetadataStoreTest<OfflinePageMetadataStoreImplFactory> { |
| 402 }; |
| 403 |
| 357 // Test that loading a store with a bad value still loads. | 404 // Test that loading a store with a bad value still loads. |
| 358 // Needs to be outside of the anonymous namespace in order for FRIEND_TEST | 405 // Needs to be outside of the anonymous namespace in order for FRIEND_TEST |
| 359 // to work. | 406 // to work. |
| 360 TEST_F(OfflinePageMetadataStoreImplTest, LoadCorruptedStore) { | 407 TEST_F(OfflinePageMetadataStoreImplTest, LoadCorruptedStore) { |
| 361 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 408 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 362 | 409 |
| 363 // Write one ok page. | 410 // Write one ok page. |
| 364 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, | 411 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestBookmarkId, |
| 365 base::FilePath(kFilePath), kFileSize); | 412 base::FilePath(kFilePath), kFileSize); |
| 366 store->AddOrUpdateOfflinePage( | 413 store->AddOrUpdateOfflinePage( |
| 367 offline_page, | 414 offline_page, |
| 368 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 415 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 369 base::Unretained(this), ADD)); | 416 base::Unretained(this), ADD)); |
| 370 PumpLoop(); | 417 this->PumpLoop(); |
| 371 EXPECT_EQ(ADD, last_called_callback_); | 418 EXPECT_EQ(ADD, this->last_called_callback_); |
| 372 EXPECT_EQ(STATUS_TRUE, last_status_); | 419 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 373 | 420 |
| 374 // Manually write one broken page (no id) | 421 // Manually write one broken page (no id) |
| 375 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> | 422 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> |
| 376 entries_to_save( | 423 entries_to_save( |
| 377 new leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); | 424 new leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); |
| 378 scoped_ptr<std::vector<std::string>> keys_to_remove( | 425 scoped_ptr<std::vector<std::string>> keys_to_remove( |
| 379 new std::vector<std::string>()); | 426 new std::vector<std::string>()); |
| 380 | 427 |
| 381 OfflinePageEntry offline_page_proto; | 428 OfflinePageEntry offline_page_proto; |
| 382 entries_to_save->push_back(std::make_pair("0", offline_page_proto)); | 429 entries_to_save->push_back(std::make_pair("0", offline_page_proto)); |
| 383 | 430 |
| 384 store->UpdateEntries( | 431 ((OfflinePageMetadataStoreImpl*)store.get()) |
| 385 std::move(entries_to_save), std::move(keys_to_remove), | 432 ->UpdateEntries( |
| 386 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 433 std::move(entries_to_save), std::move(keys_to_remove), |
| 387 base::Unretained(this), ADD)); | 434 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 388 PumpLoop(); | 435 base::Unretained(this), ADD)); |
| 436 this->PumpLoop(); |
| 389 | 437 |
| 390 EXPECT_EQ(ADD, last_called_callback_); | 438 EXPECT_EQ(ADD, this->last_called_callback_); |
| 391 EXPECT_EQ(STATUS_TRUE, last_status_); | 439 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 392 | 440 |
| 393 ClearResults(); | 441 this->ClearResults(); |
| 394 | 442 |
| 395 // Close the store first to ensure file lock is removed. | 443 // Close the store first to ensure file lock is removed. |
| 396 store.reset(); | 444 store.reset(); |
| 397 store = BuildStore(); | 445 store = this->BuildStore(); |
| 398 PumpLoop(); | 446 this->PumpLoop(); |
| 399 | 447 |
| 400 // One of the pages was busted, so only expect one page. | 448 // One of the pages was busted, so only expect one page. |
| 401 EXPECT_EQ(LOAD, last_called_callback_); | 449 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 402 EXPECT_EQ(STATUS_TRUE, last_status_); | 450 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 403 EXPECT_EQ(1U, offline_pages_.size()); | 451 EXPECT_EQ(1U, this->offline_pages_.size()); |
| 404 EXPECT_EQ(offline_page.url, offline_pages_[0].url); | 452 EXPECT_EQ(offline_page.url, this->offline_pages_[0].url); |
| 405 EXPECT_EQ(offline_page.offline_id, offline_pages_[0].offline_id); | 453 EXPECT_EQ(offline_page.offline_id, this->offline_pages_[0].offline_id); |
| 406 EXPECT_EQ(offline_page.version, offline_pages_[0].version); | 454 EXPECT_EQ(offline_page.version, this->offline_pages_[0].version); |
| 407 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | 455 EXPECT_EQ(offline_page.file_path, this->offline_pages_[0].file_path); |
| 408 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | 456 EXPECT_EQ(offline_page.file_size, this->offline_pages_[0].file_size); |
| 409 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | 457 EXPECT_EQ(offline_page.creation_time, this->offline_pages_[0].creation_time); |
| 410 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | 458 EXPECT_EQ(offline_page.last_access_time, |
| 411 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); | 459 this->offline_pages_[0].last_access_time); |
| 460 EXPECT_EQ(offline_page.access_count, this->offline_pages_[0].access_count); |
| 412 } | 461 } |
| 413 | 462 |
| 414 // Test that loading a store with nothing but bad values errors. | 463 // Test that loading a store with nothing but bad values errors. |
| 415 // Needs to be outside of the anonymous namespace in order for FRIEND_TEST | 464 // Needs to be outside of the anonymous namespace in order for FRIEND_TEST |
| 416 // to work. | 465 // to work. |
| 417 TEST_F(OfflinePageMetadataStoreImplTest, LoadTotallyCorruptedStore) { | 466 TEST_F(OfflinePageMetadataStoreImplTest, LoadTotallyCorruptedStore) { |
| 418 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 467 scoped_ptr<OfflinePageMetadataStore> store(this->BuildStore()); |
| 419 | 468 |
| 420 // Manually write two broken pages (no id) | 469 // Manually write two broken pages (no id) |
| 421 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> | 470 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> |
| 422 entries_to_save( | 471 entries_to_save( |
| 423 new leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); | 472 new leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector()); |
| 424 scoped_ptr<std::vector<std::string>> keys_to_remove( | 473 scoped_ptr<std::vector<std::string>> keys_to_remove( |
| 425 new std::vector<std::string>()); | 474 new std::vector<std::string>()); |
| 426 | 475 |
| 427 OfflinePageEntry offline_page_proto; | 476 OfflinePageEntry offline_page_proto; |
| 428 entries_to_save->push_back(std::make_pair("0", offline_page_proto)); | 477 entries_to_save->push_back(std::make_pair("0", offline_page_proto)); |
| 429 entries_to_save->push_back(std::make_pair("1", offline_page_proto)); | 478 entries_to_save->push_back(std::make_pair("1", offline_page_proto)); |
| 430 | 479 |
| 431 store->UpdateEntries( | 480 ((OfflinePageMetadataStoreImpl*)store.get()) |
| 432 std::move(entries_to_save), std::move(keys_to_remove), | 481 ->UpdateEntries( |
| 433 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 482 std::move(entries_to_save), std::move(keys_to_remove), |
| 434 base::Unretained(this), ADD)); | 483 base::Bind(&OfflinePageMetadataStoreTestBase::UpdateCallback, |
| 435 PumpLoop(); | 484 base::Unretained(this), ADD)); |
| 485 this->PumpLoop(); |
| 436 | 486 |
| 437 EXPECT_EQ(ADD, last_called_callback_); | 487 EXPECT_EQ(ADD, this->last_called_callback_); |
| 438 EXPECT_EQ(STATUS_TRUE, last_status_); | 488 EXPECT_EQ(STATUS_TRUE, this->last_status_); |
| 439 | 489 |
| 440 ClearResults(); | 490 this->ClearResults(); |
| 441 | 491 |
| 442 // Close the store first to ensure file lock is removed. | 492 // Close the store first to ensure file lock is removed. |
| 443 store.reset(); | 493 store.reset(); |
| 444 store = BuildStore(); | 494 store = this->BuildStore(); |
| 445 PumpLoop(); | 495 this->PumpLoop(); |
| 446 | 496 |
| 447 // One of the pages was busted, so only expect one page. | 497 // One of the pages was busted, so only expect one page. |
| 448 EXPECT_EQ(LOAD, last_called_callback_); | 498 EXPECT_EQ(LOAD, this->last_called_callback_); |
| 449 EXPECT_EQ(STATUS_FALSE, last_status_); | 499 EXPECT_EQ(STATUS_FALSE, this->last_status_); |
| 450 } | 500 } |
| 451 | 501 |
| 452 } // namespace offline_pages | 502 } // namespace offline_pages |
| OLD | NEW |