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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc

Issue 2234873004: Have the RequestCoordinator generate the offline_id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge, and CR fixes per Dimich Created 4 years, 4 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
OLDNEW
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 "chrome/browser/android/offline_pages/offline_page_utils.h" 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 OfflinePageModel* model = 149 OfflinePageModel* model =
150 OfflinePageModelFactory::GetForBrowserContext(profile()); 150 OfflinePageModelFactory::GetForBrowserContext(profile());
151 151
152 // Create page 1. 152 // Create page 1.
153 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver( 153 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
154 kTestPage1Url, base::FilePath(FILE_PATH_LITERAL("page1.mhtml")))); 154 kTestPage1Url, base::FilePath(FILE_PATH_LITERAL("page1.mhtml"))));
155 offline_pages::ClientId client_id; 155 offline_pages::ClientId client_id;
156 client_id.name_space = kBookmarkNamespace; 156 client_id.name_space = kBookmarkNamespace;
157 client_id.id = kTestPage1ClientId; 157 client_id.id = kTestPage1ClientId;
158 model->SavePage( 158 model->SavePage(
159 kTestPage1Url, client_id, std::move(archiver), 159 kTestPage1Url, client_id, 0ul, std::move(archiver),
160 base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr())); 160 base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
161 RunUntilIdle(); 161 RunUntilIdle();
162 offline_url_page_1_ = 162 offline_url_page_1_ =
163 model->MaybeGetPageByOfflineId(offline_id())->GetOfflineURL(); 163 model->MaybeGetPageByOfflineId(offline_id())->GetOfflineURL();
164 164
165 // Create page 2. 165 // Create page 2.
166 archiver = BuildArchiver(kTestPage2Url, 166 archiver = BuildArchiver(kTestPage2Url,
167 base::FilePath(FILE_PATH_LITERAL("page2.mhtml"))); 167 base::FilePath(FILE_PATH_LITERAL("page2.mhtml")));
168 client_id.id = kTestPage2ClientId; 168 client_id.id = kTestPage2ClientId;
169 model->SavePage( 169 model->SavePage(
170 kTestPage2Url, client_id, std::move(archiver), 170 kTestPage2Url, client_id, 0ul, std::move(archiver),
171 base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr())); 171 base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
172 RunUntilIdle(); 172 RunUntilIdle();
173 offline_url_page_2_ = 173 offline_url_page_2_ =
174 model->MaybeGetPageByOfflineId(offline_id())->GetOfflineURL(); 174 model->MaybeGetPageByOfflineId(offline_id())->GetOfflineURL();
175 175
176 // Page 3 is not created, as it is missing. 176 // Page 3 is not created, as it is missing.
177 // Create a file path that is not associated with any offline page. 177 // Create a file path that is not associated with any offline page.
178 offline_url_missing_ = net::FilePathToFileURL( 178 offline_url_missing_ = net::FilePathToFileURL(
179 profile() 179 profile()
180 ->GetPath() 180 ->GetPath()
181 .Append(chrome::kOfflinePageArchivesDirname) 181 .Append(chrome::kOfflinePageArchivesDirname)
182 .Append(FILE_PATH_LITERAL("missing_file.mhtml"))); 182 .Append(FILE_PATH_LITERAL("missing_file.mhtml")));
183 183
184 // Create page 4 - expired page. 184 // Create page 4 - expired page.
185 archiver = BuildArchiver(kTestPage4Url, 185 archiver = BuildArchiver(kTestPage4Url,
186 base::FilePath(FILE_PATH_LITERAL("page4.mhtml"))); 186 base::FilePath(FILE_PATH_LITERAL("page4.mhtml")));
187 client_id.id = kTestPage4ClientId; 187 client_id.id = kTestPage4ClientId;
188 model->SavePage( 188 model->SavePage(
189 kTestPage4Url, client_id, std::move(archiver), 189 kTestPage4Url, client_id, 0ul, std::move(archiver),
190 base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr())); 190 base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
191 RunUntilIdle(); 191 RunUntilIdle();
192 const OfflinePageItem* page_4 = model->MaybeGetPageByOfflineId(offline_id()); 192 const OfflinePageItem* page_4 = model->MaybeGetPageByOfflineId(offline_id());
193 offline_url_expired_ = page_4->GetOfflineURL(); 193 offline_url_expired_ = page_4->GetOfflineURL();
194 model->ExpirePages( 194 model->ExpirePages(
195 std::vector<int64_t>({offline_id()}), base::Time::Now(), 195 std::vector<int64_t>({offline_id()}), base::Time::Now(),
196 base::Bind(&OfflinePageUtilsTest::OnExpirePageDone, AsWeakPtr())); 196 base::Bind(&OfflinePageUtilsTest::OnExpirePageDone, AsWeakPtr()));
197 RunUntilIdle(); 197 RunUntilIdle();
198 } 198 }
199 199
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 EXPECT_FALSE( 235 EXPECT_FALSE(
236 OfflinePageUtils::IsOfflinePage(profile(), offline_url_missing())); 236 OfflinePageUtils::IsOfflinePage(profile(), offline_url_missing()));
237 EXPECT_TRUE( 237 EXPECT_TRUE(
238 OfflinePageUtils::IsOfflinePage(profile(), offline_url_expired())); 238 OfflinePageUtils::IsOfflinePage(profile(), offline_url_expired()));
239 EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage1Url)); 239 EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage1Url));
240 EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage2Url)); 240 EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage2Url));
241 EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage4Url)); 241 EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage4Url));
242 } 242 }
243 243
244 } // namespace offline_pages 244 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698