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

Side by Side Diff: remoting/host/register_support_host_request_unittest.cc

Issue 2880853002: Reports host version, host os and host os version for It2me Host. (Closed)
Patch Set: Fix Unittest Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/register_support_host_request.h" 5 #include "remoting/host/register_support_host_request.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/stringize_macros.h"
15 #include "base/test/mock_callback.h" 16 #include "base/test/mock_callback.h"
16 #include "remoting/base/constants.h" 17 #include "remoting/base/constants.h"
17 #include "remoting/base/rsa_key_pair.h" 18 #include "remoting/base/rsa_key_pair.h"
18 #include "remoting/base/test_rsa_key_pair.h" 19 #include "remoting/base/test_rsa_key_pair.h"
20 #include "remoting/host/host_details.h"
19 #include "remoting/signaling/iq_sender.h" 21 #include "remoting/signaling/iq_sender.h"
20 #include "remoting/signaling/mock_signal_strategy.h" 22 #include "remoting/signaling/mock_signal_strategy.h"
21 #include "remoting/signaling/signaling_address.h" 23 #include "remoting/signaling/signaling_address.h"
22 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" 26 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
25 #include "third_party/libjingle_xmpp/xmpp/constants.h" 27 #include "third_party/libjingle_xmpp/xmpp/constants.h"
26 28
27 using buzz::QName; 29 using buzz::QName;
28 using buzz::XmlElement; 30 using buzz::XmlElement;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 EXPECT_TRUE(stanza->NextNamed(signature_tag) == nullptr); 111 EXPECT_TRUE(stanza->NextNamed(signature_tag) == nullptr);
110 112
111 std::string time_str = 113 std::string time_str =
112 signature->Attr(QName(kChromotingXmlNamespace, "time")); 114 signature->Attr(QName(kChromotingXmlNamespace, "time"));
113 int64_t time; 115 int64_t time;
114 EXPECT_TRUE(base::StringToInt64(time_str, &time)); 116 EXPECT_TRUE(base::StringToInt64(time_str, &time));
115 int64_t now = static_cast<int64_t>(base::Time::Now().ToDoubleT()); 117 int64_t now = static_cast<int64_t>(base::Time::Now().ToDoubleT());
116 EXPECT_LE(start_time, time); 118 EXPECT_LE(start_time, time);
117 EXPECT_GE(now, time); 119 EXPECT_GE(now, time);
118 120
121 XmlElement* host_version = stanza->FirstElement()->FirstNamed(
122 QName(kChromotingXmlNamespace, "host-version"));
123 EXPECT_EQ(STRINGIZE(VERSION), host_version->BodyText());
124
125 XmlElement* host_os_name = stanza->FirstElement()->FirstNamed(
126 QName(kChromotingXmlNamespace, "host-os-name"));
127 EXPECT_EQ(GetHostOperatingSystemName(), host_os_name->BodyText());
128
129 XmlElement* host_os_version = stanza->FirstElement()->FirstNamed(
130 QName(kChromotingXmlNamespace, "host-os-version"));
131 EXPECT_EQ(GetHostOperatingSystemVersion(), host_os_version->BodyText());
132
119 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); 133 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair);
120 ASSERT_TRUE(key_pair.get()); 134 ASSERT_TRUE(key_pair.get());
121 135
122 std::string expected_signature = 136 std::string expected_signature =
123 key_pair->SignMessage(std::string(kTestJidNormalized) + ' ' + time_str); 137 key_pair->SignMessage(std::string(kTestJidNormalized) + ' ' + time_str);
124 EXPECT_EQ(expected_signature, signature->BodyText()); 138 EXPECT_EQ(expected_signature, signature->BodyText());
125 139
126 // Generate response and verify that callback is called. 140 // Generate response and verify that callback is called.
127 EXPECT_CALL(callback_, 141 EXPECT_CALL(callback_,
128 Run(kSupportId, base::TimeDelta::FromSeconds(300), "")); 142 Run(kSupportId, base::TimeDelta::FromSeconds(300), ""));
(...skipping 21 matching lines...) Expand all
150 for (auto& listener : signal_strategy_listeners_) { 164 for (auto& listener : signal_strategy_listeners_) {
151 if (listener.OnSignalStrategyIncomingStanza(response.get())) 165 if (listener.OnSignalStrategyIncomingStanza(response.get()))
152 consumed++; 166 consumed++;
153 } 167 }
154 EXPECT_EQ(1, consumed); 168 EXPECT_EQ(1, consumed);
155 169
156 base::RunLoop().RunUntilIdle(); 170 base::RunLoop().RunUntilIdle();
157 } 171 }
158 172
159 } // namespace remoting 173 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698