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

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

Issue 13227002: Revise NativeWidgetWin focus hack; force focus on restore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore FocusManager::RestoreFocusedView return values. Created 7 years, 8 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/ui/views/find_bar_view.h » ('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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 228 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
229 229
230 ClickOnView(VIEW_ID_TAB_CONTAINER); 230 ClickOnView(VIEW_ID_TAB_CONTAINER);
231 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 231 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
232 232
233 ClickOnView(VIEW_ID_OMNIBOX); 233 ClickOnView(VIEW_ID_OMNIBOX);
234 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 234 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
235 } 235 }
236 236
237 // Flaky, http://crbug.com/69034. 237 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) {
238 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
239 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 238 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
240 ASSERT_TRUE(test_server()->Start()); 239 ASSERT_TRUE(test_server()->Start());
241 240
242 // First we navigate to our test page. 241 // First we navigate to our test page.
243 GURL url = test_server()->GetURL(kSimplePage); 242 GURL url = test_server()->GetURL(kSimplePage);
244 ui_test_utils::NavigateToURL(browser(), url); 243 ui_test_utils::NavigateToURL(browser(), url);
245 244
246 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); 245 gfx::NativeWindow window = browser()->window()->GetNativeWindow();
247 246
248 // The focus should be on the Tab contents. 247 // The focus should be on the Tab contents.
249 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 248 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
250 // Now hide the window, show it again, the focus should not have changed. 249 // Now hide the window, show it again, the focus should not have changed.
251 ui_test_utils::HideNativeWindow(window); 250 ui_test_utils::HideNativeWindow(window);
252 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); 251 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
253 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 252 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
254 253
255 chrome::FocusLocationBar(browser()); 254 chrome::FocusLocationBar(browser());
256 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 255 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
257 // Hide the window, show it again, the focus should not have changed. 256 // Hide the window, show it again, the focus should not have changed.
258 ui_test_utils::HideNativeWindow(window); 257 ui_test_utils::HideNativeWindow(window);
259 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); 258 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
259 #if defined(OS_CHROMEOS)
260 // Chrome OS currently focuses the tab content on window restoration.
Ben Goodger (Google) 2013/04/02 20:32:14 why does cros differ?
msw 2013/04/03 01:54:16 I filed http://crbug.com/225963 and updated the co
261 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
262 #else
260 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 263 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
264 #endif
261 265
262 // The rest of this test does not make sense on Linux because the behavior 266 // The rest of this test does not make sense on Linux because the behavior
263 // of Activate() is not well defined and can vary by window manager. 267 // of Activate() is not well defined and can vary by window manager.
264 #if defined(OS_WIN) 268 #if defined(OS_WIN)
265 // Open a new browser window. 269 // Open a new browser window.
266 Browser* browser2 = 270 Browser* browser2 =
267 new Browser(Browser::CreateParams(browser()->profile(), 271 new Browser(Browser::CreateParams(browser()->profile(),
268 browser()->host_desktop_type())); 272 browser()->host_desktop_type()));
269 ASSERT_TRUE(browser2); 273 ASSERT_TRUE(browser2);
270 chrome::AddBlankTabAt(browser2, -1, true); 274 chrome::AddBlankTabAt(browser2, -1, true);
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 // The tab contents should have the focus in the second tab. 950 // The tab contents should have the focus in the second tab.
947 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); 951 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
948 952
949 // Go back to the first tab. The focus should not be in the omnibox. 953 // Go back to the first tab. The focus should not be in the omnibox.
950 chrome::SelectPreviousTab(browser()); 954 chrome::SelectPreviousTab(browser());
951 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 955 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
952 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 956 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
953 } 957 }
954 958
955 } // namespace 959 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/find_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698