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 #ifndef MEDIA_AUDIO_SOUNDS_TEST_UTILS_H_ | 5 #ifndef MEDIA_AUDIO_SOUNDS_TEST_UTILS_H_ |
6 #define MEDIA_AUDIO_SOUNDS_TEST_UTILS_H_ | 6 #define MEDIA_AUDIO_SOUNDS_TEST_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "media/audio/sounds/audio_stream_handler.h" | 11 #include "media/audio/sounds/audio_stream_handler.h" |
| 12 #include "media/audio/sounds/wav_parser.h" |
| 13 #include "media/audio/sounds/wav_reader.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 class MessageLoop; | 16 class MessageLoop; |
15 } | 17 } |
16 | 18 |
17 namespace media { | 19 namespace media { |
18 | 20 |
19 const int kTestAudioKey = 1000; | 21 const int kTestAudioKey = 1000; |
20 | 22 |
21 const char kTestAudioData[] = "RIFF\x26\x00\x00\x00WAVEfmt \x10\x00\x00\x00" | 23 const char kTestAudioData[] = "RIFF\x26\x00\x00\x00WAVEfmt \x10\x00\x00\x00" |
22 "\x01\x00\x02\x00\x80\xbb\x00\x00\x00\x77\x01\x00\x02\x00\x10\x00" | 24 "\x01\x00\x02\x00\x80\xbb\x00\x00\x00\x77\x01\x00\x02\x00\x10\x00" |
23 "data\x04\x00\x00\x00\x01\x00\x01\x00"; | 25 "data\x04\x00\x00\x00\x01\x00\x01\x00"; |
24 | 26 |
25 class TestObserver : public AudioStreamHandler::TestObserver { | 27 class TestObserver : public AudioStreamHandler::TestObserver { |
26 public: | 28 public: |
27 TestObserver(const base::Closure& quit); | 29 TestObserver(const base::Closure& quit); |
28 virtual ~TestObserver(); | 30 virtual ~TestObserver(); |
29 | 31 |
30 // AudioStreamHandler::TestObserver implementation: | 32 // AudioStreamHandler::TestObserver implementation: |
31 virtual void OnPlay() OVERRIDE; | 33 virtual void OnPlay() OVERRIDE; |
| 34 virtual void OnReplay() OVERRIDE; |
32 virtual void OnStop(size_t cursor) OVERRIDE; | 35 virtual void OnStop(size_t cursor) OVERRIDE; |
33 | 36 |
34 int num_play_requests() const { return num_play_requests_; } | 37 int num_play_requests() const { return num_play_requests_; } |
| 38 int num_replays() const { return num_replays_; } |
35 int num_stop_requests() const { return num_stop_requests_; } | 39 int num_stop_requests() const { return num_stop_requests_; } |
36 int cursor() const { return cursor_; } | 40 int cursor() const { return cursor_; } |
37 | 41 |
38 private: | 42 private: |
39 base::MessageLoop* loop_; | 43 base::MessageLoop* loop_; |
40 base::Closure quit_; | 44 base::Closure quit_; |
41 | 45 |
42 int num_play_requests_; | 46 int num_play_requests_; |
| 47 int num_replays_; |
43 int num_stop_requests_; | 48 int num_stop_requests_; |
44 int cursor_; | 49 int cursor_; |
45 | 50 |
46 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 51 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
47 }; | 52 }; |
48 | 53 |
| 54 class TestWavReader : public WavReader { |
| 55 public: |
| 56 explicit TestWavReader(const WavParser& parser); |
| 57 virtual ~TestWavReader(); |
| 58 |
| 59 // WavReader implementation: |
| 60 virtual bool AtEnd(size_t cursor) OVERRIDE; |
| 61 virtual bool CopyTo(AudioBus* bus, |
| 62 size_t cursor, |
| 63 size_t* bytes_written) OVERRIDE; |
| 64 |
| 65 void SimulateAtEndOnce(); |
| 66 |
| 67 private: |
| 68 const WavParser parser_; |
| 69 int num_simulate_at_end_requests_; |
| 70 }; |
| 71 |
49 } // namespace media | 72 } // namespace media |
50 | 73 |
51 #endif // MEDIA_AUDIO_SOUNDS_TEST_UTILS_H_ | 74 #endif // MEDIA_AUDIO_SOUNDS_TEST_UTILS_H_ |
OLD | NEW |