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

Side by Side Diff: content/renderer/media/webrtc/webrtc_local_audio_track_adapter_unittest.cc

Issue 187413004: Fixed the Memcheck:Uninitialized warning in WebRtcLocalAudioTrackAdapterTest_AddAndRemoveSink (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased Created 6 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 | 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 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 "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 5 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
6 #include "content/renderer/media/webrtc_local_audio_track.h" 6 #include "content/renderer/media/webrtc_local_audio_track.h"
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 9 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Adds and Removes a WebRtcAudioSink to a local audio track. 55 // Adds and Removes a WebRtcAudioSink to a local audio track.
56 TEST_F(WebRtcLocalAudioTrackAdapterTest, AddAndRemoveSink) { 56 TEST_F(WebRtcLocalAudioTrackAdapterTest, AddAndRemoveSink) {
57 // Add a sink to the webrtc track. 57 // Add a sink to the webrtc track.
58 scoped_ptr<MockWebRtcAudioSink> sink(new MockWebRtcAudioSink()); 58 scoped_ptr<MockWebRtcAudioSink> sink(new MockWebRtcAudioSink());
59 webrtc::AudioTrackInterface* webrtc_track = 59 webrtc::AudioTrackInterface* webrtc_track =
60 static_cast<webrtc::AudioTrackInterface*>(adapter_.get()); 60 static_cast<webrtc::AudioTrackInterface*>(adapter_.get());
61 webrtc_track->AddSink(sink.get()); 61 webrtc_track->AddSink(sink.get());
62 62
63 // Send a packet via |track_| and it data should reach the sink of the 63 // Send a packet via |track_| and it data should reach the sink of the
64 // |adapter_|. 64 // |adapter_|.
65 scoped_ptr<int16[]> data( 65 const int length = params_.frames_per_buffer() * params_.channels();
66 new int16[params_.frames_per_buffer() * params_.channels()]); 66 scoped_ptr<int16[]> data(new int16[length]);
67 // Initialize the data to 0 to avoid Memcheck:Uninitialized warning.
68 memset(data.get(), 0, length * sizeof(data[0]));
69
67 EXPECT_CALL(*sink, 70 EXPECT_CALL(*sink,
68 OnData(_, 16, params_.sample_rate(), params_.channels(), 71 OnData(_, 16, params_.sample_rate(), params_.channels(),
69 params_.frames_per_buffer())); 72 params_.frames_per_buffer()));
70 track_->Capture(data.get(), base::TimeDelta(), 255, false, false); 73 track_->Capture(data.get(), base::TimeDelta(), 255, false, false);
71 74
72 // Remove the sink from the webrtc track. 75 // Remove the sink from the webrtc track.
73 webrtc_track->RemoveSink(sink.get()); 76 webrtc_track->RemoveSink(sink.get());
74 sink.reset(); 77 sink.reset();
75 78
76 // Verify that no more callback gets into the sink. 79 // Verify that no more callback gets into the sink.
77 track_->Capture(data.get(), base::TimeDelta(), 255, false, false); 80 track_->Capture(data.get(), base::TimeDelta(), 255, false, false);
78 } 81 }
79 82
80 } // namespace content 83 } // namespace content
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