Skip to content

Commit

Permalink
Moves TestImeController from ash/ime/ to c/b/ui/ash/.
Browse files Browse the repository at this point in the history
So that the input_method_manager_impl_unittest won't depend on ash/.

Bug: 756059
Change-Id: Ibba9f87a05d322489a1778658c5bc4adffd908e4
Reviewed-on: https://chromium-review.googlesource.com/1177217
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Shu Chen <shuchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583936}
  • Loading branch information
shuchen-google authored and Commit Bot committed Aug 17, 2018
1 parent 4bb8218 commit 3c379dd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 31 deletions.
2 changes: 0 additions & 2 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2190,8 +2190,6 @@ static_library("test_support_common") {
"display/screen_orientation_controller_test_api.h",
"highlighter/highlighter_controller_test_api.cc",
"highlighter/highlighter_controller_test_api.h",
"ime/test_ime_controller.cc",
"ime/test_ime_controller.h",
"ime/test_ime_controller_client.cc",
"ime/test_ime_controller_client.h",
"keyboard/test_keyboard_ui.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#include <memory>
#include <utility>

#include "ash/ime/ime_controller.h"
#include "ash/ime/test_ime_controller.h"
#include "ash/shell.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
Expand All @@ -23,6 +20,7 @@
#include "chrome/browser/chromeos/input_method/mock_input_method_engine.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/ime_controller_client.h"
#include "chrome/browser/ui/ash/test_ime_controller.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
Expand Down Expand Up @@ -1425,7 +1423,7 @@ TEST_F(InputMethodManagerImplTest, SetLoginDefaultWithAllowedKeyboardLayouts) {
// Verifies that the combination of InputMethodManagerImpl and
// ImeControllerClient sends the correct data to ash.
TEST_F(InputMethodManagerImplTest, IntegrationWithAsh) {
ash::TestImeController ime_controller; // Mojo interface to ash.
TestImeController ime_controller; // Mojo interface to ash.
ImeControllerClient ime_controller_client(manager_.get());
ime_controller_client.InitForTesting(ime_controller.CreateInterfacePtr());

Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,8 @@ jumbo_split_static_library("ui") {
"ash/tablet_mode_client.cc",
"ash/tablet_mode_client.h",
"ash/tablet_mode_client_observer.h",
"ash/test_ime_controller.cc",
"ash/test_ime_controller.h",
"ash/volume_controller.cc",
"ash/volume_controller.h",
"ash/vpn_list_forwarder.cc",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/ime_controller_client_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include <utility>
#include <vector>

#include "ash/ime/test_ime_controller.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_task_environment.h"
#include "chrome/browser/ui/ash/test_ime_controller.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ime/chromeos/fake_input_method_delegate.h"
#include "ui/base/ime/chromeos/input_method_descriptor.h"
Expand Down Expand Up @@ -158,7 +158,7 @@ class ImeControllerClientTest : public testing::Test {
TestInputMethodManager input_method_manager_;

// Mock of mojo interface in ash.
ash::TestImeController ime_controller_;
TestImeController ime_controller_;

private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/ime/test_ime_controller.h"
#include "chrome/browser/ui/ash/test_ime_controller.h"

#include <memory>
#include <string>
#include <utility>

#include "ash/public/interfaces/ime_controller.mojom.h"

namespace ash {

TestImeController::TestImeController() : binding_(this) {}
TestImeController::~TestImeController() = default;

Expand All @@ -21,7 +19,7 @@ ash::mojom::ImeControllerPtr TestImeController::CreateInterfacePtr() {
return ptr;
}

void TestImeController::SetClient(mojom::ImeControllerClientPtr client) {}
void TestImeController::SetClient(ash::mojom::ImeControllerClientPtr client) {}

void TestImeController::RefreshIme(
const std::string& current_ime_id,
Expand Down Expand Up @@ -64,5 +62,3 @@ void TestImeController::ShowModeIndicator(const gfx::Rect& anchor_bounds,
const base::string16& text) {
show_mode_indicator_ = true;
}

} // namespace ash
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_IME_TEST_IME_CONTROLLER_H_
#define ASH_IME_TEST_IME_CONTROLLER_H_
#ifndef CHROME_BROWSER_UI_ASH_TEST_IME_CONTROLLER_H_
#define CHROME_BROWSER_UI_ASH_TEST_IME_CONTROLLER_H_

#include <memory>
#include <string>
#include <utility>

#include "ash/ash_export.h"
#include "ash/public/interfaces/ime_controller.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"

namespace ash {

class ASH_EXPORT TestImeController : mojom::ImeController {
class TestImeController : ash::mojom::ImeController {
public:
TestImeController();
~TestImeController() override;

// Returns a mojo interface pointer bound to this object.
mojom::ImeControllerPtr CreateInterfacePtr();
ash::mojom::ImeControllerPtr CreateInterfacePtr();

// mojom::ImeController:
void SetClient(mojom::ImeControllerClientPtr client) override;
// ash::mojom::ImeController:
void SetClient(ash::mojom::ImeControllerClientPtr client) override;
void RefreshIme(const std::string& current_ime_id,
std::vector<mojom::ImeInfoPtr> available_imes,
std::vector<mojom::ImeMenuItemPtr> menu_items) override;
std::vector<ash::mojom::ImeInfoPtr> available_imes,
std::vector<ash::mojom::ImeMenuItemPtr> menu_items) override;
void SetImesManagedByPolicy(bool managed) override;
void ShowImeMenuOnShelf(bool show) override;
void UpdateCapsLockState(bool enabled) override;
Expand All @@ -41,8 +38,8 @@ class ASH_EXPORT TestImeController : mojom::ImeController {

// The most recent values received via mojo.
std::string current_ime_id_;
std::vector<mojom::ImeInfoPtr> available_imes_;
std::vector<mojom::ImeMenuItemPtr> menu_items_;
std::vector<ash::mojom::ImeInfoPtr> available_imes_;
std::vector<ash::mojom::ImeMenuItemPtr> menu_items_;
bool managed_by_policy_ = false;
bool show_ime_menu_on_shelf_ = false;
bool show_mode_indicator_ = false;
Expand All @@ -54,11 +51,9 @@ class ASH_EXPORT TestImeController : mojom::ImeController {
bool is_voice_enabled_ = false;

private:
mojo::Binding<mojom::ImeController> binding_;
mojo::Binding<ash::mojom::ImeController> binding_;

DISALLOW_COPY_AND_ASSIGN(TestImeController);
};

} // namespace ash

#endif // ASH_IME_TEST_IME_CONTROLLER_H_
#endif // CHROME_BROWSER_UI_ASH_TEST_IME_CONTROLLER_H_

0 comments on commit 3c379dd

Please sign in to comment.