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

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

Issue 2705453003: Last_n: disable on Svelte devices. (Closed)
Patch Set: Created 3 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 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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 recent_tab_helper()->WasHidden(); 326 recent_tab_helper()->WasHidden();
327 recent_tab_helper()->ObserveAndDownloadCurrentPage(NewDownloadClientId(), 327 recent_tab_helper()->ObserveAndDownloadCurrentPage(NewDownloadClientId(),
328 123L); 328 123L);
329 RunUntilIdle(); 329 RunUntilIdle();
330 EXPECT_TRUE(model()->is_loaded()); 330 EXPECT_TRUE(model()->is_loaded());
331 // No page should be captured. 331 // No page should be captured.
332 EXPECT_EQ(0U, page_added_count()); 332 EXPECT_EQ(0U, page_added_count());
333 ASSERT_EQ(0U, GetAllPages().size()); 333 ASSERT_EQ(0U, GetAllPages().size());
334 } 334 }
335 335
336 // Checks that last_n is disabled if the device is low-end (aka svelte) but that
337 // download requests still work.
338 TEST_F(RecentTabHelperTest, LastNDisabledOnSvelte) {
339 // Simulates a low end device.
340 recent_tab_helper()->is_low_end_device_ = true;
341
342 // Navigate and finish loading then hide the tab. Nothing should be saved.
343 NavigateAndCommit(kTestPageUrl);
344 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
345 FastForwardSnapshotController();
346 recent_tab_helper()->WasHidden();
347 RunUntilIdle();
348 EXPECT_TRUE(model()->is_loaded());
349 EXPECT_EQ(0U, page_added_count());
350 ASSERT_EQ(0U, GetAllPages().size());
351
352 // But the following download request should work normally
353 recent_tab_helper()->ObserveAndDownloadCurrentPage(NewDownloadClientId(),
354 123L);
355 RunUntilIdle();
356 EXPECT_EQ(1U, page_added_count());
357 ASSERT_EQ(1U, GetAllPages().size());
358 }
359
336 // Triggers two last_n snapshot captures during a single page load. Should end 360 // Triggers two last_n snapshot captures during a single page load. Should end
337 // up with one snapshot, the 1st being replaced by the 2nd. 361 // up with one snapshot, the 1st being replaced by the 2nd.
338 TEST_F(RecentTabHelperTest, TwoCapturesSamePageLoad) { 362 TEST_F(RecentTabHelperTest, TwoCapturesSamePageLoad) {
339 NavigateAndCommit(kTestPageUrl); 363 NavigateAndCommit(kTestPageUrl);
340 // Set page loading state to the 1st snapshot-able stage. No capture so far. 364 // Set page loading state to the 1st snapshot-able stage. No capture so far.
341 recent_tab_helper()->DocumentAvailableInMainFrame(); 365 recent_tab_helper()->DocumentAvailableInMainFrame();
342 FastForwardSnapshotController(); 366 FastForwardSnapshotController();
343 RunUntilIdle(); 367 RunUntilIdle();
344 EXPECT_TRUE(model()->is_loaded()); 368 EXPECT_TRUE(model()->is_loaded());
345 EXPECT_EQ(0U, page_added_count()); 369 EXPECT_EQ(0U, page_added_count());
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 EXPECT_EQ(2U, page_added_count()); 808 EXPECT_EQ(2U, page_added_count());
785 EXPECT_EQ(0U, model_removed_count()); 809 EXPECT_EQ(0U, model_removed_count());
786 ASSERT_EQ(2U, GetAllPages().size()); 810 ASSERT_EQ(2U, GetAllPages().size());
787 const OfflinePageItem* second_page = FindPageForOfflineId(offline_id_3); 811 const OfflinePageItem* second_page = FindPageForOfflineId(offline_id_3);
788 ASSERT_TRUE(second_page); 812 ASSERT_TRUE(second_page);
789 EXPECT_EQ(client_id_3, second_page->client_id); 813 EXPECT_EQ(client_id_3, second_page->client_id);
790 EXPECT_EQ(offline_id_3, second_page->offline_id); 814 EXPECT_EQ(offline_id_3, second_page->offline_id);
791 } 815 }
792 816
793 } // namespace offline_pages 817 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698