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

Side by Side Diff: chrome/browser/ui/cocoa/dev_tools_controller_browsertest.mm

Issue 395783002: [DevTools] Move DevToolsWindow testing code to a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased, added cleanup to some tests Created 6 years, 5 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
OLDNEW
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/devtools/devtools_window_testing.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_list.h" 10 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 12 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #include "chrome/browser/ui/find_bar/find_bar.h" 13 #include "chrome/browser/ui/find_bar/find_bar.h"
13 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
14 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
16 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
19 20
20 class DevToolsControllerTest : public InProcessBrowserTest { 21 class DevToolsControllerTest : public InProcessBrowserTest {
21 public: 22 public:
22 DevToolsControllerTest() : InProcessBrowserTest(), devtools_window_(NULL) {} 23 DevToolsControllerTest() : InProcessBrowserTest(), devtools_window_(NULL) {}
23 24
24 protected: 25 protected:
25 void OpenDevToolsWindow() { 26 void OpenDevToolsWindow() {
26 devtools_window_ = 27 devtools_window_ =
27 DevToolsWindow::OpenDevToolsWindowForTest(browser(), true); 28 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true);
28 } 29 }
29 30
30 void CloseDevToolsWindow() { 31 void CloseDevToolsWindow() {
31 content::WindowedNotificationObserver close_observer( 32 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window_);
32 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
33 content::Source<content::WebContents>(
34 devtools_window_->web_contents_for_test()));
35 DevToolsWindow::ToggleDevToolsWindow(
36 browser(), DevToolsToggleAction::Toggle());
37 close_observer.Wait();
38 } 33 }
39 34
40 content::WebContents* web_contents() { 35 content::WebContents* web_contents() {
41 return browser()->tab_strip_model()->GetActiveWebContents(); 36 return browser()->tab_strip_model()->GetActiveWebContents();
42 } 37 }
43 38
44 content::WebContents* devtools_web_contents() { 39 content::WebContents* devtools_web_contents() {
45 return DevToolsWindow::GetInTabWebContents(web_contents(), NULL); 40 return DevToolsWindow::GetInTabWebContents(web_contents(), NULL);
46 } 41 }
47 42
(...skipping 10 matching lines...) Expand all
58 // Without the find bar. 53 // Without the find bar.
59 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews()); 54 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews());
60 55
61 // With the find bar. 56 // With the find bar.
62 browser()->GetFindBarController()->find_bar()->Show(false); 57 browser()->GetFindBarController()->find_bar()->Show(false);
63 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews()); 58 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews());
64 59
65 // Without the find bar. 60 // Without the find bar.
66 browser()->GetFindBarController()->find_bar()->Hide(false); 61 browser()->GetFindBarController()->find_bar()->Hide(false);
67 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews()); 62 EXPECT_TRUE(devtools_web_contents()->GetAllowOverlappingViews());
63
64 CloseDevToolsWindow();
68 } 65 }
69 66
70 // Verify that AllowOtherViews is set when and only when DevTools is visible. 67 // Verify that AllowOtherViews is set when and only when DevTools is visible.
71 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, AllowOtherViews) { 68 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, AllowOtherViews) {
72 EXPECT_FALSE(web_contents()->GetAllowOtherViews()); 69 EXPECT_FALSE(web_contents()->GetAllowOtherViews());
73 70
74 OpenDevToolsWindow(); 71 OpenDevToolsWindow();
75 EXPECT_TRUE(devtools_web_contents()->GetAllowOtherViews()); 72 EXPECT_TRUE(devtools_web_contents()->GetAllowOtherViews());
76 EXPECT_TRUE(web_contents()->GetAllowOtherViews()); 73 EXPECT_TRUE(web_contents()->GetAllowOtherViews());
77 74
78 CloseDevToolsWindow(); 75 CloseDevToolsWindow();
79 EXPECT_FALSE(web_contents()->GetAllowOtherViews()); 76 EXPECT_FALSE(web_contents()->GetAllowOtherViews());
80 } 77 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm ('k') | chrome/browser/ui/cocoa/view_id_util_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698