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

Side by Side Diff: remoting/signaling/xmpp_stream_parser_unittest.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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/signaling/xmpp_stream_parser.cc ('k') | remoting/test/access_token_fetcher.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/signaling/xmpp_stream_parser.h" 5 #include "remoting/signaling/xmpp_stream_parser.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 13 matching lines...) Expand all
24 parser_->SetCallbacks( 24 parser_->SetCallbacks(
25 base::Bind(&XmppStreamParserTest::OnStanza, base::Unretained(this)), 25 base::Bind(&XmppStreamParserTest::OnStanza, base::Unretained(this)),
26 base::Bind(&XmppStreamParserTest::OnError, base::Unretained(this))); 26 base::Bind(&XmppStreamParserTest::OnError, base::Unretained(this)));
27 } 27 }
28 28
29 void TearDown() override { 29 void TearDown() override {
30 parser_.reset(); 30 parser_.reset();
31 base::RunLoop().RunUntilIdle(); 31 base::RunLoop().RunUntilIdle();
32 } 32 }
33 33
34 void OnStanza(scoped_ptr<buzz::XmlElement> stanza) { 34 void OnStanza(std::unique_ptr<buzz::XmlElement> stanza) {
35 received_stanzas_.push_back(std::move(stanza)); 35 received_stanzas_.push_back(std::move(stanza));
36 } 36 }
37 37
38 void OnError() { 38 void OnError() {
39 error_ = true; 39 error_ = true;
40 } 40 }
41 41
42 protected: 42 protected:
43 base::MessageLoop message_loop_; 43 base::MessageLoop message_loop_;
44 44
45 scoped_ptr<XmppStreamParser> parser_; 45 std::unique_ptr<XmppStreamParser> parser_;
46 ScopedVector<buzz::XmlElement> received_stanzas_; 46 ScopedVector<buzz::XmlElement> received_stanzas_;
47 bool error_; 47 bool error_;
48 }; 48 };
49 49
50 TEST_F(XmppStreamParserTest, ParseXmppStream) { 50 TEST_F(XmppStreamParserTest, ParseXmppStream) {
51 parser_->AppendData("<stream><iq>text</iq>"); 51 parser_->AppendData("<stream><iq>text</iq>");
52 EXPECT_EQ(received_stanzas_[0]->Str(), "<iq>text</iq>"); 52 EXPECT_EQ(received_stanzas_[0]->Str(), "<iq>text</iq>");
53 }; 53 };
54 54
55 TEST_F(XmppStreamParserTest, HandleMultipleIncomingStanzas) { 55 TEST_F(XmppStreamParserTest, HandleMultipleIncomingStanzas) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 parser_->AppendData("<stream p!='a'>"); 87 parser_->AppendData("<stream p!='a'>");
88 EXPECT_TRUE(error_); 88 EXPECT_TRUE(error_);
89 }; 89 };
90 90
91 TEST_F(XmppStreamParserTest, FailOnLooseText) { 91 TEST_F(XmppStreamParserTest, FailOnLooseText) {
92 parser_->AppendData("stream<"); 92 parser_->AppendData("stream<");
93 EXPECT_TRUE(error_); 93 EXPECT_TRUE(error_);
94 }; 94 };
95 95
96 } // namespace remoting 96 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/xmpp_stream_parser.cc ('k') | remoting/test/access_token_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698