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

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

Issue 486037: Add a regression test for http://crbug.com/29473 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | « no previous file | no next file » | 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
9 #include "chrome/browser/automation/ui_controls.h" 9 #include "chrome/browser/automation/ui_controls.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 18 matching lines...) Expand all
29 #endif 29 #endif
30 30
31 #if defined(OS_LINUX) 31 #if defined(OS_LINUX)
32 #include "chrome/browser/gtk/view_id_util.h" 32 #include "chrome/browser/gtk/view_id_util.h"
33 #endif 33 #endif
34 34
35 #if defined(OS_LINUX) 35 #if defined(OS_LINUX)
36 // For some reason we hit an external DNS lookup in this test in Linux but not 36 // For some reason we hit an external DNS lookup in this test in Linux but not
37 // on Windows. TODO(estade): investigate. 37 // on Windows. TODO(estade): investigate.
38 #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial 38 #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial
39 // TODO(jcampan): http://crbug.com/23683
40 #define MAYBE_TabsRememberFocusFindInPage DISABLED_TabsRememberFocusFindInPage
39 #else 41 #else
40 #define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial 42 #define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial
43 #define MAYBE_TabsRememberFocusFindInPage TabsRememberFocusFindInPage
41 #endif 44 #endif
42 45
43 namespace { 46 namespace {
44 47
45 // The delay waited in some cases where we don't have a notifications for an 48 // The delay waited in some cases where we don't have a notifications for an
46 // action we take. 49 // action we take.
47 const int kActionDelayMs = 500; 50 const int kActionDelayMs = 500;
48 51
49 const wchar_t kSimplePage[] = L"files/focus/page_with_focus.html"; 52 const wchar_t kSimplePage[] = L"files/focus/page_with_focus.html";
50 const wchar_t kStealFocusPage[] = L"files/focus/page_steals_focus.html"; 53 const wchar_t kStealFocusPage[] = L"files/focus/page_steals_focus.html";
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 285
283 // Now come back to the tab and check the right view is focused. 286 // Now come back to the tab and check the right view is focused.
284 for (int j = 0; j < 5; j++) { 287 for (int j = 0; j < 5; j++) {
285 // Activate the tab. 288 // Activate the tab.
286 browser()->SelectTabContentsAt(j, true); 289 browser()->SelectTabContentsAt(j, true);
287 290
288 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW : 291 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW :
289 VIEW_ID_LOCATION_BAR; 292 VIEW_ID_LOCATION_BAR;
290 ASSERT_TRUE(IsViewFocused(vid)); 293 ASSERT_TRUE(IsViewFocused(vid));
291 } 294 }
295
296 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
297 browser()->SelectTabContentsAt(0, true);
298 // Try the above, but with ctrl+tab. Since tab normally changes focus,
299 // this has regressed in the past. Loop through several times to be sure.
300 for (int j = 0; j < 25; j++) {
tony 2009/12/11 22:00:35 Nit: Do we really need to run 25 times? Looks lik
Evan Stade 2009/12/11 22:11:59 it's a loop of 5, 5 times. I could reduce it, but
301 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW :
302 VIEW_ID_LOCATION_BAR;
303 ASSERT_TRUE(IsViewFocused(vid));
304
305 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true,
306 false, false,
307 new MessageLoop::QuitTask());
308 ui_test_utils::RunMessageLoop();
309 }
310
311 // As above, but with ctrl+shift+tab.
312 browser()->SelectTabContentsAt(4, true);
313 for (int j = 24; j >= 0; --j) {
314 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW :
315 VIEW_ID_LOCATION_BAR;
316 ASSERT_TRUE(IsViewFocused(vid));
317
318 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true,
319 true, false,
320 new MessageLoop::QuitTask());
321 ui_test_utils::RunMessageLoop();
322 }
292 } 323 }
293 } 324 }
294 325
295 // Tabs remember focus with find-in-page box. 326 // Tabs remember focus with find-in-page box.
296 // TODO(jcampan): http://crbug.com/23683 Disabled because it fails on Linux. 327 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
297 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocusFindInPage) {
298 HTTPTestServer* server = StartHTTPServer(); 328 HTTPTestServer* server = StartHTTPServer();
299 329
300 // First we navigate to our test page. 330 // First we navigate to our test page.
301 GURL url = server->TestServerPageW(kSimplePage); 331 GURL url = server->TestServerPageW(kSimplePage);
302 ui_test_utils::NavigateToURL(browser(), url); 332 ui_test_utils::NavigateToURL(browser(), url);
303 333
304 browser()->Find(); 334 browser()->Find();
305 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), 335 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
306 ASCIIToUTF16("a"), true, false, NULL); 336 ASCIIToUTF16("a"), true, false, NULL);
307 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 337 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 746
717 // Open a regular page, crash, reload. 747 // Open a regular page, crash, reload.
718 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); 748 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
719 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); 749 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
720 browser()->Reload(); 750 browser()->Reload();
721 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 751 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
722 // Focus should now be on the tab contents. 752 // Focus should now be on the tab contents.
723 browser()->ShowDownloadsTab(); 753 browser()->ShowDownloadsTab();
724 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 754 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
725 } 755 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698