| OLD | NEW |
| 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/media/webrtc/webrtc_rtp_dump_handler.h" | 5 #include "chrome/browser/media/webrtc/webrtc_rtp_dump_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 handler_->StopDump(RTP_DUMP_OUTGOING, | 263 handler_->StopDump(RTP_DUMP_OUTGOING, |
| 264 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, | 264 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, |
| 265 base::Unretained(this))); | 265 base::Unretained(this))); |
| 266 | 266 |
| 267 base::RunLoop().RunUntilIdle(); | 267 base::RunLoop().RunUntilIdle(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 TEST_F(WebRtcRtpDumpHandlerTest, DumpsCleanedUpIfNotReleased) { | 270 TEST_F(WebRtcRtpDumpHandlerTest, DumpsCleanedUpIfNotReleased) { |
| 271 base::ScopedTempDir temp_dir; | 271 base::ScopedTempDir temp_dir; |
| 272 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 272 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 273 ResetDumpHandler(temp_dir.path(), true); | 273 ResetDumpHandler(temp_dir.GetPath(), true); |
| 274 | 274 |
| 275 base::FilePath incoming_dump, outgoing_dump; | 275 base::FilePath incoming_dump, outgoing_dump; |
| 276 WriteFakeDumpFiles(temp_dir.path(), &incoming_dump, &outgoing_dump); | 276 WriteFakeDumpFiles(temp_dir.GetPath(), &incoming_dump, &outgoing_dump); |
| 277 | 277 |
| 278 std::string error; | 278 std::string error; |
| 279 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); | 279 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); |
| 280 | 280 |
| 281 EXPECT_CALL(*this, OnStopDumpFinished(true, testing::_)); | 281 EXPECT_CALL(*this, OnStopDumpFinished(true, testing::_)); |
| 282 handler_->StopDump(RTP_DUMP_BOTH, | 282 handler_->StopDump(RTP_DUMP_BOTH, |
| 283 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, | 283 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, |
| 284 base::Unretained(this))); | 284 base::Unretained(this))); |
| 285 base::RunLoop().RunUntilIdle(); | 285 base::RunLoop().RunUntilIdle(); |
| 286 | 286 |
| 287 handler_.reset(); | 287 handler_.reset(); |
| 288 base::RunLoop().RunUntilIdle(); | 288 base::RunLoop().RunUntilIdle(); |
| 289 | 289 |
| 290 EXPECT_FALSE(base::PathExists(incoming_dump)); | 290 EXPECT_FALSE(base::PathExists(incoming_dump)); |
| 291 EXPECT_FALSE(base::PathExists(outgoing_dump)); | 291 EXPECT_FALSE(base::PathExists(outgoing_dump)); |
| 292 } | 292 } |
| 293 | 293 |
| 294 TEST_F(WebRtcRtpDumpHandlerTest, DumpDeletedIfEndDumpFailed) { | 294 TEST_F(WebRtcRtpDumpHandlerTest, DumpDeletedIfEndDumpFailed) { |
| 295 base::ScopedTempDir temp_dir; | 295 base::ScopedTempDir temp_dir; |
| 296 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 296 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 297 | 297 |
| 298 // Make the writer return failure on EndStream. | 298 // Make the writer return failure on EndStream. |
| 299 ResetDumpHandler(temp_dir.path(), false); | 299 ResetDumpHandler(temp_dir.GetPath(), false); |
| 300 | 300 |
| 301 base::FilePath incoming_dump, outgoing_dump; | 301 base::FilePath incoming_dump, outgoing_dump; |
| 302 WriteFakeDumpFiles(temp_dir.path(), &incoming_dump, &outgoing_dump); | 302 WriteFakeDumpFiles(temp_dir.GetPath(), &incoming_dump, &outgoing_dump); |
| 303 | 303 |
| 304 std::string error; | 304 std::string error; |
| 305 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); | 305 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); |
| 306 EXPECT_CALL(*this, OnStopDumpFinished(true, testing::_)).Times(2); | 306 EXPECT_CALL(*this, OnStopDumpFinished(true, testing::_)).Times(2); |
| 307 | 307 |
| 308 handler_->StopDump(RTP_DUMP_INCOMING, | 308 handler_->StopDump(RTP_DUMP_INCOMING, |
| 309 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, | 309 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, |
| 310 base::Unretained(this))); | 310 base::Unretained(this))); |
| 311 base::RunLoop().RunUntilIdle(); | 311 base::RunLoop().RunUntilIdle(); |
| 312 | 312 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); | 410 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); |
| 411 | 411 |
| 412 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); | 412 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); |
| 413 | 413 |
| 414 handler_->StopOngoingDumps( | 414 handler_->StopOngoingDumps( |
| 415 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, | 415 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, |
| 416 base::Unretained(this))); | 416 base::Unretained(this))); |
| 417 | 417 |
| 418 base::RunLoop().RunUntilIdle(); | 418 base::RunLoop().RunUntilIdle(); |
| 419 } | 419 } |
| OLD | NEW |