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 "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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 run_loop.Run(); | 68 run_loop.Run(); |
69 | 69 |
70 SetObserverForTesting(NULL); | 70 SetObserverForTesting(NULL); |
71 | 71 |
72 ASSERT_EQ(1, observer.num_play_requests()); | 72 ASSERT_EQ(1, observer.num_play_requests()); |
73 ASSERT_EQ(1, observer.num_stop_requests()); | 73 ASSERT_EQ(1, observer.num_stop_requests()); |
74 ASSERT_EQ(4, observer.cursor()); | 74 ASSERT_EQ(4, observer.cursor()); |
75 } | 75 } |
76 | 76 |
77 TEST_F(AudioStreamHandlerTest, Rewind) { | 77 TEST_F(AudioStreamHandlerTest, ConsecutivePlayRequests) { |
78 base::RunLoop run_loop; | 78 base::RunLoop run_loop; |
79 TestObserver observer(run_loop.QuitClosure()); | 79 TestObserver observer(run_loop.QuitClosure()); |
80 SineWaveAudioSource source(CHANNEL_LAYOUT_STEREO, 200.0, 8000); | 80 SineWaveAudioSource source(CHANNEL_LAYOUT_STEREO, 200.0, 8000); |
81 | 81 |
82 SetObserverForTesting(&observer); | 82 SetObserverForTesting(&observer); |
83 SetAudioSourceForTesting(&source); | 83 SetAudioSourceForTesting(&source); |
84 | 84 |
85 ASSERT_TRUE(audio_stream_handler()->IsInitialized()); | 85 ASSERT_TRUE(audio_stream_handler()->IsInitialized()); |
86 | 86 |
87 ASSERT_TRUE(audio_stream_handler()->Play()); | 87 ASSERT_TRUE(audio_stream_handler()->Play()); |
88 base::MessageLoop::current()->PostDelayedTask( | 88 base::MessageLoop::current()->PostDelayedTask( |
89 FROM_HERE, | 89 FROM_HERE, |
90 base::Bind(base::IgnoreResult(&AudioStreamHandler::Play), | 90 base::Bind(base::IgnoreResult(&AudioStreamHandler::Play), |
91 base::Unretained(audio_stream_handler())), | 91 base::Unretained(audio_stream_handler())), |
92 base::TimeDelta::FromSeconds(3)); | 92 base::TimeDelta::FromSeconds(1)); |
93 base::MessageLoop::current()->PostDelayedTask( | 93 base::MessageLoop::current()->PostDelayedTask( |
94 FROM_HERE, | 94 FROM_HERE, |
95 base::Bind(&AudioStreamHandler::Stop, | 95 base::Bind(&AudioStreamHandler::Stop, |
96 base::Unretained(audio_stream_handler())), | 96 base::Unretained(audio_stream_handler())), |
97 base::TimeDelta::FromSeconds(6)); | 97 base::TimeDelta::FromSeconds(2)); |
98 | 98 |
99 run_loop.Run(); | 99 run_loop.Run(); |
100 | 100 |
101 SetObserverForTesting(NULL); | 101 SetObserverForTesting(NULL); |
102 SetAudioSourceForTesting(NULL); | 102 SetAudioSourceForTesting(NULL); |
103 | 103 |
104 ASSERT_EQ(2, observer.num_play_requests()); | 104 ASSERT_EQ(1, observer.num_play_requests()); |
105 ASSERT_EQ(1, observer.num_stop_requests()); | 105 ASSERT_EQ(1, observer.num_stop_requests()); |
106 } | 106 } |
107 | 107 |
108 } // namespace media | 108 } // namespace media |
OLD | NEW |