OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/copresence/test/stub_whispernet_client.h" | 5 #include "components/copresence/test/stub_whispernet_client.h" |
6 | 6 |
7 #include "components/copresence/test/audio_test_support.h" | |
8 #include "media/base/audio_bus.h" | |
9 | |
10 namespace copresence { | 7 namespace copresence { |
11 | 8 |
12 StubWhispernetClient::StubWhispernetClient(bool complete_initialization) | 9 StubWhispernetClient::StubWhispernetClient( |
13 : complete_initialization_(complete_initialization) { | 10 scoped_refptr<media::AudioBusRefCounted> samples, |
14 tokens_.push_back(AudioToken("abcdef", true)); | 11 const std::vector<AudioToken>& tokens) |
15 tokens_.push_back(AudioToken("123456", false)); | 12 : samples_(samples), |
16 samples_ = CreateRandomAudioRefCounted(0x123, 1, 0x321); | 13 tokens_(tokens) { |
17 } | 14 } |
18 | 15 |
19 StubWhispernetClient::~StubWhispernetClient() { | 16 StubWhispernetClient::~StubWhispernetClient() {} |
20 } | |
21 | 17 |
22 void StubWhispernetClient::Initialize(const SuccessCallback& init_callback) { | 18 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); | |
26 } | |
27 | 19 |
28 void StubWhispernetClient::EncodeToken(const std::string& token, | 20 void StubWhispernetClient::EncodeToken(const std::string& token, |
29 AudioType type) { | 21 AudioType type) { |
30 if (!samples_cb_.is_null()) | 22 if (!samples_cb_.is_null()) |
31 samples_cb_.Run(type, token, samples_); | 23 samples_cb_.Run(type, token, samples_); |
32 } | 24 } |
33 | 25 |
34 void StubWhispernetClient::DecodeSamples(AudioType type, | 26 void StubWhispernetClient::DecodeSamples(AudioType type, |
35 const std::string& samples, | 27 const std::string& samples, |
36 const size_t token_length[2]) { | 28 const size_t token_length[2]) { |
(...skipping 21 matching lines...) Expand all Loading... |
58 | 50 |
59 SuccessCallback StubWhispernetClient::GetDetectBroadcastCallback() { | 51 SuccessCallback StubWhispernetClient::GetDetectBroadcastCallback() { |
60 return SuccessCallback(); | 52 return SuccessCallback(); |
61 } | 53 } |
62 | 54 |
63 SuccessCallback StubWhispernetClient::GetInitializedCallback() { | 55 SuccessCallback StubWhispernetClient::GetInitializedCallback() { |
64 return SuccessCallback(); | 56 return SuccessCallback(); |
65 } | 57 } |
66 | 58 |
67 } // namespace copresence | 59 } // namespace copresence |
OLD | NEW |