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

Side by Side Diff: components/copresence/test/stub_whispernet_client.h

Issue 901753002: Cleaning up some tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using rand() instead of rand_r() on Windows Created 5 years, 10 months 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
OLDNEW
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 #ifndef COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_ 5 #ifndef COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_
6 #define COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_ 6 #define COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
13 #include "components/copresence/public/whispernet_client.h" 14 #include "components/copresence/public/whispernet_client.h"
15 #include "components/copresence/tokens.h"
16 #include "media/base/audio_bus.h"
14 17
15 namespace copresence { 18 namespace copresence {
16 19
17 // A simple WhispernetClient for testing. 20 // A simple WhispernetClient for testing.
18 class StubWhispernetClient final : public WhispernetClient { 21 class StubWhispernetClient final : public WhispernetClient {
19 public: 22 public:
20 // Constructor. The client can optionally be configured to respond 23 // Constructor. |samples| and |tokens|, if specified,
21 // as if Initialize() has completed. By default it does not. 24 // will be returned for any encoding and decoding requests.
22 explicit StubWhispernetClient(bool complete_initialization = false); 25 StubWhispernetClient(
26 scoped_refptr<media::AudioBusRefCounted> samples =
27 scoped_refptr<media::AudioBusRefCounted>(),
28 const std::vector<AudioToken>& tokens = std::vector<AudioToken>());
23 29
24 ~StubWhispernetClient() override; 30 ~StubWhispernetClient() override;
25 31
26 void Initialize(const SuccessCallback& init_callback) override; 32 void Initialize(const SuccessCallback& init_callback) override;
27 void Shutdown() override {} 33 void Shutdown() override {}
28 34
29 void EncodeToken(const std::string& token, AudioType type) override; 35 void EncodeToken(const std::string& token, AudioType type) override;
30 void DecodeSamples(AudioType type, 36 void DecodeSamples(AudioType type,
31 const std::string& samples, 37 const std::string& samples,
32 const size_t token_length[2]) override; 38 const size_t token_length[2]) override;
33 void DetectBroadcast() override {} 39 void DetectBroadcast() override {}
34 40
35 void RegisterTokensCallback(const TokensCallback& tokens_cb) override; 41 void RegisterTokensCallback(const TokensCallback& tokens_cb) override;
36 void RegisterSamplesCallback(const SamplesCallback& samples_cb) override; 42 void RegisterSamplesCallback(const SamplesCallback& samples_cb) override;
37 void RegisterDetectBroadcastCallback( 43 void RegisterDetectBroadcastCallback(
38 const SuccessCallback& /* db_cb */) override {} 44 const SuccessCallback& /* db_cb */) override {}
39 45
40 TokensCallback GetTokensCallback() override; 46 TokensCallback GetTokensCallback() override;
41 SamplesCallback GetSamplesCallback() override; 47 SamplesCallback GetSamplesCallback() override;
42 SuccessCallback GetDetectBroadcastCallback() override; 48 SuccessCallback GetDetectBroadcastCallback() override;
43 SuccessCallback GetInitializedCallback() override; 49 SuccessCallback GetInitializedCallback() override;
44 50
45 private: 51 private:
46 bool complete_initialization_;
47 TokensCallback tokens_cb_; 52 TokensCallback tokens_cb_;
48 SamplesCallback samples_cb_; 53 SamplesCallback samples_cb_;
54 scoped_refptr<media::AudioBusRefCounted> samples_;
49 std::vector<AudioToken> tokens_; 55 std::vector<AudioToken> tokens_;
50 scoped_refptr<media::AudioBusRefCounted> samples_;
51 56
52 DISALLOW_COPY_AND_ASSIGN(StubWhispernetClient); 57 DISALLOW_COPY_AND_ASSIGN(StubWhispernetClient);
53 }; 58 };
54 59
55 } // namespace copresence 60 } // namespace copresence
56 61
57 #endif // COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_ 62 #endif // COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_
OLDNEW
« no previous file with comments | « components/copresence/test/audio_test_support.cc ('k') | components/copresence/test/stub_whispernet_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698