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

Side by Side Diff: media/audio/audio_power_monitor_unittest.cc

Issue 19647013: Implement value printer to prevent Valgrind errors in AudioPowerMonitor unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implement operator<< instead. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/audio/audio_power_monitor.h" 5 #include "media/audio/audio_power_monitor.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 sizeof(float) * num_to_copy); 75 sizeof(float) * num_to_copy);
76 } 76 }
77 } 77 }
78 } 78 }
79 79
80 float expected_power_; 80 float expected_power_;
81 bool expected_clipped_; 81 bool expected_clipped_;
82 scoped_ptr<AudioBus> bus_; 82 scoped_ptr<AudioBus> bus_;
83 }; 83 };
84 84
85 // Value printer for TestScenario. Required to prevent Valgrind "access to
86 // uninitialized memory" errors (http://crbug.com/263315).
87 ::std::ostream& operator<<(::std::ostream& os, const TestScenario& ts) {
88 return os << "{" << ts.data().channels() << "-channel signal} --> {"
89 << ts.expected_power() << " dBFS, "
90 << (ts.expected_clipped() ? "clipped" : "not clipped")
91 << "}";
92 }
93
85 // An observer that receives power measurements. Each power measurement should 94 // An observer that receives power measurements. Each power measurement should
86 // should make progress towards the goal value. 95 // should make progress towards the goal value.
87 class MeasurementObserver { 96 class MeasurementObserver {
88 public: 97 public:
89 MeasurementObserver(float goal_power_measurement, bool goal_clipped) 98 MeasurementObserver(float goal_power_measurement, bool goal_clipped)
90 : goal_power_measurement_(goal_power_measurement), 99 : goal_power_measurement_(goal_power_measurement),
91 goal_clipped_(goal_clipped), measurement_count_(0), 100 goal_clipped_(goal_clipped), measurement_count_(0),
92 last_power_measurement_(AudioPowerMonitor::zero_power()), 101 last_power_measurement_(AudioPowerMonitor::zero_power()),
93 last_clipped_(false) {} 102 last_clipped_(false) {}
94 103
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 WithABadSample(std::numeric_limits<float>::quiet_NaN()), 310 WithABadSample(std::numeric_limits<float>::quiet_NaN()),
302 TestScenario(kStereoSilentNoise, 2, 2, -46, false), 311 TestScenario(kStereoSilentNoise, 2, 2, -46, false),
303 TestScenario(kStereoMaxAmplitude, 2, 2, 312 TestScenario(kStereoMaxAmplitude, 2, 2,
304 AudioPowerMonitor::max_power(), false), 313 AudioPowerMonitor::max_power(), false),
305 TestScenario(kRightChannelMaxAmplitude, 2, 4, -3, false), 314 TestScenario(kRightChannelMaxAmplitude, 2, 4, -3, false),
306 TestScenario(kLeftChannelHalfMaxAmplitude, 2, 4, -9, false), 315 TestScenario(kLeftChannelHalfMaxAmplitude, 2, 4, -9, false),
307 TestScenario(kStereoMixed, 2, 4, -2, false), 316 TestScenario(kStereoMixed, 2, 4, -2, false),
308 TestScenario(kStereoMixed2, 2, 8, -3, false))); 317 TestScenario(kStereoMixed2, 2, 8, -3, false)));
309 318
310 } // namespace media 319 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698