OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 void SetUp() override { | 28 void SetUp() override { |
29 audio_manager_ = | 29 audio_manager_ = |
30 AudioManager::CreateForTesting(base::ThreadTaskRunnerHandle::Get()); | 30 AudioManager::CreateForTesting(base::ThreadTaskRunnerHandle::Get()); |
31 SoundsManager::Create(); | 31 SoundsManager::Create(); |
32 base::RunLoop().RunUntilIdle(); | 32 base::RunLoop().RunUntilIdle(); |
33 } | 33 } |
34 | 34 |
35 void TearDown() override { | 35 void TearDown() override { |
36 SoundsManager::Shutdown(); | 36 SoundsManager::Shutdown(); |
| 37 audio_manager_->Shutdown(); |
37 base::RunLoop().RunUntilIdle(); | 38 base::RunLoop().RunUntilIdle(); |
38 } | 39 } |
39 | 40 |
40 void SetObserverForTesting(AudioStreamHandler::TestObserver* observer) { | 41 void SetObserverForTesting(AudioStreamHandler::TestObserver* observer) { |
41 AudioStreamHandler::SetObserverForTesting(observer); | 42 AudioStreamHandler::SetObserverForTesting(observer); |
42 } | 43 } |
43 | 44 |
44 void SetAudioSourceForTesting( | 45 void SetAudioSourceForTesting( |
45 AudioOutputStream::AudioSourceCallback* source) { | 46 AudioOutputStream::AudioSourceCallback* source) { |
46 AudioStreamHandler::SetAudioSourceForTesting(source); | 47 AudioStreamHandler::SetAudioSourceForTesting(source); |
47 } | 48 } |
48 | 49 |
49 private: | 50 private: |
50 base::TestMessageLoop message_loop_; | 51 base::TestMessageLoop message_loop_; |
51 ScopedAudioManagerPtr audio_manager_; | 52 std::unique_ptr<AudioManager> audio_manager_; |
52 }; | 53 }; |
53 | 54 |
54 TEST_F(SoundsManagerTest, Play) { | 55 TEST_F(SoundsManagerTest, Play) { |
55 ASSERT_TRUE(SoundsManager::Get()); | 56 ASSERT_TRUE(SoundsManager::Get()); |
56 | 57 |
57 base::RunLoop run_loop; | 58 base::RunLoop run_loop; |
58 TestObserver observer(run_loop.QuitClosure()); | 59 TestObserver observer(run_loop.QuitClosure()); |
59 | 60 |
60 SetObserverForTesting(&observer); | 61 SetObserverForTesting(&observer); |
61 | 62 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 SetObserverForTesting(NULL); | 108 SetObserverForTesting(NULL); |
108 } | 109 } |
109 | 110 |
110 TEST_F(SoundsManagerTest, Uninitialized) { | 111 TEST_F(SoundsManagerTest, Uninitialized) { |
111 ASSERT_TRUE(SoundsManager::Get()); | 112 ASSERT_TRUE(SoundsManager::Get()); |
112 ASSERT_FALSE(SoundsManager::Get()->Play(kTestAudioKey)); | 113 ASSERT_FALSE(SoundsManager::Get()->Play(kTestAudioKey)); |
113 ASSERT_FALSE(SoundsManager::Get()->Stop(kTestAudioKey)); | 114 ASSERT_FALSE(SoundsManager::Get()->Stop(kTestAudioKey)); |
114 } | 115 } |
115 | 116 |
116 } // namespace media | 117 } // namespace media |
OLD | NEW |