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

Unified Diff: remoting/host/log_to_server_unittest.cc

Issue 8468015: The host sends simple log entries to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review. Created 9 years, 1 month 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/log_to_server.cc ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/log_to_server_unittest.cc
diff --git a/remoting/host/log_to_server_unittest.cc b/remoting/host/log_to_server_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..768abc465a95dc8204a0c7cea6f0a2c9cff2dc51
--- /dev/null
+++ b/remoting/host/log_to_server_unittest.cc
@@ -0,0 +1,93 @@
+// Copyright (c) 2011 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 "base/message_loop.h"
+#include "base/message_loop_proxy.h"
+#include "remoting/jingle_glue/mock_objects.h"
+#include "remoting/host/log_to_server.h"
+#include "testing/gmock_mutant.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::_;
+using testing::InSequence;
+
+namespace remoting {
+
+namespace {
+
+ACTION_P(QuitMainMessageLoop, message_loop) {
+ message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+}
+
+} // namespace
+
+class LogToServerTest : public testing::Test {
+ public:
+ LogToServerTest() {}
+ virtual void SetUp() OVERRIDE {
+ message_loop_proxy_ = base::MessageLoopProxy::current();
+ log_to_server_.reset(new LogToServer(message_loop_proxy_));
+ }
+
+ protected:
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+ scoped_ptr<LogToServer> log_to_server_;
+ MessageLoop message_loop_;
+ MockSignalStrategy signal_strategy_;
+};
+
+TEST_F(LogToServerTest, SendNow) {
+ {
+ InSequence s;
+ EXPECT_CALL(signal_strategy_, AddListener(_));
+ EXPECT_CALL(signal_strategy_, GetNextId());
+ EXPECT_CALL(signal_strategy_, SendStanza(_));
+ EXPECT_CALL(signal_strategy_, RemoveListener(_))
+ .WillOnce(QuitMainMessageLoop(&message_loop_))
+ .RetiresOnSaturation();
+ }
+ log_to_server_->OnSignallingConnected(&signal_strategy_,
+ "host@domain.com/1234");
+ log_to_server_->OnClientAuthenticated("client@domain.com/5678");
+ log_to_server_->OnSignallingDisconnected();
+ message_loop_.Run();
+}
+
+TEST_F(LogToServerTest, SendLater) {
+ {
+ InSequence s;
+ EXPECT_CALL(signal_strategy_, AddListener(_));
+ EXPECT_CALL(signal_strategy_, GetNextId());
+ EXPECT_CALL(signal_strategy_, SendStanza(_));
+ EXPECT_CALL(signal_strategy_, RemoveListener(_))
+ .WillOnce(QuitMainMessageLoop(&message_loop_))
+ .RetiresOnSaturation();
+ }
+ log_to_server_->OnClientAuthenticated("client@domain.com/5678");
+ log_to_server_->OnSignallingConnected(&signal_strategy_,
+ "host@domain.com/1234");
+ log_to_server_->OnSignallingDisconnected();
+ message_loop_.Run();
+}
+
+TEST_F(LogToServerTest, SendTwoEntriesLater) {
+ {
+ InSequence s;
+ EXPECT_CALL(signal_strategy_, AddListener(_));
+ EXPECT_CALL(signal_strategy_, GetNextId());
+ EXPECT_CALL(signal_strategy_, SendStanza(_));
+ EXPECT_CALL(signal_strategy_, RemoveListener(_))
+ .WillOnce(QuitMainMessageLoop(&message_loop_))
+ .RetiresOnSaturation();
+ }
+ log_to_server_->OnClientAuthenticated("client@domain.com/5678");
+ log_to_server_->OnClientAuthenticated("client2@domain.com/6789");
+ log_to_server_->OnSignallingConnected(&signal_strategy_,
+ "host@domain.com/1234");
+ log_to_server_->OnSignallingDisconnected();
+ message_loop_.Run();
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/log_to_server.cc ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698