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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm

Issue 18009003: Instant Extended: Delete unused overlay code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/tab_contents/overlayable_contents_controller.h" 5 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
11 #include "chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.h" 11 #include "chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.h"
12 #include "chrome/browser/ui/cocoa/tab_contents/overlay_separator_view.h"
13 #include "chrome/browser/ui/search/instant_overlay_model.h" 12 #include "chrome/browser/ui/search/instant_overlay_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
15 #include "content/public/browser/notification_source.h" 14 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_view.h" 16 #include "content/public/browser/web_contents_view.h"
18 #import "testing/gtest_mac.h" 17 #import "testing/gtest_mac.h"
19 18
20 class OverlayableContentsControllerTest : public InProcessBrowserTest, 19 class OverlayableContentsControllerTest : public InProcessBrowserTest,
21 public content::NotificationObserver { 20 public content::NotificationObserver {
22 public: 21 public:
(...skipping 20 matching lines...) Expand all
43 instant_overlay_model_.RemoveObserver( 42 instant_overlay_model_.RemoveObserver(
44 [controller_ instantOverlayController]); 43 [controller_ instantOverlayController]);
45 instant_overlay_model_.SetOverlayContents(NULL); 44 instant_overlay_model_.SetOverlayContents(NULL);
46 controller_.reset(); 45 controller_.reset();
47 web_contents_.reset(); 46 web_contents_.reset();
48 } 47 }
49 48
50 void VerifyOverlayFrame(CGFloat expected_height, 49 void VerifyOverlayFrame(CGFloat expected_height,
51 InstantSizeUnits units) { 50 InstantSizeUnits units) {
52 NSRect container_bounds = [[controller_ view] bounds]; 51 NSRect container_bounds = [[controller_ view] bounds];
53 container_bounds.size.height -= [OverlayTopSeparatorView preferredHeight];
54 NSRect overlay_frame = 52 NSRect overlay_frame =
55 [web_contents_->GetView()->GetNativeView() frame]; 53 [web_contents_->GetView()->GetNativeView() frame];
56 54
57 EXPECT_EQ(NSMinX(container_bounds), NSMinX(overlay_frame)); 55 EXPECT_EQ(NSMinX(container_bounds), NSMinX(overlay_frame));
58 EXPECT_EQ(NSWidth(container_bounds), NSWidth(overlay_frame)); 56 EXPECT_EQ(NSWidth(container_bounds), NSWidth(overlay_frame));
59 switch (units) { 57 switch (units) {
60 case INSTANT_SIZE_PIXELS: 58 case INSTANT_SIZE_PIXELS:
61 EXPECT_EQ(expected_height, NSHeight(overlay_frame)); 59 EXPECT_EQ(expected_height, NSHeight(overlay_frame));
62 EXPECT_EQ(NSMaxY(container_bounds), NSMaxY(overlay_frame)); 60 EXPECT_EQ(NSMaxY(container_bounds), NSMaxY(overlay_frame));
63 break; 61 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 108
111 EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview], 109 EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview],
112 [controller_ view]); 110 [controller_ view]);
113 VerifyOverlayFrame(expected_height, units); 111 VerifyOverlayFrame(expected_height, units);
114 112
115 // Resize the view and verify that the overlay is also resized. 113 // Resize the view and verify that the overlay is also resized.
116 [[controller_ view] setFrameSize:NSMakeSize(300, 400)]; 114 [[controller_ view] setFrameSize:NSMakeSize(300, 400)];
117 VerifyOverlayFrame(expected_height, units); 115 VerifyOverlayFrame(expected_height, units);
118 } 116 }
119 117
120 // Verify that a bottom border is not shown when the overlay covers the entire
121 // page or when the overlay is in NTP mode.
122 IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, NoShadowFullHeight) {
123 SearchMode mode;
124 mode.mode = SearchMode::MODE_SEARCH_SUGGESTIONS;
125 instant_overlay_model_.SetOverlayState(mode, 100, INSTANT_SIZE_PERCENT);
126 EXPECT_FALSE([controller_ dropShadowView]);
127 EXPECT_FALSE([controller_ drawDropShadow]);
128
129 mode.mode = SearchMode::MODE_NTP;
130 instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT);
131 EXPECT_FALSE([controller_ dropShadowView]);
132 EXPECT_FALSE([controller_ drawDropShadow]);
133 }
134
135 // Verify that a shadow is shown when the overlay is in search mode.
136 IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, NoShadowNTP) {
137 SearchMode mode;
138 mode.mode = SearchMode::MODE_SEARCH_SUGGESTIONS;
139 instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT);
140 EXPECT_TRUE([controller_ dropShadowView]);
141 EXPECT_TRUE([controller_ drawDropShadow]);
142 EXPECT_NSEQ([controller_ view], [[controller_ dropShadowView] superview]);
143
144 NSRect dropShadowFrame = [[controller_ dropShadowView] frame];
145 NSRect controllerBounds = [[controller_ view] bounds];
146 EXPECT_EQ(NSWidth(controllerBounds), NSWidth(dropShadowFrame));
147 EXPECT_EQ([OverlayBottomSeparatorView preferredHeight],
148 NSHeight(dropShadowFrame));
149 }
150
151 // Verify that the shadow is hidden when hiding the overlay.
152 IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HideShadow) {
153 SearchMode mode;
154 mode.mode = SearchMode::MODE_SEARCH_SUGGESTIONS;
155 instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT);
156 EXPECT_TRUE([controller_ dropShadowView]);
157
158 [controller_ onActivateTabWithContents:web_contents_.get()];
159 EXPECT_FALSE([controller_ dropShadowView]);
160 }
161
162 // Verify that the web contents is not hidden when just the height changes. 118 // Verify that the web contents is not hidden when just the height changes.
163 IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HeightChangeNoHide) { 119 IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HeightChangeNoHide) {
164 SearchMode mode; 120 SearchMode mode;
165 mode.mode = SearchMode::MODE_SEARCH_SUGGESTIONS; 121 mode.mode = SearchMode::MODE_SEARCH_SUGGESTIONS;
166 instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT); 122 instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT);
167 123
168 registrar_.Add(this, 124 registrar_.Add(this,
169 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 125 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
170 content::Source<content::WebContents>(web_contents_.get())); 126 content::Source<content::WebContents>(web_contents_.get()));
171 EXPECT_EQ(0, visibility_changed_count_); 127 EXPECT_EQ(0, visibility_changed_count_);
172 instant_overlay_model_.SetOverlayState(mode, 11, INSTANT_SIZE_PERCENT); 128 instant_overlay_model_.SetOverlayState(mode, 11, INSTANT_SIZE_PERCENT);
173 EXPECT_EQ(1, visibility_changed_count_); 129 EXPECT_EQ(1, visibility_changed_count_);
174 } 130 }
175
176 IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, OverlayOffset) {
177 SearchMode mode;
178 mode.mode = SearchMode::MODE_NTP;
179 CGFloat expected_height = 10;
180 InstantSizeUnits units = INSTANT_SIZE_PIXELS;
181 instant_overlay_model_.SetOverlayState(mode, expected_height, units);
182
183 CGFloat separator_height = [OverlayTopSeparatorView preferredHeight];
184 NSView* overlay_view = web_contents_->GetView()->GetNativeView();
185 EXPECT_EQ(separator_height,
186 NSMaxY([[overlay_view superview] frame]) -
187 NSMaxY([overlay_view frame]));
188
189 CGFloat offset = 30;
190 [controller_ setOverlayContentsOffset:offset];
191 EXPECT_EQ(separator_height + offset,
192 NSMaxY([[overlay_view superview] frame]) -
193 NSMaxY([overlay_view frame]));
194 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698