Changeset 211253 in webkit


Ignore:
Timestamp:
Jan 26, 2017 8:54:09 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[WebRTC] Add a LibWebRTC mock for testing
https://bugs.webkit.org/show_bug.cgi?id=167429

Patch by Youenn Fablet <youennf@gmail.com> on 2017-01-26
Reviewed by Alex Christensen.

Source/WebCore:

Covered by updated tests although feature is behind a flag, off by default.
MockLibWebRTCPeerConnection will allow us testing the code above the WebRTC implementation above LibWebRTC,
without reyling on it and controlling the way that the peer connections will behave.
Adding support for mock factory to create real peer connections in case where we want to do full testing through the local loopback.

Tests: fast/mediastream/getUserMedia-webaudio.html

webrtc/datachannel/basic.html
webrtc/video.html

  • WebCore.xcodeproj/project.pbxproj:
  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore::Internals::useMockRTCPeerConnectionFactory):

  • testing/Internals.h:
  • testing/Internals.idl:
  • testing/MockLibWebRTCPeerConnection.cpp: Added.

(WebCore::useMockRTCPeerConnectionFactory):
(WebCore::MockLibWebRTCPeerConnectionForIceCandidates::MockLibWebRTCPeerConnectionForIceCandidates):
(WebCore::MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription):
(WebCore::MockLibWebRTCPeerConnectionForIceConnectionState::MockLibWebRTCPeerConnectionForIceConnectionState):
(WebCore::MockLibWebRTCPeerConnectionForIceConnectionState::gotLocalDescription):
(WebCore::MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory):
(WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):
(WebCore::MockLibWebRTCPeerConnectionFactory::CreateLocalMediaStream):
(WebCore::MockLibWebRTCPeerConnection::SetLocalDescription):
(WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription):
(WebCore::MockLibWebRTCPeerConnection::CreateDataChannel):
(WebCore::MockLibWebRTCPeerConnection::AddStream):
(WebCore::MockLibWebRTCPeerConnection::RemoveStream):
(WebCore::MockLibWebRTCPeerConnection::CreateOffer):
(WebCore::MockLibWebRTCPeerConnection::CreateAnswer):

  • testing/MockLibWebRTCPeerConnection.h: Added.

(WebCore::MockLibWebRTCPeerConnection::~MockLibWebRTCPeerConnection):
(WebCore::MockLibWebRTCPeerConnection::MockLibWebRTCPeerConnection):
(WebCore::MockLibWebRTCPeerConnection::local_streams):
(WebCore::MockLibWebRTCPeerConnection::remote_streams):
(WebCore::MockLibWebRTCPeerConnection::CreateDtmfSender):
(WebCore::MockLibWebRTCPeerConnection::GetStats):
(WebCore::MockLibWebRTCPeerConnection::local_description):
(WebCore::MockLibWebRTCPeerConnection::remote_description):
(WebCore::MockLibWebRTCPeerConnection::AddIceCandidate):
(WebCore::MockLibWebRTCPeerConnection::RegisterUMAObserver):
(WebCore::MockLibWebRTCPeerConnection::signaling_state):
(WebCore::MockLibWebRTCPeerConnection::ice_connection_state):
(WebCore::MockLibWebRTCPeerConnection::ice_gathering_state):
(WebCore::MockLibWebRTCPeerConnection::StopRtcEventLog):
(WebCore::MockLibWebRTCPeerConnection::Close):
(WebCore::MockLibWebRTCPeerConnection::gotLocalDescription):
(WebCore::MockLibWebRTCIceCandidate::MockLibWebRTCIceCandidate):
(WebCore::MockLibWebRTCAudioTrack::MockLibWebRTCAudioTrack):
(WebCore::MockLibWebRTCVideoTrack::MockLibWebRTCVideoTrack):
(WebCore::MockLibWebRTCDataChannel::MockLibWebRTCDataChannel):
(WebCore::MockLibWebRTCPeerConnectionFactory::create):

LayoutTests:

  • TestExpectations: Marking webrtc new tests as skipped for the moment.
  • fast/mediastream/RTCPeerConnection-createAnswer.html:
  • fast/mediastream/RTCPeerConnection-icecandidate-event.html:
  • fast/mediastream/RTCPeerConnection-iceconnectionstatechange-event.html:
  • webrtc/datachannel/basic.html: Added.
  • webrtc/routines.js: Added.

(createConnections):
(closeConnections):
(onCreateSessionDescriptionError):
(gotDescription1):
(gotDescription2):
(iceCallback1):
(iceCallback2):
(onAddIceCandidateSuccess):
(onAddIceCandidateError):

  • webrtc/video.html: Added.
Location:
trunk
Files:
9 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r211250 r211253  
     12017-01-26  Youenn Fablet  <youennf@gmail.com>
     2
     3        [WebRTC] Add a LibWebRTC mock for testing
     4        https://bugs.webkit.org/show_bug.cgi?id=167429
     5
     6        Reviewed by Alex Christensen.
     7
     8        * TestExpectations: Marking webrtc new tests as skipped for the moment.
     9        * fast/mediastream/RTCPeerConnection-createAnswer.html:
     10        * fast/mediastream/RTCPeerConnection-icecandidate-event.html:
     11        * fast/mediastream/RTCPeerConnection-iceconnectionstatechange-event.html:
     12        * webrtc/datachannel/basic.html: Added.
     13        * webrtc/routines.js: Added.
     14        (createConnections):
     15        (closeConnections):
     16        (onCreateSessionDescriptionError):
     17        (gotDescription1):
     18        (gotDescription2):
     19        (iceCallback1):
     20        (iceCallback2):
     21        (onAddIceCandidateSuccess):
     22        (onAddIceCandidateError):
     23        * webrtc/video.html: Added.
     24
    1252017-01-26  Daniel Bates  <dabates@apple.com>
    226
  • trunk/LayoutTests/TestExpectations

    r211169 r211253  
    680680media/session [ Skip ]
    681681
     682# WebRTC backend not enabled by default.
     683webrtc [ Skip ]
     684
    682685# Only iOS WK1 has testRunner.setPagePaused.
    683686fast/dom/timer-fire-after-page-pause.html [ Skip ]
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer.html

    r208057 r211253  
    6868                testPassed('createAnswer request succeeded.');
    6969
    70                 sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
     70                sessionDescription = new RTCSessionDescription({type:"offer", sdp:"v=0\r\no=- 5667094644266930845 0 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"});
    7171                shouldNotThrow('pc.setRemoteDescription(sessionDescription, setDescriptionSucceeded, setDescriptionFailed);');
    7272            }
    7373
    74             function setDescriptionFailed()
     74            function setDescriptionFailed(message)
    7575            {
    76                 testFailed('setRemoteDescription failed.');
     76                testFailed('setRemoteDescription failed: ' + message);
    7777
    7878                finishJSTest();
     
    8282            {
    8383                testPassed('setRemoteDescription succeeded.');
    84                 shouldThrow('pc.createAnswer(requestSucceeded2, requestFailed2, {});');
     84                pc.createAnswer(requestSucceeded2, requestFailed2, {});
    8585            }
    8686
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-icecandidate-event.html

    r208057 r211253  
    1010
    1111            description("Test RTCPeerConnection 'icecandidate' event and gathering done");
     12
     13            if (window.internals)
     14                internals.useMockRTCPeerConnectionFactory("ICECandidates");
    1215
    1316            if (window.testRunner)
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-iceconnectionstatechange-event.html

    r208057 r211253  
    88        <script>
    99            description("Test RTCPeerConnection 'iceconnectionstatechange' event");
     10
     11            if (window.internals)
     12                internals.useMockRTCPeerConnectionFactory("ICEConnectionState");
    1013
    1114            let expectedState;
  • trunk/Source/WebCore/ChangeLog

    r211249 r211253  
     12017-01-26  Youenn Fablet  <youennf@gmail.com>
     2
     3        [WebRTC] Add a LibWebRTC mock for testing
     4        https://bugs.webkit.org/show_bug.cgi?id=167429
     5
     6        Reviewed by Alex Christensen.
     7
     8        Covered by updated tests although feature is behind a flag, off by default.
     9        MockLibWebRTCPeerConnection will allow us testing the code above the WebRTC implementation above LibWebRTC,
     10        without reyling on it and controlling the way that the peer connections will behave.
     11        Adding support for mock factory to create real peer connections in case where we want to do full testing through the local loopback.
     12
     13        Tests: fast/mediastream/getUserMedia-webaudio.html
     14               webrtc/datachannel/basic.html
     15               webrtc/video.html
     16
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * testing/Internals.cpp:
     19        (WebCore::Internals::Internals):
     20        (WebCore::Internals::useMockRTCPeerConnectionFactory):
     21        * testing/Internals.h:
     22        * testing/Internals.idl:
     23        * testing/MockLibWebRTCPeerConnection.cpp: Added.
     24        (WebCore::useMockRTCPeerConnectionFactory):
     25        (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::MockLibWebRTCPeerConnectionForIceCandidates):
     26        (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription):
     27        (WebCore::MockLibWebRTCPeerConnectionForIceConnectionState::MockLibWebRTCPeerConnectionForIceConnectionState):
     28        (WebCore::MockLibWebRTCPeerConnectionForIceConnectionState::gotLocalDescription):
     29        (WebCore::MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory):
     30        (WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):
     31        (WebCore::MockLibWebRTCPeerConnectionFactory::CreateLocalMediaStream):
     32        (WebCore::MockLibWebRTCPeerConnection::SetLocalDescription):
     33        (WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription):
     34        (WebCore::MockLibWebRTCPeerConnection::CreateDataChannel):
     35        (WebCore::MockLibWebRTCPeerConnection::AddStream):
     36        (WebCore::MockLibWebRTCPeerConnection::RemoveStream):
     37        (WebCore::MockLibWebRTCPeerConnection::CreateOffer):
     38        (WebCore::MockLibWebRTCPeerConnection::CreateAnswer):
     39        * testing/MockLibWebRTCPeerConnection.h: Added.
     40        (WebCore::MockLibWebRTCPeerConnection::~MockLibWebRTCPeerConnection):
     41        (WebCore::MockLibWebRTCPeerConnection::MockLibWebRTCPeerConnection):
     42        (WebCore::MockLibWebRTCPeerConnection::local_streams):
     43        (WebCore::MockLibWebRTCPeerConnection::remote_streams):
     44        (WebCore::MockLibWebRTCPeerConnection::CreateDtmfSender):
     45        (WebCore::MockLibWebRTCPeerConnection::GetStats):
     46        (WebCore::MockLibWebRTCPeerConnection::local_description):
     47        (WebCore::MockLibWebRTCPeerConnection::remote_description):
     48        (WebCore::MockLibWebRTCPeerConnection::AddIceCandidate):
     49        (WebCore::MockLibWebRTCPeerConnection::RegisterUMAObserver):
     50        (WebCore::MockLibWebRTCPeerConnection::signaling_state):
     51        (WebCore::MockLibWebRTCPeerConnection::ice_connection_state):
     52        (WebCore::MockLibWebRTCPeerConnection::ice_gathering_state):
     53        (WebCore::MockLibWebRTCPeerConnection::StopRtcEventLog):
     54        (WebCore::MockLibWebRTCPeerConnection::Close):
     55        (WebCore::MockLibWebRTCPeerConnection::gotLocalDescription):
     56        (WebCore::MockLibWebRTCIceCandidate::MockLibWebRTCIceCandidate):
     57        (WebCore::MockLibWebRTCAudioTrack::MockLibWebRTCAudioTrack):
     58        (WebCore::MockLibWebRTCVideoTrack::MockLibWebRTCVideoTrack):
     59        (WebCore::MockLibWebRTCDataChannel::MockLibWebRTCDataChannel):
     60        (WebCore::MockLibWebRTCPeerConnectionFactory::create):
     61
    1622017-01-26  Jeremy Jones  <jeremyj@apple.com>
    263
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r211227 r211253  
    15451545                4157AF8012F1FB0400A8C6F5 /* MediaControlsApple.h in Headers */ = {isa = PBXBuildFile; fileRef = 4157AF7E12F1FB0400A8C6F5 /* MediaControlsApple.h */; };
    15461546                4157AF8112F1FB0400A8C6F5 /* MediaControlsApple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4157AF7F12F1FB0400A8C6F5 /* MediaControlsApple.cpp */; };
     1547                4157EBFA1E3AB67900AC9FE9 /* MockLibWebRTCPeerConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4157EBF91E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.cpp */; };
     1548                4157EBFB1E3AB67F00AC9FE9 /* MockLibWebRTCPeerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4157EBF81E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.h */; };
    15471549                41614A781DA6423B004AD06F /* HTTPHeaderValues.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41614A761DA64236004AD06F /* HTTPHeaderValues.cpp */; };
    15481550                41614A791DA64241004AD06F /* HTTPHeaderValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 41614A771DA64236004AD06F /* HTTPHeaderValues.h */; };
     
    87268728                4157AF7E12F1FB0400A8C6F5 /* MediaControlsApple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlsApple.h; sourceTree = "<group>"; };
    87278729                4157AF7F12F1FB0400A8C6F5 /* MediaControlsApple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlsApple.cpp; sourceTree = "<group>"; };
     8730                4157EBF81E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockLibWebRTCPeerConnection.h; sourceTree = "<group>"; };
     8731                4157EBF91E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockLibWebRTCPeerConnection.cpp; sourceTree = "<group>"; };
    87288732                41614A761DA64236004AD06F /* HTTPHeaderValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderValues.cpp; sourceTree = "<group>"; };
    87298733                41614A771DA64236004AD06F /* HTTPHeaderValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPHeaderValues.h; sourceTree = "<group>"; };
     
    1669416698                                51058AD91D679257009A538C /* MockGamepadProvider.cpp */,
    1669516699                                51058ADA1D679257009A538C /* MockGamepadProvider.h */,
     16700                                4157EBF81E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.h */,
     16701                                4157EBF91E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.cpp */,
    1669616702                                2D6F3E8A1C1ECB1C0061DBD4 /* MockPageOverlay.cpp */,
    1669716703                                2D6F3E8B1C1ECB1C0061DBD4 /* MockPageOverlay.h */,
     
    2491224918                                A1763F3F1E205234001D58DE /* WebArchiveDumpSupport.h in Headers */,
    2491324919                                41815C1F138319830057AAA4 /* WebCoreTestSupport.h in Headers */,
     24920                                4157EBFB1E3AB67F00AC9FE9 /* MockLibWebRTCPeerConnection.h in Headers */,
    2491424921                        );
    2491524922                        runOnlyForDeploymentPostprocessing = 0;
     
    2883528842                                417DA71D13735DFA007C57FB /* JSInternals.cpp in Sources */,
    2883628843                                A740B5A714C935AF00A77FA4 /* JSInternalSettings.cpp in Sources */,
     28844                                4157EBFA1E3AB67900AC9FE9 /* MockLibWebRTCPeerConnection.cpp in Sources */,
    2883728845                                53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
    2883828846                                A740B59714C935AF00A77FA4 /* JSMallocStatistics.cpp in Sources */,
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCUtils.cpp

    r211161 r211253  
    3232#if USE(LIBWEBRTC)
    3333
     34#include <webrtc/api/peerconnectionfactoryproxy.h>
    3435#include <webrtc/api/peerconnectionfactory.h>
    3536#include <webrtc/base/physicalsocketserver.h>
     
    7576}
    7677
     78void callOnWebRTCSignalingThread(Function<void()>&& callback)
     79{
     80    PeerConnectionFactoryAndThreads& threads = staticFactoryAndThreads();
     81    threads.signalingThread->Post(RTC_FROM_HERE, &threads, 1, new ThreadMessageData(WTFMove(callback)));
     82}
     83
    7784static void initializePeerConnectionFactoryAndThreads()
    7885{
     
    105112        initializePeerConnectionFactoryAndThreads();
    106113    return *staticFactoryAndThreads().factory;
     114}
     115
     116void setPeerConnectionFactory(rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>&& factory)
     117{
     118    if (!staticFactoryAndThreads().factory)
     119        initializePeerConnectionFactoryAndThreads();
     120
     121    staticFactoryAndThreads().factory = webrtc::PeerConnectionFactoryProxy::Create(staticFactoryAndThreads().signalingThread.get(), WTFMove(factory));
    107122}
    108123
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCUtils.h

    r211161 r211253  
    5353WEBCORE_EXPORT void callOnWebRTCNetworkThread(Function<void()>&&);
    5454
     55// Used for mock testing
     56WEBCORE_EXPORT void setPeerConnectionFactory(rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>&&);
     57WEBCORE_EXPORT void callOnWebRTCSignalingThread(Function<void()>&&);
     58
    5559} // namespace WebCore
    5660
  • trunk/Source/WebCore/testing/Internals.cpp

    r211006 r211253  
    8686#include "InternalSettings.h"
    8787#include "Language.h"
     88#include "LibWebRTCProvider.h"
     89#include "LibWebRTCUtils.h"
    8890#include "MainFrame.h"
    8991#include "MallocStatistics.h"
     
    9395#include "MemoryInfo.h"
    9496#include "MemoryPressureHandler.h"
     97#include "MockLibWebRTCPeerConnection.h"
    9598#include "MockPageOverlay.h"
    9699#include "MockPageOverlayClient.h"
     
    451454#if ENABLE(WEB_RTC)
    452455    enableMockMediaEndpoint();
     456    useMockRTCPeerConnectionFactory(String());
    453457#endif
    454458
     
    10901094{
    10911095    connection.emulatePlatformEvent(action);
     1096}
     1097
     1098void Internals::useMockRTCPeerConnectionFactory(const String& testCase)
     1099{
     1100#if USE(LIBWEBRTC)
     1101    Document* document = contextDocument();
     1102    LibWebRTCProvider* provider = (document && document->page()) ? &document->page()->libWebRTCProvider() : nullptr;
     1103    WebCore::useMockRTCPeerConnectionFactory(provider, testCase);
     1104#else
     1105    UNUSED_PARAM(testCase);
     1106#endif
    10921107}
    10931108
  • trunk/Source/WebCore/testing/Internals.h

    r211006 r211253  
    391391    void enableMockRTCPeerConnectionHandler();
    392392    void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
     393    void useMockRTCPeerConnectionFactory(const String&);
    393394#endif
    394395
  • trunk/Source/WebCore/testing/Internals.idl

    r211006 r211253  
    436436    [Conditional=MEDIA_STREAM] void setMockMediaCaptureDevicesEnabled(boolean enabled);
    437437    [Conditional=WEB_RTC] void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection connection, DOMString action);
     438    [Conditional=WEB_RTC] void useMockRTCPeerConnectionFactory(DOMString testCase);
    438439
    439440    [Conditional=VIDEO] void simulateSystemSleep();
Note: See TracChangeset for help on using the changeset viewer.