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

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

Issue 13006019: Revert 190584 "Alternate NTP Mac: Show overlay at fixed position" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 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/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
14 13
15 class DevToolsControllerTest : public InProcessBrowserTest { 14 class DevToolsControllerTest : public InProcessBrowserTest {
16 public: 15 public:
17 DevToolsControllerTest() : InProcessBrowserTest() { 16 DevToolsControllerTest() : InProcessBrowserTest() {
18 } 17 }
19 18
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 63
65 // When docked to the right the dev tools view should be shrunk so that it 64 // When docked to the right the dev tools view should be shrunk so that it
66 // doesn't overlap the bookmark bar. 65 // doesn't overlap the bookmark bar.
67 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, ViewSize) { 66 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, ViewSize) {
68 EXPECT_EQ(2u, [[[controller() splitView] subviews] count]); 67 EXPECT_EQ(2u, [[[controller() splitView] subviews] count]);
69 NSView* container_view = [[[controller() splitView] subviews] lastObject]; 68 NSView* container_view = [[[controller() splitView] subviews] lastObject];
70 EXPECT_EQ(1u, [[container_view subviews] count]); 69 EXPECT_EQ(1u, [[container_view subviews] count]);
71 NSView* dev_tools_view = [[container_view subviews] lastObject]; 70 NSView* dev_tools_view = [[container_view subviews] lastObject];
72 CGFloat width = NSWidth([[controller() splitView] bounds]); 71 CGFloat width = NSWidth([[controller() splitView] bounds]);
73 CGFloat height = NSHeight([[controller() splitView] bounds]); 72 CGFloat height = NSHeight([[controller() splitView] bounds]);
74 CGFloat offset = [controller() topContentOffset]; 73
74 SetDockSide(DEVTOOLS_DOCK_SIDE_BOTTOM);
75 EXPECT_EQ(width, NSWidth([dev_tools_view bounds]));
76
77 SetDockSide(DEVTOOLS_DOCK_SIDE_RIGHT);
78 EXPECT_EQ(height, NSHeight([dev_tools_view bounds]));
79
80 CGFloat offset = 50;
81 [controller() setTopContentOffset:offset];
75 82
76 SetDockSide(DEVTOOLS_DOCK_SIDE_BOTTOM); 83 SetDockSide(DEVTOOLS_DOCK_SIDE_BOTTOM);
77 EXPECT_EQ(width, NSWidth([dev_tools_view bounds])); 84 EXPECT_EQ(width, NSWidth([dev_tools_view bounds]));
78 85
79 SetDockSide(DEVTOOLS_DOCK_SIDE_RIGHT); 86 SetDockSide(DEVTOOLS_DOCK_SIDE_RIGHT);
80 EXPECT_EQ(height - offset, NSHeight([dev_tools_view bounds])); 87 EXPECT_EQ(height - offset, NSHeight([dev_tools_view bounds]));
81
82 CGFloat new_offset = 50;
83 [controller() setTopContentOffset:new_offset];
84
85 SetDockSide(DEVTOOLS_DOCK_SIDE_BOTTOM);
86 EXPECT_EQ(width, NSWidth([dev_tools_view bounds]));
87
88 SetDockSide(DEVTOOLS_DOCK_SIDE_RIGHT);
89 EXPECT_EQ(height - new_offset, NSHeight([dev_tools_view bounds]));
90 } 88 }
91 89
92 // Verify that the dev tool's web view is layed out correctly when docked to the 90 // Verify that the dev tool's web view is layed out correctly when docked to the
93 // right. 91 // right.
94 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, WebViewLayout) { 92 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, WebViewLayout) {
95 CGFloat offset = 50; 93 CGFloat offset = 50;
96 [controller() setTopContentOffset:offset]; 94 [controller() setTopContentOffset:offset];
97 95
98 SetDockSide(DEVTOOLS_DOCK_SIDE_RIGHT); 96 SetDockSide(DEVTOOLS_DOCK_SIDE_RIGHT);
99 AddTabAtIndex(0, 97 AddTabAtIndex(0,
100 GURL(chrome::kAboutBlankURL), 98 GURL(chrome::kAboutBlankURL),
101 content::PAGE_TRANSITION_TYPED); 99 content::PAGE_TRANSITION_TYPED);
102 DevToolsWindow::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_SHOW); 100 DevToolsWindow::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_SHOW);
103 101
104 NSView* container_view = [[[controller() splitView] subviews] lastObject]; 102 NSView* container_view = [[[controller() splitView] subviews] lastObject];
105 NSView* dev_tools_view = [[container_view subviews] lastObject]; 103 NSView* dev_tools_view = [[container_view subviews] lastObject];
106 NSView* web_view = [[dev_tools_view subviews] lastObject]; 104 NSView* web_view = [[dev_tools_view subviews] lastObject];
107 105
108 CGFloat height = NSHeight([[controller() splitView] bounds]); 106 CGFloat height = NSHeight([[controller() splitView] bounds]);
109 107
110 EXPECT_EQ(height - offset, NSHeight([web_view bounds])); 108 EXPECT_EQ(height - offset, NSHeight([web_view bounds]));
111 EXPECT_EQ(0, NSMinY([web_view bounds])); 109 EXPECT_EQ(0, NSMinY([web_view bounds]));
112 110
113 // Update the offset and verify that the view is resized. 111 // Update the offset and verify that the view is resized.
114 CGFloat new_offset = 25; 112 CGFloat new_offset = 25;
115 [controller() setTopContentOffset:new_offset]; 113 [controller() setTopContentOffset:new_offset];
116 EXPECT_EQ(height - new_offset, NSHeight([web_view bounds])); 114 EXPECT_EQ(height - new_offset, NSHeight([web_view bounds]));
117 EXPECT_EQ(0, NSMinY([web_view bounds])); 115 EXPECT_EQ(0, NSMinY([web_view bounds]));
118 } 116 }
119
120 // Verify that the dev tools undocked window is layed out correctly.
121 IN_PROC_BROWSER_TEST_F(DevToolsControllerTest, UndockedOffset) {
122 BrowserList* browser_list =
123 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
124 EXPECT_EQ(1u, browser_list->size());
125 SetDockSide(DEVTOOLS_DOCK_SIDE_UNDOCKED);
126 EXPECT_EQ(2u, browser_list->size());
127
128 Browser* dev_tools_browser = browser_list->get(1);
129 BrowserWindowController* window_controller =
130 [BrowserWindowController browserWindowControllerForWindow:
131 dev_tools_browser->window()->GetNativeWindow()];
132 EXPECT_EQ(0.0, [[window_controller devToolsController] topContentOffset]);
133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698