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

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

Issue 2542833003: Failed offline snapshots won't erase a successful one from the same page load. (Closed)
Patch Set: Fix link error and address reviewer comments. Created 4 years 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 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 "chrome/browser/android/offline_pages/recent_tab_helper.h" 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/test/scoped_feature_list.h" 10 #include "base/test/scoped_feature_list.h"
(...skipping 14 matching lines...) Expand all
25 namespace offline_pages { 25 namespace offline_pages {
26 26
27 namespace { 27 namespace {
28 const GURL kTestPageUrl("http://mystery.site/foo.html"); 28 const GURL kTestPageUrl("http://mystery.site/foo.html");
29 const GURL kTestPageUrlOther("http://crazy.site/foo_other.html"); 29 const GURL kTestPageUrlOther("http://crazy.site/foo_other.html");
30 const int kTabId = 153; 30 const int kTabId = 153;
31 } 31 }
32 32
33 class TestDelegate: public RecentTabHelper::Delegate { 33 class TestDelegate: public RecentTabHelper::Delegate {
34 public: 34 public:
35 const size_t kArchiveSizeToReport = 1234;
36
35 explicit TestDelegate( 37 explicit TestDelegate(
36 OfflinePageTestArchiver::Observer* observer, 38 OfflinePageTestArchiver::Observer* observer,
37 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
38 int tab_id, 40 int tab_id,
39 bool tab_id_result); 41 bool tab_id_result);
40 ~TestDelegate() override {} 42 ~TestDelegate() override {}
41 43
42 std::unique_ptr<OfflinePageArchiver> CreatePageArchiver( 44 std::unique_ptr<OfflinePageArchiver> CreatePageArchiver(
43 content::WebContents* web_contents) override; 45 content::WebContents* web_contents) override;
44 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override; 46 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override;
45 // There is no expectations that tab_id is always present. 47 // There is no expectations that tab_id is always present.
46 bool GetTabId(content::WebContents* web_contents, int* tab_id) override; 48 bool GetTabId(content::WebContents* web_contents, int* tab_id) override;
47 49
50 void set_archive_result(
51 offline_pages::OfflinePageArchiver::ArchiverResult result) {
52 archive_result_ = result;
53 }
54
55 void set_archive_size(int64_t size) { archive_size_ = size; }
56
48 private: 57 private:
49 OfflinePageTestArchiver::Observer* observer_; // observer owns this. 58 OfflinePageTestArchiver::Observer* observer_; // observer owns this.
50 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 59 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
51 int tab_id_; 60 int tab_id_;
52 bool tab_id_result_; 61 bool tab_id_result_;
62
63 // These values can be updated so that new OfflinePageTestArchiver instances
64 // will return different results.
65 offline_pages::OfflinePageArchiver::ArchiverResult archive_result_ =
66 offline_pages::OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED;
67 int64_t archive_size_ = kArchiveSizeToReport;
53 }; 68 };
54 69
55 class RecentTabHelperTest 70 class RecentTabHelperTest
56 : public ChromeRenderViewHostTestHarness, 71 : public ChromeRenderViewHostTestHarness,
57 public OfflinePageModel::Observer, 72 public OfflinePageModel::Observer,
58 public OfflinePageTestArchiver::Observer { 73 public OfflinePageTestArchiver::Observer {
59 public: 74 public:
60 RecentTabHelperTest(); 75 RecentTabHelperTest();
61 ~RecentTabHelperTest() override {} 76 ~RecentTabHelperTest() override {}
62 77
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int tab_id, 132 int tab_id,
118 bool tab_id_result) 133 bool tab_id_result)
119 : observer_(observer), 134 : observer_(observer),
120 task_runner_(task_runner), 135 task_runner_(task_runner),
121 tab_id_(tab_id), 136 tab_id_(tab_id),
122 tab_id_result_(tab_id_result) { 137 tab_id_result_(tab_id_result) {
123 } 138 }
124 139
125 std::unique_ptr<OfflinePageArchiver> TestDelegate::CreatePageArchiver( 140 std::unique_ptr<OfflinePageArchiver> TestDelegate::CreatePageArchiver(
126 content::WebContents* web_contents) { 141 content::WebContents* web_contents) {
127 const size_t kArchiveSizeToReport = 1234;
128 std::unique_ptr<OfflinePageTestArchiver> archiver(new OfflinePageTestArchiver( 142 std::unique_ptr<OfflinePageTestArchiver> archiver(new OfflinePageTestArchiver(
129 observer_, web_contents->GetLastCommittedURL(), 143 observer_, web_contents->GetLastCommittedURL(), archive_result_,
130 offline_pages::OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED,
131 base::string16(), kArchiveSizeToReport, 144 base::string16(), kArchiveSizeToReport,
132 base::ThreadTaskRunnerHandle::Get())); 145 base::ThreadTaskRunnerHandle::Get()));
133 return std::move(archiver); 146 return std::move(archiver);
134 } 147 }
135 148
136 scoped_refptr<base::SingleThreadTaskRunner> TestDelegate::GetTaskRunner() { 149 scoped_refptr<base::SingleThreadTaskRunner> TestDelegate::GetTaskRunner() {
137 return task_runner_; 150 return task_runner_;
138 } 151 }
139 // There is no expectations that tab_id is always present. 152 // There is no expectations that tab_id is always present.
140 bool TestDelegate::GetTabId(content::WebContents* web_contents, int* tab_id) { 153 bool TestDelegate::GetTabId(content::WebContents* web_contents, int* tab_id) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 209
197 void RecentTabHelperTest::RunUntilIdle() { 210 void RecentTabHelperTest::RunUntilIdle() {
198 base::RunLoop().RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
199 } 212 }
200 213
201 void RecentTabHelperTest::FastForwardSnapshotController() { 214 void RecentTabHelperTest::FastForwardSnapshotController() {
202 const size_t kLongDelayMs = 100*1000; 215 const size_t kLongDelayMs = 100*1000;
203 task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(kLongDelayMs)); 216 task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(kLongDelayMs));
204 } 217 }
205 218
219 // Checks the test setup.
206 TEST_F(RecentTabHelperTest, Basic) { 220 TEST_F(RecentTabHelperTest, Basic) {
207 base::test::ScopedFeatureList scoped_feature_list; 221 base::test::ScopedFeatureList scoped_feature_list;
208 scoped_feature_list.Init(); 222 scoped_feature_list.Init();
209 EXPECT_NE(nullptr, recent_tab_helper()); 223 EXPECT_NE(nullptr, recent_tab_helper());
210 } 224 }
211 225
226 // Loads a page and verifies that a snapshot is created.
212 TEST_F(RecentTabHelperTest, SimpleCapture) { 227 TEST_F(RecentTabHelperTest, SimpleCapture) {
213 NavigateAndCommit(kTestPageUrl); 228 NavigateAndCommit(kTestPageUrl);
214 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 229 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
215 FastForwardSnapshotController(); 230 FastForwardSnapshotController();
216 RunUntilIdle(); 231 RunUntilIdle();
217 EXPECT_TRUE(model()->is_loaded()); 232 EXPECT_TRUE(model()->is_loaded());
218 GetAllPages(); 233 GetAllPages();
219 EXPECT_EQ(1U, all_pages().size()); 234 EXPECT_EQ(1U, all_pages().size());
220 EXPECT_EQ(kTestPageUrl, all_pages()[0].url); 235 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
221 } 236 }
222 237
238 // Checks that WebContents with no tab IDs are properly ignored.
223 TEST_F(RecentTabHelperTest, NoTabIdNoCapture) { 239 TEST_F(RecentTabHelperTest, NoTabIdNoCapture) {
224 // Create delegate that returns 'false' as TabId retrieval result. 240 // Create delegate that returns 'false' as TabId retrieval result.
225 recent_tab_helper()->SetDelegate(base::MakeUnique<TestDelegate>( 241 recent_tab_helper()->SetDelegate(base::MakeUnique<TestDelegate>(
226 this, task_runner(), kTabId, false)); 242 this, task_runner(), kTabId, false));
227 243
228 NavigateAndCommit(kTestPageUrl); 244 NavigateAndCommit(kTestPageUrl);
229 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 245 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
230 FastForwardSnapshotController(); 246 FastForwardSnapshotController();
231 RunUntilIdle(); 247 RunUntilIdle();
232 EXPECT_TRUE(model()->is_loaded()); 248 EXPECT_TRUE(model()->is_loaded());
233 GetAllPages(); 249 GetAllPages();
234 // No page should be captured. 250 // No page should be captured.
235 EXPECT_EQ(0U, all_pages().size()); 251 EXPECT_EQ(0U, all_pages().size());
236 } 252 }
237 253
238 // Should end up with 1 page. 254 // Triggers two snapshot captures during a single page load. Should end up with
239 TEST_F(RecentTabHelperTest, TwoCapturesSameUrl) { 255 // one offline page (the 2nd snapshot should be kept).
256 TEST_F(RecentTabHelperTest, TwoCapturesSamePageLoad) {
240 NavigateAndCommit(kTestPageUrl); 257 NavigateAndCommit(kTestPageUrl);
241 // Triggers snapshot after a time delay. 258 // Triggers snapshot after a time delay.
242 recent_tab_helper()->DocumentAvailableInMainFrame(); 259 recent_tab_helper()->DocumentAvailableInMainFrame();
260 RunUntilIdle();
261 EXPECT_TRUE(model()->is_loaded());
262 EXPECT_EQ(0U, model_changed_count());
263 // Move the snapshot controller's time forward so it gets past timeouts.
264 FastForwardSnapshotController();
265 RunUntilIdle();
266 EXPECT_EQ(1U, model_changed_count());
267 EXPECT_EQ(0U, model_removed_count());
268 GetAllPages();
269 EXPECT_EQ(1U, all_pages().size());
270 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
271 int64_t first_offline_id = all_pages()[0].offline_id;
272
273 // Triggers snapshot after a time delay.
274 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
275 // Move the snapshot controller's time forward so it gets past timeouts.
276 FastForwardSnapshotController();
277 RunUntilIdle();
278 EXPECT_EQ(2U, model_changed_count());
279 EXPECT_EQ(1U, model_removed_count());
280 // the same page should be simply overridden.
281 GetAllPages();
282 EXPECT_EQ(1U, all_pages().size());
283 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
284 EXPECT_NE(first_offline_id, all_pages()[0].offline_id);
285 }
286
287 // Triggers two snapshot captures during a single page load, where the 2nd one
288 // fails. Should end up with one offline page (the 1st, successful snapshot
289 // should be kept).
290 TEST_F(RecentTabHelperTest, TwoCapturesSamePageLoadSecondFails) {
291 NavigateAndCommit(kTestPageUrl);
292 // Triggers snapshot after a time delay.
293 recent_tab_helper()->DocumentAvailableInMainFrame();
294 RunUntilIdle();
295 EXPECT_TRUE(model()->is_loaded());
296 EXPECT_EQ(0U, model_changed_count());
297 // Move the snapshot controller's time forward so it gets past timeouts.
298 FastForwardSnapshotController();
299 RunUntilIdle();
300 EXPECT_EQ(1U, model_changed_count());
301 EXPECT_EQ(0U, model_removed_count());
302 GetAllPages();
303 EXPECT_EQ(1U, all_pages().size());
304 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
305 int64_t first_offline_id = all_pages()[0].offline_id;
306
307 // Sets a new delegate that will make the second snapshot fail.
308 TestDelegate* failing_delegate =
309 new TestDelegate(this, task_runner(), kTabId, true);
310 failing_delegate->set_archive_size(-1);
311 failing_delegate->set_archive_result(
312 offline_pages::OfflinePageArchiver::ArchiverResult::
313 ERROR_ARCHIVE_CREATION_FAILED);
314 recent_tab_helper()->SetDelegate(
315 std::unique_ptr<TestDelegate>(failing_delegate));
316
317 // Triggers snapshot after a time delay.
318 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
319 // Move the snapshot controller's time forward so it gets past timeouts.
320 FastForwardSnapshotController();
321 RunUntilIdle();
322 EXPECT_EQ(1U, model_changed_count());
323 EXPECT_EQ(0U, model_removed_count());
324 // The exact same page should still be available.
325 GetAllPages();
326 EXPECT_EQ(1U, all_pages().size());
327 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
328 EXPECT_EQ(first_offline_id, all_pages()[0].offline_id);
329 }
330
331 // Triggers two snapshot captures for two different page loads for the same URL.
332 // Should end up with one offline page (snapshot from the 2nd load).
333 TEST_F(RecentTabHelperTest, TwoCapturesDifferentPageLoadsSameUrl) {
334 NavigateAndCommit(kTestPageUrl);
335 // Triggers snapshot after a time delay.
336 recent_tab_helper()->DocumentAvailableInMainFrame();
243 RunUntilIdle(); 337 RunUntilIdle();
244 EXPECT_TRUE(model()->is_loaded()); 338 EXPECT_TRUE(model()->is_loaded());
245 EXPECT_EQ(0U, model_changed_count()); 339 EXPECT_EQ(0U, model_changed_count());
246 // Move the snapshot controller's time forward so it gets past timeouts. 340 // Move the snapshot controller's time forward so it gets past timeouts.
247 FastForwardSnapshotController(); 341 FastForwardSnapshotController();
248 RunUntilIdle(); 342 RunUntilIdle();
249 EXPECT_EQ(1U, model_changed_count()); 343 EXPECT_EQ(1U, model_changed_count());
250 EXPECT_EQ(0U, model_removed_count()); 344 EXPECT_EQ(0U, model_removed_count());
251 GetAllPages(); 345 GetAllPages();
252 EXPECT_EQ(1U, all_pages().size()); 346 EXPECT_EQ(1U, all_pages().size());
253 EXPECT_EQ(kTestPageUrl, all_pages()[0].url); 347 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
348 int64_t first_offline_id = all_pages()[0].offline_id;
254 349
350 NavigateAndCommit(kTestPageUrl);
255 // Triggers snapshot after a time delay. 351 // Triggers snapshot after a time delay.
256 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 352 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
257 // Move the snapshot controller's time forward so it gets past timeouts. 353 // Move the snapshot controller's time forward so it gets past timeouts.
258 FastForwardSnapshotController(); 354 FastForwardSnapshotController();
259 RunUntilIdle(); 355 RunUntilIdle();
260 EXPECT_EQ(2U, model_changed_count()); 356 EXPECT_EQ(2U, model_changed_count());
261 EXPECT_EQ(1U, model_removed_count()); 357 EXPECT_EQ(1U, model_removed_count());
262 // the same page should be simply overridden. 358 // the same page should be simply overridden.
263 GetAllPages(); 359 GetAllPages();
264 EXPECT_EQ(1U, all_pages().size()); 360 EXPECT_EQ(1U, all_pages().size());
265 EXPECT_EQ(kTestPageUrl, all_pages()[0].url); 361 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
362 EXPECT_NE(first_offline_id, all_pages()[0].offline_id);
266 } 363 }
267 364
268 // Should end up with 1 page. 365 // Triggers two snapshot captures for two different page loads for the same URL,
269 TEST_F(RecentTabHelperTest, TwoCapturesDifferentUrls) { 366 // where the 2nd one fails. Should end up with no offline pages (privacy driven
367 // decision).
368 TEST_F(RecentTabHelperTest, TwoCapturesDifferentPageLoadsSameUrlSecondFails) {
270 NavigateAndCommit(kTestPageUrl); 369 NavigateAndCommit(kTestPageUrl);
271 // Triggers snapshot after a time delay. 370 // Triggers snapshot after a time delay.
272 recent_tab_helper()->DocumentAvailableInMainFrame(); 371 recent_tab_helper()->DocumentAvailableInMainFrame();
372 RunUntilIdle();
373 EXPECT_TRUE(model()->is_loaded());
374 EXPECT_EQ(0U, model_changed_count());
375 // Move the snapshot controller's time forward so it gets past timeouts.
376 FastForwardSnapshotController();
377 RunUntilIdle();
378 EXPECT_EQ(1U, model_changed_count());
379 EXPECT_EQ(0U, model_removed_count());
380 GetAllPages();
381 EXPECT_EQ(1U, all_pages().size());
382 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
383
384 // Sets a new delegate that will make the second snapshot fail.
385 TestDelegate* failing_delegate =
386 new TestDelegate(this, task_runner(), kTabId, true);
387 failing_delegate->set_archive_size(-1);
388 failing_delegate->set_archive_result(
389 offline_pages::OfflinePageArchiver::ArchiverResult::
390 ERROR_ARCHIVE_CREATION_FAILED);
391 recent_tab_helper()->SetDelegate(
392 std::unique_ptr<TestDelegate>(failing_delegate));
393
394 NavigateAndCommit(kTestPageUrl);
395 // Triggers snapshot after a time delay.
396 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
397 // Move the snapshot controller's time forward so it gets past timeouts.
398 FastForwardSnapshotController();
399 RunUntilIdle();
400 EXPECT_EQ(1U, model_changed_count());
401 EXPECT_EQ(1U, model_removed_count());
402 // the same page should be simply overridden.
403 GetAllPages();
404 EXPECT_EQ(0U, all_pages().size());
405 }
406
407 // Triggers two snapshot captures for two different page loads and URLs. Should
408 // end up with one offline page.
409 TEST_F(RecentTabHelperTest, TwoCapturesDifferentPageLoadsAndUrls) {
410 NavigateAndCommit(kTestPageUrl);
411 // Triggers snapshot after a time delay.
412 recent_tab_helper()->DocumentAvailableInMainFrame();
273 RunUntilIdle(); 413 RunUntilIdle();
274 EXPECT_TRUE(model()->is_loaded()); 414 EXPECT_TRUE(model()->is_loaded());
275 EXPECT_EQ(0U, model_changed_count()); 415 EXPECT_EQ(0U, model_changed_count());
276 // Move the snapshot controller's time forward so it gets past timeouts. 416 // Move the snapshot controller's time forward so it gets past timeouts.
277 FastForwardSnapshotController(); 417 FastForwardSnapshotController();
278 RunUntilIdle(); 418 RunUntilIdle();
279 EXPECT_EQ(1U, model_changed_count()); 419 EXPECT_EQ(1U, model_changed_count());
280 EXPECT_EQ(0U, model_removed_count()); 420 EXPECT_EQ(0U, model_removed_count());
281 GetAllPages(); 421 GetAllPages();
282 EXPECT_EQ(1U, all_pages().size()); 422 EXPECT_EQ(1U, all_pages().size());
283 EXPECT_EQ(kTestPageUrl, all_pages()[0].url); 423 EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
284 424
285 NavigateAndCommit(kTestPageUrlOther); 425 NavigateAndCommit(kTestPageUrlOther);
286 // Triggers snapshot after a time delay. 426 // Triggers snapshot after a time delay.
287 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 427 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
288 // Move the snapshot controller's time forward so it gets past timeouts. 428 // Move the snapshot controller's time forward so it gets past timeouts.
289 FastForwardSnapshotController(); 429 FastForwardSnapshotController();
290 RunUntilIdle(); 430 RunUntilIdle();
291 EXPECT_EQ(2U, model_changed_count()); 431 EXPECT_EQ(2U, model_changed_count());
292 EXPECT_EQ(1U, model_removed_count()); 432 EXPECT_EQ(1U, model_removed_count());
293 // the same page should be simply overridden. 433 // the same page should be simply overridden.
294 GetAllPages(); 434 GetAllPages();
295 EXPECT_EQ(1U, all_pages().size()); 435 EXPECT_EQ(1U, all_pages().size());
296 EXPECT_EQ(kTestPageUrlOther, all_pages()[0].url); 436 EXPECT_EQ(kTestPageUrlOther, all_pages()[0].url);
297 } 437 }
298 438
439 // Simulates an error (disconnection) during the load of a page. Should end up
440 // with no offline pages.
299 TEST_F(RecentTabHelperTest, NoCaptureOnErrorPage) { 441 TEST_F(RecentTabHelperTest, NoCaptureOnErrorPage) {
300 FailLoad(kTestPageUrl); 442 FailLoad(kTestPageUrl);
301 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 443 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
302 FastForwardSnapshotController(); 444 FastForwardSnapshotController();
303 RunUntilIdle(); 445 RunUntilIdle();
304 EXPECT_TRUE(model()->is_loaded()); 446 EXPECT_TRUE(model()->is_loaded());
305 GetAllPages(); 447 GetAllPages();
306 EXPECT_EQ(0U, all_pages().size()); 448 EXPECT_EQ(0U, all_pages().size());
307 } 449 }
308 450
451 // Checks that no snapshots are created if the Offline Page Cache feature is
452 // disabled.
309 TEST_F(RecentTabHelperTest, FeatureNotEnabled) { 453 TEST_F(RecentTabHelperTest, FeatureNotEnabled) {
310 base::test::ScopedFeatureList scoped_feature_list; 454 base::test::ScopedFeatureList scoped_feature_list;
311 scoped_feature_list.Init(); 455 scoped_feature_list.Init();
312 NavigateAndCommit(kTestPageUrl); 456 NavigateAndCommit(kTestPageUrl);
313 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 457 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
314 FastForwardSnapshotController(); 458 FastForwardSnapshotController();
315 RunUntilIdle(); 459 RunUntilIdle();
316 EXPECT_TRUE(model()->is_loaded()); 460 EXPECT_TRUE(model()->is_loaded());
317 GetAllPages(); 461 GetAllPages();
318 // No page should be captured. 462 // No page should be captured.
319 EXPECT_EQ(0U, all_pages().size()); 463 EXPECT_EQ(0U, all_pages().size());
320 } 464 }
321 465
466 // Simulates a download request to offline the current page. Should end up with
467 // no offline pages.
322 TEST_F(RecentTabHelperTest, DISABLED_DownloadRequest) { 468 TEST_F(RecentTabHelperTest, DISABLED_DownloadRequest) {
323 NavigateAndCommit(kTestPageUrl); 469 NavigateAndCommit(kTestPageUrl);
324 recent_tab_helper()->ObserveAndDownloadCurrentPage( 470 recent_tab_helper()->ObserveAndDownloadCurrentPage(
325 ClientId("download", "id1"), 153l); 471 ClientId("download", "id1"), 153l);
326 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 472 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
327 RunUntilIdle(); 473 RunUntilIdle();
328 EXPECT_TRUE(model()->is_loaded()); 474 EXPECT_TRUE(model()->is_loaded());
329 GetAllPages(); 475 GetAllPages();
330 EXPECT_EQ(1U, all_pages().size()); 476 EXPECT_EQ(1U, all_pages().size());
331 const OfflinePageItem& page = all_pages()[0]; 477 const OfflinePageItem& page = all_pages()[0];
332 EXPECT_EQ(kTestPageUrl, page.url); 478 EXPECT_EQ(kTestPageUrl, page.url);
333 EXPECT_EQ("download", page.client_id.name_space); 479 EXPECT_EQ("download", page.client_id.name_space);
334 EXPECT_EQ("id1", page.client_id.id); 480 EXPECT_EQ("id1", page.client_id.id);
335 EXPECT_EQ(153l, page.offline_id); 481 EXPECT_EQ(153l, page.offline_id);
336 } 482 }
337 483
338 } // namespace offline_pages 484 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/recent_tab_helper.cc ('k') | components/offline_pages/offline_page_test_archiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698