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

Side by Side Diff: chrome/browser/content_settings/content_settings_browsertest.cc

Issue 10815025: Move TitleWatcher from ui_test_utils.h to browser_test_utils.h so it can be reused by content_brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/errorpage_browsertest.cc » ('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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/common/render_messages.h" 16 #include "chrome/common/render_messages.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "content/public/test/browser_test_utils.h"
22 #include "net/test/test_server.h" 23 #include "net/test/test_server.h"
23 24
24 // Regression test for http://crbug.com/63649. 25 // Regression test for http://crbug.com/63649.
25 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, RedirectLoopCookies) { 26 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, RedirectLoopCookies) {
26 ASSERT_TRUE(test_server()->Start()); 27 ASSERT_TRUE(test_server()->Start());
27 28
28 GURL test_url = test_server()->GetURL("files/redirect-loop.html"); 29 GURL test_url = test_server()->GetURL("files/redirect-loop.html");
29 30
30 CookieSettings::Factory::GetForProfile(browser()->profile())-> 31 CookieSettings::Factory::GetForProfile(browser()->profile())->
31 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); 32 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) { 101 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) {
101 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 102 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
102 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); 103 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
103 104
104 GURL url = ui_test_utils::GetTestUrl( 105 GURL url = ui_test_utils::GetTestUrl(
105 FilePath().AppendASCII("npapi"), 106 FilePath().AppendASCII("npapi"),
106 FilePath().AppendASCII("clicktoplay.html")); 107 FilePath().AppendASCII("clicktoplay.html"));
107 ui_test_utils::NavigateToURL(browser(), url); 108 ui_test_utils::NavigateToURL(browser(), url);
108 109
109 string16 expected_title(ASCIIToUTF16("OK")); 110 string16 expected_title(ASCIIToUTF16("OK"));
110 ui_test_utils::TitleWatcher title_watcher( 111 content::TitleWatcher title_watcher(
111 chrome::GetActiveWebContents(browser()), expected_title); 112 chrome::GetActiveWebContents(browser()), expected_title);
112 113
113 content::RenderViewHost* host = 114 content::RenderViewHost* host =
114 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 115 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
115 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 116 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
116 host->GetRoutingID(), std::string())); 117 host->GetRoutingID(), std::string()));
117 118
118 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 119 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
119 } 120 }
120 121
121 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, LoadAllBlockedPlugins) { 122 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, LoadAllBlockedPlugins) {
122 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 123 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
123 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); 124 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
124 125
125 GURL url = ui_test_utils::GetTestUrl( 126 GURL url = ui_test_utils::GetTestUrl(
126 FilePath().AppendASCII("npapi"), 127 FilePath().AppendASCII("npapi"),
127 FilePath().AppendASCII("load_all_blocked_plugins.html")); 128 FilePath().AppendASCII("load_all_blocked_plugins.html"));
128 ui_test_utils::NavigateToURL(browser(), url); 129 ui_test_utils::NavigateToURL(browser(), url);
129 130
130 string16 expected_title1(ASCIIToUTF16("1")); 131 string16 expected_title1(ASCIIToUTF16("1"));
131 ui_test_utils::TitleWatcher title_watcher1( 132 content::TitleWatcher title_watcher1(
132 chrome::GetActiveWebContents(browser()), expected_title1); 133 chrome::GetActiveWebContents(browser()), expected_title1);
133 134
134 content::RenderViewHost* host = 135 content::RenderViewHost* host =
135 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 136 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
136 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 137 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
137 host->GetRoutingID(), std::string())); 138 host->GetRoutingID(), std::string()));
138 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); 139 EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle());
139 140
140 string16 expected_title2(ASCIIToUTF16("2")); 141 string16 expected_title2(ASCIIToUTF16("2"));
141 ui_test_utils::TitleWatcher title_watcher2( 142 content::TitleWatcher title_watcher2(
142 chrome::GetActiveWebContents(browser()), expected_title2); 143 chrome::GetActiveWebContents(browser()), expected_title2);
143 144
144 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 145 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
145 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 146 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
146 L"", L"window.inject()")); 147 L"", L"window.inject()"));
147 148
148 EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle()); 149 EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle());
149 } 150 }
150 151
151 // If this flakes, use http://crbug.com/113057. 152 // If this flakes, use http://crbug.com/113057.
152 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, NoCallbackAtLoad) { 153 IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, NoCallbackAtLoad) {
153 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 154 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
154 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); 155 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
155 156
156 GURL url("data:application/vnd.npapi-test,CallOnStartup();"); 157 GURL url("data:application/vnd.npapi-test,CallOnStartup();");
157 ui_test_utils::NavigateToURL(browser(), url); 158 ui_test_utils::NavigateToURL(browser(), url);
158 159
159 // Inject the callback function into the HTML page generated by the browser. 160 // Inject the callback function into the HTML page generated by the browser.
160 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 161 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
161 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 162 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
162 L"", L"CallOnStartup = function() { document.title = \"OK\"; }")); 163 L"", L"CallOnStartup = function() { document.title = \"OK\"; }"));
163 164
164 string16 expected_title(ASCIIToUTF16("OK")); 165 string16 expected_title(ASCIIToUTF16("OK"));
165 ui_test_utils::TitleWatcher title_watcher( 166 content::TitleWatcher title_watcher(
166 chrome::GetActiveWebContents(browser()), expected_title); 167 chrome::GetActiveWebContents(browser()), expected_title);
167 168
168 content::RenderViewHost* host = 169 content::RenderViewHost* host =
169 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 170 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
170 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 171 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
171 host->GetRoutingID(), std::string())); 172 host->GetRoutingID(), std::string()));
172 173
173 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 174 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
174 } 175 }
175 176
176 #endif // !defined(USE_AURA) 177 #endif // !defined(USE_AURA)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/errorpage_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698