This source file includes following definitions.
- shelf_alignment
- TEST_P
#include "ash/keyboard_overlay/keyboard_overlay_delegate.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
namespace ash {
class KeyboardOverlayDelegateTest
: public test::AshTestBase,
public testing::WithParamInterface<ShelfAlignment> {
public:
KeyboardOverlayDelegateTest() : shelf_alignment_(GetParam()) {}
virtual ~KeyboardOverlayDelegateTest() {}
ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
private:
ShelfAlignment shelf_alignment_;
DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayDelegateTest);
};
TEST_P(KeyboardOverlayDelegateTest, ShowAndClose) {
if (!SupportsMultipleDisplays())
return;
UpdateDisplay("500x400,300x200");
ash::Shell* shell = ash::Shell::GetInstance();
shell->SetShelfAlignment(shelf_alignment(), shell->GetPrimaryRootWindow());
KeyboardOverlayDelegate delegate(base::ASCIIToUTF16("Title"),
GURL("chrome://keyboardoverlay/"));
views::Widget* widget = delegate.Show(NULL);
EXPECT_TRUE(widget);
EXPECT_EQ(Shell::GetPrimaryRootWindow(),
widget->GetNativeWindow()->GetRootWindow());
gfx::Rect work_area = Shell::GetScreen()->GetPrimaryDisplay().work_area();
gfx::Rect bounds = widget->GetRestoredBounds();
EXPECT_EQ(work_area.CenterPoint().x(), bounds.CenterPoint().x());
EXPECT_EQ(work_area.bottom(), bounds.bottom());
widget->CloseNow();
}
INSTANTIATE_TEST_CASE_P(ShelfAlignmentAny,
KeyboardOverlayDelegateTest,
testing::Values(SHELF_ALIGNMENT_BOTTOM,
SHELF_ALIGNMENT_LEFT,
SHELF_ALIGNMENT_RIGHT,
SHELF_ALIGNMENT_TOP));
}