| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "ash/keyboard_overlay/keyboard_overlay_delegate.h" | 5 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/gfx/display.h" | 11 #include "ui/gfx/display.h" |
| 12 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 | 16 |
| 17 typedef test::AshTestBase KeyboardOverlayDelegateTest; | 17 typedef test::AshTestBase KeyboardOverlayDelegateTest; |
| 18 | 18 |
| 19 // Verifies we can show and close the widget for the overlay dialog. | 19 // Verifies we can show and close the widget for the overlay dialog. |
| 20 TEST_F(KeyboardOverlayDelegateTest, ShowAndClose) { | 20 TEST_F(KeyboardOverlayDelegateTest, ShowAndClose) { |
| 21 if (!SupportsMultipleDisplays()) |
| 22 return; |
| 23 |
| 21 UpdateDisplay("500x400,300x200"); | 24 UpdateDisplay("500x400,300x200"); |
| 22 KeyboardOverlayDelegate delegate(ASCIIToUTF16("Title"), | 25 KeyboardOverlayDelegate delegate(ASCIIToUTF16("Title"), |
| 23 GURL("chrome://keyboardoverlay/")); | 26 GURL("chrome://keyboardoverlay/")); |
| 24 // Showing the dialog creates a widget. | 27 // Showing the dialog creates a widget. |
| 25 views::Widget* widget = delegate.Show(NULL); | 28 views::Widget* widget = delegate.Show(NULL); |
| 26 EXPECT_TRUE(widget); | 29 EXPECT_TRUE(widget); |
| 27 | 30 |
| 28 // The widget is on the primary root window. | 31 // The widget is on the primary root window. |
| 29 EXPECT_EQ(Shell::GetPrimaryRootWindow(), | 32 EXPECT_EQ(Shell::GetPrimaryRootWindow(), |
| 30 widget->GetNativeWindow()->GetRootWindow()); | 33 widget->GetNativeWindow()->GetRootWindow()); |
| 31 | 34 |
| 32 // The widget is horizontally centered at the bottom of the work area. | 35 // The widget is horizontally centered at the bottom of the work area. |
| 33 gfx::Rect work_area = Shell::GetScreen()->GetPrimaryDisplay().work_area(); | 36 gfx::Rect work_area = Shell::GetScreen()->GetPrimaryDisplay().work_area(); |
| 34 gfx::Rect bounds = widget->GetRestoredBounds(); | 37 gfx::Rect bounds = widget->GetRestoredBounds(); |
| 35 EXPECT_EQ(work_area.CenterPoint().x(), bounds.CenterPoint().x()); | 38 EXPECT_EQ(work_area.CenterPoint().x(), bounds.CenterPoint().x()); |
| 36 EXPECT_EQ(work_area.bottom(), bounds.bottom()); | 39 EXPECT_EQ(work_area.bottom(), bounds.bottom()); |
| 37 | 40 |
| 38 // Clean up. | 41 // Clean up. |
| 39 widget->CloseNow(); | 42 widget->CloseNow(); |
| 40 } | 43 } |
| 41 | 44 |
| 42 } // namespace ash | 45 } // namespace ash |
| OLD | NEW |