summaryrefslogtreecommitdiffstats
path: root/remoting/signaling/log_to_server_unittest.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 06:10:20 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 06:10:20 +0000
commitfd0ca11848ed29a280ad45b967ad20397a613987 (patch)
treeaa0e6980bb44858d02010cf34571412a54943395 /remoting/signaling/log_to_server_unittest.cc
parent3bccb2aea8bd0d95055f1b4122ed5977e7fc9b6c (diff)
downloadchromium_src-fd0ca11848ed29a280ad45b967ad20397a613987.zip
chromium_src-fd0ca11848ed29a280ad45b967ad20397a613987.tar.gz
chromium_src-fd0ca11848ed29a280ad45b967ad20397a613987.tar.bz2
Remove remoting/jingle_glue
Moved all files from remoting/jingle_glue to remoting/signaling and remoting/protocol. The new remoting/signaling directory contains signaling layer implementation for remoting that can be used independently of remoting/protocol. TBR=rch@chromium.org Review URL: https://codereview.chromium.org/390983003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/signaling/log_to_server_unittest.cc')
-rw-r--r--remoting/signaling/log_to_server_unittest.cc93
1 files changed, 93 insertions, 0 deletions
diff --git a/remoting/signaling/log_to_server_unittest.cc b/remoting/signaling/log_to_server_unittest.cc
new file mode 100644
index 0000000..01e839b
--- /dev/null
+++ b/remoting/signaling/log_to_server_unittest.cc
@@ -0,0 +1,93 @@
+// Copyright 2014 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 "remoting/signaling/log_to_server.h"
+
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "remoting/signaling/mock_signal_strategy.h"
+#include "remoting/signaling/server_log_entry_unittest.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using buzz::XmlElement;
+using buzz::QName;
+using testing::_;
+using testing::DeleteArg;
+using testing::InSequence;
+using testing::Return;
+
+namespace remoting {
+
+namespace {
+
+const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
+const char kClientJid[] = "host@domain.com/1234";
+
+MATCHER_P2(IsLogEntry, key, value, "") {
+ XmlElement* entry = GetSingleLogEntryFromStanza(arg);
+ if (!entry) {
+ return false;
+ }
+
+ return entry->Attr(QName(std::string(), key)) == value;
+}
+
+} // namespace
+
+class LogToServerTest : public testing::Test {
+ public:
+ LogToServerTest() {}
+ virtual void SetUp() OVERRIDE {
+ EXPECT_CALL(signal_strategy_, AddListener(_));
+ EXPECT_CALL(signal_strategy_, RemoveListener(_));
+ log_to_server_.reset(
+ new LogToServer(ServerLogEntry::ME2ME, &signal_strategy_, kTestBotJid));
+ }
+
+ protected:
+ base::MessageLoop message_loop_;
+ base::RunLoop run_loop_;
+ MockSignalStrategy signal_strategy_;
+ scoped_ptr<LogToServer> log_to_server_;
+};
+
+TEST_F(LogToServerTest, LogWhenConnected) {
+ {
+ InSequence s;
+ EXPECT_CALL(signal_strategy_, GetLocalJid())
+ .WillRepeatedly(Return(kClientJid));
+ EXPECT_CALL(signal_strategy_, AddListener(_));
+ EXPECT_CALL(signal_strategy_, GetNextId());
+ EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsLogEntry("a", "1")))
+ .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
+ EXPECT_CALL(signal_strategy_, GetNextId());
+ EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsLogEntry("b", "2")))
+ .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
+ EXPECT_CALL(signal_strategy_, RemoveListener(_))
+ .RetiresOnSaturation();
+ }
+
+ ServerLogEntry entry1;
+ ServerLogEntry entry2;
+ entry1.Set("a", "1");
+ entry2.Set("b", "2");
+ log_to_server_->Log(entry1);
+ log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
+ log_to_server_->Log(entry2);
+ run_loop_.RunUntilIdle();
+}
+
+TEST_F(LogToServerTest, DontLogWhenDisconnected) {
+ EXPECT_CALL(signal_strategy_, GetLocalJid())
+ .WillRepeatedly(Return(kClientJid));
+ EXPECT_CALL(signal_strategy_, SendStanzaPtr(_)).Times(0);
+
+ ServerLogEntry entry;
+ entry.Set("foo", "bar");
+ log_to_server_->Log(entry);
+ run_loop_.RunUntilIdle();
+}
+
+} // namespace remoting