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

Side by Side Diff: chrome/browser/extensions/api/webrtc_logging_private/webrtc_event_log_apitest.cc

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path_watcher.h" 9 #include "base/files/file_path_watcher.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "base/threading/thread_restrictions.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_pr ivate_api.h" 18 #include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_pr ivate_api.h"
18 #include "chrome/browser/extensions/extension_function_test_utils.h" 19 #include "chrome/browser/extensions/extension_function_test_utils.h"
19 #include "chrome/browser/extensions/extension_tab_util.h" 20 #include "chrome/browser/extensions/extension_tab_util.h"
20 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" 21 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
21 #include "chrome/browser/media/webrtc/webrtc_browsertest_common.h" 22 #include "chrome/browser/media/webrtc/webrtc_browsertest_common.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
24 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 EXPECT_TRUE(base::JSONWriter::Write(parameters, &parameter_string)); 59 EXPECT_TRUE(base::JSONWriter::Write(parameters, &parameter_string));
59 return parameter_string; 60 return parameter_string;
60 } 61 }
61 62
62 class FileWaiter : public base::RefCountedThreadSafe<FileWaiter> { 63 class FileWaiter : public base::RefCountedThreadSafe<FileWaiter> {
63 public: 64 public:
64 explicit FileWaiter(const base::FilePath& path) 65 explicit FileWaiter(const base::FilePath& path)
65 : found_(false), path_(path) {} 66 : found_(false), path_(path) {}
66 67
67 bool Start() { 68 bool Start() {
69 base::ThreadRestrictions::ScopedAllowIO allow_io;
68 if (base::PathExists(path_)) { 70 if (base::PathExists(path_)) {
69 found_ = true; 71 found_ = true;
70 return true; 72 return true;
71 } else { 73 } else {
72 return watcher_.Watch(path_, false /* recursive */, 74 return watcher_.Watch(path_, false /* recursive */,
73 base::Bind(&FileWaiter::Callback, this)); 75 base::Bind(&FileWaiter::Callback, this));
74 } 76 }
75 } 77 }
76 78
77 // Returns true if |path_| became available. 79 // Returns true if |path_| became available.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ASSERT_NE(render_process_host, nullptr); 228 ASSERT_NE(render_process_host, nullptr);
227 int render_process_id = render_process_host->GetID(); 229 int render_process_id = render_process_host->GetID();
228 base::FilePath full_file_name = 230 base::FilePath full_file_name =
229 GetExpectedEventLogFileName(file_name_stop, render_process_id); 231 GetExpectedEventLogFileName(file_name_stop, render_process_id);
230 int64_t file_size = 0; 232 int64_t file_size = 0;
231 scoped_refptr<FileWaiter> waiter = new FileWaiter(full_file_name); 233 scoped_refptr<FileWaiter> waiter = new FileWaiter(full_file_name);
232 234
233 ASSERT_TRUE(waiter->Start()) << "ERROR watching for " 235 ASSERT_TRUE(waiter->Start()) << "ERROR watching for "
234 << full_file_name.value(); 236 << full_file_name.value();
235 ASSERT_TRUE(waiter->WaitForFile()); 237 ASSERT_TRUE(waiter->WaitForFile());
238 base::ThreadRestrictions::ScopedAllowIO allow_io;
236 ASSERT_TRUE(base::PathExists(full_file_name)); 239 ASSERT_TRUE(base::PathExists(full_file_name));
237 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size)); 240 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size));
238 EXPECT_GT(file_size, 0); 241 EXPECT_GT(file_size, 0);
239 242
240 // Clean up. 243 // Clean up.
241 base::DeleteFile(full_file_name, false); 244 base::DeleteFile(full_file_name, false);
242 } 245 }
243 246
244 IN_PROC_BROWSER_TEST_F(WebrtcEventLogApiTest, 247 IN_PROC_BROWSER_TEST_F(WebrtcEventLogApiTest,
245 TestStartTimedWebRtcEventLogging) { 248 TestStartTimedWebRtcEventLogging) {
249 base::ThreadRestrictions::ScopedAllowIO allow_io;
246 ASSERT_TRUE(embedded_test_server()->Start()); 250 ASSERT_TRUE(embedded_test_server()->Start());
247 251
248 content::WebContents* left_tab = 252 content::WebContents* left_tab =
249 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); 253 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
250 content::WebContents* right_tab = 254 content::WebContents* right_tab =
251 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); 255 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
252 256
253 SetupPeerconnectionWithLocalStream(left_tab); 257 SetupPeerconnectionWithLocalStream(left_tab);
254 SetupPeerconnectionWithLocalStream(right_tab); 258 SetupPeerconnectionWithLocalStream(right_tab);
255 259
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 ASSERT_TRUE(waiter->Start()) << "ERROR watching for " 311 ASSERT_TRUE(waiter->Start()) << "ERROR watching for "
308 << full_file_name.value(); 312 << full_file_name.value();
309 ASSERT_TRUE(waiter->WaitForFile()); 313 ASSERT_TRUE(waiter->WaitForFile());
310 ASSERT_TRUE(base::PathExists(full_file_name)); 314 ASSERT_TRUE(base::PathExists(full_file_name));
311 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size)); 315 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size));
312 EXPECT_GT(file_size, 0); 316 EXPECT_GT(file_size, 0);
313 317
314 // Clean up. 318 // Clean up.
315 base::DeleteFile(full_file_name, false); 319 base::DeleteFile(full_file_name, false);
316 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698