Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / audio_modem / test / stub_modem.cc
blobea0fb0882e86a644af29b82317310d0a14abf28f
1 // Copyright 2015 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 "components/audio_modem/test/stub_modem.h"
7 #include "base/base64.h"
8 #include "base/logging.h"
10 namespace audio_modem {
12 StubModem::StubModem() {
13 playing_[AUDIBLE] = false;
14 playing_[INAUDIBLE] = false;
15 recording_[AUDIBLE] = false;
16 recording_[INAUDIBLE] = false;
19 StubModem::~StubModem() {}
21 void StubModem::Initialize(WhispernetClient* whispernet_client,
22 const TokensCallback& tokens_cb) {
23 tokens_callback_ = tokens_cb;
26 void StubModem::StartPlaying(AudioType type) {
27 playing_[type] = true;
30 void StubModem::StopPlaying(AudioType type) {
31 playing_[type] = false;
34 void StubModem::StartRecording(AudioType type) {
35 recording_[type] = true;
38 void StubModem::StopRecording(AudioType type) {
39 recording_[type] = false;
42 const std::string StubModem::GetToken(AudioType type) const {
43 return std::string();
46 bool StubModem::IsPlayingTokenHeard(AudioType type) const {
47 return false;
50 bool StubModem::IsRecording(AudioType type) const {
51 return recording_[type];
54 bool StubModem::IsPlaying(AudioType type) const {
55 return playing_[type];
58 void StubModem::DeliverTokens(const std::vector<AudioToken>& tokens) {
59 std::vector<AudioToken> encoded_tokens;
60 for (const AudioToken& token : tokens) {
61 std::string encoded_token;
62 base::Base64Encode(token.token, & encoded_token);
63 encoded_tokens.push_back(AudioToken(encoded_token, token.audible));
65 DCHECK_EQ(tokens.size(), encoded_tokens.size());
66 tokens_callback_.Run(encoded_tokens);
69 } // namespace audio_modem