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

Side by Side Diff: components/offline_pages/background/request_queue_store_unittest.cc

Issue 2093623003: [Offline pages] Hooking up SQL store to Offline RequestQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a test for SQL store actually persisting requests across resets 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
« no previous file with comments | « chrome/common/chrome_constants.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/background/request_queue_store.h" 5 #include "components/offline_pages/background/request_queue_store.h"
6 6
7 #include <memory> 7 #include <memory>
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"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ASSERT_EQ(LastResult::kTrue, this->last_result()); 304 ASSERT_EQ(LastResult::kTrue, this->last_result());
305 this->ClearResults(); 305 this->ClearResults();
306 306
307 store->GetRequests(base::Bind(&RequestQueueStoreTestBase::GetRequestsDone, 307 store->GetRequests(base::Bind(&RequestQueueStoreTestBase::GetRequestsDone,
308 base::Unretained(this))); 308 base::Unretained(this)));
309 this->PumpLoop(); 309 this->PumpLoop();
310 ASSERT_EQ(LastResult::kTrue, this->last_result()); 310 ASSERT_EQ(LastResult::kTrue, this->last_result());
311 ASSERT_TRUE(this->last_requests().empty()); 311 ASSERT_TRUE(this->last_requests().empty());
312 } 312 }
313 313
314 class RequestQueueStoreSQLTest
315 : public RequestQueueStoreTest<RequestQueueStoreSQLFactory> {};
316
317 // Makes sure that persistent DB is actually persisting requests across store
318 // restarts.
319 TEST_F(RequestQueueStoreSQLTest, SaveCloseReopenRead) {
320 std::unique_ptr<RequestQueueStore> store(BuildStore());
321 base::Time creation_time = base::Time::Now();
322 SavePageRequest original_request(kRequestId, kUrl, kClientId, creation_time);
323 store->AddOrUpdateRequest(
324 original_request, base::Bind(&RequestQueueStoreTestBase::AddOrUpdateDone,
325 base::Unretained(this)));
326 PumpLoop();
327 ClearResults();
328
329 // Resets the store, using the same temp directory. The contents should be
330 // intact. First reset is done separately to release DB lock.
331 store.reset();
332 store = BuildStore();
333 store->GetRequests(base::Bind(&RequestQueueStoreTestBase::GetRequestsDone,
334 base::Unretained(this)));
335 ASSERT_EQ(LastResult::kNone, this->last_result());
336 this->PumpLoop();
337 ASSERT_EQ(LastResult::kTrue, this->last_result());
338 ASSERT_EQ(1ul, this->last_requests().size());
339 ASSERT_TRUE(original_request == this->last_requests()[0]);
340 }
341
314 } // offline_pages 342 } // offline_pages
OLDNEW
« no previous file with comments | « chrome/common/chrome_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698