OLD | NEW |
---|---|
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 Loading... | |
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 if (IsMus()) |
1376 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DISABLED_DesktopNativeWid getNoPaintAfterCloseTest | 1389 return; |
1377 #else | |
1378 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DesktopNativeWidgetNoPain tAfterCloseTest | |
1379 #endif | |
1380 | |
1381 TEST_F(WidgetTest, MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest) { | |
1382 DesktopAuraTestValidPaintWidget widget; | 1390 DesktopAuraTestValidPaintWidget widget; |
1383 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); | 1391 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); |
1384 RunPendingMessages(); | 1392 widget.WaitUntilPaint(); |
1385 EXPECT_TRUE(widget.ReadReceivedPaintAndReset()); | 1393 EXPECT_TRUE(widget.ReadReceivedPaintAndReset()); |
1386 widget.SchedulePaintInRect(widget.GetRestoredBounds()); | 1394 widget.SchedulePaintInRect(widget.GetRestoredBounds()); |
1387 widget.Close(); | 1395 widget.Close(); |
1388 RunPendingMessages(); | 1396 RunPendingMessages(); |
1389 EXPECT_FALSE(widget.ReadReceivedPaintAndReset()); | 1397 EXPECT_FALSE(widget.ReadReceivedPaintAndReset()); |
1390 EXPECT_FALSE(widget.received_paint_while_hidden()); | 1398 EXPECT_FALSE(widget.received_paint_while_hidden()); |
1391 } | 1399 } |
1392 | 1400 |
1393 // Flaky; see https://crbug.com/596039. | 1401 TEST_F(WidgetTest, DesktopNativeWidgetNoPaintAfterHideTest) { |
1394 #if defined(OS_LINUX) || defined(OS_WIN) | 1402 if (IsMus()) |
sky
2016/06/01 17:18:27
Can you link this and the next to bugs with a TODO
sadrul
2016/06/01 18:28:55
Done.
| |
1395 #define MAYBE_DesktopNativeWidgetNoPaintAfterHideTest DISABLED_DesktopNativeWidg etNoPaintAfterHideTest | 1403 return; |
1396 #else | |
1397 #define MAYBE_DesktopNativeWidgetNoPaintAfterHideTest DesktopNativeWidgetNoPaint AfterHideTest | |
1398 #endif | |
1399 TEST_F(WidgetTest, MAYBE_DesktopNativeWidgetNoPaintAfterHideTest) { | |
1400 DesktopAuraTestValidPaintWidget widget; | 1404 DesktopAuraTestValidPaintWidget widget; |
1401 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); | 1405 widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); |
1402 RunPendingMessages(); | 1406 widget.WaitUntilPaint(); |
1403 EXPECT_TRUE(widget.ReadReceivedPaintAndReset()); | 1407 EXPECT_TRUE(widget.ReadReceivedPaintAndReset()); |
1404 widget.SchedulePaintInRect(widget.GetRestoredBounds()); | 1408 widget.SchedulePaintInRect(widget.GetRestoredBounds()); |
1405 widget.Hide(); | 1409 widget.Hide(); |
1406 RunPendingMessages(); | 1410 RunPendingMessages(); |
1407 EXPECT_FALSE(widget.ReadReceivedPaintAndReset()); | 1411 EXPECT_FALSE(widget.ReadReceivedPaintAndReset()); |
1408 EXPECT_FALSE(widget.received_paint_while_hidden()); | 1412 EXPECT_FALSE(widget.received_paint_while_hidden()); |
1409 widget.Close(); | 1413 widget.Close(); |
1410 } | 1414 } |
1411 | 1415 |
1412 // Test to ensure that the aura Window's visiblity state is set to visible if | 1416 // 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 Loading... | |
3637 private: | 3641 private: |
3638 const ui::ModalType type_; | 3642 const ui::ModalType type_; |
3639 | 3643 |
3640 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); | 3644 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); |
3641 }; | 3645 }; |
3642 | 3646 |
3643 // Tests the case where an intervening owner popup window is destroyed out from | 3647 // 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 | 3648 // under the currently active modal top-level window. In this instance, the |
3645 // remaining top-level windows should be re-enabled. | 3649 // remaining top-level windows should be re-enabled. |
3646 TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) { | 3650 TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) { |
3651 // Modality etc. are controlled by mus. | |
3652 if (IsMus()) | |
3653 return; | |
3647 // top_level_widget owns owner_dialog_widget which owns owned_dialog_widget. | 3654 // top_level_widget owns owner_dialog_widget which owns owned_dialog_widget. |
3648 Widget top_level_widget; | 3655 Widget top_level_widget; |
3649 Widget owner_dialog_widget; | 3656 Widget owner_dialog_widget; |
3650 Widget owned_dialog_widget; | 3657 Widget owned_dialog_widget; |
3651 // Create the top level widget. | 3658 // Create the top level widget. |
3652 Widget::InitParams init_params = | 3659 Widget::InitParams init_params = |
3653 CreateParams(Widget::InitParams::TYPE_WINDOW); | 3660 CreateParams(Widget::InitParams::TYPE_WINDOW); |
3654 init_params.show_state = ui::SHOW_STATE_NORMAL; | 3661 init_params.show_state = ui::SHOW_STATE_NORMAL; |
3655 gfx::Rect initial_bounds(0, 0, 500, 500); | 3662 gfx::Rect initial_bounds(0, 0, 500, 500); |
3656 init_params.bounds = initial_bounds; | 3663 init_params.bounds = initial_bounds; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3712 EXPECT_FALSE(!!IsWindow(owned_hwnd)); | 3719 EXPECT_FALSE(!!IsWindow(owned_hwnd)); |
3713 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); | 3720 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); |
3714 | 3721 |
3715 top_level_widget.CloseNow(); | 3722 top_level_widget.CloseNow(); |
3716 } | 3723 } |
3717 | 3724 |
3718 #endif // defined(OS_WIN) | 3725 #endif // defined(OS_WIN) |
3719 | 3726 |
3720 } // namespace test | 3727 } // namespace test |
3721 } // namespace views | 3728 } // namespace views |
OLD | NEW |