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

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 comments. 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..8a1e479e87ab8ce02fd84f920cae2df93b362e1b 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,12 @@ 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 kTestPage1BookmarkId = 1234;
-const int64_t kTestPage2BookmarkId = 5678;
+const int64_t kTestPage1OfflineId = 1234;
+const int64_t kTestPage2OfflineId = 5678;
const int64_t kTestFileSize = 876543LL;
+const char* kTestClientNamespace = "test";
+const char* kTestPage1ClientId = "1234";
+const char* kTestPage2ClientId = "5678";
} // namespace
@@ -124,24 +128,28 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
// Create page 1.
scoped_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
kTestPage1Url, base::FilePath(FILE_PATH_LITERAL("page1.mhtml"))));
+ offline_pages::ClientId cid;
+ cid.space = kTestClientNamespace;
+ cid.id = kTestPage1ClientId;
model->SavePage(
- kTestPage1Url, kTestPage1BookmarkId, std::move(archiver),
+ kTestPage1Url, kTestPage1OfflineId, cid, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
+ cid.id = kTestPage2ClientId;
// Create page 2.
archiver = BuildArchiver(kTestPage2Url,
base::FilePath(FILE_PATH_LITERAL("page2.mhtml")));
model->SavePage(
- kTestPage2Url, kTestPage2BookmarkId, std::move(archiver),
+ kTestPage2Url, kTestPage2OfflineId, cid, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
// Make a copy of local paths of the two pages stored in the model.
offline_url_page_1_ =
- model->GetPageByBookmarkId(kTestPage1BookmarkId)->GetOfflineURL();
+ model->GetPageByOfflineId(kTestPage1OfflineId)->GetOfflineURL();
offline_url_page_2_ =
- model->GetPageByBookmarkId(kTestPage2BookmarkId)->GetOfflineURL();
+ model->GetPageByOfflineId(kTestPage2OfflineId)->GetOfflineURL();
// Create a file path that is not associated with any offline page.
offline_url_missing_ = net::FilePathToFileURL(
profile()
@@ -201,9 +209,9 @@ TEST_F(OfflinePageUtilsTest, GetOnlineURLForOfflineURL) {
}
TEST_F(OfflinePageUtilsTest, GetBookmarkIdForOfflineURL) {
- EXPECT_EQ(kTestPage1BookmarkId, OfflinePageUtils::GetBookmarkIdForOfflineURL(
+ EXPECT_EQ(kTestPage1OfflineId, OfflinePageUtils::GetBookmarkIdForOfflineURL(
profile(), offline_url_page_1()));
- EXPECT_EQ(kTestPage2BookmarkId, OfflinePageUtils::GetBookmarkIdForOfflineURL(
+ EXPECT_EQ(kTestPage2OfflineId, OfflinePageUtils::GetBookmarkIdForOfflineURL(
profile(), offline_url_page_2()));
EXPECT_EQ(-1, OfflinePageUtils::GetBookmarkIdForOfflineURL(
profile(), offline_url_missing()));

Powered by Google App Engine
This is Rietveld 408576698