Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: content/test/layout_tests/runner/MockWebRTCDTMFSenderHandler.cpp

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 /*
6 * Copyright (C) 2013 Google Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include "content/test/layout_tests/runner/MockWebRTCDTMFSenderHandler.h"
31
32 #include <assert.h>
33
34 #include "content/public/test/layout_tests/WebTestDelegate.h"
35 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
36 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandlerClient.h"
37
38 using namespace blink;
39
40 namespace WebTestRunner {
41
42 class DTMFSenderToneTask : public WebMethodTask<MockWebRTCDTMFSenderHandler> {
43 public:
44 DTMFSenderToneTask(MockWebRTCDTMFSenderHandler* object, WebRTCDTMFSenderHand lerClient* client)
45 : WebMethodTask<MockWebRTCDTMFSenderHandler>(object)
46 , m_client(client)
47 {
48 }
49
50 virtual void runIfValid() OVERRIDE
51 {
52 WebString tones = m_object->currentToneBuffer();
53 m_object->clearToneBuffer();
54 m_client->didPlayTone(tones);
55 }
56
57 private:
58 WebRTCDTMFSenderHandlerClient* m_client;
59 };
60
61 /////////////////////
62
63 MockWebRTCDTMFSenderHandler::MockWebRTCDTMFSenderHandler(const WebMediaStreamTra ck& track, WebTestDelegate* delegate)
64 : m_client(0)
65 , m_track(track)
66 , m_delegate(delegate)
67 {
68 }
69
70 void MockWebRTCDTMFSenderHandler::setClient(WebRTCDTMFSenderHandlerClient* clien t)
71 {
72 m_client = client;
73 }
74
75 WebString MockWebRTCDTMFSenderHandler::currentToneBuffer()
76 {
77 return m_toneBuffer;
78 }
79
80 bool MockWebRTCDTMFSenderHandler::canInsertDTMF()
81 {
82 assert(m_client && !m_track.isNull());
83 return m_track.source().type() == WebMediaStreamSource::TypeAudio && m_track .isEnabled() && m_track.source().readyState() == WebMediaStreamSource::ReadyStat eLive;
84 }
85
86 bool MockWebRTCDTMFSenderHandler::insertDTMF(const WebString& tones, long durati on, long interToneGap)
87 {
88 assert(m_client);
89 if (!canInsertDTMF())
90 return false;
91
92 m_toneBuffer = tones;
93 m_delegate->postTask(new DTMFSenderToneTask(this, m_client));
94 m_delegate->postTask(new DTMFSenderToneTask(this, m_client));
95 return true;
96 }
97
98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698