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