Changeset 157892 in webkit


Ignore:
Timestamp:
Oct 23, 2013 3:26:42 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Adding mock class to test RTCDataChannelHandler
https://bugs.webkit.org/show_bug.cgi?id=123205

Patch by Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> on 2013-10-23
Reviewed by Eric Carlson.

Source/WebCore:

Now RTCPeerConnectionHandler-datachannel LayouTest can run properly.
Also updated the expected file, removing the reliable property check (which was removed in the spec)

Existing tests updated.

  • CMakeLists.txt:
  • platform/mediastream/RTCDataChannelHandlerClient.h:
  • platform/mock/RTCDataChannelHandlerMock.cpp: Added.
  • platform/mock/RTCDataChannelHandlerMock.h: Added.
  • platform/mock/RTCNotifiersMock.cpp:

(WebCore::RemoteDataChannelNotifier::RemoteDataChannelNotifier):
(WebCore::RemoteDataChannelNotifier::fire):
(WebCore::DataChannelStateNotifier::DataChannelStateNotifier):
(WebCore::DataChannelStateNotifier::fire):

  • platform/mock/RTCNotifiersMock.h:
  • platform/mock/RTCPeerConnectionHandlerMock.cpp:

(WebCore::RTCPeerConnectionHandlerMock::createDataChannel):

LayoutTests:

The reliable property was removed in the spec

  • fast/mediastream/RTCPeerConnection-datachannel-expected.txt:
  • fast/mediastream/RTCPeerConnection-datachannel.html:
Location:
trunk
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r157889 r157892  
     12013-10-23  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
     2
     3        Adding mock class to test RTCDataChannelHandler
     4        https://bugs.webkit.org/show_bug.cgi?id=123205
     5
     6        Reviewed by Eric Carlson.
     7
     8        The reliable property was removed in the spec
     9
     10        * fast/mediastream/RTCPeerConnection-datachannel-expected.txt:
     11        * fast/mediastream/RTCPeerConnection-datachannel.html:
     12
    1132013-10-23  Bem Jones-Bey  <bjonesbe@adobe.com>
    214
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel-expected.txt

    r155794 r157892  
    55
    66PASS dc = pc.createDataChannel("label1"); did not throw exception.
    7 PASS dc.reliable is true
    87PASS dc = pc.createDataChannel("label2", {}); did not throw exception.
    9 PASS dc.reliable is true
    108PASS dc = pc.createDataChannel("label3", {ordered:true}); did not throw exception.
    11 PASS dc.reliable is true
    129PASS dc = pc.createDataChannel("label3", {ordered:false}); did not throw exception.
    13 PASS dc.reliable is false
    1410PASS dc = pc.createDataChannel("label3", {maxRetransmits:0}); did not throw exception.
    15 PASS dc.reliable is false
    1611PASS dc = pc.createDataChannel("label3", {maxRetransmitTime:0}); did not throw exception.
    17 PASS dc.reliable is false
    1812PASS pc is connected
    1913PASS dc = pc.createDataChannel("label"); did not throw exception.
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel.html

    r155794 r157892  
    8484pc = new webkitRTCPeerConnection(null, null);
    8585shouldNotThrow('dc = pc.createDataChannel("label1");');
    86 shouldBe("dc.reliable", "true");
    8786shouldNotThrow('dc = pc.createDataChannel("label2", {});');
    88 shouldBe("dc.reliable", "true");
    8987shouldNotThrow('dc = pc.createDataChannel("label3", {ordered:true});');
    90 shouldBe("dc.reliable", "true");
    9188shouldNotThrow('dc = pc.createDataChannel("label3", {ordered:false});');
    92 shouldBe("dc.reliable", "false");
    9389shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmits:0});');
    94 shouldBe("dc.reliable", "false");
    9590shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmitTime:0});');
    96 shouldBe("dc.reliable", "false");
    9791
    9892pc = new webkitRTCPeerConnection(null, null);
  • trunk/Source/WebCore/CMakeLists.txt

    r157869 r157892  
    19971997    platform/mock/GeolocationClientMock.cpp
    19981998    platform/mock/MockMediaStreamCenter.cpp
     1999    platform/mock/RTCDataChannelHandlerMock.cpp
    19992000    platform/mock/RTCNotifiersMock.cpp
    20002001    platform/mock/RTCPeerConnectionHandlerMock.cpp
  • trunk/Source/WebCore/ChangeLog

    r157890 r157892  
     12013-10-23  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
     2
     3        Adding mock class to test RTCDataChannelHandler
     4        https://bugs.webkit.org/show_bug.cgi?id=123205
     5
     6        Reviewed by Eric Carlson.
     7
     8        Now RTCPeerConnectionHandler-datachannel LayouTest can run properly.
     9        Also updated the expected file, removing the reliable property check (which was removed in the spec)
     10
     11        Existing tests updated.
     12
     13        * CMakeLists.txt:
     14        * platform/mediastream/RTCDataChannelHandlerClient.h:
     15        * platform/mock/RTCDataChannelHandlerMock.cpp: Added.
     16        * platform/mock/RTCDataChannelHandlerMock.h: Added.
     17        * platform/mock/RTCNotifiersMock.cpp:
     18        (WebCore::RemoteDataChannelNotifier::RemoteDataChannelNotifier):
     19        (WebCore::RemoteDataChannelNotifier::fire):
     20        (WebCore::DataChannelStateNotifier::DataChannelStateNotifier):
     21        (WebCore::DataChannelStateNotifier::fire):
     22        * platform/mock/RTCNotifiersMock.h:
     23        * platform/mock/RTCPeerConnectionHandlerMock.cpp:
     24        (WebCore::RTCPeerConnectionHandlerMock::createDataChannel):
     25
    1262013-10-23  Andreas Kling  <akling@apple.com>
    227
  • trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h

    r137441 r157892  
    2828#if ENABLE(MEDIA_STREAM)
    2929
     30#include <wtf/text/WTFString.h>
     31
    3032namespace WebCore {
    3133
  • trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp

    r157891 r157892  
    2828#if ENABLE(MEDIA_STREAM)
    2929
     30#include "RTCDataChannelHandlerMock.h"
     31
     32#include "RTCDataChannelHandlerClient.h"
    3033#include "RTCNotifiersMock.h"
    31 
    32 #include "RTCSessionDescriptionDescriptor.h"
    33 #include "RTCSessionDescriptionRequest.h"
    34 #include "RTCVoidRequest.h"
    3534
    3635namespace WebCore {
    3736
    38 SessionRequestNotifier::SessionRequestNotifier(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> descriptor)
    39     : m_request(request)
    40     , m_descriptor(descriptor)
     37RTCDataChannelHandlerMock::RTCDataChannelHandlerMock(const String& label, const RTCDataChannelInit& init)
     38    : m_label(label)
     39    , m_protocol(init.protocol)
     40    , m_maxRetransmitTime(init.maxRetransmitTime)
     41    , m_maxRetransmits(init.maxRetransmits)
     42    , m_id(init.id)
     43    , m_ordered(init.ordered)
     44    , m_negotiated(init.negotiated)
    4145{
    4246}
    4347
    44 void SessionRequestNotifier::fire()
     48void RTCDataChannelHandlerMock::setClient(RTCDataChannelHandlerClient* client)
    4549{
    46     if (m_descriptor)
    47         m_request->requestSucceeded(m_descriptor);
    48     else
    49         m_request->requestFailed("TEST_ERROR");
     50    if (!client)
     51        return;
     52
     53    m_client = client;
     54    RefPtr<DataChannelStateNotifier> notifier = adoptRef(new DataChannelStateNotifier(m_client, RTCDataChannelHandlerClient::ReadyStateOpen));
     55    m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
    5056}
    5157
    52 VoidRequestNotifier::VoidRequestNotifier(PassRefPtr<RTCVoidRequest> request, bool success)
    53     : m_request(request)
    54     , m_success(success)
     58bool RTCDataChannelHandlerMock::sendStringData(const String& string)
    5559{
     60    m_client->didReceiveStringData(string);
     61    return true;
    5662}
    5763
    58 void VoidRequestNotifier::fire()
     64bool RTCDataChannelHandlerMock::sendRawData(const char* data, size_t size)
    5965{
    60     if (m_success)
    61         m_request->requestSucceeded();
    62     else
    63         m_request->requestFailed("TEST_ERROR");
     66    m_client->didReceiveRawData(data, size);
     67    return true;
    6468}
    6569
    66 IceConnectionNotifier::IceConnectionNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::IceConnectionState connectionState, RTCPeerConnectionHandlerClient::IceGatheringState gatheringState)
    67     : m_client(client)
    68     , m_connectionState(connectionState)
    69     , m_gatheringState(gatheringState)
     70void RTCDataChannelHandlerMock::close()
    7071{
    71 }
    72 
    73 void IceConnectionNotifier::fire()
    74 {
    75     m_client->didChangeIceGatheringState(m_gatheringState);
    76     m_client->didChangeIceConnectionState(m_connectionState);
     72    RefPtr<DataChannelStateNotifier> notifier = adoptRef(new DataChannelStateNotifier(m_client, RTCDataChannelHandlerClient::ReadyStateClosed));
     73    m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
    7774}
    7875
  • trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h

    r157891 r157892  
    2424 */
    2525
    26 #ifndef RTCNotifiersMock_h
    27 #define RTCNotifiersMock_h
     26#ifndef RTCDataChannelHandlerMock_h
     27#define RTCDataChannelHandlerMock_h
    2828
    2929#if ENABLE(MEDIA_STREAM)
    3030
    31 #include "RTCPeerConnectionHandlerClient.h"
     31#include "RTCDataChannelHandler.h"
     32#include "RTCPeerConnectionHandler.h"
    3233#include "TimerEventBasedMock.h"
    33 #include <wtf/PassRefPtr.h>
    34 #include <wtf/RefPtr.h>
    3534
    3635namespace WebCore {
    3736
    38 class RTCSessionDescriptionDescriptor;
    39 class RTCSessionDescriptionRequest;
    40 class RTCVoidRequest;
     37class RTCDataChannelHandlerMock FINAL : public RTCDataChannelHandler, public TimerEventBasedMock {
     38public:
     39    RTCDataChannelHandlerMock(const String&, const RTCDataChannelInit&);
     40    virtual ~RTCDataChannelHandlerMock() { }
    4141
    42 class SessionRequestNotifier : public MockNotifier {
    43 public:
    44     SessionRequestNotifier(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>);
     42    virtual void setClient(RTCDataChannelHandlerClient*) OVERRIDE;
    4543
    46     void fire() OVERRIDE;
     44    virtual String label() OVERRIDE { return m_label; }
     45    virtual bool ordered() OVERRIDE { return m_ordered; }
     46    virtual unsigned short maxRetransmitTime() OVERRIDE { return m_maxRetransmitTime; }
     47    virtual unsigned short maxRetransmits() OVERRIDE { return m_maxRetransmits; }
     48    virtual String protocol() OVERRIDE { return m_protocol; }
     49    virtual bool negotiated() OVERRIDE { return m_negotiated; }
     50    virtual unsigned short id() OVERRIDE { return m_id; }
     51    virtual unsigned long bufferedAmount() OVERRIDE { return 0; }
     52
     53    virtual bool sendStringData(const String&) OVERRIDE;
     54    virtual bool sendRawData(const char*, size_t) OVERRIDE;
     55    virtual void close() OVERRIDE;
    4756
    4857private:
    49     RefPtr<RTCSessionDescriptionRequest> m_request;
    50     RefPtr<RTCSessionDescriptionDescriptor> m_descriptor;
    51 };
     58    RTCDataChannelHandlerClient* m_client;
    5259
    53 class VoidRequestNotifier : public MockNotifier {
    54 public:
    55     VoidRequestNotifier(PassRefPtr<RTCVoidRequest>, bool);
    56 
    57     void fire() OVERRIDE;
    58 
    59 private:
    60     RefPtr<RTCVoidRequest> m_request;
    61     bool m_success;
    62 };
    63 
    64 class IceConnectionNotifier : public MockNotifier {
    65 public:
    66     IceConnectionNotifier(RTCPeerConnectionHandlerClient*, RTCPeerConnectionHandlerClient::IceConnectionState, RTCPeerConnectionHandlerClient::IceGatheringState);
    67 
    68     void fire() OVERRIDE;
    69 
    70 private:
    71     RTCPeerConnectionHandlerClient* m_client;
    72     RTCPeerConnectionHandlerClient::IceConnectionState m_connectionState;
    73     RTCPeerConnectionHandlerClient::IceGatheringState m_gatheringState;
     60    String m_label;
     61    String m_protocol;
     62    unsigned short m_maxRetransmitTime;
     63    unsigned short m_maxRetransmits;
     64    unsigned short m_id;
     65    bool m_ordered;
     66    bool m_negotiated;
    7467};
    7568
     
    7871#endif // ENABLE(MEDIA_STREAM)
    7972
    80 #endif // RTCNotifiersMock_h
     73#endif // RTCDataChannelHandlerMock_h
  • trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp

    r157808 r157892  
    3030#include "RTCNotifiersMock.h"
    3131
     32#include "RTCDataChannelHandlerMock.h"
    3233#include "RTCSessionDescriptionDescriptor.h"
    3334#include "RTCSessionDescriptionRequest.h"
     
    7778}
    7879
     80RemoteDataChannelNotifier::RemoteDataChannelNotifier(RTCPeerConnectionHandlerClient* client)
     81    : m_client(client)
     82{
     83}
     84
     85void RemoteDataChannelNotifier::fire()
     86{
     87    m_client->didAddRemoteDataChannel(adoptPtr(new RTCDataChannelHandlerMock("RTCDataChannelHandlerMock", RTCDataChannelInit())));
     88}
     89
     90DataChannelStateNotifier::DataChannelStateNotifier(RTCDataChannelHandlerClient* client, RTCDataChannelHandlerClient::ReadyState state)
     91    : m_client(client)
     92    , m_state(state)
     93{
     94}
     95
     96void DataChannelStateNotifier::fire()
     97{
     98    m_client->didChangeReadyState(m_state);
     99}
     100
    79101} // namespace WebCore
    80102
  • trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h

    r157808 r157892  
    2929#if ENABLE(MEDIA_STREAM)
    3030
     31#include "RTCDataChannelHandlerClient.h"
    3132#include "RTCPeerConnectionHandlerClient.h"
    3233#include "TimerEventBasedMock.h"
     
    7475};
    7576
     77class RemoteDataChannelNotifier : public MockNotifier {
     78public:
     79    RemoteDataChannelNotifier(RTCPeerConnectionHandlerClient*);
     80
     81    void fire() OVERRIDE;
     82
     83private:
     84    RTCPeerConnectionHandlerClient* m_client;
     85};
     86
     87class DataChannelStateNotifier : public MockNotifier {
     88public:
     89    DataChannelStateNotifier(RTCDataChannelHandlerClient*, RTCDataChannelHandlerClient::ReadyState);
     90
     91    void fire() OVERRIDE;
     92
     93private:
     94    RTCDataChannelHandlerClient* m_client;
     95    RTCDataChannelHandlerClient::ReadyState m_state;
     96};
     97
    7698} // namespace WebCore
    7799
  • trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp

    r157808 r157892  
    3333#include "RTCDTMFSenderHandler.h"
    3434#include "RTCDataChannelHandler.h"
     35#include "RTCDataChannelHandlerMock.h"
    3536#include "RTCNotifiersMock.h"
    3637#include "RTCSessionDescriptionRequest.h"
     
    153154}
    154155
    155 PassOwnPtr<RTCDataChannelHandler> RTCPeerConnectionHandlerMock::createDataChannel(const String&, const RTCDataChannelInit&)
     156PassOwnPtr<RTCDataChannelHandler> RTCPeerConnectionHandlerMock::createDataChannel(const String& label, const RTCDataChannelInit& init)
    156157{
    157     // Requires a mock implementation of RTCDataChannelHandler.
    158     // This must be implemented once the mock implementation of RTCDataChannelHandler is ready.
    159     notImplemented();
    160     return 0;
     158    RefPtr<RemoteDataChannelNotifier> notifier = adoptRef(new RemoteDataChannelNotifier(m_client));
     159    m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
     160    return adoptPtr(new RTCDataChannelHandlerMock(label, init));
    161161}
    162162
Note: See TracChangeset for help on using the changeset viewer.