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

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

Issue 7809003: Simplify IqRequest interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/jingle_glue/iq_request.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 base::Unretained(&callback_)))); 69 base::Unretained(&callback_))));
70 70
71 MockIqRequest* iq_request = new MockIqRequest(); 71 MockIqRequest* iq_request = new MockIqRequest();
72 iq_request->Init(); 72 iq_request->Init();
73 EXPECT_CALL(*iq_request, set_callback(_)).Times(1); 73 EXPECT_CALL(*iq_request, set_callback(_)).Times(1);
74 74
75 EXPECT_CALL(signal_strategy_, CreateIqRequest()) 75 EXPECT_CALL(signal_strategy_, CreateIqRequest())
76 .WillOnce(Return(iq_request)); 76 .WillOnce(Return(iq_request));
77 77
78 XmlElement* sent_iq = NULL; 78 XmlElement* sent_iq = NULL;
79 EXPECT_CALL(*iq_request, SendIq(buzz::STR_SET, kChromotingBotJid, NotNull())) 79 EXPECT_CALL(*iq_request, SendIq(NotNull()))
80 .WillOnce(SaveArg<2>(&sent_iq)); 80 .WillOnce(SaveArg<0>(&sent_iq));
81 81
82 request->OnSignallingConnected(&signal_strategy_, kTestJid); 82 request->OnSignallingConnected(&signal_strategy_, kTestJid);
83 message_loop_.RunAllPending(); 83 message_loop_.RunAllPending();
84 84
85 // Verify format of the query. 85 // Verify format of the query.
86 scoped_ptr<XmlElement> stanza(sent_iq); 86 scoped_ptr<XmlElement> stanza(sent_iq);
87 ASSERT_TRUE(stanza != NULL); 87 ASSERT_TRUE(stanza != NULL);
88 88
89 EXPECT_EQ(stanza->Attr(buzz::QName("", "to")),
90 std::string(kChromotingBotJid));
91 EXPECT_EQ(stanza->Attr(buzz::QName("", "type")), "set");
92
89 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"), 93 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"),
90 stanza->Name()); 94 stanza->FirstElement()->Name());
91 95
92 QName signature_tag(kChromotingXmlNamespace, "signature"); 96 QName signature_tag(kChromotingXmlNamespace, "signature");
93 XmlElement* signature = stanza->FirstNamed(signature_tag); 97 XmlElement* signature = stanza->FirstElement()->FirstNamed(signature_tag);
94 ASSERT_TRUE(signature != NULL); 98 ASSERT_TRUE(signature != NULL);
95 EXPECT_TRUE(stanza->NextNamed(signature_tag) == NULL); 99 EXPECT_TRUE(stanza->NextNamed(signature_tag) == NULL);
96 100
97 std::string time_str = 101 std::string time_str =
98 signature->Attr(QName(kChromotingXmlNamespace, "time")); 102 signature->Attr(QName(kChromotingXmlNamespace, "time"));
99 int64 time; 103 int64 time;
100 EXPECT_TRUE(base::StringToInt64(time_str, &time)); 104 EXPECT_TRUE(base::StringToInt64(time_str, &time));
101 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); 105 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT());
102 EXPECT_LE(start_time, time); 106 EXPECT_LE(start_time, time);
103 EXPECT_GE(now, time); 107 EXPECT_GE(now, time);
(...skipping 23 matching lines...) Expand all
127 XmlElement* support_id_lifetime = new XmlElement( 131 XmlElement* support_id_lifetime = new XmlElement(
128 QName(kChromotingXmlNamespace, "support-id-lifetime")); 132 QName(kChromotingXmlNamespace, "support-id-lifetime"));
129 support_id_lifetime->AddText(kSupportIdLifetime); 133 support_id_lifetime->AddText(kSupportIdLifetime);
130 result->AddElement(support_id_lifetime); 134 result->AddElement(support_id_lifetime);
131 135
132 iq_request->callback().Run(response.get()); 136 iq_request->callback().Run(response.get());
133 message_loop_.RunAllPending(); 137 message_loop_.RunAllPending();
134 } 138 }
135 139
136 } // namespace remoting 140 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/jingle_glue/iq_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698