OLD | NEW |
(Empty) | |
| 1 // Copyright 2004 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBRTC_LIBJINGLE_XMPP_UTIL_UNITTEST_H_ |
| 6 #define WEBRTC_LIBJINGLE_XMPP_UTIL_UNITTEST_H_ |
| 7 |
| 8 #include <sstream> |
| 9 #include <string> |
| 10 #include "third_party/libjingle_xmpp/xmpp/xmppengine.h" |
| 11 |
| 12 namespace buzz { |
| 13 |
| 14 // This class captures callbacks from engine. |
| 15 class XmppTestHandler : public XmppOutputHandler, public XmppSessionHandler, |
| 16 public XmppStanzaHandler { |
| 17 public: |
| 18 explicit XmppTestHandler(XmppEngine* engine) : engine_(engine) {} |
| 19 virtual ~XmppTestHandler() {} |
| 20 |
| 21 void SetEngine(XmppEngine* engine); |
| 22 |
| 23 // Output handler |
| 24 virtual void WriteOutput(const char * bytes, size_t len); |
| 25 virtual void StartTls(const std::string & cname); |
| 26 virtual void CloseConnection(); |
| 27 |
| 28 // Session handler |
| 29 virtual void OnStateChange(int state); |
| 30 |
| 31 // Stanza handler |
| 32 virtual bool HandleStanza(const XmlElement* stanza); |
| 33 |
| 34 std::string OutputActivity(); |
| 35 std::string SessionActivity(); |
| 36 std::string StanzaActivity(); |
| 37 |
| 38 private: |
| 39 XmppEngine* engine_; |
| 40 std::stringstream output_; |
| 41 std::stringstream session_; |
| 42 std::stringstream stanza_; |
| 43 }; |
| 44 |
| 45 } // namespace buzz |
| 46 |
| 47 inline std::ostream& operator<<(std::ostream& os, const buzz::Jid& jid) { |
| 48 os << jid.Str(); |
| 49 return os; |
| 50 } |
| 51 |
| 52 #endif // WEBRTC_LIBJINGLE_XMPP_UTIL_UNITTEST_H_ |
OLD | NEW |