@@ -160,9 +160,9 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
160
160
161
161
~BrowserViewLayoutTest () override {}
162
162
163
- BrowserViewLayout* layout () { return layout_. get () ; }
163
+ BrowserViewLayout* layout () { return layout_; }
164
164
MockBrowserViewLayoutDelegate* delegate () { return delegate_; }
165
- views::View* root_view () { return root_view_ .get (); }
165
+ views::View* browser_view () { return browser_view_ .get (); }
166
166
views::View* top_container () { return top_container_; }
167
167
TabStrip* tab_strip () { return tab_strip_; }
168
168
views::View* webui_tab_strip () { return webui_tab_strip_; }
@@ -174,13 +174,13 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
174
174
void SetUp () override {
175
175
ChromeViewsTestBase::SetUp ();
176
176
177
- root_view_ = CreateFixedSizeView (gfx::Size (800 , 600 ));
177
+ browser_view_ = CreateFixedSizeView (gfx::Size (800 , 600 ));
178
178
179
179
immersive_mode_controller_ =
180
180
std::make_unique<MockImmersiveModeController>();
181
181
182
182
top_container_ =
183
- root_view_ ->AddChildView (CreateFixedSizeView (gfx::Size (800 , 60 )));
183
+ browser_view_ ->AddChildView (CreateFixedSizeView (gfx::Size (800 , 60 )));
184
184
auto tab_strip = std::make_unique<TabStrip>(
185
185
std::make_unique<FakeBaseTabStripController>());
186
186
tab_strip_ = tab_strip.get ();
@@ -194,11 +194,11 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
194
194
separator_ =
195
195
top_container_->AddChildView (std::make_unique<views::Separator>());
196
196
197
- infobar_container_ = root_view_ ->AddChildView (
197
+ infobar_container_ = browser_view_ ->AddChildView (
198
198
std::make_unique<InfoBarContainerView>(nullptr ));
199
199
200
200
contents_container_ =
201
- root_view_ ->AddChildView (CreateFixedSizeView (gfx::Size (800 , 600 )));
201
+ browser_view_ ->AddChildView (CreateFixedSizeView (gfx::Size (800 , 600 )));
202
202
devtools_web_view_ = contents_container_->AddChildView (
203
203
CreateFixedSizeView (gfx::Size (800 , 600 )));
204
204
devtools_web_view_->SetVisible (false );
@@ -208,10 +208,9 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
208
208
std::make_unique<ContentsLayoutManager>(devtools_web_view_,
209
209
contents_web_view_));
210
210
211
- // TODO(jamescook): Attach |layout_| to |root_view_|?
212
211
auto delegate = std::make_unique<MockBrowserViewLayoutDelegate>();
213
212
delegate_ = delegate.get ();
214
- layout_ = std::make_unique<BrowserViewLayout>(
213
+ auto layout = std::make_unique<BrowserViewLayout>(
215
214
std::move (delegate),
216
215
/* host_view=*/ nullptr ,
217
216
/* browser_view=*/ nullptr , top_container_, tab_strip_region_view,
@@ -222,15 +221,17 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
222
221
/* right_aligned_side_panel_separator=*/ nullptr ,
223
222
/* lens_side_panel=*/ nullptr , immersive_mode_controller_.get (),
224
223
separator_);
225
- layout_->set_webui_tab_strip (webui_tab_strip ());
224
+ layout->set_webui_tab_strip (webui_tab_strip ());
225
+ layout_ = layout.get ();
226
+ browser_view_->SetLayoutManager (std::move (layout));
226
227
}
227
228
228
229
private:
229
- std::unique_ptr< BrowserViewLayout> layout_;
230
+ BrowserViewLayout* layout_;
230
231
raw_ptr<MockBrowserViewLayoutDelegate> delegate_; // Owned by |layout_|.
231
- std::unique_ptr<views::View> root_view_ ;
232
+ std::unique_ptr<views::View> browser_view_ ;
232
233
233
- // Views owned by |root_view_ |.
234
+ // Views owned by |browser_view_ |.
234
235
raw_ptr<views::View> top_container_;
235
236
raw_ptr<TabStrip> tab_strip_;
236
237
raw_ptr<views::View> webui_tab_strip_;
@@ -256,7 +257,7 @@ TEST_F(BrowserViewLayoutTest, Layout) {
256
257
delegate ()->set_tab_strip_visible (false );
257
258
delegate ()->set_toolbar_visible (false );
258
259
delegate ()->set_bookmark_bar_visible (false );
259
- layout ()-> Layout ( root_view ());
260
+ RunScheduledLayout ( browser_view ());
260
261
261
262
// Top views are zero-height.
262
263
EXPECT_EQ (gfx::Rect (0 , 0 , 0 , 0 ), tab_strip ()->bounds ());
@@ -267,7 +268,7 @@ TEST_F(BrowserViewLayoutTest, Layout) {
267
268
268
269
// Turn on the toolbar, like in a pop-up window.
269
270
delegate ()->set_toolbar_visible (true );
270
- layout ()-> Layout ( root_view ());
271
+ RunScheduledLayout ( browser_view ());
271
272
272
273
// Now the toolbar has bounds and other views shift down.
273
274
EXPECT_EQ (gfx::Rect (0 , 0 , 0 , 0 ), tab_strip ()->bounds ());
@@ -279,7 +280,7 @@ TEST_F(BrowserViewLayoutTest, Layout) {
279
280
280
281
// Disable the contents separator.
281
282
delegate ()->set_content_separator_enabled (false );
282
- layout ()-> Layout ( root_view ());
283
+ RunScheduledLayout ( browser_view ());
283
284
284
285
// Now the separator is not visible and the content grows vertically.
285
286
EXPECT_EQ (gfx::Rect (0 , 0 , 0 , 0 ), tab_strip ()->bounds ());
@@ -315,7 +316,7 @@ TEST_F(BrowserViewLayoutTest, LayoutContentsWithTopControlsSlideBehavior) {
315
316
delegate ()->set_toolbar_visible (true );
316
317
delegate ()->set_top_controls_slide_enabled (true );
317
318
delegate ()->set_top_controls_shown_ratio (1 .f );
318
- layout ()-> Layout ( root_view ());
319
+ RunScheduledLayout ( browser_view ());
319
320
EXPECT_EQ (gfx::Rect (0 , 0 , 800 , 30 ), top_container ()->bounds ());
320
321
EXPECT_EQ (gfx::Rect (0 , 0 , 800 , kToolbarHeight ), toolbar ()->bounds ());
321
322
EXPECT_EQ (gfx::Rect (0 , kToolbarHeight , 800 , views::Separator::kThickness ),
@@ -324,7 +325,7 @@ TEST_F(BrowserViewLayoutTest, LayoutContentsWithTopControlsSlideBehavior) {
324
325
325
326
// Top controls are half shown, half hidden.
326
327
delegate ()->set_top_controls_shown_ratio (0 .5f );
327
- layout ()-> Layout ( root_view ());
328
+ RunScheduledLayout ( browser_view ());
328
329
EXPECT_EQ (gfx::Rect (0 , 0 , 800 , 30 ), top_container ()->bounds ());
329
330
EXPECT_EQ (gfx::Rect (0 , 0 , 800 , kToolbarHeight ), toolbar ()->bounds ());
330
331
EXPECT_EQ (gfx::Rect (0 , kToolbarHeight , 800 , views::Separator::kThickness ),
@@ -334,7 +335,7 @@ TEST_F(BrowserViewLayoutTest, LayoutContentsWithTopControlsSlideBehavior) {
334
335
// Top controls are fully hidden. the contents are expanded in height by an
335
336
// amount equal to the top controls height.
336
337
delegate ()->set_top_controls_shown_ratio (0 .f );
337
- layout ()-> Layout ( root_view ());
338
+ RunScheduledLayout ( browser_view ());
338
339
EXPECT_EQ (gfx::Rect (0 , -30 , 800 , 30 ), top_container ()->bounds ());
339
340
EXPECT_EQ (gfx::Rect (0 , 0 , 800 , kToolbarHeight ), toolbar ()->bounds ());
340
341
EXPECT_EQ (gfx::Rect (0 , kToolbarHeight , 800 , views::Separator::kThickness ),
@@ -346,12 +347,12 @@ TEST_F(BrowserViewLayoutTest, WebUITabStripPushesDownContents) {
346
347
delegate ()->set_tab_strip_visible (false );
347
348
delegate ()->set_toolbar_visible (true );
348
349
webui_tab_strip ()->SetVisible (false );
349
- layout ()-> Layout ( root_view ());
350
+ RunScheduledLayout ( browser_view ());
350
351
const gfx::Rect original_contents_bounds = contents_container ()->bounds ();
351
352
EXPECT_EQ (gfx::Size (), webui_tab_strip ()->size ());
352
353
353
354
webui_tab_strip ()->SetVisible (true );
354
- layout ()-> Layout ( root_view ());
355
+ RunScheduledLayout ( browser_view ());
355
356
EXPECT_LT (0 , webui_tab_strip ()->size ().height ());
356
357
EXPECT_EQ (original_contents_bounds.size (), contents_container ()->size ());
357
358
EXPECT_EQ (webui_tab_strip ()->size ().height (),
0 commit comments