Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: remoting/host/local_input_monitor_unittest.cc

Issue 12594009: Converted LocalInputMonitor into a SessionController instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/local_input_monitor_mac.mm ('k') | remoting/host/local_input_monitor_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/local_input_monitor_unittest.cc
diff --git a/remoting/host/local_input_monitor_unittest.cc b/remoting/host/local_input_monitor_unittest.cc
index a3c18361b17baeb0374d638e9880050297f39735..c1da580cb4302b06bbd7b031f75de4f82ba2b46e 100644
--- a/remoting/host/local_input_monitor_unittest.cc
+++ b/remoting/host/local_input_monitor_unittest.cc
@@ -7,8 +7,10 @@
#include "base/message_loop.h"
#include "base/run_loop.h"
#include "remoting/base/auto_thread_task_runner.h"
+#include "remoting/host/client_session_control.h"
+#include "remoting/host/host_mock_objects.h"
#include "remoting/host/local_input_monitor.h"
-#include "remoting/host/mouse_move_observer.h"
+#include "remoting/protocol/protocol_mock_objects.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkPoint.h"
@@ -17,6 +19,7 @@ namespace remoting {
using testing::_;
using testing::AnyNumber;
+using testing::ReturnRef;
namespace {
@@ -26,49 +29,57 @@ const MessageLoop::Type kDesiredMessageLoopType = MessageLoop::TYPE_UI;
const MessageLoop::Type kDesiredMessageLoopType = MessageLoop::TYPE_IO;
#endif // !defined(OS_WIN)
-class FakeMouseMoveObserver : public MouseMoveObserver {
- public:
- FakeMouseMoveObserver() {}
- virtual ~FakeMouseMoveObserver() {}
-
- // Ignore mouse events to avoid breaking the test of someone moves the mouse.
- virtual void OnLocalMouseMoved(const SkIPoint&) OVERRIDE {}
- void OnDisconnectCallback() {}
-};
-
} // namespace
class LocalInputMonitorTest : public testing::Test {
public:
- LocalInputMonitorTest() : message_loop_(kDesiredMessageLoopType) {
- }
+ LocalInputMonitorTest();
- virtual void SetUp() OVERRIDE {
- // Arrange to run |message_loop_| until no components depend on it.
- task_runner_ = new AutoThreadTaskRunner(
- message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
- }
+ virtual void SetUp() OVERRIDE;
MessageLoop message_loop_;
base::RunLoop run_loop_;
scoped_refptr<AutoThreadTaskRunner> task_runner_;
- FakeMouseMoveObserver mouse_move_observer_;
+ std::string client_jid_;
+ MockClientSessionControl client_session_control_;
+ base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_;
};
+LocalInputMonitorTest::LocalInputMonitorTest()
+ : message_loop_(kDesiredMessageLoopType),
+ client_jid_("user@domain/rest-of-jid"),
+ client_session_control_factory_(&client_session_control_) {
+}
+
+void LocalInputMonitorTest::SetUp() {
+ // Arrange to run |message_loop_| until no components depend on it.
+ task_runner_ = new AutoThreadTaskRunner(
+ message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
+}
+
+
// This test is really to exercise only the creation and destruction code in
// LocalInputMonitor.
TEST_F(LocalInputMonitorTest, Basic) {
+ // Ignore all callbacks.
+ EXPECT_CALL(client_session_control_, client_jid())
+ .Times(AnyNumber())
+ .WillRepeatedly(ReturnRef(client_jid_));
+ EXPECT_CALL(client_session_control_, DisconnectSession())
+ .Times(AnyNumber());
+ EXPECT_CALL(client_session_control_, OnLocalMouseMoved(_))
+ .Times(AnyNumber());
+ EXPECT_CALL(client_session_control_, SetDisableInputs(_))
+ .Times(0);
+
{
scoped_ptr<LocalInputMonitor> local_input_monitor =
- LocalInputMonitor::Create(task_runner_, task_runner_, task_runner_);
+ LocalInputMonitor::Create(task_runner_,
+ task_runner_,
+ task_runner_,
+ client_session_control_factory_.GetWeakPtr());
task_runner_ = NULL;
-
- local_input_monitor->Start(
- &mouse_move_observer_,
- base::Bind(&FakeMouseMoveObserver::OnDisconnectCallback,
- base::Unretained(&mouse_move_observer_)));
- local_input_monitor->Stop();
}
run_loop_.Run();
« no previous file with comments | « remoting/host/local_input_monitor_mac.mm ('k') | remoting/host/local_input_monitor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698