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

Unified Diff: remoting/host/chromoting_host_unittest.cc

Issue 6724033: Remove authenticated_ fields from stubs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix .gyp file for unit tests. Created 9 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
Index: remoting/host/chromoting_host_unittest.cc
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index 5338c080771088911aad2eb709968a0c0e58d462..b614fe07633da657663caaae4100908b82072a27 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/task.h"
#include "remoting/host/capturer_fake.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/host_mock_objects.h"
#include "remoting/host/in_memory_host_config.h"
+#include "remoting/host/user_authenticator_fake.h"
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/protocol_mock_objects.h"
#include "remoting/protocol/session_config.h"
@@ -38,6 +40,10 @@ namespace remoting {
namespace {
+UserAuthenticator* MakeUserAuthenticator() {
+ return new UserAuthenticatorFake();
+}
+
void PostQuitTask(MessageLoop* message_loop) {
message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
}
@@ -53,6 +59,12 @@ ACTION_P(QuitMainMessageLoop, message_loop) {
PostQuitTask(message_loop);
}
+// A task that does nothing.
+class DummyTask : public Task {
Alpha Left Google 2011/03/28 16:22:26 Alternatively you can also do: void DummyTask() {
simonmorris 2011/03/29 17:07:51 Done.
+ public:
+ void Run() {}
+};
+
} // namespace
class ChromotingHostTest : public testing::Test {
@@ -83,6 +95,9 @@ class ChromotingHostTest : public testing::Test {
DesktopEnvironment* desktop =
new DesktopEnvironment(capturer, input_stub_);
host_ = ChromotingHost::Create(&context_, config_, desktop);
+ credentials_.set_type(protocol::PASSWORD);
+ credentials_.set_username("user");
+ credentials_.set_credential("password");
connection_ = new MockConnectionToClient(
&message_loop_, &handler_, host_stub_, input_stub_);
connection2_ = new MockConnectionToClient(
@@ -140,8 +155,11 @@ class ChromotingHostTest : public testing::Test {
void SimulateClientConnection(int connection_index) {
scoped_refptr<MockConnectionToClient> connection =
(connection_index == 0) ? connection_ : connection2_;
- scoped_refptr<ClientSession> client = new ClientSession(host_.get(),
- connection);
+ scoped_refptr<ClientSession> client = new ClientSession(
+ host_.get(),
+ base::Bind(MakeUserAuthenticator),
+ connection,
+ input_stub_);
connection->set_host_stub(client.get());
context_.network_message_loop()->PostTask(
@@ -156,9 +174,10 @@ class ChromotingHostTest : public testing::Test {
connection));
context_.network_message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(host_.get(),
- &ChromotingHost::LocalLoginSucceeded,
- connection));
+ NewRunnableMethod(client.get(),
+ &ClientSession::BeginSessionRequest,
+ &credentials_,
+ new DummyTask()));
}
// Helper method to remove a client connection from ChromotingHost.
@@ -176,6 +195,7 @@ class ChromotingHostTest : public testing::Test {
scoped_refptr<ChromotingHost> host_;
scoped_refptr<InMemoryHostConfig> config_;
MockChromotingHostContext context_;
+ protocol::LocalLoginCredentials credentials_;
scoped_refptr<MockConnectionToClient> connection_;
scoped_refptr<MockSession> session_;
scoped_ptr<SessionConfig> session_config_;

Powered by Google App Engine
This is Rietveld 408576698