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

Side by Side Diff: ash/wm/workspace/snap_sizer_unittest.cc

Issue 23471004: Only support left/right maximizing at 50% width when the --ash-enable-alternate-caption-button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/wm/workspace/snap_sizer.h"
6
7 #include "ash/root_window_controller.h"
8 #include "ash/screen_ash.h"
9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/test/ash_test_base.h"
11 #include "ui/aura/window.h"
12
13 namespace ash {
14
15 typedef test::AshTestBase SnapSizerTest;
16
17 using internal::SnapSizer;
18
19 TEST_F(SnapSizerTest, Basic) {
20 if (!SupportsMultipleDisplays())
21 return;
22
23 UpdateDisplay("0+0-500x400, 0+500-600x400");
24 scoped_ptr<aura::Window> window(
25 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100)));
26
27 internal::RootWindowController* root_window_controller =
28 internal::RootWindowController::ForWindow(window.get());
29 internal::ShelfLayoutManager* shelf_layout_manager =
30 root_window_controller->GetShelfLayoutManager();
31 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf_layout_manager->GetAlignment());
32 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
33 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());
34
35 const int kSnappedHeight = 400 -
36 internal::ShelfLayoutManager::GetPreferredShelfSize();
37 const gfx::Rect kSnappedLeftPrimaryDisplay(0, 0, 250, kSnappedHeight);
38 const gfx::Rect kSnappedRightPrimaryDisplay(250, 0, 250, kSnappedHeight);
39 const gfx::Rect kSnappedLeftSecondaryDisplay(500, 0, 300, kSnappedHeight);
40 const gfx::Rect kSnappedRightSecondaryDisplay(800, 0, 300, kSnappedHeight);
41
42 // Sanity test.
43 SnapSizer sizer1(window.get(),
44 gfx::Point(),
45 SnapSizer::LEFT_EDGE,
46 SnapSizer::STEP_YES);
47 EXPECT_EQ(kSnappedLeftPrimaryDisplay.ToString(),
48 sizer1.target_bounds().ToString());
49 sizer1.Snap();
50 EXPECT_EQ(kSnappedLeftPrimaryDisplay.ToString(),
51 window->GetBoundsInScreen().ToString());
52
53 SnapSizer sizer2(window.get(),
54 gfx::Point(),
55 SnapSizer::RIGHT_EDGE,
56 SnapSizer::STEP_YES);
57 sizer2.Snap();
58 EXPECT_EQ(kSnappedRightPrimaryDisplay.ToString(),
59 window->GetBoundsInScreen().ToString());
60
61 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100),
62 ScreenAsh::GetSecondaryDisplay());
63 SnapSizer::SnapWindow(window.get(), SnapSizer::LEFT_EDGE,
64 SnapSizer::STEP_YES);
65 EXPECT_EQ(kSnappedLeftSecondaryDisplay.ToString(),
66 window->GetBoundsInScreen().ToString());
67
68 SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE,
69 SnapSizer::STEP_YES);
70 EXPECT_EQ(kSnappedRightSecondaryDisplay.ToString(),
71 window->GetBoundsInScreen().ToString());
72
73 // Because SnapSizer currently has a single possible state (side maximized),
74 // SnapSizer should always size the window to the same bounds for a given edge
75 // regardless of the StepBehavior.
76 SnapSizer::SnapWindow(window.get(), SnapSizer::RIGHT_EDGE,
77 SnapSizer::STEP_YES);
78 EXPECT_EQ(kSnappedRightSecondaryDisplay.ToString(),
79 window->GetBoundsInScreen().ToString());
80 }
81
82 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698