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

Side by Side Diff: chrome/browser/media/webrtc_rtp_dump_handler_unittest.cc

Issue 322603003: Fix a crash in WebRtcRtpDumpHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 // 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 scoped_ptr<WebRtcRtpDumpWriter> writer(new FakeDumpWriter( 73 scoped_ptr<WebRtcRtpDumpWriter> writer(new FakeDumpWriter(
74 10, 74 10,
75 base::Bind(&WebRtcRtpDumpHandler::OnMaxDumpSizeReached, 75 base::Bind(&WebRtcRtpDumpHandler::OnMaxDumpSizeReached,
76 base::Unretained(handler_.get())), 76 base::Unretained(handler_.get())),
77 end_dump_success)); 77 end_dump_success));
78 78
79 handler_->SetDumpWriterForTesting(writer.Pass()); 79 handler_->SetDumpWriterForTesting(writer.Pass());
80 } 80 }
81 81
82 void DeleteDumpHandler() { handler_.reset(); }
83
82 void WriteFakeDumpFiles(const base::FilePath& dir, 84 void WriteFakeDumpFiles(const base::FilePath& dir,
83 base::FilePath* incoming_dump, 85 base::FilePath* incoming_dump,
84 base::FilePath* outgoing_dump) { 86 base::FilePath* outgoing_dump) {
85 *incoming_dump = dir.AppendASCII("recv"); 87 *incoming_dump = dir.AppendASCII("recv");
86 *outgoing_dump = dir.AppendASCII("send"); 88 *outgoing_dump = dir.AppendASCII("send");
87 const char dummy[] = "dummy"; 89 const char dummy[] = "dummy";
88 EXPECT_GT(base::WriteFile(*incoming_dump, dummy, arraysize(dummy)), 0); 90 EXPECT_GT(base::WriteFile(*incoming_dump, dummy, arraysize(dummy)), 0);
89 EXPECT_GT(base::WriteFile(*outgoing_dump, dummy, arraysize(dummy)), 0); 91 EXPECT_GT(base::WriteFile(*outgoing_dump, dummy, arraysize(dummy)), 0);
90 } 92 }
91 93
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 handler_->StopOngoingDumps( 386 handler_->StopOngoingDumps(
385 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, 387 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished,
386 base::Unretained(this))); 388 base::Unretained(this)));
387 389
388 base::RunLoop().RunUntilIdle(); 390 base::RunLoop().RunUntilIdle();
389 391
390 WebRtcRtpDumpHandler::ReleasedDumps dumps(handler_->ReleaseDumps()); 392 WebRtcRtpDumpHandler::ReleasedDumps dumps(handler_->ReleaseDumps());
391 EXPECT_FALSE(dumps.incoming_dump_path.empty()); 393 EXPECT_FALSE(dumps.incoming_dump_path.empty());
392 EXPECT_FALSE(dumps.outgoing_dump_path.empty()); 394 EXPECT_FALSE(dumps.outgoing_dump_path.empty());
393 } 395 }
396
397 TEST_F(WebRtcRtpDumpHandlerTest, DeleteHandlerBeforeStopCallback) {
398 std::string error;
399
400 EXPECT_CALL(*this, OnStopOngoingDumpsFinished())
401 .WillOnce(testing::InvokeWithoutArgs(
402 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler));
403
404 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error));
405
406 handler_->StopOngoingDumps(
407 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished,
408 base::Unretained(this)));
409
410 base::RunLoop().RunUntilIdle();
411 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_rtp_dump_handler.cc ('k') | chrome/browser/media/webrtc_rtp_dump_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698