michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef TEST_PCOBSERVER_H_ michael@0: #define TEST_PCOBSERVER_H_ michael@0: michael@0: #include "nsNetCID.h" michael@0: #include "nsITimer.h" michael@0: #include "nsComponentManagerUtils.h" michael@0: #include "nsIComponentManager.h" michael@0: #include "nsIComponentRegistrar.h" michael@0: michael@0: #include "mozilla/Mutex.h" michael@0: #include "AudioSegment.h" michael@0: #include "MediaSegment.h" michael@0: #include "StreamBuffer.h" michael@0: #include "nsTArray.h" michael@0: #include "nsIRunnable.h" michael@0: #include "nsISupportsImpl.h" michael@0: #include "nsIDOMMediaStream.h" michael@0: #include "mozilla/dom/PeerConnectionObserverEnumsBinding.h" michael@0: #include "PeerConnectionImpl.h" michael@0: #include "nsWeakReference.h" michael@0: michael@0: namespace sipcc { michael@0: class PeerConnectionImpl; michael@0: } michael@0: michael@0: class nsIDOMWindow; michael@0: class nsIDOMDataChannel; michael@0: michael@0: namespace test { michael@0: michael@0: class AFakePCObserver : public nsSupportsWeakReference michael@0: { michael@0: protected: michael@0: typedef mozilla::ErrorResult ER; michael@0: public: michael@0: enum Action { michael@0: OFFER, michael@0: ANSWER michael@0: }; michael@0: michael@0: enum ResponseState { michael@0: stateNoResponse, michael@0: stateSuccess, michael@0: stateError michael@0: }; michael@0: michael@0: AFakePCObserver(sipcc::PeerConnectionImpl *peerConnection, michael@0: const std::string &aName) : michael@0: state(stateNoResponse), addIceSuccessCount(0), michael@0: onAddStreamCalled(false), michael@0: name(aName), michael@0: pc(peerConnection) { michael@0: } michael@0: michael@0: virtual ~AFakePCObserver() {} michael@0: michael@0: std::vector GetStreams() { return streams; } michael@0: michael@0: ResponseState state; michael@0: char *lastString; michael@0: sipcc::PeerConnectionImpl::Error lastStatusCode; michael@0: mozilla::dom::PCObserverStateType lastStateType; michael@0: int addIceSuccessCount; michael@0: bool onAddStreamCalled; michael@0: std::string name; michael@0: std::vector candidates; michael@0: michael@0: virtual NS_IMETHODIMP OnCreateOfferSuccess(const char* offer, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnCreateOfferError(uint32_t code, const char *msg, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnCreateAnswerSuccess(const char* answer, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnCreateAnswerError(uint32_t code, const char *msg, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnSetLocalDescriptionSuccess(ER&) = 0; michael@0: virtual NS_IMETHODIMP OnSetRemoteDescriptionSuccess(ER&) = 0; michael@0: virtual NS_IMETHODIMP OnSetLocalDescriptionError(uint32_t code, const char *msg, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnSetRemoteDescriptionError(uint32_t code, const char *msg, ER&) = 0; michael@0: virtual NS_IMETHODIMP NotifyConnection(ER&) = 0; michael@0: virtual NS_IMETHODIMP NotifyClosedConnection(ER&) = 0; michael@0: virtual NS_IMETHODIMP NotifyDataChannel(nsIDOMDataChannel *channel, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnStateChange(mozilla::dom::PCObserverStateType state_type, ER&, michael@0: void* = nullptr) = 0; michael@0: virtual NS_IMETHODIMP OnAddStream(nsIDOMMediaStream *stream, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnRemoveStream(ER&) = 0; michael@0: virtual NS_IMETHODIMP OnAddTrack(ER&) = 0; michael@0: virtual NS_IMETHODIMP OnRemoveTrack(ER&) = 0; michael@0: virtual NS_IMETHODIMP OnAddIceCandidateSuccess(ER&) = 0; michael@0: virtual NS_IMETHODIMP OnAddIceCandidateError(uint32_t code, const char *msg, ER&) = 0; michael@0: virtual NS_IMETHODIMP OnIceCandidate(uint16_t level, const char *mid, michael@0: const char *candidate, ER&) = 0; michael@0: protected: michael@0: sipcc::PeerConnectionImpl *pc; michael@0: std::vector streams; michael@0: }; michael@0: } michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: typedef test::AFakePCObserver PeerConnectionObserver; michael@0: } michael@0: } michael@0: michael@0: #endif