Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / components / copresence / test / stub_whispernet_client.cc
blobe82dd59c2559fe1ac3162e972594fa02d57ae89f
1 // Copyright 2014 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/copresence/test/stub_whispernet_client.h"
7 #include "components/copresence/test/audio_test_support.h"
8 #include "media/base/audio_bus.h"
10 namespace copresence {
12 StubWhispernetClient::StubWhispernetClient(bool complete_initialization)
13 : complete_initialization_(complete_initialization) {
14 tokens_.push_back(AudioToken("abcdef", true));
15 tokens_.push_back(AudioToken("123456", false));
16 samples_ = CreateRandomAudioRefCounted(0x123, 1, 0x321);
19 StubWhispernetClient::~StubWhispernetClient() {
22 void StubWhispernetClient::Initialize(const SuccessCallback& init_callback) {
23 // TODO(ckehoe): Consider updating tests to use this.
24 if (complete_initialization_)
25 init_callback.Run(true);
28 void StubWhispernetClient::EncodeToken(const std::string& token,
29 AudioType type) {
30 if (!samples_cb_.is_null())
31 samples_cb_.Run(type, token, samples_);
34 void StubWhispernetClient::DecodeSamples(AudioType type,
35 const std::string& samples,
36 const size_t token_length[2]) {
37 if (!tokens_cb_.is_null())
38 tokens_cb_.Run(tokens_);
41 void StubWhispernetClient::RegisterTokensCallback(
42 const TokensCallback& tokens_cb) {
43 tokens_cb_ = tokens_cb;
46 void StubWhispernetClient::RegisterSamplesCallback(
47 const SamplesCallback& samples_cb) {
48 samples_cb_ = samples_cb;
51 TokensCallback StubWhispernetClient::GetTokensCallback() {
52 return tokens_cb_;
55 SamplesCallback StubWhispernetClient::GetSamplesCallback() {
56 return samples_cb_;
59 SuccessCallback StubWhispernetClient::GetDetectBroadcastCallback() {
60 return SuccessCallback();
63 SuccessCallback StubWhispernetClient::GetInitializedCallback() {
64 return SuccessCallback();
67 } // namespace copresence