Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 5 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/devtools/devtools_window.h" | 7 #include "chrome/browser/devtools/devtools_window.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_list.h" | 9 #include "chrome/browser/ui/browser_list.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 12 #include "chrome/browser/ui/find_bar/find_bar.h" | 12 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 13 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 13 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "content/public/browser/notification_types.h" | |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/test/test_utils.h" | |
| 17 | 19 |
| 18 class DevToolsControllerTest : public InProcessBrowserTest { | 20 class DevToolsControllerTest : public InProcessBrowserTest { |
| 19 public: | 21 public: |
| 20 DevToolsControllerTest() : InProcessBrowserTest() { | 22 DevToolsControllerTest() |
| 23 : InProcessBrowserTest() | |
| 24 , devtools_window_(NULL) {} | |
|
jochen (gone - plz use gerrit)
2014/07/14 11:15:23
please clang-format
dgozman
2014/07/15 14:38:41
Done.
| |
| 25 | |
| 26 protected: | |
| 27 void OpenDevToolsWindow() { | |
| 28 devtools_window_ = | |
| 29 DevToolsWindow::OpenDevToolsWindowForTest(browser(), true); | |
| 21 } | 30 } |
| 22 | 31 |
| 23 virtual void SetUpOnMainThread() OVERRIDE { | 32 void CloseDevToolsWindow() { |
| 24 DevToolsWindow::OpenDevToolsWindowForTest(browser(), true); | 33 content::WindowedNotificationObserver close_observer( |
| 34 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | |
| 35 content::Source<content::WebContents>( | |
| 36 devtools_window_->web_contents_for_test())); | |
| 37 DevToolsWindow::ToggleDevToolsWindow( | |
| 38 browser(), DevToolsToggleAction::Toggle()); | |
| 39 close_observer.Wait(); | |
| 25 } | 40 } |
| 26 | 41 |
| 42 content::WebContents* web_contents() { | |
| 43 return browser()->tab_strip_model()->GetActiveWebContents(); | |
| 44 } | |
| 45 | |
| 46 content::WebContents* devtools_web_contents() { | |
| 47 return DevToolsWindow::GetInTabWebContents(web_contents(), NULL); | |
| 48 } | |
| 49 | |
| 50 DevToolsWindow* devtools_window_; | |
| 51 | |
| 27 private: | 52 private: |
| 28 DISALLOW_COPY_AND_ASSIGN(DevToolsControllerTest); | 53 DISALLOW_COPY_AND_ASSIGN(DevToolsControllerTest); |
| 29 }; | 54 }; |
| 30 | 55 |
| 31 // Verify that AllowOverlappingViews is set while the find bar is visible. | 56 // Verify that AllowOverlappingViews is set while the find bar is visible. |
| 32 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, AllowOverlappingViews) { | 57 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, AllowOverlappingViews) { |
| 33 content::WebContents* web_contents = | 58 OpenDevToolsWindow(); |
| 34 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 35 content::WebContents* dev_tools = | |
| 36 DevToolsWindow::GetInTabWebContents(web_contents, NULL); | |
| 37 | 59 |
| 38 // Without the find bar. | 60 // Without the find bar. |
| 39 EXPECT_TRUE(dev_tools->GetAllowOverlappingViews()); | 61 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews()); |
| 40 | 62 |
| 41 // With the find bar. | 63 // With the find bar. |
| 42 browser()->GetFindBarController()->find_bar()->Show(false); | 64 browser()->GetFindBarController()->find_bar()->Show(false); |
| 43 EXPECT_TRUE(dev_tools->GetAllowOverlappingViews()); | 65 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews()); |
| 44 | 66 |
| 45 // Without the find bar. | 67 // Without the find bar. |
| 46 browser()->GetFindBarController()->find_bar()->Hide(false); | 68 browser()->GetFindBarController()->find_bar()->Hide(false); |
| 47 EXPECT_TRUE(dev_tools->GetAllowOverlappingViews()); | 69 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews()); |
| 48 } | 70 } |
| 71 | |
| 72 // Verify that AllowOtherViews is set when and only when DevTools is visible. | |
| 73 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, AllowOtherViews) { | |
| 74 EXPECT_FALSE(web_contents()->GetAllowOtherViews()); | |
| 75 | |
| 76 OpenDevToolsWindow(); | |
| 77 EXPECT_TRUE(devtools_web_contents()->GetAllowOtherViews()); | |
| 78 EXPECT_TRUE(web_contents()->GetAllowOtherViews()); | |
| 79 | |
| 80 CloseDevToolsWindow(); | |
| 81 EXPECT_FALSE(web_contents()->GetAllowOtherViews()); | |
| 82 } | |
| OLD | NEW |