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

Side by Side Diff: third_party/libjingle_xmpp/xmpp/util_unittest.cc

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Explicitly use webrtc_overrides/webrtc/base/logging.h Created 3 years, 11 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <iostream>
12 #include <sstream>
13 #include <string>
14 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
15 #include "third_party/libjingle_xmpp/xmpp/util_unittest.h"
16 #include "third_party/libjingle_xmpp/xmpp/xmppengine.h"
17 #include "third_party/webrtc/base/gunit.h"
18
19 namespace buzz {
20
21 void XmppTestHandler::WriteOutput(const char * bytes, size_t len) {
22 output_ << std::string(bytes, len);
23 }
24
25 void XmppTestHandler::StartTls(const std::string & cname) {
26 output_ << "[START-TLS " << cname << "]";
27 }
28
29 void XmppTestHandler::CloseConnection() {
30 output_ << "[CLOSED]";
31 }
32
33 void XmppTestHandler::OnStateChange(int state) {
34 switch (static_cast<XmppEngine::State>(state)) {
35 case XmppEngine::STATE_START:
36 session_ << "[START]";
37 break;
38 case XmppEngine::STATE_OPENING:
39 session_ << "[OPENING]";
40 break;
41 case XmppEngine::STATE_OPEN:
42 session_ << "[OPEN]";
43 break;
44 case XmppEngine::STATE_CLOSED:
45 session_ << "[CLOSED]";
46 switch (engine_->GetError(NULL)) {
47 case XmppEngine::ERROR_NONE:
48 // do nothing
49 break;
50 case XmppEngine::ERROR_XML:
51 session_ << "[ERROR-XML]";
52 break;
53 case XmppEngine::ERROR_STREAM:
54 session_ << "[ERROR-STREAM]";
55 break;
56 case XmppEngine::ERROR_VERSION:
57 session_ << "[ERROR-VERSION]";
58 break;
59 case XmppEngine::ERROR_UNAUTHORIZED:
60 session_ << "[ERROR-UNAUTHORIZED]";
61 break;
62 case XmppEngine::ERROR_TLS:
63 session_ << "[ERROR-TLS]";
64 break;
65 case XmppEngine::ERROR_AUTH:
66 session_ << "[ERROR-AUTH]";
67 break;
68 case XmppEngine::ERROR_BIND:
69 session_ << "[ERROR-BIND]";
70 break;
71 case XmppEngine::ERROR_CONNECTION_CLOSED:
72 session_ << "[ERROR-CONNECTION-CLOSED]";
73 break;
74 case XmppEngine::ERROR_DOCUMENT_CLOSED:
75 session_ << "[ERROR-DOCUMENT-CLOSED]";
76 break;
77 default:
78 break;
79 }
80 break;
81 default:
82 break;
83 }
84 }
85
86 bool XmppTestHandler::HandleStanza(const XmlElement * stanza) {
87 stanza_ << stanza->Str();
88 return true;
89 }
90
91 std::string XmppTestHandler::OutputActivity() {
92 std::string result = output_.str();
93 output_.str("");
94 return result;
95 }
96
97 std::string XmppTestHandler::SessionActivity() {
98 std::string result = session_.str();
99 session_.str("");
100 return result;
101 }
102
103 std::string XmppTestHandler::StanzaActivity() {
104 std::string result = stanza_.str();
105 stanza_.str("");
106 return result;
107 }
108
109 } // namespace buzz
OLDNEW
« no previous file with comments | « third_party/libjingle_xmpp/xmpp/util_unittest.h ('k') | third_party/libjingle_xmpp/xmpp/xmppclient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698