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

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

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stddef.h>
6 #include <stdint.h>
7
5 #include "base/bind.h" 8 #include "base/bind.h"
6 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
8 #include "base/location.h" 11 #include "base/location.h"
9 #include "base/macros.h" 12 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 14 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
14 #include "chrome/browser/media/webrtc_rtp_dump_handler.h" 17 #include "chrome/browser/media/webrtc_rtp_dump_handler.h"
15 #include "chrome/browser/media/webrtc_rtp_dump_writer.h" 18 #include "chrome/browser/media/webrtc_rtp_dump_writer.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
19 22
20 class FakeDumpWriter : public WebRtcRtpDumpWriter { 23 class FakeDumpWriter : public WebRtcRtpDumpWriter {
21 public: 24 public:
22 FakeDumpWriter(size_t max_dump_size, 25 FakeDumpWriter(size_t max_dump_size,
23 const base::Closure& max_size_reached_callback, 26 const base::Closure& max_size_reached_callback,
24 bool end_dump_success) 27 bool end_dump_success)
25 : WebRtcRtpDumpWriter(base::FilePath(), 28 : WebRtcRtpDumpWriter(base::FilePath(),
26 base::FilePath(), 29 base::FilePath(),
27 max_dump_size, 30 max_dump_size,
28 base::Closure()), 31 base::Closure()),
29 max_dump_size_(max_dump_size), 32 max_dump_size_(max_dump_size),
30 current_dump_size_(0), 33 current_dump_size_(0),
31 max_size_reached_callback_(max_size_reached_callback), 34 max_size_reached_callback_(max_size_reached_callback),
32 end_dump_success_(end_dump_success) {} 35 end_dump_success_(end_dump_success) {}
33 36
34 void WriteRtpPacket(const uint8* packet_header, 37 void WriteRtpPacket(const uint8_t* packet_header,
35 size_t header_length, 38 size_t header_length,
36 size_t packet_length, 39 size_t packet_length,
37 bool incoming) override { 40 bool incoming) override {
38 current_dump_size_ += header_length; 41 current_dump_size_ += header_length;
39 if (current_dump_size_ > max_dump_size_) 42 if (current_dump_size_ > max_dump_size_)
40 max_size_reached_callback_.Run(); 43 max_size_reached_callback_.Run();
41 } 44 }
42 45
43 void EndDump(RtpDumpType type, 46 void EndDump(RtpDumpType type,
44 const EndDumpCallback& finished_callback) override { 47 const EndDumpCallback& finished_callback) override {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 base::RunLoop().RunUntilIdle(); 159 base::RunLoop().RunUntilIdle();
157 ResetDumpHandler(base::FilePath(), true); 160 ResetDumpHandler(base::FilePath(), true);
158 } 161 }
159 } 162 }
160 163
161 TEST_F(WebRtcRtpDumpHandlerTest, StoppedWhenMaxSizeReached) { 164 TEST_F(WebRtcRtpDumpHandlerTest, StoppedWhenMaxSizeReached) {
162 std::string error; 165 std::string error;
163 166
164 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_INCOMING, &error)); 167 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_INCOMING, &error));
165 168
166 std::vector<uint8> buffer(100, 0); 169 std::vector<uint8_t> buffer(100, 0);
167 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), true); 170 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), true);
168 base::RunLoop().RunUntilIdle(); 171 base::RunLoop().RunUntilIdle();
169 172
170 // Dumping should have been stopped, so ready to release. 173 // Dumping should have been stopped, so ready to release.
171 WebRtcRtpDumpHandler::ReleasedDumps dumps = handler_->ReleaseDumps(); 174 WebRtcRtpDumpHandler::ReleasedDumps dumps = handler_->ReleaseDumps();
172 EXPECT_FALSE(dumps.incoming_dump_path.empty()); 175 EXPECT_FALSE(dumps.incoming_dump_path.empty());
173 } 176 }
174 177
175 TEST_F(WebRtcRtpDumpHandlerTest, PacketIgnoredIfDumpingNotStarted) { 178 TEST_F(WebRtcRtpDumpHandlerTest, PacketIgnoredIfDumpingNotStarted) {
176 std::vector<uint8> buffer(100, 0); 179 std::vector<uint8_t> buffer(100, 0);
177 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), true); 180 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), true);
178 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), false); 181 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), false);
179 base::RunLoop().RunUntilIdle(); 182 base::RunLoop().RunUntilIdle();
180 } 183 }
181 184
182 TEST_F(WebRtcRtpDumpHandlerTest, PacketIgnoredIfDumpingStopped) { 185 TEST_F(WebRtcRtpDumpHandlerTest, PacketIgnoredIfDumpingStopped) {
183 std::string error; 186 std::string error;
184 187
185 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_INCOMING, &error)); 188 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_INCOMING, &error));
186 189
187 EXPECT_CALL(*this, OnStopDumpFinished(true, testing::_)); 190 EXPECT_CALL(*this, OnStopDumpFinished(true, testing::_));
188 handler_->StopDump(RTP_DUMP_INCOMING, 191 handler_->StopDump(RTP_DUMP_INCOMING,
189 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished, 192 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopDumpFinished,
190 base::Unretained(this))); 193 base::Unretained(this)));
191 194
192 std::vector<uint8> buffer(100, 0); 195 std::vector<uint8_t> buffer(100, 0);
193 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), true); 196 handler_->OnRtpPacket(&buffer[0], buffer.size(), buffer.size(), true);
194 base::RunLoop().RunUntilIdle(); 197 base::RunLoop().RunUntilIdle();
195 } 198 }
196 199
197 TEST_F(WebRtcRtpDumpHandlerTest, CannotStartMoreThanFiveDumps) { 200 TEST_F(WebRtcRtpDumpHandlerTest, CannotStartMoreThanFiveDumps) {
198 std::string error; 201 std::string error;
199 202
200 handler_.reset(); 203 handler_.reset();
201 204
202 scoped_ptr<WebRtcRtpDumpHandler> handlers[6]; 205 scoped_ptr<WebRtcRtpDumpHandler> handlers[6];
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); 408 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler));
406 409
407 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); 410 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error));
408 411
409 handler_->StopOngoingDumps( 412 handler_->StopOngoingDumps(
410 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, 413 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished,
411 base::Unretained(this))); 414 base::Unretained(this)));
412 415
413 base::RunLoop().RunUntilIdle(); 416 base::RunLoop().RunUntilIdle();
414 } 417 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_rtp_dump_handler.cc ('k') | chrome/browser/media/webrtc_rtp_dump_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698