Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / keyboard_overlay / keyboard_overlay_delegate_unittest.cc
blob2605263c3cd189948b56c37ef8833bb38173247b
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.
5 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h"
7 #include "ash/shelf/shelf_types.h"
8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/aura/window.h"
12 #include "ui/gfx/display.h"
13 #include "ui/gfx/screen.h"
14 #include "ui/views/widget/widget.h"
16 namespace ash {
18 class KeyboardOverlayDelegateTest
19 : public test::AshTestBase,
20 public testing::WithParamInterface<ShelfAlignment> {
21 public:
22 KeyboardOverlayDelegateTest() : shelf_alignment_(GetParam()) {}
23 virtual ~KeyboardOverlayDelegateTest() {}
24 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
26 private:
27 ShelfAlignment shelf_alignment_;
29 DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayDelegateTest);
32 // Verifies we can show and close the widget for the overlay dialog.
33 TEST_P(KeyboardOverlayDelegateTest, ShowAndClose) {
34 if (!SupportsMultipleDisplays())
35 return;
37 UpdateDisplay("500x400,300x200");
38 ash::Shell* shell = ash::Shell::GetInstance();
39 shell->SetShelfAlignment(shelf_alignment(), shell->GetPrimaryRootWindow());
40 KeyboardOverlayDelegate delegate(base::ASCIIToUTF16("Title"),
41 GURL("chrome://keyboardoverlay/"));
42 // Showing the dialog creates a widget.
43 views::Widget* widget = delegate.Show(NULL);
44 EXPECT_TRUE(widget);
46 // The widget is on the primary root window.
47 EXPECT_EQ(Shell::GetPrimaryRootWindow(),
48 widget->GetNativeWindow()->GetRootWindow());
50 // The widget is horizontally centered at the bottom of the work area.
51 gfx::Rect work_area = Shell::GetScreen()->GetPrimaryDisplay().work_area();
52 gfx::Rect bounds = widget->GetRestoredBounds();
53 EXPECT_EQ(work_area.CenterPoint().x(), bounds.CenterPoint().x());
54 EXPECT_EQ(work_area.bottom(), bounds.bottom());
56 // Clean up.
57 widget->CloseNow();
60 // Tests run three times - for all possible values of shelf alignment
61 INSTANTIATE_TEST_CASE_P(ShelfAlignmentAny,
62 KeyboardOverlayDelegateTest,
63 testing::Values(SHELF_ALIGNMENT_BOTTOM,
64 SHELF_ALIGNMENT_LEFT,
65 SHELF_ALIGNMENT_RIGHT,
66 SHELF_ALIGNMENT_TOP));
68 } // namespace ash