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

Unified Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 79023009: Avoids centering docked windows, Unsnaps when centering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoids centering docked windows, Unsnaps when centering. (Added test) Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ash/accelerators/accelerator_controller_unittest.cc
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index cece32878d685de81159d3703d3988b835885285..3f0dbc9d7fe2e1ed85600334ab36c9cac84b240e 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -9,6 +9,7 @@
#include "ash/caps_lock_delegate.h"
#include "ash/display/display_manager.h"
#include "ash/ime_control_delegate.h"
+#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/system/brightness_control_delegate.h"
@@ -536,6 +537,37 @@ TEST_F(AcceleratorControllerTest, WindowSnap) {
}
}
+TEST_F(AcceleratorControllerTest, CenterWindowAccelerator) {
+ scoped_ptr<aura::Window> window(
+ CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
+ const ui::Accelerator dummy;
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->Activate();
+
+ // Center the window using accelerator.
+ GetController()->PerformAction(WINDOW_POSITION_CENTER, dummy);
+ gfx::Rect work_area =
+ Shell::GetScreen()->GetDisplayNearestWindow(window.get()).work_area();
+ gfx::Rect bounds = window->GetBoundsInScreen();
+ EXPECT_NEAR(bounds.x() - work_area.x(),
+ work_area.right() - bounds.right(),
+ 1);
+ EXPECT_NEAR(bounds.y() - work_area.y(),
+ work_area.bottom() - bounds.bottom(),
+ 1);
+
+ // Add the window to docked container and try to center it.
+ window->SetBounds(gfx::Rect(0, 0, 20, 20));
+ aura::Window* docked_container = Shell::GetContainer(
+ window->GetRootWindow(), internal::kShellWindowId_DockedContainer);
+ docked_container->AddChild(window.get());
+ gfx::Rect docked_bounds = window->GetBoundsInScreen();
+ GetController()->PerformAction(WINDOW_POSITION_CENTER, dummy);
+ // It should not get centered and should remain docked.
+ EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
+ EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString());
+}
+
TEST_F(AcceleratorControllerTest, ControllerContext) {
ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE);
ui::Accelerator accelerator_a2(ui::VKEY_A, ui::EF_NONE);

Powered by Google App Engine
This is Rietveld 408576698