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

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

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/media/webrtc_log_uploader.h" 15 #include "chrome/browser/media/webrtc_log_uploader.h"
16 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 const char kTestTime[] = "time"; 20 const char kTestTime[] = "time";
19 const char kTestReportId[] = "report-id"; 21 const char kTestReportId[] = "report-id";
20 const char kTestLocalId[] = "local-id"; 22 const char kTestLocalId[] = "local-id";
21 23
22 class WebRtcLogUploaderTest : public testing::Test { 24 class WebRtcLogUploaderTest : public testing::Test {
23 public: 25 public:
24 WebRtcLogUploaderTest() {} 26 WebRtcLogUploaderTest() {}
25 27
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 152
151 // The RTP dump takes 4 lines: content-disposition, content-type, empty 153 // The RTP dump takes 4 lines: content-disposition, content-type, empty
152 // line, dump content. 154 // line, dump content.
153 EXPECT_LT(i, lines.size() - 3); 155 EXPECT_LT(i, lines.size() - 3);
154 156
155 EXPECT_EQ("Content-Type: application/gzip", lines[i + 1]); 157 EXPECT_EQ("Content-Type: application/gzip", lines[i + 1]);
156 EXPECT_EQ("", lines[i + 2]); 158 EXPECT_EQ("", lines[i + 2]);
157 EXPECT_EQ(dump_content, lines[i + 3]); 159 EXPECT_EQ(dump_content, lines[i + 3]);
158 } 160 }
159 161
162 content::TestBrowserThreadBundle thread_bundle_;
160 base::FilePath test_list_path_; 163 base::FilePath test_list_path_;
161 }; 164 };
162 165
163 TEST_F(WebRtcLogUploaderTest, AddLocallyStoredLogInfoToUploadListFile) { 166 TEST_F(WebRtcLogUploaderTest, AddLocallyStoredLogInfoToUploadListFile) {
164 // Get a temporary filename. We don't want the file to exist to begin with 167 // Get a temporary filename. We don't want the file to exist to begin with
165 // since that's the normal use case, hence the delete. 168 // since that's the normal use case, hence the delete.
166 ASSERT_TRUE(base::CreateTemporaryFile(&test_list_path_)); 169 ASSERT_TRUE(base::CreateTemporaryFile(&test_list_path_));
167 EXPECT_TRUE(base::DeleteFile(test_list_path_, false)); 170 EXPECT_TRUE(base::DeleteFile(test_list_path_, false));
168 scoped_ptr<WebRtcLogUploader> webrtc_log_uploader(new WebRtcLogUploader()); 171 scoped_ptr<WebRtcLogUploader> webrtc_log_uploader(new WebRtcLogUploader());
169 172
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 base::WriteFile(incoming_dump, 243 base::WriteFile(incoming_dump,
241 &incoming_dump_content[0], 244 &incoming_dump_content[0],
242 incoming_dump_content.size()); 245 incoming_dump_content.size());
243 base::WriteFile(outgoing_dump, 246 base::WriteFile(outgoing_dump,
244 &outgoing_dump_content[0], 247 &outgoing_dump_content[0],
245 outgoing_dump_content.size()); 248 outgoing_dump_content.size());
246 249
247 WebRtcLogUploadDoneData upload_done_data; 250 WebRtcLogUploadDoneData upload_done_data;
248 upload_done_data.log_path = temp_dir.path().AppendASCII("log"); 251 upload_done_data.log_path = temp_dir.path().AppendASCII("log");
249 252
253 scoped_ptr<Profile> profile(new TestingProfile());
254 scoped_refptr<WebRtcLoggingHandlerHost> host(
255 new WebRtcLoggingHandlerHost(profile.get()));
256
250 upload_done_data.incoming_rtp_dump = incoming_dump; 257 upload_done_data.incoming_rtp_dump = incoming_dump;
251 upload_done_data.outgoing_rtp_dump = outgoing_dump; 258 upload_done_data.outgoing_rtp_dump = outgoing_dump;
259 upload_done_data.host = host.get();
252 260
253 scoped_ptr<WebRtcLogBuffer> log(new WebRtcLogBuffer()); 261 scoped_ptr<WebRtcLogBuffer> log(new WebRtcLogBuffer());
254 log->SetComplete(); 262 log->SetComplete();
255 webrtc_log_uploader->LoggingStoppedDoUpload( 263 webrtc_log_uploader->LoggingStoppedDoUpload(
256 log.Pass(), make_scoped_ptr(new MetaDataMap()), upload_done_data); 264 log.Pass(), make_scoped_ptr(new MetaDataMap()), upload_done_data);
257 265
258 VerifyRtpDumpInMultipart(post_data, "rtpdump_recv", incoming_dump_content); 266 VerifyRtpDumpInMultipart(post_data, "rtpdump_recv", incoming_dump_content);
259 VerifyRtpDumpInMultipart(post_data, "rtpdump_send", outgoing_dump_content); 267 VerifyRtpDumpInMultipart(post_data, "rtpdump_send", outgoing_dump_content);
260 268
261 webrtc_log_uploader->StartShutdown(); 269 webrtc_log_uploader->StartShutdown();
262 } 270 }
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | chrome/browser/metrics/thread_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698