Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / audio_modem / test / stub_whispernet_client.h
blob9a0e8c6d735ce166809c582c4d32d6fa90ce5a62
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 #ifndef COMPONENTS_AUDIO_MODEM_TEST_STUB_WHISPERNET_CLIENT_H_
6 #define COMPONENTS_AUDIO_MODEM_TEST_STUB_WHISPERNET_CLIENT_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "components/audio_modem/public/whispernet_client.h"
15 #include "media/base/audio_bus.h"
17 namespace audio_modem {
19 // A simple WhispernetClient for testing.
20 class StubWhispernetClient final : public WhispernetClient {
21 public:
22 // Constructor. |samples| and |tokens|, if specified,
23 // will be returned for any encoding and decoding requests.
24 StubWhispernetClient(
25 scoped_refptr<media::AudioBusRefCounted> samples =
26 scoped_refptr<media::AudioBusRefCounted>(),
27 const std::vector<AudioToken>& tokens = std::vector<AudioToken>());
29 ~StubWhispernetClient() override;
31 void Initialize(const SuccessCallback& init_callback) override;
33 void EncodeToken(const std::string& token,
34 AudioType type,
35 const TokenParameters token_params[2]) override;
36 void DecodeSamples(AudioType type,
37 const std::string& samples,
38 const TokenParameters token_params[2]) override;
40 void RegisterTokensCallback(const TokensCallback& tokens_cb) override;
41 void RegisterSamplesCallback(const SamplesCallback& samples_cb) override;
43 TokensCallback GetTokensCallback() override;
44 SamplesCallback GetSamplesCallback() override;
45 SuccessCallback GetInitializedCallback() override;
47 private:
48 TokensCallback tokens_cb_;
49 SamplesCallback samples_cb_;
50 scoped_refptr<media::AudioBusRefCounted> samples_;
51 std::vector<AudioToken> tokens_;
53 DISALLOW_COPY_AND_ASSIGN(StubWhispernetClient);
56 } // namespace audio_modem
58 #endif // COMPONENTS_AUDIO_MODEM_TEST_STUB_WHISPERNET_CLIENT_H_