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

Side by Side Diff: chrome/browser/copresence/chrome_whispernet_client_browsertest.cc

Issue 1002323002: Fixing memory error in ChromeWhispernetClientTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/copresence/chrome_whispernet_client.h" 5 #include "chrome/browser/copresence/chrome_whispernet_client.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <string> 9 #include <string>
10 10
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 saved_samples_index_ = 0; 199 saved_samples_index_ = 0;
200 converter_->Convert(converted_samples.get()); 200 converter_->Convert(converted_samples.get());
201 201
202 return converted_samples; 202 return converted_samples;
203 } 203 }
204 204
205 // AudioConverter::InputCallback overrides: 205 // AudioConverter::InputCallback overrides:
206 double ProvideInput(media::AudioBus* dest, 206 double ProvideInput(media::AudioBus* dest,
207 base::TimeDelta /* buffer_delay */) override { 207 base::TimeDelta /* buffer_delay */) override {
208 int remaining_frames = saved_samples_->frames() - saved_samples_index_; 208 // Copy any saved samples we have to the output bus.
209 int frames_to_copy = std::min(remaining_frames, dest->frames()); 209 const int remaining_frames =
210 saved_samples_->frames() - saved_samples_index_;
211 const int frames_to_copy = std::min(remaining_frames, dest->frames());
210 saved_samples_stereo_->CopyPartialFramesTo(saved_samples_index_, 212 saved_samples_stereo_->CopyPartialFramesTo(saved_samples_index_,
211 frames_to_copy, 0, dest); 213 frames_to_copy, 0, dest);
212 saved_samples_index_ += frames_to_copy; 214 saved_samples_index_ += frames_to_copy;
215
216 // Pad any remaining space with zeroes.
217 for (int i = remaining_frames; i < dest->frames(); i++) {
DaleCurtis 2015/03/18 16:52:23 Should really be dest->ZeroPartialFrames() instead
218 for (int c = 0; c < dest->channels(); c++)
219 dest->channel(c)[i] = 0;
220 }
221
222 // Return the volume level.
213 return 1.0; 223 return 1.0;
214 } 224 }
215 225
216 scoped_ptr<base::RunLoop> run_loop_; 226 scoped_ptr<base::RunLoop> run_loop_;
217 bool initialized_; 227 bool initialized_;
218 228
219 std::string expected_token_; 229 std::string expected_token_;
220 bool expected_audible_; 230 bool expected_audible_;
221 231
222 scoped_refptr<media::AudioBusRefCounted> saved_samples_; 232 scoped_refptr<media::AudioBusRefCounted> saved_samples_;
223 scoped_refptr<media::AudioBusRefCounted> saved_samples_stereo_; 233 scoped_refptr<media::AudioBusRefCounted> saved_samples_stereo_;
224 int saved_samples_index_; 234 int saved_samples_index_;
225 235
226 scoped_ptr<media::AudioConverter> converter_; 236 scoped_ptr<media::AudioConverter> converter_;
227 237
228 media::AudioParameters default_params_; 238 media::AudioParameters default_params_;
229 media::AudioParameters coder_params_; 239 media::AudioParameters coder_params_;
230 240
231 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClientTest); 241 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClientTest);
232 }; 242 };
233 243
234 // These tests are irrelevant if NACL is disabled. See crbug.com/449198. 244 // These tests are irrelevant if NACL is disabled. See crbug.com/449198.
235 // TODO(crbug/464120): There is also a problem in Windows debug mode. 245 #if defined(DISABLE_NACL)
236 // TODO(crbug/464843): There is also a problem under MSan.
237 #if defined(DISABLE_NACL) || \
238 (!defined(NDEBUG) && defined(OS_WIN)) || \
Lei Zhang 2015/03/13 23:32:23 I'm not familiar with this issue, but if you are s
Charlie 2015/03/13 23:49:26 Yes, the windows debug bots are passing after this
239 defined(MEMORY_SANITIZER)
240 #define MAYBE_Initialize DISABLED_Initialize 246 #define MAYBE_Initialize DISABLED_Initialize
241 #define MAYBE_EncodeAndDecode DISABLED_EncodeAndDecode 247 #define MAYBE_EncodeAndDecode DISABLED_EncodeAndDecode
242 #define MAYBE_TokenLengths DISABLED_TokenLengths 248 #define MAYBE_TokenLengths DISABLED_TokenLengths
243 #define MAYBE_Crc DISABLED_Crc 249 #define MAYBE_Crc DISABLED_Crc
244 #define MAYBE_Parity DISABLED_Parity 250 #define MAYBE_Parity DISABLED_Parity
245 #define MAYBE_MultipleClients DISABLED_MultipleClients
246 #else 251 #else
247 #define MAYBE_Initialize Initialize 252 #define MAYBE_Initialize Initialize
248 #define MAYBE_EncodeAndDecode EncodeAndDecode 253 #define MAYBE_EncodeAndDecode EncodeAndDecode
249 #define MAYBE_TokenLengths TokenLengths 254 #define MAYBE_TokenLengths TokenLengths
250 #define MAYBE_Crc Crc 255 #define MAYBE_Crc Crc
251 #define MAYBE_Parity Parity 256 #define MAYBE_Parity Parity
257 #endif
258
259 // This test trips up ASAN on ChromeOS. See:
260 // https://code.google.com/p/address-sanitizer/issues/detail?id=189
261 #if defined(DISABLE_NACL) || defined(OS_CHROMEOS)
262 #define MAYBE_MultipleClients DISABLED_MultipleClients
263 #else
252 #define MAYBE_MultipleClients MultipleClients 264 #define MAYBE_MultipleClients MultipleClients
253 #endif 265 #endif
254 266
255 IN_PROC_BROWSER_TEST_F(ChromeWhispernetClientTest, MAYBE_Initialize) { 267 IN_PROC_BROWSER_TEST_F(ChromeWhispernetClientTest, MAYBE_Initialize) {
256 InitializeWhispernet(); 268 InitializeWhispernet();
257 } 269 }
258 270
259 IN_PROC_BROWSER_TEST_F(ChromeWhispernetClientTest, MAYBE_EncodeAndDecode) { 271 IN_PROC_BROWSER_TEST_F(ChromeWhispernetClientTest, MAYBE_EncodeAndDecode) {
260 scoped_ptr<WhispernetClient> client( 272 scoped_ptr<WhispernetClient> client(
261 new ChromeWhispernetClient(browser()->profile())); 273 new ChromeWhispernetClient(browser()->profile()));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 364
353 EncodeTokenAndSaveSamples(client_3.get(), true, kSixZeros, token_params); 365 EncodeTokenAndSaveSamples(client_3.get(), true, kSixZeros, token_params);
354 DecodeSamplesAndVerifyToken(client_3.get(), true, kSixZeros, token_params); 366 DecodeSamplesAndVerifyToken(client_3.get(), true, kSixZeros, token_params);
355 367
356 const size_t kLongTokenLengths[2] = {8, 9}; 368 const size_t kLongTokenLengths[2] = {8, 9};
357 GetTokenParamsForLengths(kLongTokenLengths, token_params); 369 GetTokenParamsForLengths(kLongTokenLengths, token_params);
358 370
359 EncodeTokenAndSaveSamples(client_2.get(), true, kEightZeros, token_params); 371 EncodeTokenAndSaveSamples(client_2.get(), true, kEightZeros, token_params);
360 DecodeSamplesAndVerifyToken(client_2.get(), true, kEightZeros, token_params); 372 DecodeSamplesAndVerifyToken(client_2.get(), true, kEightZeros, token_params);
361 } 373 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698