Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/tests/test_audio_config.h" | 5 #include "ppapi/tests/test_audio_config.h" |
| 6 | 6 |
| 7 #include "ppapi/c/ppb_audio_config.h" | 7 #include "ppapi/c/ppb_audio_config.h" |
| 8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
| 9 #include "ppapi/tests/testing_instance.h" | 9 #include "ppapi/tests/testing_instance.h" |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 }; | 30 }; |
| 31 static const uint32_t kRequestFrameCounts[] = { | 31 static const uint32_t kRequestFrameCounts[] = { |
| 32 PP_AUDIOMINSAMPLEFRAMECOUNT, | 32 PP_AUDIOMINSAMPLEFRAMECOUNT, |
| 33 PP_AUDIOMAXSAMPLEFRAMECOUNT, | 33 PP_AUDIOMAXSAMPLEFRAMECOUNT, |
| 34 // Include some "okay-looking" frame counts; check their validity below. | 34 // Include some "okay-looking" frame counts; check their validity below. |
| 35 1024, | 35 1024, |
| 36 2048, | 36 2048, |
| 37 4096 | 37 4096 |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Ask PPB_AudioConfig about the recommended sample rate. | |
|
viettrungluu
2012/06/15 21:33:17
Please add a separate test for this ("TestRecommen
| |
| 41 PP_AudioSampleRate sample_rate = audio_config_interface_->RecommendSampleRate( | |
| 42 instance_->pp_instance()); | |
| 43 ASSERT_TRUE(sample_rate == PP_AUDIOSAMPLERATE_NONE || | |
| 44 sample_rate == PP_AUDIOSAMPLERATE_44100 || | |
| 45 sample_rate == PP_AUDIOSAMPLERATE_48000); | |
| 46 | |
| 40 for (size_t i = 0; i < sizeof(kSampleRates)/sizeof(kSampleRates[0]); i++) { | 47 for (size_t i = 0; i < sizeof(kSampleRates)/sizeof(kSampleRates[0]); i++) { |
| 41 PP_AudioSampleRate sample_rate = kSampleRates[i]; | 48 PP_AudioSampleRate sample_rate = kSampleRates[i]; |
| 42 | 49 |
| 43 for (size_t j = 0; | 50 for (size_t j = 0; |
| 44 j < sizeof(kRequestFrameCounts)/sizeof(kRequestFrameCounts); | 51 j < sizeof(kRequestFrameCounts)/sizeof(kRequestFrameCounts); |
| 45 j++) { | 52 j++) { |
| 46 uint32_t request_frame_count = kRequestFrameCounts[j]; | 53 uint32_t request_frame_count = kRequestFrameCounts[j]; |
| 47 ASSERT_TRUE(request_frame_count >= PP_AUDIOMINSAMPLEFRAMECOUNT); | 54 ASSERT_TRUE(request_frame_count >= PP_AUDIOMINSAMPLEFRAMECOUNT); |
| 48 ASSERT_TRUE(request_frame_count <= PP_AUDIOMAXSAMPLEFRAMECOUNT); | 55 ASSERT_TRUE(request_frame_count <= PP_AUDIOMAXSAMPLEFRAMECOUNT); |
| 49 | 56 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 PP_AUDIOMAXSAMPLEFRAMECOUNT + 1u); | 94 PP_AUDIOMAXSAMPLEFRAMECOUNT + 1u); |
| 88 ASSERT_EQ(0, ac); | 95 ASSERT_EQ(0, ac); |
| 89 | 96 |
| 90 // Test rest of API whose failure cases are defined. | 97 // Test rest of API whose failure cases are defined. |
| 91 ASSERT_FALSE(audio_config_interface_->IsAudioConfig(0)); | 98 ASSERT_FALSE(audio_config_interface_->IsAudioConfig(0)); |
| 92 ASSERT_EQ(PP_AUDIOSAMPLERATE_NONE, audio_config_interface_->GetSampleRate(0)); | 99 ASSERT_EQ(PP_AUDIOSAMPLERATE_NONE, audio_config_interface_->GetSampleRate(0)); |
| 93 ASSERT_EQ(0u, audio_config_interface_->GetSampleFrameCount(0)); | 100 ASSERT_EQ(0u, audio_config_interface_->GetSampleFrameCount(0)); |
| 94 | 101 |
| 95 PASS(); | 102 PASS(); |
| 96 } | 103 } |
| OLD | NEW |