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

Unified Diff: third_party/libjingle_xmpp/xmpp/fakexmppclient.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libjingle_xmpp/xmpp/constants.cc ('k') | third_party/libjingle_xmpp/xmpp/jid.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libjingle_xmpp/xmpp/fakexmppclient.h
diff --git a/third_party/libjingle_xmpp/xmpp/fakexmppclient.h b/third_party/libjingle_xmpp/xmpp/fakexmppclient.h
new file mode 100644
index 0000000000000000000000000000000000000000..988fbe3e883c9f45e02b3a2ed08431cca973ef39
--- /dev/null
+++ b/third_party/libjingle_xmpp/xmpp/fakexmppclient.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2011 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+// A fake XmppClient for use in unit tests.
+
+#ifndef WEBRTC_LIBJINGLE_XMPP_FAKEXMPPCLIENT_H_
+#define WEBRTC_LIBJINGLE_XMPP_FAKEXMPPCLIENT_H_
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#include "third_party/libjingle_xmpp/xmpp/xmpptask.h"
+
+namespace buzz {
+
+class XmlElement;
+
+class FakeXmppClient : public XmppTaskParentInterface,
+ public XmppClientInterface {
+ public:
+ explicit FakeXmppClient(rtc::TaskParent* parent)
+ : XmppTaskParentInterface(parent) {
+ }
+
+ // As XmppTaskParentInterface
+ virtual XmppClientInterface* GetClient() {
+ return this;
+ }
+
+ virtual int ProcessStart() {
+ return STATE_RESPONSE;
+ }
+
+ // As XmppClientInterface
+ virtual XmppEngine::State GetState() const {
+ return XmppEngine::STATE_OPEN;
+ }
+
+ virtual const Jid& jid() const {
+ return jid_;
+ }
+
+ virtual std::string NextId() {
+ // Implement if needed for tests.
+ return "0";
+ }
+
+ virtual XmppReturnStatus SendStanza(const XmlElement* stanza) {
+ sent_stanzas_.push_back(stanza);
+ return XMPP_RETURN_OK;
+ }
+
+ const std::vector<const XmlElement*>& sent_stanzas() {
+ return sent_stanzas_;
+ }
+
+ virtual XmppReturnStatus SendStanzaError(
+ const XmlElement * pelOriginal,
+ XmppStanzaError code,
+ const std::string & text) {
+ // Implement if needed for tests.
+ return XMPP_RETURN_OK;
+ }
+
+ virtual void AddXmppTask(XmppTask* task,
+ XmppEngine::HandlerLevel level) {
+ tasks_.push_back(task);
+ }
+
+ virtual void RemoveXmppTask(XmppTask* task) {
+ std::remove(tasks_.begin(), tasks_.end(), task);
+ }
+
+ // As FakeXmppClient
+ void set_jid(const Jid& jid) {
+ jid_ = jid;
+ }
+
+ // Takes ownership of stanza.
+ void HandleStanza(XmlElement* stanza) {
+ for (std::vector<XmppTask*>::iterator task = tasks_.begin();
+ task != tasks_.end(); ++task) {
+ if ((*task)->HandleStanza(stanza)) {
+ delete stanza;
+ return;
+ }
+ }
+ delete stanza;
+ }
+
+ private:
+ Jid jid_;
+ std::vector<XmppTask*> tasks_;
+ std::vector<const XmlElement*> sent_stanzas_;
+};
+
+} // namespace buzz
+
+#endif // WEBRTC_LIBJINGLE_XMPP_FAKEXMPPCLIENT_H_
« no previous file with comments | « third_party/libjingle_xmpp/xmpp/constants.cc ('k') | third_party/libjingle_xmpp/xmpp/jid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698