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

Unified Diff: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc

Issue 1694863003: Refactor the offline page storage to include client namespace and id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address changes Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
index 6a0c8f18732f98f2784be0576d4d26aab1b0e2e5..1cdcf05a38688a1775afc3bae468e022c6a1b28a 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
@@ -22,6 +22,7 @@
#include "components/offline_pages/offline_page_switches.h"
#include "components/offline_pages/offline_page_test_archiver.h"
#include "components/offline_pages/offline_page_test_store.h"
+#include "components/offline_pages/proto/offline_pages.pb.h"
#include "net/base/filename_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -32,9 +33,11 @@ namespace {
const GURL kTestPage1Url("http://test.org/page1");
const GURL kTestPage2Url("http://test.org/page2");
const GURL kTestPage3Url("http://test.org/page3");
+const int64_t kTestFileSize = 876543LL;
+const char* kTestPage1ClientId = "1234";
+const char* kTestPage2ClientId = "5678";
const int64_t kTestPage1BookmarkId = 1234;
const int64_t kTestPage2BookmarkId = 5678;
-const int64_t kTestFileSize = 876543LL;
} // namespace
@@ -50,7 +53,8 @@ class OfflinePageUtilsTest
void RunUntilIdle();
// Necessary callbacks for the offline page model.
- void OnSavePageDone(OfflinePageModel::SavePageResult result);
+ void OnSavePageDone(OfflinePageModel::SavePageResult result,
+ int64_t offlineId);
void OnClearAllDone();
// OfflinePageTestArchiver::Observer implementation:
@@ -65,6 +69,8 @@ class OfflinePageUtilsTest
TestingProfile* profile() { return &profile_; }
+ int64_t offline_id() const { return offline_id_; }
+
private:
void CreateOfflinePages();
scoped_ptr<OfflinePageTestArchiver> BuildArchiver(
@@ -75,6 +81,8 @@ class OfflinePageUtilsTest
GURL offline_url_page_2_;
GURL offline_url_missing_;
+ int64_t offline_id_;
+
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
base::ThreadTaskRunnerHandle task_runner_handle_;
TestingProfile profile_;
@@ -106,8 +114,9 @@ void OfflinePageUtilsTest::RunUntilIdle() {
}
void OfflinePageUtilsTest::OnSavePageDone(
- OfflinePageModel::SavePageResult result) {
- // Result ignored here.
+ OfflinePageModel::SavePageResult result,
+ int64_t offline_id) {
+ offline_id_ = offline_id;
}
void OfflinePageUtilsTest::OnClearAllDone() {
@@ -124,24 +133,28 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
// Create page 1.
scoped_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
kTestPage1Url, base::FilePath(FILE_PATH_LITERAL("page1.mhtml"))));
+ offline_pages::ClientId client_id;
+ client_id.name_space = BOOKMARK_NAMESPACE;
+ client_id.id = kTestPage1ClientId;
model->SavePage(
- kTestPage1Url, kTestPage1BookmarkId, std::move(archiver),
+ kTestPage1Url, client_id, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
+ int64_t offline1 = offline_id();
+ client_id.id = kTestPage2ClientId;
// Create page 2.
archiver = BuildArchiver(kTestPage2Url,
base::FilePath(FILE_PATH_LITERAL("page2.mhtml")));
model->SavePage(
- kTestPage2Url, kTestPage2BookmarkId, std::move(archiver),
+ kTestPage2Url, client_id, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
+ int64_t offline2 = offline_id();
// Make a copy of local paths of the two pages stored in the model.
- offline_url_page_1_ =
- model->GetPageByBookmarkId(kTestPage1BookmarkId)->GetOfflineURL();
- offline_url_page_2_ =
- model->GetPageByBookmarkId(kTestPage2BookmarkId)->GetOfflineURL();
+ offline_url_page_1_ = model->GetPageByOfflineId(offline1)->GetOfflineURL();
+ offline_url_page_2_ = model->GetPageByOfflineId(offline2)->GetOfflineURL();
// Create a file path that is not associated with any offline page.
offline_url_missing_ = net::FilePathToFileURL(
profile()

Powered by Google App Engine
This is Rietveld 408576698