browser_view_browsertest.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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
3// found in the LICENSE file.
4
5#include "chrome/browser/ui/views/frame/browser_view.h"
6
7#include "chrome/browser/ui/browser_commands.h"
8#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9#include "chrome/test/base/in_process_browser_test.h"
10#include "ui/views/focus/focus_manager.h"
11#include "ui/views/view.h"
12
13using views::FocusManager;
14using views::View;
15
16typedef InProcessBrowserTest BrowserViewTest;
17
18// Active window and focus testing is not reliable on Windows crbug.com/79493
19#if defined(OS_WIN)
20#define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus
21#else
22#define MAYBE_FullscreenClearsFocus FullscreenClearsFocus
23#endif
24IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) {
25  BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
26  LocationBarView* location_bar_view = browser_view->GetLocationBarView();
27  FocusManager* focus_manager = browser_view->GetFocusManager();
28
29  // Focus starts in the location bar or one of its children.
30  EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView()));
31
32  chrome::ToggleFullscreenMode(browser());
33  EXPECT_TRUE(browser_view->IsFullscreen());
34
35  // Focus is released from the location bar.
36  EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView()));
37}
38