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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "components/copresence/mediums/audio/audio_player.h" | 9 #include "components/copresence/mediums/audio/audio_player.h" |
10 #include "components/copresence/mediums/audio/audio_recorder.h" | 10 #include "components/copresence/mediums/audio/audio_recorder.h" |
11 #include "components/copresence/test/audio_test_support.h" | 11 #include "components/copresence/test/audio_test_support.h" |
12 #include "media/base/audio_bus.h" | 12 #include "media/base/audio_bus.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using ::testing::_; | 16 using ::testing::_; |
17 using ::testing::Le; | 17 using ::testing::Le; |
18 | 18 |
19 namespace copresence { | 19 namespace copresence { |
20 | 20 |
21 class TestAudioPlayer : public AudioPlayer { | 21 class TestAudioPlayer : public AudioPlayer { |
22 public: | 22 public: |
23 TestAudioPlayer() {} | 23 TestAudioPlayer() {} |
24 virtual ~TestAudioPlayer() {} | 24 virtual ~TestAudioPlayer() {} |
25 | 25 |
26 // AudioPlayer overrides: | 26 // AudioPlayer overrides: |
27 virtual void Initialize() OVERRIDE {} | 27 virtual void Initialize() override {} |
28 virtual void Play( | 28 virtual void Play( |
29 const scoped_refptr<media::AudioBusRefCounted>& /* samples */) OVERRIDE { | 29 const scoped_refptr<media::AudioBusRefCounted>& /* samples */) override { |
30 set_is_playing(true); | 30 set_is_playing(true); |
31 } | 31 } |
32 virtual void Stop() OVERRIDE { set_is_playing(false); } | 32 virtual void Stop() override { set_is_playing(false); } |
33 virtual void Finalize() OVERRIDE { delete this; } | 33 virtual void Finalize() override { delete this; } |
34 | 34 |
35 private: | 35 private: |
36 DISALLOW_COPY_AND_ASSIGN(TestAudioPlayer); | 36 DISALLOW_COPY_AND_ASSIGN(TestAudioPlayer); |
37 }; | 37 }; |
38 | 38 |
39 class TestAudioRecorder : public AudioRecorder { | 39 class TestAudioRecorder : public AudioRecorder { |
40 public: | 40 public: |
41 TestAudioRecorder() : AudioRecorder(AudioRecorder::DecodeSamplesCallback()) {} | 41 TestAudioRecorder() : AudioRecorder(AudioRecorder::DecodeSamplesCallback()) {} |
42 virtual ~TestAudioRecorder() {} | 42 virtual ~TestAudioRecorder() {} |
43 | 43 |
44 // AudioRecorder overrides: | 44 // AudioRecorder overrides: |
45 virtual void Initialize() OVERRIDE {} | 45 virtual void Initialize() override {} |
46 virtual void Record() OVERRIDE { set_is_recording(true); } | 46 virtual void Record() override { set_is_recording(true); } |
47 virtual void Stop() OVERRIDE { set_is_recording(false); } | 47 virtual void Stop() override { set_is_recording(false); } |
48 virtual void Finalize() OVERRIDE { delete this; } | 48 virtual void Finalize() override { delete this; } |
49 | 49 |
50 private: | 50 private: |
51 DISALLOW_COPY_AND_ASSIGN(TestAudioRecorder); | 51 DISALLOW_COPY_AND_ASSIGN(TestAudioRecorder); |
52 }; | 52 }; |
53 | 53 |
54 class AudioDirectiveHandlerTest : public testing::Test { | 54 class AudioDirectiveHandlerTest : public testing::Test { |
55 public: | 55 public: |
56 AudioDirectiveHandlerTest() | 56 AudioDirectiveHandlerTest() |
57 : directive_handler_(new AudioDirectiveHandler( | 57 : directive_handler_(new AudioDirectiveHandler( |
58 AudioRecorder::DecodeSamplesCallback(), | 58 AudioRecorder::DecodeSamplesCallback(), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 EXPECT_EQ(true, directive_handler_->recorder_->IsRecording()); | 130 EXPECT_EQ(true, directive_handler_->recorder_->IsRecording()); |
131 | 131 |
132 directive_handler_->RemoveInstructions("op_id3"); | 132 directive_handler_->RemoveInstructions("op_id3"); |
133 EXPECT_FALSE(directive_handler_->recorder_->IsRecording()); | 133 EXPECT_FALSE(directive_handler_->recorder_->IsRecording()); |
134 } | 134 } |
135 | 135 |
136 // TODO(rkc): Write more tests that check more convoluted sequences of | 136 // TODO(rkc): Write more tests that check more convoluted sequences of |
137 // transmits/receives. | 137 // transmits/receives. |
138 | 138 |
139 } // namespace copresence | 139 } // namespace copresence |
OLD | NEW |