Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / libjingle / xmpp / util_unittest.h
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 #ifndef WEBRTC_LIBJINGLE_XMPP_UTIL_UNITTEST_H_
12 #define WEBRTC_LIBJINGLE_XMPP_UTIL_UNITTEST_H_
13
14 #include <sstream>
15 #include <string>
16 #include "webrtc/libjingle/xmpp/xmppengine.h"
17
18 namespace buzz {
19
20 // This class captures callbacks from engine.
21 class XmppTestHandler : public XmppOutputHandler,  public XmppSessionHandler,
22                         public XmppStanzaHandler {
23  public:
24   explicit XmppTestHandler(XmppEngine* engine) : engine_(engine) {}
25   virtual ~XmppTestHandler() {}
26
27   void SetEngine(XmppEngine* engine);
28
29   // Output handler
30   virtual void WriteOutput(const char * bytes, size_t len);
31   virtual void StartTls(const std::string & cname);
32   virtual void CloseConnection();
33
34   // Session handler
35   virtual void OnStateChange(int state);
36
37   // Stanza handler
38   virtual bool HandleStanza(const XmlElement* stanza);
39
40   std::string OutputActivity();
41   std::string SessionActivity();
42   std::string StanzaActivity();
43
44  private:
45   XmppEngine* engine_;
46   std::stringstream output_;
47   std::stringstream session_;
48   std::stringstream stanza_;
49 };
50
51 }  // namespace buzz
52
53 inline std::ostream& operator<<(std::ostream& os, const buzz::Jid& jid) {
54   os << jid.Str();
55   return os;
56 }
57
58 #endif  // WEBRTC_LIBJINGLE_XMPP_UTIL_UNITTEST_H_