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/app/chrome_command_ids.h"
8#include "chrome/browser/autocomplete/autocomplete_controller.h"
9#include "chrome/browser/search/search.h"
10#include "chrome/browser/ui/browser_commands.h"
11#include "chrome/browser/ui/omnibox/omnibox_view.h"
12#include "chrome/browser/ui/search/instant_test_utils.h"
13#include "chrome/browser/ui/tabs/tab_strip_model.h"
14#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
15#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
16#include "chrome/browser/ui/views/frame/top_container_view.h"
17#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
18#include "chrome/browser/ui/views/tabs/tab.h"
19#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
20#include "chrome/common/instant_types.h"
21#include "chrome/common/url_constants.h"
22#include "chrome/test/base/in_process_browser_test.h"
23#include "chrome/test/base/ui_test_utils.h"
24#include "ui/views/controls/webview/webview.h"
25#include "ui/views/focus/focus_manager.h"
26#include "ui/views/window/non_client_view.h"
27
28#if defined(OS_CHROMEOS)
29#include "chrome/browser/chrome_notification_types.h"
30#include "content/public/browser/notification_service.h"
31#include "ui/compositor/layer.h"
32#include "ui/compositor/scoped_animation_duration_scale_mode.h"
33#endif
34
35using views::FocusManager;
36
37typedef InProcessBrowserTest BrowserViewTest;
38
39// Active window and focus testing is not reliable on Windows crbug.com/79493
40// TODO(linux_aura) http://crbug.com/163931
41#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA))
42#define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus
43#else
44#define MAYBE_FullscreenClearsFocus FullscreenClearsFocus
45#endif
46IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) {
47  BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
48  LocationBarView* location_bar_view = browser_view->GetLocationBarView();
49  FocusManager* focus_manager = browser_view->GetFocusManager();
50
51  // Focus starts in the location bar or one of its children.
52  EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView()));
53
54  chrome::ToggleFullscreenMode(browser());
55  EXPECT_TRUE(browser_view->IsFullscreen());
56
57  // Focus is released from the location bar.
58  EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView()));
59}
60