media/webrtc/signaling/test/FakePCObserver.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/signaling/test/FakePCObserver.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,105 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef TEST_PCOBSERVER_H_
     1.9 +#define TEST_PCOBSERVER_H_
    1.10 +
    1.11 +#include "nsNetCID.h"
    1.12 +#include "nsITimer.h"
    1.13 +#include "nsComponentManagerUtils.h"
    1.14 +#include "nsIComponentManager.h"
    1.15 +#include "nsIComponentRegistrar.h"
    1.16 +
    1.17 +#include "mozilla/Mutex.h"
    1.18 +#include "AudioSegment.h"
    1.19 +#include "MediaSegment.h"
    1.20 +#include "StreamBuffer.h"
    1.21 +#include "nsTArray.h"
    1.22 +#include "nsIRunnable.h"
    1.23 +#include "nsISupportsImpl.h"
    1.24 +#include "nsIDOMMediaStream.h"
    1.25 +#include "mozilla/dom/PeerConnectionObserverEnumsBinding.h"
    1.26 +#include "PeerConnectionImpl.h"
    1.27 +#include "nsWeakReference.h"
    1.28 +
    1.29 +namespace sipcc {
    1.30 +class PeerConnectionImpl;
    1.31 +}
    1.32 +
    1.33 +class nsIDOMWindow;
    1.34 +class nsIDOMDataChannel;
    1.35 +
    1.36 +namespace test {
    1.37 +
    1.38 +class AFakePCObserver : public nsSupportsWeakReference
    1.39 +{
    1.40 +protected:
    1.41 +  typedef mozilla::ErrorResult ER;
    1.42 +public:
    1.43 +  enum Action {
    1.44 +    OFFER,
    1.45 +    ANSWER
    1.46 +  };
    1.47 +
    1.48 +  enum ResponseState {
    1.49 +    stateNoResponse,
    1.50 +    stateSuccess,
    1.51 +    stateError
    1.52 +  };
    1.53 +
    1.54 +  AFakePCObserver(sipcc::PeerConnectionImpl *peerConnection,
    1.55 +                  const std::string &aName) :
    1.56 +    state(stateNoResponse), addIceSuccessCount(0),
    1.57 +    onAddStreamCalled(false),
    1.58 +    name(aName),
    1.59 +    pc(peerConnection) {
    1.60 +  }
    1.61 +
    1.62 +  virtual ~AFakePCObserver() {}
    1.63 +
    1.64 +  std::vector<mozilla::DOMMediaStream *> GetStreams() { return streams; }
    1.65 +
    1.66 +  ResponseState state;
    1.67 +  char *lastString;
    1.68 +  sipcc::PeerConnectionImpl::Error lastStatusCode;
    1.69 +  mozilla::dom::PCObserverStateType lastStateType;
    1.70 +  int addIceSuccessCount;
    1.71 +  bool onAddStreamCalled;
    1.72 +  std::string name;
    1.73 +  std::vector<std::string> candidates;
    1.74 +
    1.75 +  virtual NS_IMETHODIMP OnCreateOfferSuccess(const char* offer, ER&) = 0;
    1.76 +  virtual NS_IMETHODIMP OnCreateOfferError(uint32_t code, const char *msg, ER&) = 0;
    1.77 +  virtual NS_IMETHODIMP OnCreateAnswerSuccess(const char* answer, ER&) = 0;
    1.78 +  virtual NS_IMETHODIMP OnCreateAnswerError(uint32_t code, const char *msg, ER&) = 0;
    1.79 +  virtual NS_IMETHODIMP OnSetLocalDescriptionSuccess(ER&) = 0;
    1.80 +  virtual NS_IMETHODIMP OnSetRemoteDescriptionSuccess(ER&) = 0;
    1.81 +  virtual NS_IMETHODIMP OnSetLocalDescriptionError(uint32_t code, const char *msg, ER&) = 0;
    1.82 +  virtual NS_IMETHODIMP OnSetRemoteDescriptionError(uint32_t code, const char *msg, ER&) = 0;
    1.83 +  virtual NS_IMETHODIMP NotifyConnection(ER&) = 0;
    1.84 +  virtual NS_IMETHODIMP NotifyClosedConnection(ER&) = 0;
    1.85 +  virtual NS_IMETHODIMP NotifyDataChannel(nsIDOMDataChannel *channel, ER&) = 0;
    1.86 +  virtual NS_IMETHODIMP OnStateChange(mozilla::dom::PCObserverStateType state_type, ER&,
    1.87 +                                      void* = nullptr) = 0;
    1.88 +  virtual NS_IMETHODIMP OnAddStream(nsIDOMMediaStream *stream, ER&) = 0;
    1.89 +  virtual NS_IMETHODIMP OnRemoveStream(ER&) = 0;
    1.90 +  virtual NS_IMETHODIMP OnAddTrack(ER&) = 0;
    1.91 +  virtual NS_IMETHODIMP OnRemoveTrack(ER&) = 0;
    1.92 +  virtual NS_IMETHODIMP OnAddIceCandidateSuccess(ER&) = 0;
    1.93 +  virtual NS_IMETHODIMP OnAddIceCandidateError(uint32_t code, const char *msg, ER&) = 0;
    1.94 +  virtual NS_IMETHODIMP OnIceCandidate(uint16_t level, const char *mid,
    1.95 +                                       const char *candidate, ER&) = 0;
    1.96 +protected:
    1.97 +  sipcc::PeerConnectionImpl *pc;
    1.98 +  std::vector<mozilla::DOMMediaStream *> streams;
    1.99 +};
   1.100 +}
   1.101 +
   1.102 +namespace mozilla {
   1.103 +namespace dom {
   1.104 +typedef test::AFakePCObserver PeerConnectionObserver;
   1.105 +}
   1.106 +}
   1.107 +
   1.108 +#endif

mercurial