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

Side by Side Diff: chrome/browser/browser_focus_uitest.cc

Issue 101013: Migrating the SSL UI tests to be browser tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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/ssl/ssl_browser_tests.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/ref_counted.h" 6 #include "base/ref_counted.h"
7 #include "chrome/browser/automation/ui_controls.h" 7 #include "chrome/browser/automation/ui_controls.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/tab_contents/web_contents.h" 9 #include "chrome/browser/tab_contents/web_contents.h"
10 #include "chrome/browser/view_ids.h" 10 #include "chrome/browser/view_ids.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 }; 257 };
258 258
259 // Test forward focus traversal. 259 // Test forward focus traversal.
260 for (int i = 0; i < 3; ++i) { 260 for (int i = 0; i < 3; ++i) {
261 // Location bar should be focused. 261 // Location bar should be focused.
262 EXPECT_EQ(location_bar, focus_manager->GetFocusedView()); 262 EXPECT_EQ(location_bar, focus_manager->GetFocusedView());
263 263
264 // Now let's press tab to move the focus. 264 // Now let's press tab to move the focus.
265 for (int j = 0; j < 7; ++j) { 265 for (int j = 0; j < 7; ++j) {
266 // Let's make sure the focus is on the expected element in the page. 266 // Let's make sure the focus is on the expected element in the page.
267 ui_test_utils::JavaScriptRunner js_runner( 267 std::string actual;
268 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
268 browser()->GetSelectedTabContents()->AsWebContents(), 269 browser()->GetSelectedTabContents()->AsWebContents(),
269 L"", 270 L"",
270 L"window.domAutomationController.send(getFocusedElement());"); 271 L"window.domAutomationController.send(getFocusedElement());",
271 std::string actual = js_runner.Run(); 272 &actual));
272 ASSERT_STREQ(kExpElementIDs[j], actual.c_str()); 273 ASSERT_STREQ(kExpElementIDs[j], actual.c_str());
273 274
274 ui_controls::SendKeyPressNotifyWhenDone(L'\t', false, false, false, 275 ui_controls::SendKeyPressNotifyWhenDone(L'\t', false, false, false,
275 new MessageLoop::QuitTask()); 276 new MessageLoop::QuitTask());
276 ui_test_utils::RunMessageLoop(); 277 ui_test_utils::RunMessageLoop();
277 // Ideally, we wouldn't sleep here and instead would use the event 278 // Ideally, we wouldn't sleep here and instead would use the event
278 // processed ack notification from the renderer. I am reluctant to create 279 // processed ack notification from the renderer. I am reluctant to create
279 // a new notification/callback for that purpose just for this test. 280 // a new notification/callback for that purpose just for this test.
280 ::Sleep(kActionDelayMs); 281 ::Sleep(kActionDelayMs);
281 } 282 }
(...skipping 11 matching lines...) Expand all
293 EXPECT_EQ(location_bar, focus_manager->GetFocusedView()); 294 EXPECT_EQ(location_bar, focus_manager->GetFocusedView());
294 295
295 // Now let's press shift-tab to move the focus in reverse. 296 // Now let's press shift-tab to move the focus in reverse.
296 for (int j = 0; j < 7; ++j) { 297 for (int j = 0; j < 7; ++j) {
297 ui_controls::SendKeyPressNotifyWhenDone(L'\t', false, true, false, 298 ui_controls::SendKeyPressNotifyWhenDone(L'\t', false, true, false,
298 new MessageLoop::QuitTask()); 299 new MessageLoop::QuitTask());
299 ui_test_utils::RunMessageLoop(); 300 ui_test_utils::RunMessageLoop();
300 ::Sleep(kActionDelayMs); 301 ::Sleep(kActionDelayMs);
301 302
302 // Let's make sure the focus is on the expected element in the page. 303 // Let's make sure the focus is on the expected element in the page.
303 ui_test_utils::JavaScriptRunner js_runner( 304 std::string actual;
305 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
304 browser()->GetSelectedTabContents()->AsWebContents(), 306 browser()->GetSelectedTabContents()->AsWebContents(),
305 L"", 307 L"",
306 L"window.domAutomationController.send(getFocusedElement());"); 308 L"window.domAutomationController.send(getFocusedElement());",
307 std::string actual = js_runner.Run(); 309 &actual));
308 ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str()); 310 ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str());
309 } 311 }
310 312
311 // At this point the renderer has sent us a message asking to advance the 313 // At this point the renderer has sent us a message asking to advance the
312 // focus (as the end of the focus loop was reached in the renderer). 314 // focus (as the end of the focus loop was reached in the renderer).
313 // We need to run the message loop to process it. 315 // We need to run the message loop to process it.
314 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 316 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
315 ui_test_utils::RunMessageLoop(); 317 ui_test_utils::RunMessageLoop();
316 } 318 }
317 } 319 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 408
407 // Open the new tab, focus should be on the location bar. 409 // Open the new tab, focus should be on the location bar.
408 browser()->NewTab(); 410 browser()->NewTab();
409 EXPECT_EQ(browser_view->GetLocationBarView(), 411 EXPECT_EQ(browser_view->GetLocationBarView(),
410 focus_manager->GetFocusedView()); 412 focus_manager->GetFocusedView());
411 413
412 // Open the download tab, focus should be on the tab contents. 414 // Open the download tab, focus should be on the tab contents.
413 browser()->ShowDownloadsTab(); 415 browser()->ShowDownloadsTab();
414 EXPECT_EQ(browser_view->GetContentsView(), focus_manager->GetFocusedView()); 416 EXPECT_EQ(browser_view->GetContentsView(), focus_manager->GetFocusedView());
415 } 417 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698