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

Side by Side Diff: chrome/browser/resource_coordinator/tab_manager_unittest.cc

Issue 2935183002: [TabMetrics] Add signals that mark the start and end of session restore. (Closed)
Patch Set: Enable SessionRestoreObserverTest only when session service available. Created 3 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/resource_coordinator/tab_manager.h" 5 #include "chrome/browser/resource_coordinator/tab_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "base/test/mock_entropy_provider.h" 17 #include "base/test/mock_entropy_provider.h"
17 #include "base/test/simple_test_tick_clock.h" 18 #include "base/test/simple_test_tick_clock.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/resource_coordinator/tab_manager_web_contents_data.h" 23 #include "chrome/browser/resource_coordinator/tab_manager_web_contents_data.h"
22 #include "chrome/browser/resource_coordinator/tab_stats.h" 24 #include "chrome/browser/resource_coordinator/tab_stats.h"
25 #include "chrome/browser/sessions/tab_loader.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" 27 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h"
25 #include "chrome/common/chrome_features.h" 28 #include "chrome/common/chrome_features.h"
26 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
27 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 30 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
28 #include "chrome/test/base/testing_profile.h" 31 #include "chrome/test/base/testing_profile.h"
29 #include "components/variations/variations_associated_data.h" 32 #include "components/variations/variations_associated_data.h"
30 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
31 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
32 #include "content/public/test/mock_render_process_host.h" 35 #include "content/public/test/mock_render_process_host.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 tab_manager.IdFromWebContents(web_contents3b)); 574 tab_manager.IdFromWebContents(web_contents3b));
572 575
573 EXPECT_TRUE(tab_stats[0].is_in_visible_window); 576 EXPECT_TRUE(tab_stats[0].is_in_visible_window);
574 EXPECT_TRUE(tab_stats[1].is_in_visible_window); 577 EXPECT_TRUE(tab_stats[1].is_in_visible_window);
575 EXPECT_FALSE(tab_stats[2].is_in_visible_window); 578 EXPECT_FALSE(tab_stats[2].is_in_visible_window);
576 EXPECT_FALSE(tab_stats[3].is_in_visible_window); 579 EXPECT_FALSE(tab_stats[3].is_in_visible_window);
577 EXPECT_FALSE(tab_stats[4].is_in_visible_window); 580 EXPECT_FALSE(tab_stats[4].is_in_visible_window);
578 EXPECT_FALSE(tab_stats[5].is_in_visible_window); 581 EXPECT_FALSE(tab_stats[5].is_in_visible_window);
579 } 582 }
580 583
584 TEST_F(TabManagerTest, OnSessionRestoreStartedAndFinishedLoadingTabs) {
585 std::unique_ptr<content::WebContents> test_contents(
586 WebContentsTester::CreateTestWebContents(browser_context(), nullptr));
587
588 std::vector<SessionRestoreDelegate::RestoredTab> restored_tabs{
589 SessionRestoreDelegate::RestoredTab(test_contents.get(), false, false,
590 false)};
591
592 TabManager* tab_manager = g_browser_process->GetTabManager();
593 EXPECT_FALSE(tab_manager->IsSessionRestoreLoadingTabs());
594
595 TabLoader::RestoreTabs(restored_tabs, base::TimeTicks());
596 EXPECT_TRUE(tab_manager->IsSessionRestoreLoadingTabs());
597
598 WebContentsTester::For(test_contents.get())
599 ->NavigateAndCommit(GURL("about:blank"));
600 WebContentsTester::For(test_contents.get())->TestSetIsLoading(false);
601 EXPECT_FALSE(tab_manager->IsSessionRestoreLoadingTabs());
602 }
603
581 } // namespace resource_coordinator 604 } // namespace resource_coordinator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698