chrome/browser/chromeos/input_method/ refactoring [part 3 of 6].
Add a mock implementation of the chromeos::input_method::CandidateWindowController interface. This is for http://codereview.chromium.org/9999018/.
BUG=chromium-os:19655
TEST=try
Review URL: https://chromiumcodereview.appspot.com/10034009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131973 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chromeos/input_method/mock_candidate_window.cc b/chrome/browser/chromeos/input_method/mock_candidate_window.cc
new file mode 100644
index 0000000..96e5e30d
--- /dev/null
+++ b/chrome/browser/chromeos/input_method/mock_candidate_window.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 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 "chrome/browser/chromeos/input_method/mock_candidate_window.h"
+
+namespace chromeos {
+namespace input_method {
+
+MockCandidateWindowController::MockCandidateWindowController()
+ : init_count_(0),
+ add_observer_count_(0),
+ remove_observer_count_(0) {
+}
+
+MockCandidateWindowController::~MockCandidateWindowController() {
+}
+
+bool MockCandidateWindowController::Init() {
+ ++init_count_;
+ return true;
+}
+
+void MockCandidateWindowController::AddObserver(
+ CandidateWindowController::Observer* observer) {
+ ++add_observer_count_;
+ observers_.AddObserver(observer);
+}
+
+void MockCandidateWindowController::RemoveObserver(
+ CandidateWindowController::Observer* observer) {
+ ++remove_observer_count_;
+ observers_.RemoveObserver(observer);
+}
+
+void MockCandidateWindowController::NotifyCandidateWindowOpened() {
+ FOR_EACH_OBSERVER(CandidateWindowController::Observer, observers_,
+ CandidateWindowOpened());
+}
+
+void MockCandidateWindowController::NotifyCandidateWindowClosed() {
+ FOR_EACH_OBSERVER(CandidateWindowController::Observer, observers_,
+ CandidateWindowClosed());
+}
+
+} // namespace input_method
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/mock_candidate_window.h b/chrome/browser/chromeos/input_method/mock_candidate_window.h
new file mode 100644
index 0000000..754ad92
--- /dev/null
+++ b/chrome/browser/chromeos/input_method/mock_candidate_window.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_CANDIDATE_WINDOW_H_
+#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_CANDIDATE_WINDOW_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/observer_list.h"
+#include "chrome/browser/chromeos/input_method/candidate_window.h"
+
+namespace chromeos {
+namespace input_method {
+
+// The mock CandidateWindowController implementation for testing.
+class MockCandidateWindowController : public CandidateWindowController {
+ public:
+ MockCandidateWindowController();
+ virtual ~MockCandidateWindowController();
+
+ // CandidateWindowController overrides:
+ virtual bool Init() OVERRIDE;
+ virtual void AddObserver(Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(Observer* observer) OVERRIDE;
+
+ // Notifies observers.
+ void NotifyCandidateWindowOpened();
+ void NotifyCandidateWindowClosed();
+
+ int init_count_;
+ int add_observer_count_;
+ int remove_observer_count_;
+
+ private:
+ ObserverList<CandidateWindowController::Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockCandidateWindowController);
+};
+
+} // namespace input_method
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_CANDIDATE_WINDOW_H_
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 655deb6e..24f86606 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -95,6 +95,8 @@
'browser/chromeos/cros/mock_network_library.h',
'browser/chromeos/cryptohome/mock_async_method_caller.cc',
'browser/chromeos/cryptohome/mock_async_method_caller.h',
+ 'browser/chromeos/input_method/mock_candidate_window.cc',
+ 'browser/chromeos/input_method/mock_candidate_window.h',
'browser/chromeos/input_method/mock_xkeyboard.cc',
'browser/chromeos/input_method/mock_xkeyboard.h',
'browser/chromeos/login/mock_login_status_consumer.cc',