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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout_unittest.cc

Issue 22265009: Implement initial version of scroll end effect Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to outstanding comments from sadrul@ Created 7 years, 1 month 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 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/ui/views/frame/browser_view.h" 7 #include "chrome/browser/ui/views/frame/browser_view.h"
8 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 8 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
9 #include "chrome/browser/ui/views/frame/contents_container.h" 9 #include "chrome/browser/ui/views/frame/contents_container.h"
10 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 10 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
11 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 11 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
12 #include "chrome/browser/ui/views/tabs/tab_strip.h" 12 #include "chrome/browser/ui/views/tabs/tab_strip.h"
13 #include "chrome/test/base/browser_with_test_window_test.h" 13 #include "chrome/test/base/browser_with_test_window_test.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/views/controls/webview/webview.h"
15 16
16 class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate { 17 class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate {
17 public: 18 public:
18 MockBrowserViewLayoutDelegate() 19 MockBrowserViewLayoutDelegate()
19 : tab_strip_visible_(true), 20 : tab_strip_visible_(true),
20 toolbar_visible_(true), 21 toolbar_visible_(true),
21 bookmark_bar_visible_(true), 22 bookmark_bar_visible_(true),
22 download_shelf_needs_layout_(false) { 23 download_shelf_needs_layout_(false) {
23 } 24 }
24 virtual ~MockBrowserViewLayoutDelegate() {} 25 virtual ~MockBrowserViewLayoutDelegate() {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual gfx::Size GetPreferredSize() OVERRIDE { 88 virtual gfx::Size GetPreferredSize() OVERRIDE {
88 return size_; 89 return size_;
89 } 90 }
90 91
91 private: 92 private:
92 gfx::Size size_; 93 gfx::Size size_;
93 94
94 DISALLOW_COPY_AND_ASSIGN(MockView); 95 DISALLOW_COPY_AND_ASSIGN(MockView);
95 }; 96 };
96 97
98 // A simple web view that prefers an initial size.
99 class MockWebView : public views::WebView {
100 public:
101 explicit MockWebView(gfx::Size initial_size)
102 : views::WebView(NULL),
103 size_(initial_size) {
104 SetBoundsRect(gfx::Rect(gfx::Point(), size_));
105 }
106 virtual ~MockWebView() {}
107
108 // views::View overrides:
109 virtual gfx::Size GetPreferredSize() OVERRIDE {
110 return size_;
111 }
112
113 private:
114 gfx::Size size_;
115
116 DISALLOW_COPY_AND_ASSIGN(MockWebView);
117 };
118
119
97 /////////////////////////////////////////////////////////////////////////////// 120 ///////////////////////////////////////////////////////////////////////////////
98 121
99 class MockImmersiveModeController : public ImmersiveModeController { 122 class MockImmersiveModeController : public ImmersiveModeController {
100 public: 123 public:
101 MockImmersiveModeController() {} 124 MockImmersiveModeController() {}
102 virtual ~MockImmersiveModeController() {} 125 virtual ~MockImmersiveModeController() {}
103 126
104 // ImmersiveModeController overrides: 127 // ImmersiveModeController overrides:
105 virtual void Init(BrowserView* browser_view) OVERRIDE {} 128 virtual void Init(BrowserView* browser_view) OVERRIDE {}
106 virtual void SetEnabled(bool enabled) OVERRIDE {} 129 virtual void SetEnabled(bool enabled) OVERRIDE {}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 tab_strip_ = new TabStrip(NULL); 180 tab_strip_ = new TabStrip(NULL);
158 top_container_->AddChildView(tab_strip_); 181 top_container_->AddChildView(tab_strip_);
159 toolbar_ = new MockView(gfx::Size(800, 30)); 182 toolbar_ = new MockView(gfx::Size(800, 30));
160 top_container_->AddChildView(toolbar_); 183 top_container_->AddChildView(toolbar_);
161 root_view_->AddChildView(top_container_); 184 root_view_->AddChildView(top_container_);
162 185
163 infobar_container_ = new InfoBarContainerView(NULL); 186 infobar_container_ = new InfoBarContainerView(NULL);
164 root_view_->AddChildView(infobar_container_); 187 root_view_->AddChildView(infobar_container_);
165 188
166 contents_split_ = new MockView(gfx::Size(800, 600)); 189 contents_split_ = new MockView(gfx::Size(800, 600));
167 active_web_view_ = new MockView(gfx::Size(800, 600)); 190 active_web_view_ = new MockWebView(gfx::Size(800, 600));
168 contents_container_ = new ContentsContainer(active_web_view_); 191 contents_container_ = new ContentsContainer(active_web_view_);
169 contents_split_->AddChildView(contents_container_); 192 contents_split_->AddChildView(contents_container_);
170 root_view_->AddChildView(contents_split_); 193 root_view_->AddChildView(contents_split_);
171 194
172 // TODO(jamescook): Attach |layout_| to |root_view_|? 195 // TODO(jamescook): Attach |layout_| to |root_view_|?
173 layout_.reset(new BrowserViewLayout); 196 layout_.reset(new BrowserViewLayout);
174 delegate_ = new MockBrowserViewLayoutDelegate; 197 delegate_ = new MockBrowserViewLayoutDelegate;
175 layout_->Init(delegate_, 198 layout_->Init(delegate_,
176 browser(), 199 browser(),
177 NULL, // BrowserView. 200 NULL, // BrowserView.
(...skipping 11 matching lines...) Expand all
189 MockBrowserViewLayoutDelegate* delegate_; // Owned by |layout_|. 212 MockBrowserViewLayoutDelegate* delegate_; // Owned by |layout_|.
190 scoped_ptr<MockView> root_view_; 213 scoped_ptr<MockView> root_view_;
191 214
192 // Views owned by |root_view_|. 215 // Views owned by |root_view_|.
193 MockView* top_container_; 216 MockView* top_container_;
194 TabStrip* tab_strip_; 217 TabStrip* tab_strip_;
195 MockView* toolbar_; 218 MockView* toolbar_;
196 InfoBarContainerView* infobar_container_; 219 InfoBarContainerView* infobar_container_;
197 MockView* contents_split_; 220 MockView* contents_split_;
198 ContentsContainer* contents_container_; 221 ContentsContainer* contents_container_;
199 MockView* active_web_view_; 222 MockWebView* active_web_view_;
200 223
201 scoped_ptr<MockImmersiveModeController> immersive_mode_controller_; 224 scoped_ptr<MockImmersiveModeController> immersive_mode_controller_;
202 225
203 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayoutTest); 226 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayoutTest);
204 }; 227 };
205 228
206 // Test basic construction and initialization. 229 // Test basic construction and initialization.
207 TEST_F(BrowserViewLayoutTest, BrowserViewLayout) { 230 TEST_F(BrowserViewLayoutTest, BrowserViewLayout) {
208 EXPECT_TRUE(layout()->browser()); 231 EXPECT_TRUE(layout()->browser());
209 EXPECT_TRUE(layout()->GetWebContentsModalDialogHost()); 232 EXPECT_TRUE(layout()->GetWebContentsModalDialogHost());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 const int kBottom = 500; 270 const int kBottom = 500;
248 EXPECT_EQ(kBottom, layout()->LayoutDownloadShelf(kBottom)); 271 EXPECT_EQ(kBottom, layout()->LayoutDownloadShelf(kBottom));
249 272
250 // Download shelf layout moves up the bottom edge and sets visibility. 273 // Download shelf layout moves up the bottom edge and sets visibility.
251 delegate()->set_download_shelf_needs_layout(true); 274 delegate()->set_download_shelf_needs_layout(true);
252 download_shelf->SetVisible(false); 275 download_shelf->SetVisible(false);
253 EXPECT_EQ(450, layout()->LayoutDownloadShelf(kBottom)); 276 EXPECT_EQ(450, layout()->LayoutDownloadShelf(kBottom));
254 EXPECT_TRUE(download_shelf->visible()); 277 EXPECT_TRUE(download_shelf->visible());
255 EXPECT_EQ("0,450 0x50", download_shelf->bounds().ToString()); 278 EXPECT_EQ("0,450 0x50", download_shelf->bounds().ToString());
256 } 279 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/frame/contents_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698