Skip to content

Commit cf3832c

Browse files
Elaine ChienChromium LUCI CQ
Elaine Chien
authored and
Chromium LUCI CQ
committed
Remove remaining Layout() calls in tests in c/b/ui/view/frame/
Bug: 1350521 Change-Id: Ic74aa13cb48ab5041dbc60f3444a8d0e1074047f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3829749 Commit-Queue: Elaine Chien <[email protected]> Reviewed-by: Peter Kasting <[email protected]> Cr-Commit-Position: refs/heads/main@{#1035069}
1 parent b90cfa0 commit cf3832c

5 files changed

+28
-27
lines changed

chrome/browser/ui/views/frame/browser_frame_view_layout_linux_native_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ TEST_F(BrowserFrameViewLayoutLinuxNativeTest, NativeNavButtons) {
250250
layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons);
251251
ResetNativeNavButtonImagesFromButtonProvider();
252252

253-
root_view_->Layout();
253+
RunScheduledLayout(root_view_);
254254

255255
const int frame_top_thickness = FrameInsets().top();
256256

chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos_browsertest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ IN_PROC_BROWSER_TEST_P(WebAppNonClientFrameViewAshTest,
963963

964964
// In order to receive focus, the geo icon must be laid out (and be both
965965
// visible and nonzero size).
966-
web_app_frame_toolbar_->Layout();
966+
RunScheduledLayouts();
967967

968968
EXPECT_FALSE(web_app_menu_button_->HasFocus());
969969
EXPECT_FALSE(geolocation_icon->HasFocus());

chrome/browser/ui/views/frame/browser_view_layout_unittest.cc

+21-20
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
160160

161161
~BrowserViewLayoutTest() override {}
162162

163-
BrowserViewLayout* layout() { return layout_.get(); }
163+
BrowserViewLayout* layout() { return layout_; }
164164
MockBrowserViewLayoutDelegate* delegate() { return delegate_; }
165-
views::View* root_view() { return root_view_.get(); }
165+
views::View* browser_view() { return browser_view_.get(); }
166166
views::View* top_container() { return top_container_; }
167167
TabStrip* tab_strip() { return tab_strip_; }
168168
views::View* webui_tab_strip() { return webui_tab_strip_; }
@@ -174,13 +174,13 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
174174
void SetUp() override {
175175
ChromeViewsTestBase::SetUp();
176176

177-
root_view_ = CreateFixedSizeView(gfx::Size(800, 600));
177+
browser_view_ = CreateFixedSizeView(gfx::Size(800, 600));
178178

179179
immersive_mode_controller_ =
180180
std::make_unique<MockImmersiveModeController>();
181181

182182
top_container_ =
183-
root_view_->AddChildView(CreateFixedSizeView(gfx::Size(800, 60)));
183+
browser_view_->AddChildView(CreateFixedSizeView(gfx::Size(800, 60)));
184184
auto tab_strip = std::make_unique<TabStrip>(
185185
std::make_unique<FakeBaseTabStripController>());
186186
tab_strip_ = tab_strip.get();
@@ -194,11 +194,11 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
194194
separator_ =
195195
top_container_->AddChildView(std::make_unique<views::Separator>());
196196

197-
infobar_container_ = root_view_->AddChildView(
197+
infobar_container_ = browser_view_->AddChildView(
198198
std::make_unique<InfoBarContainerView>(nullptr));
199199

200200
contents_container_ =
201-
root_view_->AddChildView(CreateFixedSizeView(gfx::Size(800, 600)));
201+
browser_view_->AddChildView(CreateFixedSizeView(gfx::Size(800, 600)));
202202
devtools_web_view_ = contents_container_->AddChildView(
203203
CreateFixedSizeView(gfx::Size(800, 600)));
204204
devtools_web_view_->SetVisible(false);
@@ -208,10 +208,9 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
208208
std::make_unique<ContentsLayoutManager>(devtools_web_view_,
209209
contents_web_view_));
210210

211-
// TODO(jamescook): Attach |layout_| to |root_view_|?
212211
auto delegate = std::make_unique<MockBrowserViewLayoutDelegate>();
213212
delegate_ = delegate.get();
214-
layout_ = std::make_unique<BrowserViewLayout>(
213+
auto layout = std::make_unique<BrowserViewLayout>(
215214
std::move(delegate),
216215
/*host_view=*/nullptr,
217216
/*browser_view=*/nullptr, top_container_, tab_strip_region_view,
@@ -222,15 +221,17 @@ class BrowserViewLayoutTest : public ChromeViewsTestBase {
222221
/*right_aligned_side_panel_separator=*/nullptr,
223222
/*lens_side_panel=*/nullptr, immersive_mode_controller_.get(),
224223
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));
226227
}
227228

228229
private:
229-
std::unique_ptr<BrowserViewLayout> layout_;
230+
BrowserViewLayout* layout_;
230231
raw_ptr<MockBrowserViewLayoutDelegate> delegate_; // Owned by |layout_|.
231-
std::unique_ptr<views::View> root_view_;
232+
std::unique_ptr<views::View> browser_view_;
232233

233-
// Views owned by |root_view_|.
234+
// Views owned by |browser_view_|.
234235
raw_ptr<views::View> top_container_;
235236
raw_ptr<TabStrip> tab_strip_;
236237
raw_ptr<views::View> webui_tab_strip_;
@@ -256,7 +257,7 @@ TEST_F(BrowserViewLayoutTest, Layout) {
256257
delegate()->set_tab_strip_visible(false);
257258
delegate()->set_toolbar_visible(false);
258259
delegate()->set_bookmark_bar_visible(false);
259-
layout()->Layout(root_view());
260+
RunScheduledLayout(browser_view());
260261

261262
// Top views are zero-height.
262263
EXPECT_EQ(gfx::Rect(0, 0, 0, 0), tab_strip()->bounds());
@@ -267,7 +268,7 @@ TEST_F(BrowserViewLayoutTest, Layout) {
267268

268269
// Turn on the toolbar, like in a pop-up window.
269270
delegate()->set_toolbar_visible(true);
270-
layout()->Layout(root_view());
271+
RunScheduledLayout(browser_view());
271272

272273
// Now the toolbar has bounds and other views shift down.
273274
EXPECT_EQ(gfx::Rect(0, 0, 0, 0), tab_strip()->bounds());
@@ -279,7 +280,7 @@ TEST_F(BrowserViewLayoutTest, Layout) {
279280

280281
// Disable the contents separator.
281282
delegate()->set_content_separator_enabled(false);
282-
layout()->Layout(root_view());
283+
RunScheduledLayout(browser_view());
283284

284285
// Now the separator is not visible and the content grows vertically.
285286
EXPECT_EQ(gfx::Rect(0, 0, 0, 0), tab_strip()->bounds());
@@ -315,7 +316,7 @@ TEST_F(BrowserViewLayoutTest, LayoutContentsWithTopControlsSlideBehavior) {
315316
delegate()->set_toolbar_visible(true);
316317
delegate()->set_top_controls_slide_enabled(true);
317318
delegate()->set_top_controls_shown_ratio(1.f);
318-
layout()->Layout(root_view());
319+
RunScheduledLayout(browser_view());
319320
EXPECT_EQ(gfx::Rect(0, 0, 800, 30), top_container()->bounds());
320321
EXPECT_EQ(gfx::Rect(0, 0, 800, kToolbarHeight), toolbar()->bounds());
321322
EXPECT_EQ(gfx::Rect(0, kToolbarHeight, 800, views::Separator::kThickness),
@@ -324,7 +325,7 @@ TEST_F(BrowserViewLayoutTest, LayoutContentsWithTopControlsSlideBehavior) {
324325

325326
// Top controls are half shown, half hidden.
326327
delegate()->set_top_controls_shown_ratio(0.5f);
327-
layout()->Layout(root_view());
328+
RunScheduledLayout(browser_view());
328329
EXPECT_EQ(gfx::Rect(0, 0, 800, 30), top_container()->bounds());
329330
EXPECT_EQ(gfx::Rect(0, 0, 800, kToolbarHeight), toolbar()->bounds());
330331
EXPECT_EQ(gfx::Rect(0, kToolbarHeight, 800, views::Separator::kThickness),
@@ -334,7 +335,7 @@ TEST_F(BrowserViewLayoutTest, LayoutContentsWithTopControlsSlideBehavior) {
334335
// Top controls are fully hidden. the contents are expanded in height by an
335336
// amount equal to the top controls height.
336337
delegate()->set_top_controls_shown_ratio(0.f);
337-
layout()->Layout(root_view());
338+
RunScheduledLayout(browser_view());
338339
EXPECT_EQ(gfx::Rect(0, -30, 800, 30), top_container()->bounds());
339340
EXPECT_EQ(gfx::Rect(0, 0, 800, kToolbarHeight), toolbar()->bounds());
340341
EXPECT_EQ(gfx::Rect(0, kToolbarHeight, 800, views::Separator::kThickness),
@@ -346,12 +347,12 @@ TEST_F(BrowserViewLayoutTest, WebUITabStripPushesDownContents) {
346347
delegate()->set_tab_strip_visible(false);
347348
delegate()->set_toolbar_visible(true);
348349
webui_tab_strip()->SetVisible(false);
349-
layout()->Layout(root_view());
350+
RunScheduledLayout(browser_view());
350351
const gfx::Rect original_contents_bounds = contents_container()->bounds();
351352
EXPECT_EQ(gfx::Size(), webui_tab_strip()->size());
352353

353354
webui_tab_strip()->SetVisible(true);
354-
layout()->Layout(root_view());
355+
RunScheduledLayout(browser_view());
355356
EXPECT_LT(0, webui_tab_strip()->size().height());
356357
EXPECT_EQ(original_contents_bounds.size(), contents_container()->size());
357358
EXPECT_EQ(webui_tab_strip()->size().height(),

chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class OpaqueBrowserFrameViewLayoutTest
370370
TEST_P(OpaqueBrowserFrameViewLayoutTest, BasicWindow) {
371371
// Tests the layout of a default chrome window with a tabstrip and no window
372372
// title.
373-
root_view_->Layout();
373+
RunScheduledLayout(root_view_);
374374
ExpectCaptionButtons(false, 0);
375375
ExpectTabStripAndMinimumSize(false);
376376
ExpectWindowIcon(false);
@@ -385,7 +385,7 @@ TEST_P(OpaqueBrowserFrameViewLayoutTest, WindowButtonsOnLeft) {
385385
leading_buttons.push_back(views::FrameButton::kMaximize);
386386
layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons);
387387

388-
root_view_->Layout();
388+
RunScheduledLayout(root_view_);
389389
ExpectCaptionButtons(true, 0);
390390
ExpectTabStripAndMinimumSize(true);
391391
ExpectWindowIcon(true);
@@ -396,7 +396,7 @@ TEST_P(OpaqueBrowserFrameViewLayoutTest, WithoutCaptionButtons) {
396396
// should force the tab strip to be condensed).
397397
delegate_->set_show_caption_buttons(false);
398398

399-
root_view_->Layout();
399+
RunScheduledLayout(root_view_);
400400
ExpectCaptionButtons(false, 0);
401401
ExpectTabStripAndMinimumSize(false);
402402
ExpectWindowIcon(false);
@@ -407,7 +407,7 @@ TEST_P(OpaqueBrowserFrameViewLayoutTest, WindowWithTitleAndIcon) {
407407
delegate_->set_window_title(u"Window Title");
408408
AddWindowTitleIcons();
409409

410-
root_view_->Layout();
410+
RunScheduledLayout(root_view_);
411411
ExpectCaptionButtons(false, 0);
412412
ExpectWindowIcon(false);
413413
ExpectWindowTitle();

chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class LayoutTestView : public views::View {
9898
explicit LayoutTestView(BrowserView* parent) {
9999
DCHECK(parent);
100100
parent->AddChildView(this);
101-
parent->Layout();
101+
parent->GetWidget()->LayoutRootViewIfNecessary();
102102
layout_count_ = 0;
103103
}
104104
~LayoutTestView() override = default;

0 commit comments

Comments
 (0)