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

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

Issue 11419276: Remove tabstrip wrappers in browser_tabstrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 8 years 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 | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/browser_navigator.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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Alternate focus for the tab. 333 // Alternate focus for the tab.
334 const bool kFocusPage[3][5] = { 334 const bool kFocusPage[3][5] = {
335 { true, true, true, true, false }, 335 { true, true, true, true, false },
336 { false, false, false, false, false }, 336 { false, false, false, false, false },
337 { false, true, false, true, false } 337 { false, true, false, true, false }
338 }; 338 };
339 339
340 for (int i = 1; i < 3; i++) { 340 for (int i = 1; i < 3; i++) {
341 for (int j = 0; j < 5; j++) { 341 for (int j = 0; j < 5; j++) {
342 // Activate the tab. 342 // Activate the tab.
343 chrome::ActivateTabAt(browser(), j, true); 343 browser()->tab_strip_model()->ActivateTabAt(j, true);
344 344
345 // Activate the location bar or the page. 345 // Activate the location bar or the page.
346 if (kFocusPage[i][j]) { 346 if (kFocusPage[i][j]) {
347 chrome::GetWebContentsAt(browser(), j)->GetView()->Focus(); 347 browser()->tab_strip_model()->GetWebContentsAt(j)->GetView()->Focus();
348 } else { 348 } else {
349 chrome::FocusLocationBar(browser()); 349 chrome::FocusLocationBar(browser());
350 } 350 }
351 } 351 }
352 352
353 // Now come back to the tab and check the right view is focused. 353 // Now come back to the tab and check the right view is focused.
354 for (int j = 0; j < 5; j++) { 354 for (int j = 0; j < 5; j++) {
355 // Activate the tab. 355 // Activate the tab.
356 chrome::ActivateTabAt(browser(), j, true); 356 browser()->tab_strip_model()->ActivateTabAt(j, true);
357 357
358 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER : 358 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER :
359 location_bar_focus_view_id_; 359 location_bar_focus_view_id_;
360 ASSERT_TRUE(IsViewFocused(vid)); 360 ASSERT_TRUE(IsViewFocused(vid));
361 } 361 }
362 362
363 chrome::ActivateTabAt(browser(), 0, true); 363 browser()->tab_strip_model()->ActivateTabAt(0, true);
364 // Try the above, but with ctrl+tab. Since tab normally changes focus, 364 // Try the above, but with ctrl+tab. Since tab normally changes focus,
365 // this has regressed in the past. Loop through several times to be sure. 365 // this has regressed in the past. Loop through several times to be sure.
366 for (int j = 0; j < 15; j++) { 366 for (int j = 0; j < 15; j++) {
367 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER : 367 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER :
368 location_bar_focus_view_id_; 368 location_bar_focus_view_id_;
369 ASSERT_TRUE(IsViewFocused(vid)); 369 ASSERT_TRUE(IsViewFocused(vid));
370 370
371 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 371 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
372 browser(), ui::VKEY_TAB, true, false, false, false)); 372 browser(), ui::VKEY_TAB, true, false, false, false));
373 } 373 }
374 374
375 // As above, but with ctrl+shift+tab. 375 // As above, but with ctrl+shift+tab.
376 chrome::ActivateTabAt(browser(), 4, true); 376 browser()->tab_strip_model()->ActivateTabAt(4, true);
377 for (int j = 14; j >= 0; --j) { 377 for (int j = 14; j >= 0; --j) {
378 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER : 378 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER :
379 location_bar_focus_view_id_; 379 location_bar_focus_view_id_;
380 ASSERT_TRUE(IsViewFocused(vid)); 380 ASSERT_TRUE(IsViewFocused(vid));
381 381
382 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 382 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
383 browser(), ui::VKEY_TAB, true, true, false, false)); 383 browser(), ui::VKEY_TAB, true, true, false, false));
384 } 384 }
385 } 385 }
386 } 386 }
(...skipping 16 matching lines...) Expand all
403 chrome::FocusLocationBar(browser()); 403 chrome::FocusLocationBar(browser());
404 404
405 // Create a 2nd tab. 405 // Create a 2nd tab.
406 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED); 406 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED);
407 407
408 // Focus should be on the recently opened tab page. 408 // Focus should be on the recently opened tab page.
409 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 409 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
410 410
411 // Select 1st tab, focus should still be on the location-bar. 411 // Select 1st tab, focus should still be on the location-bar.
412 // (bug http://crbug.com/23296) 412 // (bug http://crbug.com/23296)
413 chrome::ActivateTabAt(browser(), 0, true); 413 browser()->tab_strip_model()->ActivateTabAt(0, true);
414 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 414 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
415 415
416 // Now open the find box again, switch to another tab and come back, the focus 416 // Now open the find box again, switch to another tab and come back, the focus
417 // should return to the find box. 417 // should return to the find box.
418 chrome::Find(browser()); 418 chrome::Find(browser());
419 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 419 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
420 chrome::ActivateTabAt(browser(), 1, true); 420 browser()->tab_strip_model()->ActivateTabAt(1, true);
421 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 421 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
422 chrome::ActivateTabAt(browser(), 0, true); 422 browser()->tab_strip_model()->ActivateTabAt(0, true);
423 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 423 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
424 } 424 }
425 425
426 // Background window does not steal focus. 426 // Background window does not steal focus.
427 // Flaky, http://crbug.com/62538. 427 // Flaky, http://crbug.com/62538.
428 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, 428 IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
429 DISABLED_BackgroundBrowserDontStealFocus) { 429 DISABLED_BackgroundBrowserDontStealFocus) {
430 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 430 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
431 ASSERT_TRUE(test_server()->Start()); 431 ASSERT_TRUE(test_server()->Start());
432 432
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); 958 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
959 959
960 // Go back to the first tab. The focus should not be in the omnibox. 960 // Go back to the first tab. The focus should not be in the omnibox.
961 chrome::SelectPreviousTab(browser()); 961 chrome::SelectPreviousTab(browser());
962 EXPECT_EQ(0, browser()->active_index()); 962 EXPECT_EQ(0, browser()->active_index());
963 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), 963 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
964 VIEW_ID_LOCATION_BAR)); 964 VIEW_ID_LOCATION_BAR));
965 } 965 }
966 966
967 } // namespace 967 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/browser_navigator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698