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

Side by Side Diff: webrtc/modules/audio_device/android/audio_manager_unittest.cc

Issue 1305983003: Convert some more things to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Support Android's C89 mode Created 5 years, 3 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webrtc/base/format_macros.h"
12 #include "webrtc/base/scoped_ptr.h" 13 #include "webrtc/base/scoped_ptr.h"
13 #include "webrtc/modules/audio_device/android/build_info.h" 14 #include "webrtc/modules/audio_device/android/build_info.h"
14 #include "webrtc/modules/audio_device/android/audio_manager.h" 15 #include "webrtc/modules/audio_device/android/audio_manager.h"
15 #include "webrtc/modules/audio_device/android/ensure_initialized.h" 16 #include "webrtc/modules/audio_device/android/ensure_initialized.h"
16 17
17 #define PRINT(...) fprintf(stderr, __VA_ARGS__); 18 #define PRINT(...) fprintf(stderr, __VA_ARGS__);
18 19
19 namespace webrtc { 20 namespace webrtc {
20 21
21 static const char kTag[] = " "; 22 static const char kTag[] = " ";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 audio_manager()->IsLowLatencyPlayoutSupported() ? "Yes" : "No"); 66 audio_manager()->IsLowLatencyPlayoutSupported() ? "Yes" : "No");
66 } 67 }
67 68
68 TEST_F(AudioManagerTest, ShowAudioParameterInfo) { 69 TEST_F(AudioManagerTest, ShowAudioParameterInfo) {
69 const bool low_latency_out = audio_manager()->IsLowLatencyPlayoutSupported(); 70 const bool low_latency_out = audio_manager()->IsLowLatencyPlayoutSupported();
70 PRINT("PLAYOUT:\n"); 71 PRINT("PLAYOUT:\n");
71 PRINT("%saudio layer: %s\n", kTag, 72 PRINT("%saudio layer: %s\n", kTag,
72 low_latency_out ? "Low latency OpenSL" : "Java/JNI based AudioTrack"); 73 low_latency_out ? "Low latency OpenSL" : "Java/JNI based AudioTrack");
73 PRINT("%ssample rate: %d Hz\n", kTag, playout_parameters_.sample_rate()); 74 PRINT("%ssample rate: %d Hz\n", kTag, playout_parameters_.sample_rate());
74 PRINT("%schannels: %d\n", kTag, playout_parameters_.channels()); 75 PRINT("%schannels: %d\n", kTag, playout_parameters_.channels());
75 PRINT("%sframes per buffer: %d <=> %.2f ms\n", kTag, 76 PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag,
76 playout_parameters_.frames_per_buffer(), 77 playout_parameters_.frames_per_buffer(),
77 playout_parameters_.GetBufferSizeInMilliseconds()); 78 playout_parameters_.GetBufferSizeInMilliseconds());
78 PRINT("RECORD: \n"); 79 PRINT("RECORD: \n");
79 PRINT("%saudio layer: %s\n", kTag, "Java/JNI based AudioRecord"); 80 PRINT("%saudio layer: %s\n", kTag, "Java/JNI based AudioRecord");
80 PRINT("%ssample rate: %d Hz\n", kTag, record_parameters_.sample_rate()); 81 PRINT("%ssample rate: %d Hz\n", kTag, record_parameters_.sample_rate());
81 PRINT("%schannels: %d\n", kTag, record_parameters_.channels()); 82 PRINT("%schannels: %d\n", kTag, record_parameters_.channels());
82 PRINT("%sframes per buffer: %d <=> %.2f ms\n", kTag, 83 PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag,
83 record_parameters_.frames_per_buffer(), 84 record_parameters_.frames_per_buffer(),
84 record_parameters_.GetBufferSizeInMilliseconds()); 85 record_parameters_.GetBufferSizeInMilliseconds());
85 } 86 }
86 87
87 // Add device-specific information to the test for logging purposes. 88 // Add device-specific information to the test for logging purposes.
88 TEST_F(AudioManagerTest, ShowDeviceInfo) { 89 TEST_F(AudioManagerTest, ShowDeviceInfo) {
89 BuildInfo build_info; 90 BuildInfo build_info;
90 PRINT("%smodel: %s\n", kTag, build_info.GetDeviceModel().c_str()); 91 PRINT("%smodel: %s\n", kTag, build_info.GetDeviceModel().c_str());
91 PRINT("%sbrand: %s\n", kTag, build_info.GetBrand().c_str()); 92 PRINT("%sbrand: %s\n", kTag, build_info.GetBrand().c_str());
92 PRINT("%smanufacturer: %s\n", 93 PRINT("%smanufacturer: %s\n",
93 kTag, build_info.GetDeviceManufacturer().c_str()); 94 kTag, build_info.GetDeviceManufacturer().c_str());
94 } 95 }
95 96
96 // Add Android build information to the test for logging purposes. 97 // Add Android build information to the test for logging purposes.
97 TEST_F(AudioManagerTest, ShowBuildInfo) { 98 TEST_F(AudioManagerTest, ShowBuildInfo) {
98 BuildInfo build_info; 99 BuildInfo build_info;
99 PRINT("%sbuild release: %s\n", kTag, build_info.GetBuildRelease().c_str()); 100 PRINT("%sbuild release: %s\n", kTag, build_info.GetBuildRelease().c_str());
100 PRINT("%sbuild id: %s\n", kTag, build_info.GetAndroidBuildId().c_str()); 101 PRINT("%sbuild id: %s\n", kTag, build_info.GetAndroidBuildId().c_str());
101 PRINT("%sbuild type: %s\n", kTag, build_info.GetBuildType().c_str()); 102 PRINT("%sbuild type: %s\n", kTag, build_info.GetBuildType().c_str());
102 PRINT("%sSDK version: %s\n", kTag, build_info.GetSdkVersion().c_str()); 103 PRINT("%sSDK version: %s\n", kTag, build_info.GetSdkVersion().c_str());
103 } 104 }
104 105
105 // Basic test of the AudioParameters class using default construction where 106 // Basic test of the AudioParameters class using default construction where
106 // all members are set to zero. 107 // all members are set to zero.
107 TEST_F(AudioManagerTest, AudioParametersWithDefaultConstruction) { 108 TEST_F(AudioManagerTest, AudioParametersWithDefaultConstruction) {
108 AudioParameters params; 109 AudioParameters params;
109 EXPECT_FALSE(params.is_valid()); 110 EXPECT_FALSE(params.is_valid());
110 EXPECT_EQ(0, params.sample_rate()); 111 EXPECT_EQ(0, params.sample_rate());
111 EXPECT_EQ(0, params.channels()); 112 EXPECT_EQ(0, params.channels());
112 EXPECT_EQ(0, params.frames_per_buffer()); 113 EXPECT_EQ(0U, params.frames_per_buffer());
113 EXPECT_EQ(0U, params.frames_per_10ms_buffer()); 114 EXPECT_EQ(0U, params.frames_per_10ms_buffer());
114 EXPECT_EQ(0, params.GetBytesPerFrame()); 115 EXPECT_EQ(0U, params.GetBytesPerFrame());
115 EXPECT_EQ(0, params.GetBytesPerBuffer()); 116 EXPECT_EQ(0U, params.GetBytesPerBuffer());
116 EXPECT_EQ(0U, params.GetBytesPer10msBuffer()); 117 EXPECT_EQ(0U, params.GetBytesPer10msBuffer());
117 EXPECT_EQ(0.0f, params.GetBufferSizeInMilliseconds()); 118 EXPECT_EQ(0.0f, params.GetBufferSizeInMilliseconds());
118 } 119 }
119 120
120 // Basic test of the AudioParameters class using non default construction. 121 // Basic test of the AudioParameters class using non default construction.
121 TEST_F(AudioManagerTest, AudioParametersWithNonDefaultConstruction) { 122 TEST_F(AudioManagerTest, AudioParametersWithNonDefaultConstruction) {
122 const int kSampleRate = 48000; 123 const int kSampleRate = 48000;
123 const int kChannels = 1; 124 const int kChannels = 1;
124 const int kFramesPerBuffer = 480; 125 const size_t kFramesPerBuffer = 480;
125 const size_t kFramesPer10msBuffer = 480; 126 const size_t kFramesPer10msBuffer = 480;
126 const int kBytesPerFrame = 2; 127 const size_t kBytesPerFrame = 2;
127 const float kBufferSizeInMs = 10.0f; 128 const float kBufferSizeInMs = 10.0f;
128 AudioParameters params(kSampleRate, kChannels, kFramesPerBuffer); 129 AudioParameters params(kSampleRate, kChannels, kFramesPerBuffer);
129 EXPECT_TRUE(params.is_valid()); 130 EXPECT_TRUE(params.is_valid());
130 EXPECT_EQ(kSampleRate, params.sample_rate()); 131 EXPECT_EQ(kSampleRate, params.sample_rate());
131 EXPECT_EQ(kChannels, params.channels()); 132 EXPECT_EQ(kChannels, params.channels());
132 EXPECT_EQ(kFramesPerBuffer, params.frames_per_buffer()); 133 EXPECT_EQ(kFramesPerBuffer, params.frames_per_buffer());
133 EXPECT_EQ(static_cast<size_t>(kSampleRate / 100), 134 EXPECT_EQ(static_cast<size_t>(kSampleRate / 100),
134 params.frames_per_10ms_buffer()); 135 params.frames_per_10ms_buffer());
135 EXPECT_EQ(kBytesPerFrame, params.GetBytesPerFrame()); 136 EXPECT_EQ(kBytesPerFrame, params.GetBytesPerFrame());
136 EXPECT_EQ(kBytesPerFrame * kFramesPerBuffer, params.GetBytesPerBuffer()); 137 EXPECT_EQ(kBytesPerFrame * kFramesPerBuffer, params.GetBytesPerBuffer());
137 EXPECT_EQ(kBytesPerFrame * kFramesPer10msBuffer, 138 EXPECT_EQ(kBytesPerFrame * kFramesPer10msBuffer,
138 params.GetBytesPer10msBuffer()); 139 params.GetBytesPer10msBuffer());
139 EXPECT_EQ(kBufferSizeInMs, params.GetBufferSizeInMilliseconds()); 140 EXPECT_EQ(kBufferSizeInMs, params.GetBufferSizeInMilliseconds());
140 } 141 }
141 142
142 } // namespace webrtc 143 } // namespace webrtc
143 144
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_manager.cc ('k') | webrtc/modules/audio_device/android/fine_audio_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698