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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 2032573002: views: Fix a couple of flaky tests on windows/linux, disable them on mus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 public: 1308 public:
1309 DesktopAuraTestValidPaintWidget() 1309 DesktopAuraTestValidPaintWidget()
1310 : received_paint_(false), 1310 : received_paint_(false),
1311 expect_paint_(true), 1311 expect_paint_(true),
1312 received_paint_while_hidden_(false) {} 1312 received_paint_while_hidden_(false) {}
1313 1313
1314 ~DesktopAuraTestValidPaintWidget() override {} 1314 ~DesktopAuraTestValidPaintWidget() override {}
1315 1315
1316 void InitForTest(Widget::InitParams create_params); 1316 void InitForTest(Widget::InitParams create_params);
1317 1317
1318 bool ReadReceivedPaintAndReset() {
1319 bool result = received_paint_;
1320 received_paint_ = false;
1321 return result;
1322 }
1323
1324 bool received_paint_while_hidden() const {
1325 return received_paint_while_hidden_;
1326 }
1327
1328 void WaitUntilPaint() {
1329 if (received_paint_)
1330 return;
1331 base::RunLoop runloop;
1332 quit_closure_ = runloop.QuitClosure();
1333 runloop.Run();
1334 quit_closure_ = base::Closure();
1335 }
1336
1337 // views::Widget:
1318 void Show() override { 1338 void Show() override {
1319 expect_paint_ = true; 1339 expect_paint_ = true;
1320 views::Widget::Show(); 1340 views::Widget::Show();
1321 } 1341 }
1322 1342
1323 void Close() override { 1343 void Close() override {
1324 expect_paint_ = false; 1344 expect_paint_ = false;
1325 views::Widget::Close(); 1345 views::Widget::Close();
1326 } 1346 }
1327 1347
1328 void Hide() { 1348 void Hide() {
1329 expect_paint_ = false; 1349 expect_paint_ = false;
1330 views::Widget::Hide(); 1350 views::Widget::Hide();
1331 } 1351 }
1332 1352
1333 void OnNativeWidgetPaint(const ui::PaintContext& context) override { 1353 void OnNativeWidgetPaint(const ui::PaintContext& context) override {
1334 received_paint_ = true; 1354 received_paint_ = true;
1335 EXPECT_TRUE(expect_paint_); 1355 EXPECT_TRUE(expect_paint_);
1336 if (!expect_paint_) 1356 if (!expect_paint_)
1337 received_paint_while_hidden_ = true; 1357 received_paint_while_hidden_ = true;
1338 views::Widget::OnNativeWidgetPaint(context); 1358 views::Widget::OnNativeWidgetPaint(context);
1339 } 1359 if (!quit_closure_.is_null())
1340 1360 quit_closure_.Run();
1341 bool ReadReceivedPaintAndReset() {
1342 bool result = received_paint_;
1343 received_paint_ = false;
1344 return result;
1345 }
1346
1347 bool received_paint_while_hidden() const {
1348 return received_paint_while_hidden_;
1349 } 1361 }
1350 1362
1351 private: 1363 private:
1352 bool received_paint_; 1364 bool received_paint_;
1353 bool expect_paint_; 1365 bool expect_paint_;
1354 bool received_paint_while_hidden_; 1366 bool received_paint_while_hidden_;
1367 base::Closure quit_closure_;
1355 1368
1356 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTestValidPaintWidget); 1369 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTestValidPaintWidget);
1357 }; 1370 };
1358 1371
1359 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) { 1372 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) {
1360 init_params.bounds = gfx::Rect(0, 0, 200, 200); 1373 init_params.bounds = gfx::Rect(0, 0, 200, 200);
1361 init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1374 init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1362 init_params.native_widget = 1375 init_params.native_widget =
1363 CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr); 1376 CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr);
1364 Init(init_params); 1377 Init(init_params);
1365 1378
1366 View* contents_view = new View; 1379 View* contents_view = new View;
1367 contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS); 1380 contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
1368 SetContentsView(contents_view); 1381 SetContentsView(contents_view);
1369 1382
1370 Show(); 1383 Show();
1371 Activate(); 1384 Activate();
1372 } 1385 }
1373 1386
1374 #if defined(OS_LINUX) || defined(OS_WIN) 1387 TEST_F(WidgetTest, DesktopNativeWidgetNoPaintAfterCloseTest) {
1375 // Flaky on Linux rel ng: https://crbug.com/596039. 1388 // TODO(sad): Desktop widgets do not work well in mus https://crbug.com/616551
1376 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DISABLED_DesktopNativeWid getNoPaintAfterCloseTest 1389 if (IsMus())
1377 #else 1390 return;
1378 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DesktopNativeWidgetNoPain tAfterCloseTest
1379 #endif
1380
1381 TEST_F(WidgetTest, MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest) {
1382 DesktopAuraTestValidPaintWidget widget; 1391 DesktopAuraTestValidPaintWidget widget;
1383 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); 1392 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS));
1384 RunPendingMessages(); 1393 widget.WaitUntilPaint();
1385 EXPECT_TRUE(widget.ReadReceivedPaintAndReset()); 1394 EXPECT_TRUE(widget.ReadReceivedPaintAndReset());
1386 widget.SchedulePaintInRect(widget.GetRestoredBounds()); 1395 widget.SchedulePaintInRect(widget.GetRestoredBounds());
1387 widget.Close(); 1396 widget.Close();
1388 RunPendingMessages(); 1397 RunPendingMessages();
1389 EXPECT_FALSE(widget.ReadReceivedPaintAndReset()); 1398 EXPECT_FALSE(widget.ReadReceivedPaintAndReset());
1390 EXPECT_FALSE(widget.received_paint_while_hidden()); 1399 EXPECT_FALSE(widget.received_paint_while_hidden());
1391 } 1400 }
1392 1401
1393 // Flaky; see https://crbug.com/596039. 1402 TEST_F(WidgetTest, DesktopNativeWidgetNoPaintAfterHideTest) {
1394 #if defined(OS_LINUX) || defined(OS_WIN) 1403 // TODO(sad): Desktop widgets do not work well in mus https://crbug.com/616551
1395 #define MAYBE_DesktopNativeWidgetNoPaintAfterHideTest DISABLED_DesktopNativeWidg etNoPaintAfterHideTest 1404 if (IsMus())
1396 #else 1405 return;
1397 #define MAYBE_DesktopNativeWidgetNoPaintAfterHideTest DesktopNativeWidgetNoPaint AfterHideTest
1398 #endif
1399 TEST_F(WidgetTest, MAYBE_DesktopNativeWidgetNoPaintAfterHideTest) {
1400 DesktopAuraTestValidPaintWidget widget; 1406 DesktopAuraTestValidPaintWidget widget;
1401 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); 1407 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS));
1402 RunPendingMessages(); 1408 widget.WaitUntilPaint();
1403 EXPECT_TRUE(widget.ReadReceivedPaintAndReset()); 1409 EXPECT_TRUE(widget.ReadReceivedPaintAndReset());
1404 widget.SchedulePaintInRect(widget.GetRestoredBounds()); 1410 widget.SchedulePaintInRect(widget.GetRestoredBounds());
1405 widget.Hide(); 1411 widget.Hide();
1406 RunPendingMessages(); 1412 RunPendingMessages();
1407 EXPECT_FALSE(widget.ReadReceivedPaintAndReset()); 1413 EXPECT_FALSE(widget.ReadReceivedPaintAndReset());
1408 EXPECT_FALSE(widget.received_paint_while_hidden()); 1414 EXPECT_FALSE(widget.received_paint_while_hidden());
1409 widget.Close(); 1415 widget.Close();
1410 } 1416 }
1411 1417
1412 // Test to ensure that the aura Window's visiblity state is set to visible if 1418 // Test to ensure that the aura Window's visiblity state is set to visible if
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 private: 3643 private:
3638 const ui::ModalType type_; 3644 const ui::ModalType type_;
3639 3645
3640 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); 3646 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate);
3641 }; 3647 };
3642 3648
3643 // Tests the case where an intervening owner popup window is destroyed out from 3649 // Tests the case where an intervening owner popup window is destroyed out from
3644 // under the currently active modal top-level window. In this instance, the 3650 // under the currently active modal top-level window. In this instance, the
3645 // remaining top-level windows should be re-enabled. 3651 // remaining top-level windows should be re-enabled.
3646 TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) { 3652 TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) {
3653 // Modality etc. are controlled by mus.
3654 if (IsMus())
3655 return;
3647 // top_level_widget owns owner_dialog_widget which owns owned_dialog_widget. 3656 // top_level_widget owns owner_dialog_widget which owns owned_dialog_widget.
3648 Widget top_level_widget; 3657 Widget top_level_widget;
3649 Widget owner_dialog_widget; 3658 Widget owner_dialog_widget;
3650 Widget owned_dialog_widget; 3659 Widget owned_dialog_widget;
3651 // Create the top level widget. 3660 // Create the top level widget.
3652 Widget::InitParams init_params = 3661 Widget::InitParams init_params =
3653 CreateParams(Widget::InitParams::TYPE_WINDOW); 3662 CreateParams(Widget::InitParams::TYPE_WINDOW);
3654 init_params.show_state = ui::SHOW_STATE_NORMAL; 3663 init_params.show_state = ui::SHOW_STATE_NORMAL;
3655 gfx::Rect initial_bounds(0, 0, 500, 500); 3664 gfx::Rect initial_bounds(0, 0, 500, 500);
3656 init_params.bounds = initial_bounds; 3665 init_params.bounds = initial_bounds;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3712 EXPECT_FALSE(!!IsWindow(owned_hwnd)); 3721 EXPECT_FALSE(!!IsWindow(owned_hwnd));
3713 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); 3722 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd));
3714 3723
3715 top_level_widget.CloseNow(); 3724 top_level_widget.CloseNow();
3716 } 3725 }
3717 3726
3718 #endif // defined(OS_WIN) 3727 #endif // defined(OS_WIN)
3719 3728
3720 } // namespace test 3729 } // namespace test
3721 } // namespace views 3730 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698