Commit 02e508ce authored by Blake O'Hare's avatar Blake O'Hare Committed by Commit Bot

Use the centralized TestKeyboardUI instead of ash-test-specific ones

This is mostly duplicate code.

Bug: 
Change-Id: Id152dc65ef53eac65d40ef38b6b9da3f962ae9ba
Reviewed-on: https://chromium-review.googlesource.com/832295Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Blake O'Hare <blakeo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533168}
parent affdaea5
......@@ -1228,6 +1228,8 @@ static_library("ash_shell_lib") {
"//ui/base",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/keyboard",
"//ui/keyboard:test_support",
"//ui/message_center",
"//ui/views",
"//ui/views:test_support",
......@@ -1751,8 +1753,6 @@ static_library("test_support_common") {
"highlighter/highlighter_controller_test_api.h",
"ime/test_ime_controller.cc",
"ime/test_ime_controller.h",
"keyboard/test_keyboard_ui.cc",
"keyboard/test_keyboard_ui.h",
"laser/laser_pointer_controller_test_api.cc",
"laser/laser_pointer_controller_test_api.h",
"lock_screen_action/lock_screen_action_background_controller_impl_test_api.h",
......@@ -1888,6 +1888,7 @@ static_library("test_support_common") {
"//ui/gl",
"//ui/gl:test_support",
"//ui/keyboard",
"//ui/keyboard:test_support",
"//ui/message_center",
"//ui/message_center/public/cpp",
"//ui/views",
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/keyboard/test_keyboard_ui.h"
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/mock_input_method.h"
namespace ash {
TestKeyboardUI::TestKeyboardUI() = default;
TestKeyboardUI::~TestKeyboardUI() = default;
bool TestKeyboardUI::HasContentsWindow() const {
return !!keyboard_;
}
bool TestKeyboardUI::ShouldWindowOverscroll(aura::Window* window) const {
return true;
}
aura::Window* TestKeyboardUI::GetContentsWindow() {
if (!keyboard_) {
keyboard_.reset(new aura::Window(&delegate_));
keyboard_->Init(ui::LAYER_NOT_DRAWN);
}
return keyboard_.get();
}
ui::InputMethod* TestKeyboardUI::GetInputMethod() {
aura::Window* active_window = wm::GetActiveWindow();
aura::Window* root_window = active_window ? active_window->GetRootWindow()
: Shell::GetPrimaryRootWindow();
return root_window->GetHost()->GetInputMethod();
}
void TestKeyboardUI::ReloadKeyboardIfNeeded() {}
void TestKeyboardUI::InitInsets(const gfx::Rect& keyboard_bounds) {}
void TestKeyboardUI::ResetInsets() {}
} // namespace ash
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_KEYBOARD_TEST_KEYBOARD_UI_H_
#define ASH_KEYBOARD_TEST_KEYBOARD_UI_H_
#include <memory>
#include "base/macros.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/keyboard/keyboard_ui.h"
namespace aura {
class Window;
} // namespace aura
namespace ash {
// Stub implementation of keyboard::KeyboardUI
class TestKeyboardUI : public keyboard::KeyboardUI {
public:
TestKeyboardUI();
~TestKeyboardUI() override;
bool HasContentsWindow() const override;
bool ShouldWindowOverscroll(aura::Window* window) const override;
aura::Window* GetContentsWindow() override;
private:
// Overridden from keyboard::KeyboardUI:
ui::InputMethod* GetInputMethod() override;
void ReloadKeyboardIfNeeded() override;
void InitInsets(const gfx::Rect& keyboard_bounds) override;
void ResetInsets() override;
aura::test::TestWindowDelegate delegate_;
std::unique_ptr<aura::Window> keyboard_;
DISALLOW_COPY_AND_ASSIGN(TestKeyboardUI);
};
} // namespace ash
#endif // ASH_KEYBOARD_TEST_KEYBOARD_UI_H_
......@@ -8,7 +8,6 @@
#include "ash/accessibility/default_accessibility_delegate.h"
#include "ash/default_wallpaper_delegate.h"
#include "ash/keyboard/test_keyboard_ui.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h"
......@@ -20,8 +19,11 @@
#include "base/strings/utf_string_conversions.h"
#include "components/user_manager/user_info_impl.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/keyboard/keyboard_test_util.h"
#include "ui/keyboard/keyboard_ui.h"
namespace ash {
namespace shell {
......@@ -51,7 +53,8 @@ void ShellDelegateImpl::PreInit() {}
void ShellDelegateImpl::PreShutdown() {}
std::unique_ptr<keyboard::KeyboardUI> ShellDelegateImpl::CreateKeyboardUI() {
return std::make_unique<TestKeyboardUI>();
return std::make_unique<keyboard::TestKeyboardUI>(
Shell::GetPrimaryRootWindow()->GetHost()->GetInputMethod());
}
void ShellDelegateImpl::OpenUrlFromArc(const GURL& url) {}
......
......@@ -5,12 +5,14 @@
#include "ash/test_shell_delegate.h"
#include "ash/accessibility/default_accessibility_delegate.h"
#include "ash/keyboard/test_keyboard_ui.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/test_screenshot_delegate.h"
#include "ash/wallpaper/test_wallpaper_delegate.h"
#include "base/logging.h"
#include "ui/aura/window_tree_host.h"
#include "ui/gfx/image/image.h"
#include "ui/keyboard/keyboard_test_util.h"
namespace ash {
......@@ -39,7 +41,8 @@ void TestShellDelegate::PreInit() {}
void TestShellDelegate::PreShutdown() {}
std::unique_ptr<keyboard::KeyboardUI> TestShellDelegate::CreateKeyboardUI() {
return std::make_unique<TestKeyboardUI>();
return std::make_unique<keyboard::TestKeyboardUI>(
Shell::GetPrimaryRootWindow()->GetHost()->GetInputMethod());
}
void TestShellDelegate::OpenUrlFromArc(const GURL& url) {}
......
......@@ -9,6 +9,7 @@
#include "ui/aura/window.h"
#include "ui/base/ime/dummy_input_method.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_export.h"
#include "ui/keyboard/keyboard_ui.h"
namespace gfx {
......@@ -33,7 +34,7 @@ void WaitControllerStateChangesTo(const KeyboardControllerState state);
gfx::Rect KeyboardBoundsFromRootBounds(const gfx::Rect& root_bounds,
int keyboard_height);
class TestKeyboardUI : public KeyboardUI {
class KEYBOARD_EXPORT TestKeyboardUI : public KeyboardUI {
public:
TestKeyboardUI(ui::InputMethod* input_method);
~TestKeyboardUI() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment