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/handlers/audio/audio_directive_handler.h" | 5 #include "components/copresence/handlers/audio/audio_directive_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 void EncodeToken(const std::string&, | 24 void EncodeToken(const std::string&, |
25 AudioType, | 25 AudioType, |
26 const AudioManager::SamplesCallback&) { | 26 const AudioManager::SamplesCallback&) { |
27 } | 27 } |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 class AudioManagerStub final : public AudioManager { | 31 class AudioManagerStub final : public AudioManager { |
32 public: | 32 public: |
33 AudioManagerStub() {} | 33 AudioManagerStub() {} |
34 virtual ~AudioManagerStub() {} | 34 ~AudioManagerStub() override {} |
35 | 35 |
36 // AudioManager overrides: | 36 // AudioManager overrides: |
37 void Initialize(const DecodeSamplesCallback& decode_cb, | 37 void Initialize(const DecodeSamplesCallback& decode_cb, |
38 const EncodeTokenCallback& encode_cb) override {} | 38 const EncodeTokenCallback& encode_cb) override {} |
39 void StartPlaying(AudioType type) override { playing_[type] = true; } | 39 void StartPlaying(AudioType type) override { playing_[type] = true; } |
40 void StopPlaying(AudioType type) override { playing_[type] = false; } | 40 void StopPlaying(AudioType type) override { playing_[type] = false; } |
41 void StartRecording(AudioType type) override { recording_[type] = true; } | 41 void StartRecording(AudioType type) override { recording_[type] = true; } |
42 void StopRecording(AudioType type) override { recording_[type] = false; } | 42 void StopRecording(AudioType type) override { recording_[type] = false; } |
43 void SetToken(AudioType type, const std::string& url_unsafe_token) override {} | 43 void SetToken(AudioType type, const std::string& url_unsafe_token) override {} |
44 const std::string GetToken(AudioType type) override { return std::string(); } | 44 const std::string GetToken(AudioType type) override { return std::string(); } |
(...skipping 11 matching lines...) Expand all Loading... |
56 class AudioDirectiveHandlerTest : public testing::Test { | 56 class AudioDirectiveHandlerTest : public testing::Test { |
57 public: | 57 public: |
58 AudioDirectiveHandlerTest() | 58 AudioDirectiveHandlerTest() |
59 : directive_handler_(new AudioDirectiveHandler()) { | 59 : directive_handler_(new AudioDirectiveHandler()) { |
60 scoped_ptr<AudioManagerStub> manager(new AudioManagerStub); | 60 scoped_ptr<AudioManagerStub> manager(new AudioManagerStub); |
61 manager_ptr_ = manager.get(); | 61 manager_ptr_ = manager.get(); |
62 directive_handler_->set_audio_manager_for_testing(manager.Pass()); | 62 directive_handler_->set_audio_manager_for_testing(manager.Pass()); |
63 directive_handler_->Initialize(base::Bind(&DecodeSamples), | 63 directive_handler_->Initialize(base::Bind(&DecodeSamples), |
64 base::Bind(&EncodeToken)); | 64 base::Bind(&EncodeToken)); |
65 } | 65 } |
66 virtual ~AudioDirectiveHandlerTest() {} | 66 ~AudioDirectiveHandlerTest() override {} |
67 | 67 |
68 void DirectiveAdded() {} | 68 void DirectiveAdded() {} |
69 | 69 |
70 protected: | 70 protected: |
71 copresence::TokenInstruction CreateTransmitInstruction( | 71 copresence::TokenInstruction CreateTransmitInstruction( |
72 const std::string& token, | 72 const std::string& token, |
73 bool audible) { | 73 bool audible) { |
74 copresence::TokenInstruction instruction; | 74 copresence::TokenInstruction instruction; |
75 instruction.set_token_instruction_type(copresence::TRANSMIT); | 75 instruction.set_token_instruction_type(copresence::TRANSMIT); |
76 instruction.set_token_id(token); | 76 instruction.set_token_id(token); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 // We are now at base + 2676ms. | 200 // We are now at base + 2676ms. |
201 timer_ptr->Fire(); | 201 timer_ptr->Fire(); |
202 EXPECT_FALSE(IsRecording(AUDIBLE)); | 202 EXPECT_FALSE(IsRecording(AUDIBLE)); |
203 } | 203 } |
204 | 204 |
205 // TODO(rkc): Write more tests that check more convoluted sequences of | 205 // TODO(rkc): Write more tests that check more convoluted sequences of |
206 // transmits/receives. | 206 // transmits/receives. |
207 | 207 |
208 } // namespace copresence | 208 } // namespace copresence |
OLD | NEW |