1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h"
9 #include "remoting/base/auto_thread_task_runner.h"
10 #include "remoting/host/client_session_control.h"
11 #include "remoting/host/host_mock_objects.h"
12 #include "remoting/host/local_input_monitor.h"
13 #include "remoting/protocol/protocol_mock_objects.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkPoint.h"
21 using testing::AnyNumber;
22 using testing::ReturnRef;
27 const base::MessageLoop::Type kDesiredMessageLoopType =
28 base::MessageLoop::TYPE_UI;
29 #else // !defined(OS_WIN)
30 const base::MessageLoop::Type kDesiredMessageLoopType =
31 base::MessageLoop::TYPE_IO;
32 #endif // !defined(OS_WIN)
36 class LocalInputMonitorTest : public testing::Test {
38 LocalInputMonitorTest();
40 virtual void SetUp() OVERRIDE;
42 base::MessageLoop message_loop_;
43 base::RunLoop run_loop_;
44 scoped_refptr<AutoThreadTaskRunner> task_runner_;
46 std::string client_jid_;
47 MockClientSessionControl client_session_control_;
48 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_;
51 LocalInputMonitorTest::LocalInputMonitorTest()
52 : message_loop_(kDesiredMessageLoopType),
53 client_jid_("user@domain/rest-of-jid"),
54 client_session_control_factory_(&client_session_control_) {
57 void LocalInputMonitorTest::SetUp() {
58 // Arrange to run |message_loop_| until no components depend on it.
59 task_runner_ = new AutoThreadTaskRunner(
60 message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
64 // This test is really to exercise only the creation and destruction code in
66 TEST_F(LocalInputMonitorTest, Basic) {
67 // Ignore all callbacks.
68 EXPECT_CALL(client_session_control_, client_jid())
70 .WillRepeatedly(ReturnRef(client_jid_));
71 EXPECT_CALL(client_session_control_, DisconnectSession())
73 EXPECT_CALL(client_session_control_, OnLocalMouseMoved(_))
75 EXPECT_CALL(client_session_control_, SetDisableInputs(_))
79 scoped_ptr<LocalInputMonitor> local_input_monitor =
80 LocalInputMonitor::Create(task_runner_,
83 client_session_control_factory_.GetWeakPtr());
90 } // namespace remoting