[Webkit-unassigned] [Bug 122848] Adding Mock class to test RTCPeerConnection

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Oct 16 22:25:35 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=122848





--- Comment #2 from Eric Carlson <eric.carlson at apple.com>  2013-10-16 22:24:20 PST ---
(From update of attachment 214287)
View in context: https://bugs.webkit.org/attachment.cgi?id=214287&action=review

> Source/WebCore/ChangeLog:44
> +        (WebCore::RTCPeerConnectionHandlerMock::create):
> +        (WebCore::RTCPeerConnectionHandlerMock::RTCPeerConnectionHandlerMock):
> +        (WebCore::RTCPeerConnectionHandlerMock::initialize):
> +        (WebCore::RTCPeerConnectionHandlerMock::createOffer):
> +        (WebCore::RTCPeerConnectionHandlerMock::createAnswer):
> +        (WebCore::RTCPeerConnectionHandlerMock::setLocalDescription):
> +        (WebCore::RTCPeerConnectionHandlerMock::setRemoteDescription):
> +        (WebCore::RTCPeerConnectionHandlerMock::localDescription):
> +        (WebCore::RTCPeerConnectionHandlerMock::remoteDescription):
> +        (WebCore::RTCPeerConnectionHandlerMock::updateIce):
> +        (WebCore::RTCPeerConnectionHandlerMock::addIceCandidate):
> +        (WebCore::RTCPeerConnectionHandlerMock::addStream):
> +        (WebCore::RTCPeerConnectionHandlerMock::removeStream):
> +        (WebCore::RTCPeerConnectionHandlerMock::getStats):
> +        (WebCore::RTCPeerConnectionHandlerMock::createDataChannel):
> +        (WebCore::RTCPeerConnectionHandlerMock::createDTMFSender):
> +        (WebCore::RTCPeerConnectionHandlerMock::stop):

Nit: these un-commented method names for the newly added file are unnecessary.

> Source/WebCore/ChangeLog:57
> +        (WebCore::RequestNotifier::~RequestNotifier):
> +        (WebCore::SessionRequestNotifier::SessionRequestNotifier):
> +        (WebCore::SessionRequestNotifier::fire):
> +        (WebCore::VoidRequestNotifier::VoidRequestNotifier):
> +        (WebCore::VoidRequestNotifier::fire):
> +        (WebCore::IceConnectionNotifier::IceConnectionNotifier):
> +        (WebCore::IceConnectionNotifier::fire):
> +        (WebCore::RTCPeerConnectionHandlerMock::~RTCPeerConnectionHandlerMock):
> +        (WebCore::RTCPeerConnectionHandlerMock::removeEventFromVector):
> +        (WebCore::TimerEvent::TimerEvent):
> +        (WebCore::TimerEvent::~TimerEvent):
> +        (WebCore::TimerEvent::timerFired):

Ditto.

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:2
> + *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).

Is this correct?

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:48
> +bool RTCPeerConnectionHandlerMock::initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints> constraints)

"constraints" is unused. The parameter name should be omitted and you should have a FIXME with a bug number about adding support.

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:67
> +void RTCPeerConnectionHandlerMock::createAnswer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<MediaConstraints> constraints)

Ditto.

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:120
> +bool RTCPeerConnectionHandlerMock::addIceCandidate(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCIceCandidateDescriptor> iceDescriptor)

"iceDescriptor" is unused, you should omit the name.

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:127
> +bool RTCPeerConnectionHandlerMock::addStream(PassRefPtr<MediaStreamDescriptor>, PassRefPtr<MediaConstraints>)

FIXME about adding support for constraints?

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:142
> +void RTCPeerConnectionHandlerMock::getStats(PassRefPtr<RTCStatsRequest>)
> +{
> +}

FIXME?

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp:152
> +PassOwnPtr<RTCDTMFSenderHandler> RTCPeerConnectionHandlerMock::createDTMFSender(PassRefPtr<MediaStreamSource>)
> +{
> +    return 0;
> +}

Ditto.

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h:2
> + *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).

Is this correct?

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h:106
> +class RequestNotifier : public RefCounted<RequestNotifier> {
> +public:
> +    virtual ~RequestNotifier() { }
> +    virtual void fire() = 0;
> +};
> +
> +class SessionRequestNotifier : public RequestNotifier {
> +public:
> +    SessionRequestNotifier(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor)
> +        : m_request(request)
> +        , m_descriptor(descriptor)
> +    { }
> +
> +    void fire()
> +    {
> +        if (m_descriptor)
> +            m_request->requestSucceeded(m_descriptor);
> +        else
> +            m_request->requestFailed("TEST_ERROR");
> +    }
> +
> +private:
> +    RefPtr<RTCSessionDescriptionRequest> m_request;
> +    RefPtr<RTCSessionDescriptionDescriptor> m_descriptor;
> +};
> +
> +class VoidRequestNotifier : public RequestNotifier {
> +public:
> +    VoidRequestNotifier(PassRefPtr<RTCVoidRequest> request, bool success)
> +        : m_request(request)
> +        , m_success(success)
> +    { }
> +
> +    void fire()
> +    {
> +        if (m_success)
> +            m_request->requestSucceeded();
> +        else
> +            m_request->requestFailed("TEST_ERROR");
> +    }
> +
> +private:
> +    RefPtr<RTCVoidRequest> m_request;
> +    bool m_success;
> +};
> +
> +class IceConnectionNotifier : public RequestNotifier {
> +public:
> +    IceConnectionNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::IceConnectionState connectionState, RTCPeerConnectionHandlerClient::IceGatheringState gatheringState)
> +        : m_client(client)
> +        , m_connectionState(connectionState)
> +        , m_gatheringState(gatheringState)
> +    { }
> +
> +    void fire()
> +    {
> +        m_client->didChangeIceGatheringState(m_gatheringState);
> +        m_client->didChangeIceConnectionState(m_connectionState);
> +    }
> +
> +private:
> +    RTCPeerConnectionHandlerClient* m_client;
> +    RTCPeerConnectionHandlerClient::IceConnectionState m_connectionState;
> +    RTCPeerConnectionHandlerClient::IceGatheringState m_gatheringState;
> +};

Do these need to be in the header file?

> Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h:168
> +struct TimerEvent : public RefCounted<TimerEvent> {
> +    TimerEvent(RTCPeerConnectionHandlerMock* mock, PassRefPtr<RequestNotifier> notifier)
> +        : m_mock(mock)
> +        , m_timer(this, &TimerEvent::timerFired)
> +        , m_notifier(notifier)
> +    {
> +        m_timer.startOneShot(0.5);
> +    }
> +
> +    virtual ~TimerEvent() { }
> +
> +    void timerFired(Timer<TimerEvent>*)
> +    {
> +        m_notifier->fire();
> +        m_mock->removeEventFromVector(this);
> +    }
> +
> +    RTCPeerConnectionHandlerMock* m_mock;
> +    Timer<TimerEvent> m_timer;
> +    RefPtr<RequestNotifier> m_notifier;
> +};

Ditto.

> Source/WebCore/testing/Internals.cpp:654
> +    RTCPeerConnectionHandler::create = RTCPeerConnectionHandlerMock::create;

Clever!

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list