1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/shell/renderer/test_runner/MockWebRTCDTMFSenderHandler.h"
9 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
11 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandlerClient.h"
13 using namespace blink
;
15 namespace WebTestRunner
{
17 class DTMFSenderToneTask
: public WebMethodTask
<MockWebRTCDTMFSenderHandler
> {
19 DTMFSenderToneTask(MockWebRTCDTMFSenderHandler
* object
, WebRTCDTMFSenderHandlerClient
* client
)
20 : WebMethodTask
<MockWebRTCDTMFSenderHandler
>(object
)
25 virtual void runIfValid() OVERRIDE
27 WebString tones
= m_object
->currentToneBuffer();
28 m_object
->clearToneBuffer();
29 m_client
->didPlayTone(tones
);
33 WebRTCDTMFSenderHandlerClient
* m_client
;
38 MockWebRTCDTMFSenderHandler::MockWebRTCDTMFSenderHandler(const WebMediaStreamTrack
& track
, WebTestDelegate
* delegate
)
41 , m_delegate(delegate
)
45 void MockWebRTCDTMFSenderHandler::setClient(WebRTCDTMFSenderHandlerClient
* client
)
50 WebString
MockWebRTCDTMFSenderHandler::currentToneBuffer()
55 bool MockWebRTCDTMFSenderHandler::canInsertDTMF()
57 assert(m_client
&& !m_track
.isNull());
58 return m_track
.source().type() == WebMediaStreamSource::TypeAudio
&& m_track
.isEnabled() && m_track
.source().readyState() == WebMediaStreamSource::ReadyStateLive
;
61 bool MockWebRTCDTMFSenderHandler::insertDTMF(const WebString
& tones
, long duration
, long interToneGap
)
68 m_delegate
->postTask(new DTMFSenderToneTask(this, m_client
));
69 m_delegate
->postTask(new DTMFSenderToneTask(this, m_client
));