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

Unified Diff: chrome/browser/sessions/tab_restore_browsertest.cc

Issue 2727663004: Use TabLoader in TabRestoreService. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/tab_restore_browsertest.cc
diff --git a/chrome/browser/sessions/tab_restore_browsertest.cc b/chrome/browser/sessions/tab_restore_browsertest.cc
index b7e444d76ae84f1095dd57728058f957f25d1af3..c0aff3695868ed360e519aaab122c234ffe527ae 100644
--- a/chrome/browser/sessions/tab_restore_browsertest.cc
+++ b/chrome/browser/sessions/tab_restore_browsertest.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/lifetime/scoped_keep_alive.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/sessions/session_restore_test_helper.h"
+#include "chrome/browser/sessions/tab_loader.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -638,15 +639,16 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWindow) {
EXPECT_EQ(initial_tab_count + 2, browser->tab_strip_model()->count());
load_stop_observer.Wait();
+ EXPECT_EQ(initial_tab_count + 1, browser->tab_strip_model()->active_index());
content::WebContents* restored_tab =
- browser->tab_strip_model()->GetWebContentsAt(initial_tab_count);
+ browser->tab_strip_model()->GetWebContentsAt(initial_tab_count + 1);
EnsureTabFinishedRestoring(restored_tab);
- EXPECT_EQ(url1_, restored_tab->GetURL());
+ EXPECT_EQ(url2_, restored_tab->GetURL());
restored_tab =
- browser->tab_strip_model()->GetWebContentsAt(initial_tab_count + 1);
+ browser->tab_strip_model()->GetWebContentsAt(initial_tab_count);
EnsureTabFinishedRestoring(restored_tab);
- EXPECT_EQ(url2_, restored_tab->GetURL());
+ EXPECT_EQ(url1_, restored_tab->GetURL());
}
// Restore tab with special URL chrome://credits/ and make sure the page loads
@@ -759,3 +761,50 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest,
Browser* browser = GetBrowser(0);
EXPECT_EQ(4, browser->tab_strip_model()->count());
}
+
+#if BUILDFLAG(ENABLE_SESSION_SERVICE)
sky 2017/03/02 19:12:05 Why does this require session service?
Michael K. (Yandex Team) 2017/03/03 08:26:37 Because of TabLoader: it depends on this buildflag
+IN_PROC_BROWSER_TEST_F(TabRestoreTest,
+ TabsFromRestoredWindowsAreLoadedGradually) {
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), url2_,
+ WindowOpenDisposition::NEW_WINDOW,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER);
+ Browser* browser2 = GetBrowser(1);
+
+ // Add tabs and close browser.
+ AddSomeTabs(browser2, 3);
+ EXPECT_EQ(4, browser2->tab_strip_model()->count());
sky 2017/03/02 19:12:05 Use a constant for this so to make it clear the re
Michael K. (Yandex Team) 2017/03/03 08:26:37 Done.
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::NotificationService::AllSources());
+ chrome::CloseWindow(browser2);
+ observer.Wait();
+
+ // Limit the number of restored tabs that should be loaded.
sky 2017/03/02 19:12:05 'should be' -> 'are'
Michael K. (Yandex Team) 2017/03/03 08:26:37 Done.
+ TabLoader::SetMaxLoadedTabCountForTest(2);
+
+ // Restore recently closed window.
+ content::WindowedNotificationObserver open_window_observer(
+ chrome::NOTIFICATION_BROWSER_OPENED,
+ content::NotificationService::AllSources());
+ chrome::OpenWindowWithRestoredTabs(browser()->profile());
+ open_window_observer.Wait();
+ browser2 = GetBrowser(1);
+
+ EXPECT_EQ(4, browser2->tab_strip_model()->count());
+ EXPECT_EQ(3, browser2->tab_strip_model()->active_index());
+ // These two tabs should be loaded by TabLoader.
+ EnsureTabFinishedRestoring(browser2->tab_strip_model()->GetWebContentsAt(3));
+ EnsureTabFinishedRestoring(browser2->tab_strip_model()->GetWebContentsAt(0));
+ // It isn't necessary but just to be sure there is no any async task that
sky 2017/03/02 19:12:05 I don't understand this comment. Can you elaborate
Michael K. (Yandex Team) 2017/03/03 08:26:37 I made small fix here in the next patchset. What
+ // could have an impact on the expectations below.
+ content::RunAllPendingInMessageLoop();
+
+ // These tabs shouldn't want to be loaded.
+ for (int tab_idx = 1; tab_idx < 3; ++tab_idx) {
+ auto* contents = browser2->tab_strip_model()->GetWebContentsAt(tab_idx);
+ EXPECT_FALSE(contents->IsLoading());
+ EXPECT_TRUE(contents->GetController().NeedsReload());
+ }
+}
+#endif // ENABLE_SESSION_SERVICE

Powered by Google App Engine
This is Rietveld 408576698