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

Side by Side Diff: components/copresence/mediums/audio/audio_manager_unittest.cc

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
« no previous file with comments | « no previous file | components/copresence/test/audio_test_support.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/copresence/mediums/audio/audio_manager.h" 5 #include "components/copresence/mediums/audio/audio_manager.h"
6 6
7 #include <vector>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
9 #include "components/copresence/mediums/audio/audio_manager_impl.h" 11 #include "components/copresence/mediums/audio/audio_manager_impl.h"
10 #include "components/copresence/mediums/audio/audio_player.h" 12 #include "components/copresence/mediums/audio/audio_player.h"
11 #include "components/copresence/mediums/audio/audio_recorder.h" 13 #include "components/copresence/mediums/audio/audio_recorder.h"
14 #include "components/copresence/test/audio_test_support.h"
12 #include "components/copresence/test/stub_whispernet_client.h" 15 #include "components/copresence/test/stub_whispernet_client.h"
13 #include "media/base/audio_bus.h" 16 #include "media/base/audio_bus.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 namespace copresence { 19 namespace copresence {
17 20
18 class AudioPlayerStub final : public AudioPlayer { 21 class AudioPlayerStub final : public AudioPlayer {
19 public: 22 public:
20 AudioPlayerStub() : is_playing_(false) {} 23 AudioPlayerStub() : is_playing_(false) {}
21 ~AudioPlayerStub() override {} 24 ~AudioPlayerStub() override {}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 private: 59 private:
57 RecordedSamplesCallback cb_; 60 RecordedSamplesCallback cb_;
58 bool is_recording_; 61 bool is_recording_;
59 62
60 DISALLOW_COPY_AND_ASSIGN(AudioRecorderStub); 63 DISALLOW_COPY_AND_ASSIGN(AudioRecorderStub);
61 }; 64 };
62 65
63 class AudioManagerTest : public testing::Test { 66 class AudioManagerTest : public testing::Test {
64 public: 67 public:
65 AudioManagerTest() 68 AudioManagerTest()
66 : whispernet_client_(new StubWhispernetClient), 69 : audio_manager_(new AudioManagerImpl()),
67 audio_manager_(new AudioManagerImpl()),
68 audible_player_(new AudioPlayerStub), 70 audible_player_(new AudioPlayerStub),
69 inaudible_player_(new AudioPlayerStub), 71 inaudible_player_(new AudioPlayerStub),
70 recorder_(new AudioRecorderStub), 72 recorder_(new AudioRecorderStub),
71 last_received_decode_type_(AUDIO_TYPE_UNKNOWN) { 73 last_received_decode_type_(AUDIO_TYPE_UNKNOWN) {
74 std::vector<AudioToken> tokens;
75 tokens.push_back(AudioToken("abcdef", true));
76 tokens.push_back(AudioToken("123456", false));
77 whispernet_client_.reset(new StubWhispernetClient(
78 CreateRandomAudioRefCounted(0x123, 1, 0x321), tokens));
79
72 audio_manager_->set_player_for_testing(AUDIBLE, audible_player_); 80 audio_manager_->set_player_for_testing(AUDIBLE, audible_player_);
73 audio_manager_->set_player_for_testing(INAUDIBLE, inaudible_player_); 81 audio_manager_->set_player_for_testing(INAUDIBLE, inaudible_player_);
74 audio_manager_->set_recorder_for_testing(recorder_); 82 audio_manager_->set_recorder_for_testing(recorder_);
75 audio_manager_->Initialize( 83 audio_manager_->Initialize(
76 whispernet_client_.get(), 84 whispernet_client_.get(),
77 base::Bind(&AudioManagerTest::GetTokens, base::Unretained(this))); 85 base::Bind(&AudioManagerTest::GetTokens, base::Unretained(this)));
78 } 86 }
79 87
80 ~AudioManagerTest() override {} 88 ~AudioManagerTest() override {}
81 89
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 audio_manager_->StartRecording(INAUDIBLE); 144 audio_manager_->StartRecording(INAUDIBLE);
137 recorder_->TriggerDecodeRequest(); 145 recorder_->TriggerDecodeRequest();
138 EXPECT_EQ(BOTH, last_received_decode_type_); 146 EXPECT_EQ(BOTH, last_received_decode_type_);
139 147
140 audio_manager_->StopRecording(AUDIBLE); 148 audio_manager_->StopRecording(AUDIBLE);
141 recorder_->TriggerDecodeRequest(); 149 recorder_->TriggerDecodeRequest();
142 EXPECT_EQ(INAUDIBLE, last_received_decode_type_); 150 EXPECT_EQ(INAUDIBLE, last_received_decode_type_);
143 } 151 }
144 152
145 } // namespace copresence 153 } // namespace copresence
OLDNEW
« no previous file with comments | « no previous file | components/copresence/test/audio_test_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698