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

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