Changeset 157808 in webkit


Ignore:
Timestamp:
Oct 22, 2013 1:18:36 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Adding Mock class to test RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=122848

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

The following tests can be run:

RTCPeerConnection-createAnswer.html
RTCPeerConnection-createOffer.html
RTCPeerConnection-ice.html
RTCPeerConnection-localDescription.html
RTCPeerConnection-remoteDescription.html
RTCPeerConnection-state.html

Tests that require a MediaStream object, by invoking getUserMedia,
are not ready to run yet.

No new tests needed.

  • CMakeLists.txt:
  • platform/mediastream/RTCPeerConnectionHandler.cpp:

(WebCore::createHandler):

  • platform/mediastream/RTCPeerConnectionHandler.h:
  • platform/mediastream/RTCPeerConnectionHandlerClient.h:
  • platform/mock/RTCNotifiersMock.cpp: Added.
  • platform/mock/RTCNotifiersMock.h: Added.
  • platform/mock/RTCPeerConnectionHandlerMock.cpp: Added.
  • platform/mock/RTCPeerConnectionHandlerMock.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.
  • platform/mock/TimerEventBasedMock.h: Added.
  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore::Internals::enableMockRTCPeerConnectionHandler):

  • testing/Internals.h:
Location:
trunk/Source/WebCore
Files:
4 added
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r157766 r157808  
    19971997    platform/mock/GeolocationClientMock.cpp
    19981998    platform/mock/MockMediaStreamCenter.cpp
     1999    platform/mock/RTCNotifiersMock.cpp
     2000    platform/mock/RTCPeerConnectionHandlerMock.cpp
    19992001    platform/mock/ScrollbarThemeMock.cpp
    20002002
  • trunk/Source/WebCore/ChangeLog

    r157807 r157808  
     12013-10-22  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
     2
     3        Adding Mock class to test RTCPeerConnection
     4        https://bugs.webkit.org/show_bug.cgi?id=122848
     5
     6        Reviewed by Eric Carlson.
     7
     8        The following tests can be run:
     9
     10            RTCPeerConnection-createAnswer.html
     11            RTCPeerConnection-createOffer.html
     12            RTCPeerConnection-ice.html
     13            RTCPeerConnection-localDescription.html
     14            RTCPeerConnection-remoteDescription.html
     15            RTCPeerConnection-state.html
     16
     17        Tests that require a MediaStream object, by invoking getUserMedia,
     18        are not ready to run yet.
     19
     20        No new tests needed.
     21
     22        * CMakeLists.txt:
     23        * platform/mediastream/RTCPeerConnectionHandler.cpp:
     24        (WebCore::createHandler):
     25        * platform/mediastream/RTCPeerConnectionHandler.h:
     26        * platform/mediastream/RTCPeerConnectionHandlerClient.h:
     27        * platform/mock/RTCNotifiersMock.cpp: Added.
     28        * platform/mock/RTCNotifiersMock.h: Added.
     29        * platform/mock/RTCPeerConnectionHandlerMock.cpp: Added.
     30        * platform/mock/RTCPeerConnectionHandlerMock.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.
     31        * platform/mock/TimerEventBasedMock.h: Added.
     32        * testing/Internals.cpp:
     33        (WebCore::Internals::Internals):
     34        (WebCore::Internals::enableMockRTCPeerConnectionHandler):
     35        * testing/Internals.h:
     36
    1372013-10-22  Zan Dobersek  <zdobersek@igalia.com>
    238
  • trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp

    r137441 r157808  
    4040class RTCPeerConnectionHandlerClient;
    4141
    42 PassOwnPtr<RTCPeerConnectionHandler> RTCPeerConnectionHandler::create(RTCPeerConnectionHandlerClient*)
     42static PassOwnPtr<RTCPeerConnectionHandler> createHandler(RTCPeerConnectionHandlerClient*)
    4343{
    4444    return nullptr;
    4545}
    4646
     47CreatePeerConnectionHandler RTCPeerConnectionHandler::create = createHandler;
     48
    4749} // namespace WebCore
    4850
  • trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h

    r156473 r157808  
    4646class RTCDataChannelHandler;
    4747class RTCIceCandidateDescriptor;
     48class RTCPeerConnectionHandler;
    4849class RTCPeerConnectionHandlerClient;
    4950class RTCSessionDescriptionDescriptor;
     
    6869};
    6970
     71typedef PassOwnPtr<RTCPeerConnectionHandler> (*CreatePeerConnectionHandler)(RTCPeerConnectionHandlerClient*);
     72
    7073class RTCPeerConnectionHandler {
    7174public:
    72     static PassOwnPtr<RTCPeerConnectionHandler> create(RTCPeerConnectionHandlerClient*);
     75    static CreatePeerConnectionHandler create;
    7376    virtual ~RTCPeerConnectionHandler() { }
    7477
  • trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h

    r146582 r157808  
    3434#if ENABLE(MEDIA_STREAM)
    3535
     36#include <wtf/PassOwnPtr.h>
    3637#include <wtf/PassRefPtr.h>
    3738
  • trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h

    r157807 r157808  
    11/*
    2  * Copyright (C) 2012 Google Inc. All rights reserved.
     2 *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions
    66 * are met:
    7  *
    87 * 1. Redistributions of source code must retain the above copyright
    98 *    notice, this list of conditions and the following disclaimer.
    109 * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer
    12  *    in the documentation and/or other materials provided with the
    13  *    distribution.
    14  * 3. Neither the name of Google Inc. nor the names of its contributors
    15  *    may be used to endorse or promote products derived from this
    16  *    software without specific prior written permission.
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
    1712 *
    1813 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     
    2924 */
    3025
    31 #ifndef RTCPeerConnectionHandler_h
    32 #define RTCPeerConnectionHandler_h
     26#ifndef RTCPeerConnectionHandlerMock_h
     27#define RTCPeerConnectionHandlerMock_h
    3328
    3429#if ENABLE(MEDIA_STREAM)
    3530
    36 #include "MediaStreamDescriptor.h"
    37 #include <wtf/PassOwnPtr.h>
    38 #include <wtf/PassRefPtr.h>
     31#include "RTCPeerConnectionHandler.h"
     32#include "RTCSessionDescriptionDescriptor.h"
     33#include "TimerEventBasedMock.h"
    3934
    4035namespace WebCore {
    4136
    42 class MediaConstraints;
    43 class MediaStreamSource;
    44 class RTCConfiguration;
    45 class RTCDTMFSenderHandler;
    46 class RTCDataChannelHandler;
    47 class RTCIceCandidateDescriptor;
    48 class RTCPeerConnectionHandlerClient;
    49 class RTCSessionDescriptionDescriptor;
    50 class RTCSessionDescriptionRequest;
    51 class RTCStatsRequest;
    52 class RTCVoidRequest;
    53 
    54 struct RTCDataChannelInit {
    55 public:
    56     RTCDataChannelInit()
    57         : ordered(true)
    58         , maxRetransmitTime(-1)
    59         , maxRetransmits(-1)
    60         , negotiated(false)
    61         , id(-1) { }
    62     bool ordered;
    63     int maxRetransmitTime;
    64     int maxRetransmits;
    65     String protocol;
    66     bool negotiated;
    67     int id;
    68 };
    69 
    70 class RTCPeerConnectionHandler {
     37class RTCPeerConnectionHandlerMock FINAL : public RTCPeerConnectionHandler, public TimerEventBasedMock {
    7138public:
    7239    static PassOwnPtr<RTCPeerConnectionHandler> create(RTCPeerConnectionHandlerClient*);
    73     virtual ~RTCPeerConnectionHandler() { }
     40    virtual ~RTCPeerConnectionHandlerMock() { }
    7441
    75     virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) = 0;
     42    virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE;
    7643
    77     virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) = 0;
    78     virtual void createAnswer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) = 0;
    79     virtual void setLocalDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) = 0;
    80     virtual void setRemoteDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) = 0;
    81     virtual PassRefPtr<RTCSessionDescriptionDescriptor> localDescription() = 0;
    82     virtual PassRefPtr<RTCSessionDescriptionDescriptor> remoteDescription() = 0;
    83     virtual bool updateIce(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) = 0;
    84     virtual bool addIceCandidate(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCIceCandidateDescriptor>) = 0;
    85     virtual bool addStream(PassRefPtr<MediaStreamDescriptor>, PassRefPtr<MediaConstraints>) = 0;
    86     virtual void removeStream(PassRefPtr<MediaStreamDescriptor>) = 0;
    87     virtual void getStats(PassRefPtr<RTCStatsRequest>) = 0;
    88     virtual PassOwnPtr<RTCDataChannelHandler> createDataChannel(const String& label, const RTCDataChannelInit&) = 0;
    89     virtual PassOwnPtr<RTCDTMFSenderHandler> createDTMFSender(PassRefPtr<MediaStreamSource>) = 0;
    90     virtual void stop() = 0;
     44    virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) OVERRIDE;
     45    virtual void createAnswer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) OVERRIDE;
     46    virtual void setLocalDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) OVERRIDE;
     47    virtual void setRemoteDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) OVERRIDE;
     48    virtual PassRefPtr<RTCSessionDescriptionDescriptor> localDescription() OVERRIDE;
     49    virtual PassRefPtr<RTCSessionDescriptionDescriptor> remoteDescription() OVERRIDE;
     50    virtual bool updateIce(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE;
     51    virtual bool addIceCandidate(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCIceCandidateDescriptor>) OVERRIDE;
     52    virtual bool addStream(PassRefPtr<MediaStreamDescriptor>, PassRefPtr<MediaConstraints>) OVERRIDE;
     53    virtual void removeStream(PassRefPtr<MediaStreamDescriptor>) OVERRIDE;
     54    virtual void getStats(PassRefPtr<RTCStatsRequest>) OVERRIDE;
     55    virtual PassOwnPtr<RTCDataChannelHandler> createDataChannel(const String& label, const RTCDataChannelInit&) OVERRIDE;
     56    virtual PassOwnPtr<RTCDTMFSenderHandler> createDTMFSender(PassRefPtr<MediaStreamSource>) OVERRIDE;
     57    virtual void stop() OVERRIDE;
    9158
    9259protected:
    93     RTCPeerConnectionHandler() { }
     60    RTCPeerConnectionHandlerMock(RTCPeerConnectionHandlerClient*);
     61
     62private:
     63    RTCPeerConnectionHandlerClient* m_client;
     64
     65    RefPtr<RTCSessionDescriptionDescriptor> m_localSessionDescription;
     66    RefPtr<RTCSessionDescriptionDescriptor> m_remoteSessionDescription;
    9467};
    9568
     
    9871#endif // ENABLE(MEDIA_STREAM)
    9972
    100 #endif // RTCPeerConnectionHandler_h
     73#endif // RTCPeerConnectionHandlerMock_h
  • trunk/Source/WebCore/testing/Internals.cpp

    r157702 r157808  
    149149#if ENABLE(MEDIA_STREAM)
    150150#include "MockMediaStreamCenter.h"
     151#include "RTCPeerConnection.h"
     152#include "RTCPeerConnectionHandlerMock.h"
    151153#endif
    152154
     
    281283        document->page()->group().captionPreferences()->setTestingMode(true);
    282284#endif
    283    
     285
    284286#if ENABLE(MEDIA_STREAM)
    285287    MockMediaStreamCenter::registerMockMediaStreamCenter();
     288    enableMockRTCPeerConnectionHandler();
    286289#endif
    287290}
     
    645648}
    646649#endif
    647    
     650
     651#if ENABLE(MEDIA_STREAM)
     652void Internals::enableMockRTCPeerConnectionHandler()
     653{
     654    RTCPeerConnectionHandler::create = RTCPeerConnectionHandlerMock::create;
     655}
     656#endif
     657
    648658PassRefPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionCode& ec)
    649659{
  • trunk/Source/WebCore/testing/Internals.h

    r157361 r157808  
    294294#endif
    295295
     296#if ENABLE(MEDIA_STREAM)
     297    void enableMockRTCPeerConnectionHandler();
     298#endif
     299
    296300    String getImageSourceURL(Element*, ExceptionCode&);
    297301
Note: See TracChangeset for help on using the changeset viewer.