| Index: ash/wm/workspace/snap_sizer_unittest.cc
|
| diff --git a/ash/wm/workspace/snap_sizer_unittest.cc b/ash/wm/workspace/snap_sizer_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e737b1ccf6c89de26533249ccb7593a785297ef9
|
| --- /dev/null
|
| +++ b/ash/wm/workspace/snap_sizer_unittest.cc
|
| @@ -0,0 +1,82 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ash/wm/workspace/snap_sizer.h"
|
| +
|
| +#include "ash/root_window_controller.h"
|
| +#include "ash/screen_ash.h"
|
| +#include "ash/shelf/shelf_layout_manager.h"
|
| +#include "ash/test/ash_test_base.h"
|
| +#include "ui/aura/window.h"
|
| +
|
| +namespace ash {
|
| +
|
| +typedef test::AshTestBase SnapSizerTest;
|
| +
|
| +using internal::SnapSizer;
|
| +
|
| +TEST_F(SnapSizerTest, Basic) {
|
| + if (!SupportsMultipleDisplays())
|
| + return;
|
| +
|
| + UpdateDisplay("0+0-500x400, 0+500-600x400");
|
| + scoped_ptr<aura::Window> window(
|
| + CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100)));
|
| +
|
| + internal::RootWindowController* root_window_controller =
|
| + internal::RootWindowController::ForWindow(window.get());
|
| + internal::ShelfLayoutManager* shelf_layout_manager =
|
| + root_window_controller->GetShelfLayoutManager();
|
| + EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf_layout_manager->GetAlignment());
|
| + shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
|
| + EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());
|
| +
|
| + const int kSnappedHeight = 400 -
|
| + internal::ShelfLayoutManager::GetPreferredShelfSize();
|
| + const gfx::Rect kSnappedLeftPrimaryDisplay(0, 0, 250, kSnappedHeight);
|
| + const gfx::Rect kSnappedRightPrimaryDisplay(250, 0, 250, kSnappedHeight);
|
| + const gfx::Rect kSnappedLeftSecondaryDisplay(500, 0, 300, kSnappedHeight);
|
| + const gfx::Rect kSnappedRightSecondaryDisplay(800, 0, 300, kSnappedHeight);
|
| +
|
| + // Sanity test.
|
| + SnapSizer sizer1(window.get(),
|
| + gfx::Point(),
|
| + SnapSizer::LEFT_EDGE,
|
| + SnapSizer::STEP_YES);
|
| + EXPECT_EQ(kSnappedLeftPrimaryDisplay.ToString(),
|
| + sizer1.target_bounds().ToString());
|
| + sizer1.Snap();
|
| + EXPECT_EQ(kSnappedLeftPrimaryDisplay.ToString(),
|
| + window->GetBoundsInScreen().ToString());
|
| +
|
| + SnapSizer sizer2(window.get(),
|
| + gfx::Point(),
|
| + SnapSizer::RIGHT_EDGE,
|
| + SnapSizer::STEP_YES);
|
| + sizer2.Snap();
|
| + EXPECT_EQ(kSnappedRightPrimaryDisplay.ToString(),
|
| + window->GetBoundsInScreen().ToString());
|
| +
|
| + window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100),
|
| + ScreenAsh::GetSecondaryDisplay());
|
| + SnapSizer::SnapWindow(window.get(), SnapSizer::LEFT_EDGE,
|
| + SnapSizer::STEP_YES);
|
| + EXPECT_EQ(kSnappedLeftSecondaryDisplay.ToString(),
|
| + window->GetBoundsInScreen().ToString());
|
| +
|
| + SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE,
|
| + SnapSizer::STEP_YES);
|
| + EXPECT_EQ(kSnappedRightSecondaryDisplay.ToString(),
|
| + window->GetBoundsInScreen().ToString());
|
| +
|
| + // Because SnapSizer currently has a single possible state (side maximized),
|
| + // SnapSizer should always size the window to the same bounds for a given edge
|
| + // regardless of the StepBehavior.
|
| + SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE,
|
| + SnapSizer::STEP_YES);
|
| + EXPECT_EQ(kSnappedRightSecondaryDisplay.ToString(),
|
| + window->GetBoundsInScreen().ToString());
|
| +}
|
| +
|
| +} // namespace ash
|
|
|