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

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

Issue 1707233002: Reduce the fullscreen window height by 1px on activation loss. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 4 years, 10 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
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 <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 3373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100)); 3384 ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
3385 ::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(110, 110)); 3385 ::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(110, 110));
3386 RunPendingMessages(); 3386 RunPendingMessages();
3387 3387
3388 EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN)); 3388 EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
3389 EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND)); 3389 EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND));
3390 3390
3391 widget.CloseNow(); 3391 widget.CloseNow();
3392 } 3392 }
3393 3393
3394 // On Windows if we create a fullscreen window on a thread, then it affects the
3395 // way other windows on the thread interact with the taskbar. To workaround
3396 // this we reduce the bounds of a fullscreen window by 1px when it loses
3397 // activation. This test verifies the same.
3398 TEST_F(WidgetTest, FullscreenBoundsReducedOnActivationLoss) {
3399 Widget widget1;
3400 Widget::InitParams params =
3401 CreateParams(Widget::InitParams::TYPE_WINDOW);
3402 params.native_widget = new PlatformDesktopNativeWidget(&widget1);
3403 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
3404 widget1.Init(params);
3405 widget1.SetBounds(gfx::Rect(0, 0, 200, 200));
3406 widget1.Show();
3407
3408 Widget widget2;
3409 params.native_widget = new PlatformDesktopNativeWidget(&widget2);
3410 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
3411 widget2.Init(params);
3412 widget2.SetBounds(gfx::Rect(0, 0, 200, 200));
3413 widget2.Show();
3414
3415 widget1.SetFullscreen(true);
3416 EXPECT_TRUE(widget1.IsFullscreen());
3417 // Ensure that the StopIgnoringPosChanges task in HWNDMessageHandler runs.
3418 // This task is queued when a widget becomes fullscreen.
3419 RunPendingMessages();
3420
3421 gfx::Rect fullscreen_bounds = widget1.GetWindowBoundsInScreen();
3422
3423 widget2.Activate();
3424
3425 gfx::Rect fullscreen_bounds_after_activation_loss =
3426 widget1.GetWindowBoundsInScreen();
3427
3428 // After deactivation loss the bounds of the fullscreen widget should be
3429 // reduced by 1px.
3430 EXPECT_EQ(fullscreen_bounds.height() -
3431 fullscreen_bounds_after_activation_loss.height(), 1);
3432
3433 widget1.Activate();
3434
3435 gfx::Rect fullscreen_bounds_after_activate =
3436 widget1.GetWindowBoundsInScreen();
3437
3438 // After activation the bounds of the fullscreen widget should be restored.
3439 EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate);
3440
3441 widget1.CloseNow();
3442 widget2.CloseNow();
3443 }
3394 #endif 3444 #endif
3395 3445
3396 // Test that SetAlwaysOnTop and IsAlwaysOnTop are consistent. 3446 // Test that SetAlwaysOnTop and IsAlwaysOnTop are consistent.
3397 TEST_F(WidgetTest, AlwaysOnTop) { 3447 TEST_F(WidgetTest, AlwaysOnTop) {
3398 WidgetAutoclosePtr widget(CreateTopLevelNativeWidget()); 3448 WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
3399 EXPECT_FALSE(widget->IsAlwaysOnTop()); 3449 EXPECT_FALSE(widget->IsAlwaysOnTop());
3400 widget->SetAlwaysOnTop(true); 3450 widget->SetAlwaysOnTop(true);
3401 EXPECT_TRUE(widget->IsAlwaysOnTop()); 3451 EXPECT_TRUE(widget->IsAlwaysOnTop());
3402 widget->SetAlwaysOnTop(false); 3452 widget->SetAlwaysOnTop(false);
3403 EXPECT_FALSE(widget->IsAlwaysOnTop()); 3453 EXPECT_FALSE(widget->IsAlwaysOnTop());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 // Moving the child to a different widget should call the removals observer. 3563 // Moving the child to a different widget should call the removals observer.
3514 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); 3564 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget());
3515 widget2->client_view()->AddChildView(child); 3565 widget2->client_view()->AddChildView(child);
3516 EXPECT_TRUE(removals_observer.DidRemoveView(child)); 3566 EXPECT_TRUE(removals_observer.DidRemoveView(child));
3517 3567
3518 widget->RemoveRemovalsObserver(&removals_observer); 3568 widget->RemoveRemovalsObserver(&removals_observer);
3519 } 3569 }
3520 3570
3521 } // namespace test 3571 } // namespace test
3522 } // namespace views 3572 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698