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

Side by Side Diff: media/audio/sounds/audio_stream_handler_unittest.cc

Issue 115693004: Added volume adjust sound behind the flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed creation of AudioParameters. Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 void SetObserverForTesting(AudioStreamHandler::TestObserver* observer) { 43 void SetObserverForTesting(AudioStreamHandler::TestObserver* observer) {
44 AudioStreamHandler::SetObserverForTesting(observer); 44 AudioStreamHandler::SetObserverForTesting(observer);
45 } 45 }
46 46
47 void SetAudioSourceForTesting( 47 void SetAudioSourceForTesting(
48 AudioOutputStream::AudioSourceCallback* source) { 48 AudioOutputStream::AudioSourceCallback* source) {
49 AudioStreamHandler::SetAudioSourceForTesting(source); 49 AudioStreamHandler::SetAudioSourceForTesting(source);
50 } 50 }
51 51
52 void AllowReplayOnceForTesting() {
53 audio_stream_handler_->AllowReplayOnceForTesting();
54 }
55
52 private: 56 private:
53 scoped_ptr<AudioManager> audio_manager_; 57 scoped_ptr<AudioManager> audio_manager_;
54 scoped_ptr<AudioStreamHandler> audio_stream_handler_; 58 scoped_ptr<AudioStreamHandler> audio_stream_handler_;
55 59
56 base::MessageLoop message_loop_; 60 base::MessageLoop message_loop_;
57 }; 61 };
58 62
59 TEST_F(AudioStreamHandlerTest, Play) { 63 TEST_F(AudioStreamHandlerTest, Play) {
60 base::RunLoop run_loop; 64 base::RunLoop run_loop;
61 TestObserver observer(run_loop.QuitClosure()); 65 TestObserver observer(run_loop.QuitClosure());
62 66
63 SetObserverForTesting(&observer); 67 SetObserverForTesting(&observer);
64 68
65 ASSERT_TRUE(audio_stream_handler()->IsInitialized()); 69 ASSERT_TRUE(audio_stream_handler()->IsInitialized());
66 ASSERT_TRUE(audio_stream_handler()->Play()); 70 ASSERT_TRUE(audio_stream_handler()->Play());
67 71
68 run_loop.Run(); 72 run_loop.Run();
69 73
70 SetObserverForTesting(NULL); 74 SetObserverForTesting(NULL);
71 75
72 ASSERT_EQ(1, observer.num_play_requests()); 76 ASSERT_EQ(1, observer.num_play_requests());
73 ASSERT_EQ(1, observer.num_stop_requests()); 77 ASSERT_EQ(1, observer.num_stop_requests());
74 ASSERT_EQ(4, observer.cursor()); 78 ASSERT_EQ(4, observer.cursor());
75 } 79 }
76 80
77 TEST_F(AudioStreamHandlerTest, Rewind) { 81 TEST_F(AudioStreamHandlerTest, Replay) {
78 base::RunLoop run_loop; 82 base::RunLoop run_loop;
79 TestObserver observer(run_loop.QuitClosure()); 83 TestObserver observer(run_loop.QuitClosure());
80 SineWaveAudioSource source(CHANNEL_LAYOUT_STEREO, 200.0, 8000);
81
82 SetObserverForTesting(&observer); 84 SetObserverForTesting(&observer);
83 SetAudioSourceForTesting(&source);
84 85
85 ASSERT_TRUE(audio_stream_handler()->IsInitialized()); 86 ASSERT_TRUE(audio_stream_handler()->IsInitialized());
86 87
88 AllowReplayOnceForTesting();
87 ASSERT_TRUE(audio_stream_handler()->Play()); 89 ASSERT_TRUE(audio_stream_handler()->Play());
88 base::MessageLoop::current()->PostDelayedTask( 90 ASSERT_TRUE(audio_stream_handler()->Play());
89 FROM_HERE,
90 base::Bind(base::IgnoreResult(&AudioStreamHandler::Play),
91 base::Unretained(audio_stream_handler())),
92 base::TimeDelta::FromSeconds(3));
93 base::MessageLoop::current()->PostDelayedTask(
94 FROM_HERE,
95 base::Bind(&AudioStreamHandler::Stop,
96 base::Unretained(audio_stream_handler())),
97 base::TimeDelta::FromSeconds(6));
98 91
99 run_loop.Run(); 92 run_loop.Run();
100 93
101 SetObserverForTesting(NULL); 94 SetObserverForTesting(NULL);
102 SetAudioSourceForTesting(NULL); 95 SetAudioSourceForTesting(NULL);
103 96
104 ASSERT_EQ(2, observer.num_play_requests()); 97 ASSERT_EQ(1, observer.num_play_requests());
98 ASSERT_EQ(1, observer.num_replays());
105 ASSERT_EQ(1, observer.num_stop_requests()); 99 ASSERT_EQ(1, observer.num_stop_requests());
106 } 100 }
107 101
108 } // namespace media 102 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698