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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 23523024: Fix and re-enable PrerenderTaskManager test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorder functions Created 7 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/task_manager/task_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 1882
1883 // Make sure the PrerenderContents for the next urls are now in the manager 1883 // Make sure the PrerenderContents for the next urls are now in the manager
1884 // and not pending. One and only one of the URLs (the last seen) should be the 1884 // and not pending. One and only one of the URLs (the last seen) should be the
1885 // active entry. 1885 // active entry.
1886 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB); 1886 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB);
1887 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC); 1887 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC);
1888 EXPECT_TRUE(url_b_is_active_prerender && url_c_is_active_prerender); 1888 EXPECT_TRUE(url_b_is_active_prerender && url_c_is_active_prerender);
1889 } 1889 }
1890 1890
1891 // See crbug.com/131836. 1891 // See crbug.com/131836.
1892 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) { 1892 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTaskManager) {
1893 // Show the task manager. This populates the model. 1893 // Show the task manager. This populates the model.
1894 chrome::OpenTaskManager(current_browser()); 1894 chrome::OpenTaskManager(current_browser());
1895 // Wait for the model of task manager to start. 1895 // Wait for the model of task manager to start.
1896 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); 1896 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
1897 1897
1898 // Start with two resources. 1898 // Start with two resources.
1899 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 1899 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
1900 1900
1901 // One of the resources that has a WebContents associated with it should have 1901 // One of the resources that has a WebContents associated with it should have
1902 // the Prerender prefix. 1902 // the Prerender prefix.
1903 const string16 prefix = 1903 const string16 prefix =
1904 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, string16()); 1904 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, string16());
1905 string16 prerender_title; 1905 string16 prerender_title;
1906 int num_prerender_tabs = 0; 1906 int num_prerender_tabs = 0;
1907 1907
1908 const TaskManagerModel* model = GetModel(); 1908 TaskManagerModel* model = GetModel();
1909 // The task manager caches values. Force the titles to be fresh.
1910 model->Refresh();
1909 for (int i = 0; i < model->ResourceCount(); ++i) { 1911 for (int i = 0; i < model->ResourceCount(); ++i) {
1910 if (model->GetResourceWebContents(i)) { 1912 if (model->GetResourceWebContents(i)) {
1911 prerender_title = model->GetResourceTitle(i); 1913 prerender_title = model->GetResourceTitle(i);
1912 if (StartsWith(prerender_title, prefix, true)) 1914 if (StartsWith(prerender_title, prefix, true))
1913 ++num_prerender_tabs; 1915 ++num_prerender_tabs;
1914 } 1916 }
1915 } 1917 }
1916 EXPECT_EQ(1, num_prerender_tabs); 1918 EXPECT_EQ(1, num_prerender_tabs);
1917 const string16 prerender_page_title = prerender_title.substr(prefix.length()); 1919 const string16 prerender_page_title = prerender_title.substr(prefix.length());
1918 1920
1919 NavigateToDestURL(); 1921 NavigateToDestURL();
1920 1922
1921 // There should be no tabs with the Prerender prefix. 1923 // There should be no tabs with the Prerender prefix.
1922 const string16 tab_prefix = 1924 const string16 tab_prefix =
1923 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, string16()); 1925 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, string16());
1924 num_prerender_tabs = 0; 1926 num_prerender_tabs = 0;
1925 int num_tabs_with_prerender_page_title = 0; 1927 int num_tabs_with_prerender_page_title = 0;
1928 model->Refresh();
1926 for (int i = 0; i < model->ResourceCount(); ++i) { 1929 for (int i = 0; i < model->ResourceCount(); ++i) {
1927 if (model->GetResourceWebContents(i)) { 1930 if (model->GetResourceWebContents(i)) {
1928 string16 tab_title = model->GetResourceTitle(i); 1931 string16 tab_title = model->GetResourceTitle(i);
1929 if (StartsWith(tab_title, prefix, true)) { 1932 if (StartsWith(tab_title, prefix, true)) {
1930 ++num_prerender_tabs; 1933 ++num_prerender_tabs;
1931 } else { 1934 } else {
1932 EXPECT_TRUE(StartsWith(tab_title, tab_prefix, true)); 1935 EXPECT_TRUE(StartsWith(tab_title, tab_prefix, true));
1933 1936
1934 // The prerender tab should now be a normal tab but the title should be 1937 // The prerender tab should now be a normal tab but the title should be
1935 // the same. Depending on timing, there may be more than one of these. 1938 // the same. Depending on timing, there may be more than one of these.
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 PrerenderTestURL("files/prerender/prerender_page.html", 2949 PrerenderTestURL("files/prerender/prerender_page.html",
2947 FINAL_STATUS_PAGE_BEING_CAPTURED, 1); 2950 FINAL_STATUS_PAGE_BEING_CAPTURED, 1);
2948 WebContents* web_contents = 2951 WebContents* web_contents =
2949 current_browser()->tab_strip_model()->GetActiveWebContents(); 2952 current_browser()->tab_strip_model()->GetActiveWebContents();
2950 web_contents->IncrementCapturerCount(); 2953 web_contents->IncrementCapturerCount();
2951 NavigateToDestURLWithDisposition(CURRENT_TAB, false); 2954 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
2952 web_contents->DecrementCapturerCount(); 2955 web_contents->DecrementCapturerCount();
2953 } 2956 }
2954 2957
2955 } // namespace prerender 2958 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/task_manager/task_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698