1 // Copyright 2013 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.
5 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
7 #include "chrome/browser/devtools/devtools_window.h"
8 #include "chrome/browser/devtools/devtools_window_testing.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_list.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #include "chrome/browser/ui/find_bar/find_bar.h"
14 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
15 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/web_contents.h"
19 #include "content/public/test/test_utils.h"
21 class DevToolsControllerTest : public InProcessBrowserTest {
23 DevToolsControllerTest() : InProcessBrowserTest(), devtools_window_(NULL) {}
26 void OpenDevToolsWindow() {
28 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true);
31 void CloseDevToolsWindow() {
32 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window_);
35 content::WebContents* web_contents() {
36 return browser()->tab_strip_model()->GetActiveWebContents();
39 content::WebContents* devtools_web_contents() {
40 return DevToolsWindow::GetInTabWebContents(web_contents(), NULL);
43 DevToolsWindow* devtools_window_;
46 DISALLOW_COPY_AND_ASSIGN(DevToolsControllerTest);
49 // Verify that AllowOtherViews is set when and only when DevTools is visible.
50 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, AllowOtherViews) {
51 EXPECT_FALSE(web_contents()->GetAllowOtherViews());
54 EXPECT_TRUE(devtools_web_contents()->GetAllowOtherViews());
55 EXPECT_TRUE(web_contents()->GetAllowOtherViews());
57 CloseDevToolsWindow();
58 EXPECT_FALSE(web_contents()->GetAllowOtherViews());