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

Side by Side Diff: chrome/browser/translate/translate_browsertest.cc

Issue 14180010: Translate: browser test for Chrome Translate in an isolated world (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: factor out infobar check Created 7 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 }; // namespace 43 }; // namespace
44 44
45 class TranslateBrowserTest : public InProcessBrowserTest { 45 class TranslateBrowserTest : public InProcessBrowserTest {
46 public: 46 public:
47 TranslateBrowserTest() 47 TranslateBrowserTest()
48 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, 48 : https_server_(net::SpawnedTestServer::TYPE_HTTPS,
49 SSLOptions(SSLOptions::CERT_OK), 49 SSLOptions(SSLOptions::CERT_OK),
50 base::FilePath(kTranslateRoot)) {} 50 base::FilePath(kTranslateRoot)) {}
51 51
52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
53 ASSERT_TRUE(https_server_.Start()); 53 ASSERT_TRUE(https_server_.Start());
54 // Setup altenate security-origin for testing in order to allow XHR against
palmer 2013/08/01 21:22:38 Typos: "alternate", "security origin" (or just "or
Takashi Toyoshima 2013/08/02 04:40:19 Done.
Takashi Toyoshima 2013/08/02 04:40:19 Done.
55 // local test server. Note that this flag shows a confirm infobar in tests.
56 GURL origin = GetSecureURL("");
57 command_line->AppendSwitchASCII(switches::kTranslateSecurityOrigin,
58 origin.spec());
54 } 59 }
55 60
56 protected: 61 protected:
57 GURL GetNonSecureURL(const std::string& path) const { 62 GURL GetNonSecureURL(const std::string& path) const {
58 std::string prefix(kNonSecurePrefix); 63 std::string prefix(kNonSecurePrefix);
59 return embedded_test_server()->GetURL(prefix + path); 64 return embedded_test_server()->GetURL(prefix + path);
60 } 65 }
61 66
62 GURL GetSecureURL(const std::string& path) const { 67 GURL GetSecureURL(const std::string& path) const {
63 std::string prefix(kSecurePrefix); 68 std::string prefix(kSecurePrefix);
64 return https_server_.GetURL(prefix + path); 69 return https_server_.GetURL(prefix + path);
65 } 70 }
66 71
72 TranslateInfoBarDelegate* GetExistingTranslateInfoBarDelegate() {
73 if (!infobar_service_) {
74 content::WebContents* web_contents =
75 browser()->tab_strip_model()->GetActiveWebContents();
76 if (web_contents)
77 infobar_service_ = InfoBarService::FromWebContents(web_contents);
78 }
79 if (!infobar_service_) {
80 EXPECT_TRUE(false) << "infobar service is not available";
81 return NULL;
82 }
83
84 TranslateInfoBarDelegate* delegate = NULL;
85 for (size_t i = 0; i < infobar_service_->infobar_count(); ++i) {
86 // Check if the shown infobar is a confirm infobar coming from the
87 // |kTranslateSecurityOrigin| flag specified in SetUpCommandLine().
88 // This infobar appears in all tests of TranslateBrowserTest and can be
89 // ignored here.
90 ConfirmInfoBarDelegate* confirm =
91 infobar_service_->infobar_at(i)->AsConfirmInfoBarDelegate();
92 if (confirm)
93 continue;
94
95 TranslateInfoBarDelegate* translate =
96 infobar_service_->infobar_at(i)->AsTranslateInfoBarDelegate();
97 if (translate) {
98 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly";
99 delegate = translate;
100 continue;
101 }
102
103 // Other infobar should not be shown.
104 EXPECT_TRUE(delegate);
105 }
106 return delegate;
107 }
108
67 private: 109 private:
68 net::SpawnedTestServer https_server_; 110 net::SpawnedTestServer https_server_;
111 InfoBarService* infobar_service_;
69 112
70 typedef net::SpawnedTestServer::SSLOptions SSLOptions; 113 typedef net::SpawnedTestServer::SSLOptions SSLOptions;
71 114
72 DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest); 115 DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest);
73 }; 116 };
74 117
75 // TODO(toyoshim): This test should be changed to work in an isolated world. 118 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, TranslateInIsolatedWorld) {
76 // See also http://crbug.com/164547 .
77 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, DISABLED_Translate) {
78 #if defined(OS_WIN) && defined(USE_ASH) 119 #if defined(OS_WIN) && defined(USE_ASH)
79 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 120 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
80 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 121 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
81 return; 122 return;
82 #endif 123 #endif
83 124
125 net::TestURLFetcherFactory factory;
84 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 126 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
85 127
86 content::WebContents* web_contents = 128 // Check if there is no Translate infobar.
87 browser()->tab_strip_model()->GetActiveWebContents(); 129 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate();
88 ASSERT_TRUE(web_contents); 130 EXPECT_FALSE(translate);
89
90 net::TestURLFetcherFactory factory;
91 131
92 // Setup infobar observer. 132 // Setup infobar observer.
93 InfoBarService* infobar_service =
94 InfoBarService::FromWebContents(web_contents);
95 ASSERT_TRUE(infobar_service);
96 EXPECT_EQ(0U, infobar_service->infobar_count());
97 content::WindowedNotificationObserver infobar( 133 content::WindowedNotificationObserver infobar(
98 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 134 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
99 content::NotificationService::AllSources()); 135 content::NotificationService::AllSources());
100 136
101 // Setup page title observer. 137 // Setup page title observer.
138 content::WebContents* web_contents =
139 browser()->tab_strip_model()->GetActiveWebContents();
140 ASSERT_TRUE(web_contents);
102 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); 141 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
103 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 142 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
104 143
105 // Visit non-secure page which is going to be translated. 144 // Visit non-secure page which is going to be translated.
106 ui_test_utils::NavigateToURL(browser(), GetNonSecureURL(kFrenchTestPath)); 145 ui_test_utils::NavigateToURL(browser(), GetNonSecureURL(kFrenchTestPath));
107 146
108 // Wait for Chrome Translate infobar. 147 // Wait for Chrome Translate infobar.
109 infobar.Wait(); 148 infobar.Wait();
110 149
111 // Perform Chrome Translate. 150 // Perform Chrome Translate.
112 ASSERT_EQ(1U, infobar_service->infobar_count()); 151 translate = GetExistingTranslateInfoBarDelegate();
113 TranslateInfoBarDelegate* translate =
114 infobar_service->infobar_at(0)->AsTranslateInfoBarDelegate();
115 ASSERT_TRUE(translate); 152 ASSERT_TRUE(translate);
116 translate->Translate(); 153 translate->Translate();
117 154
118 // Hook URLFetcher for element.js. 155 // Hook URLFetcher for element.js.
119 GURL script1_url = GetSecureURL(kMainScriptPath); 156 GURL script1_url = GetSecureURL(kMainScriptPath);
120 GURL script2_url = GetSecureURL(kElementMainScriptPath); 157 GURL script2_url = GetSecureURL(kElementMainScriptPath);
121 std::string element_js = "main_script_url = '" + script1_url.spec() + "';\n"; 158 std::string element_js = "main_script_url = '" + script1_url.spec() + "';\n";
122 element_js += "element_main_script_url = '" + script2_url.spec() + "';\n"; 159 element_js += "element_main_script_url = '" + script2_url.spec() + "';\n";
123 element_js += 160 element_js +=
124 "google = { 'translate' : { 'TranslateService' : function() { return {\n" 161 "google = { 'translate' : { 'TranslateService' : function() { return {\n"
(...skipping 25 matching lines...) Expand all
150 187
151 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) { 188 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) {
152 #if defined(OS_WIN) && defined(USE_ASH) 189 #if defined(OS_WIN) && defined(USE_ASH)
153 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 190 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
154 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 191 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
155 return; 192 return;
156 #endif 193 #endif
157 194
158 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 195 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
159 196
197 // Check if there is no Translate infobar.
198 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate();
199 EXPECT_FALSE(translate);
200
201 // Setup page title observer.
160 content::WebContents* web_contents = 202 content::WebContents* web_contents =
161 browser()->tab_strip_model()->GetActiveWebContents(); 203 browser()->tab_strip_model()->GetActiveWebContents();
162 ASSERT_TRUE(web_contents); 204 ASSERT_TRUE(web_contents);
163
164 // Check infobar count.
165 InfoBarService* infobar_service =
166 InfoBarService::FromWebContents(web_contents);
167 ASSERT_TRUE(infobar_service);
168 EXPECT_EQ(0U, infobar_service->infobar_count());
169
170 // Setup page title observer.
171 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); 205 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
172 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 206 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
173 207
174 // Visit a test page. 208 // Visit a test page.
175 ui_test_utils::NavigateToURL( 209 ui_test_utils::NavigateToURL(
176 browser(), 210 browser(),
177 GetNonSecureURL(kRefreshMetaTagTestPath)); 211 GetNonSecureURL(kRefreshMetaTagTestPath));
178 212
179 // Wait for the page title is changed after the test finished. 213 // Wait for the page title is changed after the test finished.
180 const string16 result = watcher.WaitAndGetTitle(); 214 const string16 result = watcher.WaitAndGetTitle();
181 EXPECT_EQ("PASS", UTF16ToASCII(result)); 215 EXPECT_EQ("PASS", UTF16ToASCII(result));
182 216
183 // Check there is not infobar. 217 // Check if there is no Translate infobar.
184 EXPECT_EQ(0U, infobar_service->infobar_count()); 218 translate = GetExistingTranslateInfoBarDelegate();
219 EXPECT_FALSE(translate);
185 } 220 }
186 221
187 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, 222 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest,
188 IgnoreRefreshMetaTagInCaseInsensitive) { 223 IgnoreRefreshMetaTagInCaseInsensitive) {
189 #if defined(OS_WIN) && defined(USE_ASH) 224 #if defined(OS_WIN) && defined(USE_ASH)
190 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 225 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
191 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 226 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
192 return; 227 return;
193 #endif 228 #endif
194 229
195 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 230 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
196 231
232 // Check if there is no Translate infobar.
233 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate();
234 EXPECT_FALSE(translate);
235
236 // Setup page title observer.
197 content::WebContents* web_contents = 237 content::WebContents* web_contents =
198 browser()->tab_strip_model()->GetActiveWebContents(); 238 browser()->tab_strip_model()->GetActiveWebContents();
199 ASSERT_TRUE(web_contents); 239 ASSERT_TRUE(web_contents);
200
201 // Check infobar count.
202 InfoBarService* infobar_service =
203 InfoBarService::FromWebContents(web_contents);
204 ASSERT_TRUE(infobar_service);
205 EXPECT_EQ(0U, infobar_service->infobar_count());
206
207 // Setup page title observer.
208 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); 240 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
209 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 241 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
210 242
211 // Visit a test page. 243 // Visit a test page.
212 ui_test_utils::NavigateToURL( 244 ui_test_utils::NavigateToURL(
213 browser(), 245 browser(),
214 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); 246 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath));
215 247
216 // Wait for the page title is changed after the test finished. 248 // Wait for the page title is changed after the test finished.
217 const string16 result = watcher.WaitAndGetTitle(); 249 const string16 result = watcher.WaitAndGetTitle();
218 EXPECT_EQ("PASS", UTF16ToASCII(result)); 250 EXPECT_EQ("PASS", UTF16ToASCII(result));
219 251
220 // Check there is not infobar. 252 // Check if there is no Translate infobar.
221 EXPECT_EQ(0U, infobar_service->infobar_count()); 253 translate = GetExistingTranslateInfoBarDelegate();
254 EXPECT_FALSE(translate);
222 } 255 }
223 256
257 // TODO(toyoshim): Refactoring this test, too.
palmer 2013/08/01 21:22:38 Typo: "Refactor" (it's a command to yourself)
Takashi Toyoshima 2013/08/02 04:40:19 Oops. This was a memo when I'm doing this change.
224 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { 258 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) {
225 #if defined(OS_WIN) && defined(USE_ASH) 259 #if defined(OS_WIN) && defined(USE_ASH)
226 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 260 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
227 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 261 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
228 return; 262 return;
229 #endif 263 #endif
230 264
231 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 265 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
232 266
267 // Check if there is no Translate infobar.
268 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate();
269 EXPECT_FALSE(translate);
270
271 // Setup page title observer.
233 content::WebContents* web_contents = 272 content::WebContents* web_contents =
234 browser()->tab_strip_model()->GetActiveWebContents(); 273 browser()->tab_strip_model()->GetActiveWebContents();
235 ASSERT_TRUE(web_contents); 274 ASSERT_TRUE(web_contents);
236
237 // Check infobar count.
238 InfoBarService* infobar_service =
239 InfoBarService::FromWebContents(web_contents);
240 ASSERT_TRUE(infobar_service);
241 EXPECT_EQ(0U, infobar_service->infobar_count());
242
243 // Setup page title observer.
244 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); 275 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
245 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 276 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
246 277
247 // Visit a test page. 278 // Visit a test page.
248 ui_test_utils::NavigateToURL( 279 ui_test_utils::NavigateToURL(
249 browser(), 280 browser(),
250 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); 281 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath));
251 282
252 // Wait for the page title is changed after the test finished. 283 // Wait for the page title is changed after the test finished.
253 const string16 result = watcher.WaitAndGetTitle(); 284 const string16 result = watcher.WaitAndGetTitle();
254 EXPECT_EQ("PASS", UTF16ToASCII(result)); 285 EXPECT_EQ("PASS", UTF16ToASCII(result));
255 286
256 // Check there is not infobar. 287 // Check if there is no Translate infobar.
257 EXPECT_EQ(0U, infobar_service->infobar_count()); 288 translate = GetExistingTranslateInfoBarDelegate();
289 EXPECT_FALSE(translate);
258 } 290 }
259 291
260 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { 292 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) {
261 #if defined(OS_WIN) && defined(USE_ASH) 293 #if defined(OS_WIN) && defined(USE_ASH)
262 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 294 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
263 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 295 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
264 return; 296 return;
265 #endif 297 #endif
266 298
267 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 299 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
268 300
301 // Check if there is no Translate infobar.
302 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate();
303 EXPECT_FALSE(translate);
304
305 // Setup page title observer.
269 content::WebContents* web_contents = 306 content::WebContents* web_contents =
270 browser()->tab_strip_model()->GetActiveWebContents(); 307 browser()->tab_strip_model()->GetActiveWebContents();
271 ASSERT_TRUE(web_contents); 308 ASSERT_TRUE(web_contents);
272
273 // Check infobar count.
274 InfoBarService* infobar_service =
275 InfoBarService::FromWebContents(web_contents);
276 ASSERT_TRUE(infobar_service);
277 EXPECT_EQ(0U, infobar_service->infobar_count());
278
279 // Setup page title observer.
280 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); 309 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
281 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 310 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
282 311
283 // Visit a test page. 312 // Visit a test page.
284 ui_test_utils::NavigateToURL( 313 ui_test_utils::NavigateToURL(
285 browser(), 314 browser(),
286 GetNonSecureURL(kUpdateLocationTestPath)); 315 GetNonSecureURL(kUpdateLocationTestPath));
287 316
288 // Wait for the page title is changed after the test finished. 317 // Wait for the page title is changed after the test finished.
289 const string16 result = watcher.WaitAndGetTitle(); 318 const string16 result = watcher.WaitAndGetTitle();
290 EXPECT_EQ("PASS", UTF16ToASCII(result)); 319 EXPECT_EQ("PASS", UTF16ToASCII(result));
291 320
292 // Check there is not infobar. 321 // Check if there is no Translate infobar.
293 EXPECT_EQ(0U, infobar_service->infobar_count()); 322 translate = GetExistingTranslateInfoBarDelegate();
323 EXPECT_FALSE(translate);
294 } 324 }
295 325
296 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { 326 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) {
297 #if defined(OS_WIN) && defined(USE_ASH) 327 #if defined(OS_WIN) && defined(USE_ASH)
298 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 328 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
299 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 329 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
300 return; 330 return;
301 #endif 331 #endif
302 332
303 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 333 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
304 334
335 // Check if there is no Translate infobar.
336 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate();
337 EXPECT_FALSE(translate);
338
339 // Setup page title observer.
305 content::WebContents* web_contents = 340 content::WebContents* web_contents =
306 browser()->tab_strip_model()->GetActiveWebContents(); 341 browser()->tab_strip_model()->GetActiveWebContents();
307 ASSERT_TRUE(web_contents); 342 ASSERT_TRUE(web_contents);
308
309 // Check infobar count.
310 InfoBarService* infobar_service =
311 InfoBarService::FromWebContents(web_contents);
312 ASSERT_TRUE(infobar_service);
313 EXPECT_EQ(0U, infobar_service->infobar_count());
314
315 // Setup page title observer.
316 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); 343 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
317 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 344 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
318 345
319 // Visit a test page. 346 // Visit a test page.
320 ui_test_utils::NavigateToURL( 347 ui_test_utils::NavigateToURL(
321 browser(), 348 browser(),
322 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); 349 GetNonSecureURL(kUpdateLocationAtOnloadTestPath));
323 350
324 // Wait for the page title is changed after the test finished. 351 // Wait for the page title is changed after the test finished.
325 const string16 result = watcher.WaitAndGetTitle(); 352 const string16 result = watcher.WaitAndGetTitle();
326 EXPECT_EQ("PASS", UTF16ToASCII(result)); 353 EXPECT_EQ("PASS", UTF16ToASCII(result));
327 354
328 // Check there is not infobar. 355 // Check if there is no Translate infobar.
329 EXPECT_EQ(0U, infobar_service->infobar_count()); 356 translate = GetExistingTranslateInfoBarDelegate();
357 EXPECT_FALSE(translate);
330 } 358 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/ui/startup/bad_flags_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698