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 <set> | 6 #include <set> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3262 }; | 3262 }; |
3263 | 3263 |
3264 SubclassWindowHelper* SubclassWindowHelper::instance_ = nullptr; | 3264 SubclassWindowHelper* SubclassWindowHelper::instance_ = nullptr; |
3265 | 3265 |
3266 // This test validates whether the WM_SYSCOMMAND message for SC_MOVE is | 3266 // This test validates whether the WM_SYSCOMMAND message for SC_MOVE is |
3267 // received when we post a WM_NCLBUTTONDOWN message for the caption in the | 3267 // received when we post a WM_NCLBUTTONDOWN message for the caption in the |
3268 // following scenarios:- | 3268 // following scenarios:- |
3269 // 1. Posting a WM_NCMOUSEMOVE message for a different location. | 3269 // 1. Posting a WM_NCMOUSEMOVE message for a different location. |
3270 // 2. Posting a WM_NCMOUSEMOVE message with a different hittest code. | 3270 // 2. Posting a WM_NCMOUSEMOVE message with a different hittest code. |
3271 // 3. Posting a WM_MOUSEMOVE message. | 3271 // 3. Posting a WM_MOUSEMOVE message. |
3272 // Disabled because of flaky timeouts: http://crbug.com/592742 | 3272 TEST_F(WidgetTest, SysCommandMoveOnNCLButtonDownOnCaptionAndMoveTest) { |
3273 TEST_F(WidgetTest, DISABLED_SysCommandMoveOnNCLButtonDownOnCaptionAndMoveTest) { | |
3274 Widget widget; | 3273 Widget widget; |
3275 Widget::InitParams params = | 3274 Widget::InitParams params = |
3276 CreateParams(Widget::InitParams::TYPE_WINDOW); | 3275 CreateParams(Widget::InitParams::TYPE_WINDOW); |
3277 params.native_widget = | 3276 params.native_widget = |
3278 CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); | 3277 CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); |
3279 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 3278 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
3280 widget.Init(params); | 3279 widget.Init(params); |
3281 widget.SetBounds(gfx::Rect(0, 0, 200, 200)); | 3280 widget.SetBounds(gfx::Rect(0, 0, 200, 200)); |
3282 widget.Show(); | 3281 widget.Show(); |
3283 ::SetCursorPos(500, 500); | 3282 RunPendingMessages(); |
3284 | 3283 |
3285 HWND window = widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(); | 3284 HWND window = widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(); |
3286 | 3285 |
3287 SubclassWindowHelper subclass_helper(window); | 3286 SubclassWindowHelper subclass_helper(window); |
3288 | 3287 |
3289 // Posting just a WM_NCLBUTTONDOWN message should not result in a | 3288 // Posting just a WM_NCLBUTTONDOWN message should not result in a |
3290 // WM_SYSCOMMAND | 3289 // WM_SYSCOMMAND |
3291 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); | 3290 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); |
3292 RunPendingMessages(); | 3291 RunPendingMessages(); |
| 3292 |
3293 EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN)); | 3293 EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN)); |
3294 EXPECT_FALSE(subclass_helper.received_message(WM_SYSCOMMAND)); | 3294 EXPECT_FALSE(subclass_helper.received_message(WM_SYSCOMMAND)); |
3295 | 3295 |
3296 subclass_helper.Clear(); | 3296 subclass_helper.Clear(); |
3297 // Posting a WM_NCLBUTTONDOWN message followed by a WM_NCMOUSEMOVE at the | 3297 // Posting a WM_NCLBUTTONDOWN message followed by a WM_NCMOUSEMOVE at the |
3298 // same location should not result in a WM_SYSCOMMAND message. | 3298 // same location should not result in a WM_SYSCOMMAND message. |
3299 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); | 3299 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); |
3300 ::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(100, 100)); | 3300 ::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(100, 100)); |
3301 RunPendingMessages(); | 3301 RunPendingMessages(); |
3302 | 3302 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3336 | 3336 |
3337 EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN)); | 3337 EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN)); |
3338 EXPECT_TRUE(subclass_helper.received_message(WM_MOUSEMOVE)); | 3338 EXPECT_TRUE(subclass_helper.received_message(WM_MOUSEMOVE)); |
3339 EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND)); | 3339 EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND)); |
3340 | 3340 |
3341 widget.CloseNow(); | 3341 widget.CloseNow(); |
3342 } | 3342 } |
3343 | 3343 |
3344 // This test validates that destroying the window in the context of the | 3344 // This test validates that destroying the window in the context of the |
3345 // WM_SYSCOMMAND message with SC_MOVE does not crash. | 3345 // WM_SYSCOMMAND message with SC_MOVE does not crash. |
3346 // Disabled because of flaky timeouts: http://crbug.com/592742 | 3346 TEST_F(WidgetTest, DestroyInSysCommandNCLButtonDownOnCaption) { |
3347 TEST_F(WidgetTest, DISABLED_DestroyInSysCommandNCLButtonDownOnCaption) { | |
3348 Widget widget; | 3347 Widget widget; |
3349 Widget::InitParams params = | 3348 Widget::InitParams params = |
3350 CreateParams(Widget::InitParams::TYPE_WINDOW); | 3349 CreateParams(Widget::InitParams::TYPE_WINDOW); |
3351 params.native_widget = | 3350 params.native_widget = |
3352 CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); | 3351 CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); |
3353 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 3352 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
3354 widget.Init(params); | 3353 widget.Init(params); |
3355 widget.SetBounds(gfx::Rect(0, 0, 200, 200)); | 3354 widget.SetBounds(gfx::Rect(0, 0, 200, 200)); |
3356 widget.Show(); | 3355 widget.Show(); |
3357 ::SetCursorPos(500, 500); | 3356 RunPendingMessages(); |
3358 | 3357 |
3359 HWND window = widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(); | 3358 HWND window = widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(); |
3360 | 3359 |
3361 SubclassWindowHelper subclass_helper(window); | 3360 SubclassWindowHelper subclass_helper(window); |
3362 | 3361 |
3363 // Destroying the window in the context of the WM_SYSCOMMAND message | 3362 // Destroying the window in the context of the WM_SYSCOMMAND message |
3364 // should not crash. | 3363 // should not crash. |
3365 subclass_helper.set_message_to_destroy_on(WM_SYSCOMMAND); | 3364 subclass_helper.set_message_to_destroy_on(WM_SYSCOMMAND); |
3366 | 3365 |
3367 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); | 3366 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3496 // Moving the child to a different widget should call the removals observer. | 3495 // Moving the child to a different widget should call the removals observer. |
3497 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); | 3496 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); |
3498 widget2->client_view()->AddChildView(child); | 3497 widget2->client_view()->AddChildView(child); |
3499 EXPECT_TRUE(removals_observer.DidRemoveView(child)); | 3498 EXPECT_TRUE(removals_observer.DidRemoveView(child)); |
3500 | 3499 |
3501 widget->RemoveRemovalsObserver(&removals_observer); | 3500 widget->RemoveRemovalsObserver(&removals_observer); |
3502 } | 3501 } |
3503 | 3502 |
3504 } // namespace test | 3503 } // namespace test |
3505 } // namespace views | 3504 } // namespace views |
OLD | NEW |