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

Unified Diff: components/audio_modem/modem_unittest.cc

Issue 865483005: Creating the audio_modem component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging again 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/audio_modem/modem_impl.cc ('k') | components/audio_modem/public/audio_modem_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/audio_modem/modem_unittest.cc
diff --git a/components/copresence/mediums/audio/audio_manager_unittest.cc b/components/audio_modem/modem_unittest.cc
similarity index 65%
rename from components/copresence/mediums/audio/audio_manager_unittest.cc
rename to components/audio_modem/modem_unittest.cc
index 1e541be0b243b37d1b2e7a32e05191b7944ee7b2..042b9787570f478984e8df5530eabd543b4864d9 100644
--- a/components/copresence/mediums/audio/audio_manager_unittest.cc
+++ b/components/audio_modem/modem_unittest.cc
@@ -1,22 +1,22 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/copresence/mediums/audio/audio_manager.h"
+#include "components/audio_modem/public/modem.h"
#include <vector>
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
-#include "components/copresence/mediums/audio/audio_manager_impl.h"
-#include "components/copresence/mediums/audio/audio_player.h"
-#include "components/copresence/mediums/audio/audio_recorder.h"
-#include "components/copresence/test/audio_test_support.h"
-#include "components/copresence/test/stub_whispernet_client.h"
+#include "components/audio_modem/audio_player.h"
+#include "components/audio_modem/audio_recorder.h"
+#include "components/audio_modem/modem_impl.h"
+#include "components/audio_modem/test/random_samples.h"
+#include "components/audio_modem/test/stub_whispernet_client.h"
#include "media/base/audio_bus.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace copresence {
+namespace audio_modem {
class AudioPlayerStub final : public AudioPlayer {
public:
@@ -63,10 +63,10 @@ class AudioRecorderStub final : public AudioRecorder {
DISALLOW_COPY_AND_ASSIGN(AudioRecorderStub);
};
-class AudioManagerTest : public testing::Test {
+class ModemTest : public testing::Test {
public:
- AudioManagerTest()
- : audio_manager_(new AudioManagerImpl()),
+ ModemTest()
+ : modem_(new ModemImpl),
audible_player_(new AudioPlayerStub),
inaudible_player_(new AudioPlayerStub),
recorder_(new AudioRecorderStub),
@@ -74,18 +74,19 @@ class AudioManagerTest : public testing::Test {
std::vector<AudioToken> tokens;
tokens.push_back(AudioToken("abcdef", true));
tokens.push_back(AudioToken("123456", false));
- whispernet_client_.reset(new StubWhispernetClient(
+ client_.reset(new StubWhispernetClient(
CreateRandomAudioRefCounted(0x123, 1, 0x321), tokens));
- audio_manager_->set_player_for_testing(AUDIBLE, audible_player_);
- audio_manager_->set_player_for_testing(INAUDIBLE, inaudible_player_);
- audio_manager_->set_recorder_for_testing(recorder_);
- audio_manager_->Initialize(
- whispernet_client_.get(),
- base::Bind(&AudioManagerTest::GetTokens, base::Unretained(this)));
+ // TODO(ckehoe): Pass these into the Modem constructor instead.
+ modem_->set_player_for_testing(AUDIBLE, audible_player_);
+ modem_->set_player_for_testing(INAUDIBLE, inaudible_player_);
+ modem_->set_recorder_for_testing(recorder_);
+ modem_->Initialize(
+ client_.get(),
+ base::Bind(&ModemTest::GetTokens, base::Unretained(this)));
}
- ~AudioManagerTest() override {}
+ ~ModemTest() override {}
protected:
void GetTokens(const std::vector<AudioToken>& tokens) {
@@ -104,12 +105,11 @@ class AudioManagerTest : public testing::Test {
}
base::MessageLoop message_loop_;
- // Order is important, |whispernet_client_| needs to get destructed *after*
- // |audio_manager_|.
- scoped_ptr<WhispernetClient> whispernet_client_;
- scoped_ptr<AudioManagerImpl> audio_manager_;
+ // This order is important. The WhispernetClient needs to outlive the Modem.
+ scoped_ptr<WhispernetClient> client_;
+ scoped_ptr<ModemImpl> modem_;
- // These will be deleted by |audio_manager_|'s dtor calling finalize on them.
+ // These will be deleted by the Modem's destructor calling finalize on them.
AudioPlayerStub* audible_player_;
AudioPlayerStub* inaudible_player_;
AudioRecorderStub* recorder_;
@@ -117,37 +117,37 @@ class AudioManagerTest : public testing::Test {
AudioType last_received_decode_type_;
private:
- DISALLOW_COPY_AND_ASSIGN(AudioManagerTest);
+ DISALLOW_COPY_AND_ASSIGN(ModemTest);
};
-TEST_F(AudioManagerTest, EncodeToken) {
- audio_manager_->StartPlaying(AUDIBLE);
+TEST_F(ModemTest, EncodeToken) {
+ modem_->StartPlaying(AUDIBLE);
// No token yet, player shouldn't be playing.
EXPECT_FALSE(audible_player_->IsPlaying());
- audio_manager_->SetToken(INAUDIBLE, "abcd");
+ modem_->SetToken(INAUDIBLE, "abcd");
// No *audible* token yet, so player still shouldn't be playing.
EXPECT_FALSE(audible_player_->IsPlaying());
- audio_manager_->SetToken(AUDIBLE, "abcd");
+ modem_->SetToken(AUDIBLE, "abcd");
EXPECT_TRUE(audible_player_->IsPlaying());
}
-TEST_F(AudioManagerTest, Record) {
+TEST_F(ModemTest, Record) {
recorder_->TriggerDecodeRequest();
EXPECT_EQ(AUDIO_TYPE_UNKNOWN, last_received_decode_type_);
- audio_manager_->StartRecording(AUDIBLE);
+ modem_->StartRecording(AUDIBLE);
recorder_->TriggerDecodeRequest();
EXPECT_EQ(AUDIBLE, last_received_decode_type_);
- audio_manager_->StartRecording(INAUDIBLE);
+ modem_->StartRecording(INAUDIBLE);
recorder_->TriggerDecodeRequest();
EXPECT_EQ(BOTH, last_received_decode_type_);
- audio_manager_->StopRecording(AUDIBLE);
+ modem_->StopRecording(AUDIBLE);
recorder_->TriggerDecodeRequest();
EXPECT_EQ(INAUDIBLE, last_received_decode_type_);
}
-} // namespace copresence
+} // namespace audio_modem
« no previous file with comments | « components/audio_modem/modem_impl.cc ('k') | components/audio_modem/public/audio_modem_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698