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

Side by Side Diff: content/browser/media/webrtc_getusermedia_browsertest.cc

Issue 750183008: DevTools: Parallelize trace messages serialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests were fixed Created 6 years 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/debug/trace_event_impl.h" 6 #include "base/debug/trace_event_impl.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/test/trace_event_analyzer.h" 9 #include "base/test/trace_event_analyzer.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 base::debug::TraceLog::RECORDING_MODE, 89 base::debug::TraceLog::RECORDING_MODE,
90 trace_options); 90 trace_options);
91 // Check that we are indeed recording. 91 // Check that we are indeed recording.
92 EXPECT_EQ(trace_log_->GetNumTracesRecorded(), 1); 92 EXPECT_EQ(trace_log_->GetNumTracesRecorded(), 1);
93 } 93 }
94 94
95 void StopTracing() { 95 void StopTracing() {
96 CHECK(message_loop_runner_.get() == NULL) 96 CHECK(message_loop_runner_.get() == NULL)
97 << "Calling StopTracing more than once"; 97 << "Calling StopTracing more than once";
98 trace_log_->SetDisabled(); 98 trace_log_->SetDisabled();
99 message_loop_proxy_ = base::MessageLoopProxy::current();
99 message_loop_runner_ = new MessageLoopRunner; 100 message_loop_runner_ = new MessageLoopRunner;
100 trace_log_->Flush(base::Bind( 101 trace_log_->Flush(base::Bind(
101 &WebRtcGetUserMediaBrowserTest::OnTraceDataCollected, 102 &WebRtcGetUserMediaBrowserTest::OnTraceDataCollected,
102 base::Unretained(this))); 103 base::Unretained(this)));
103 message_loop_runner_->Run(); 104 message_loop_runner_->Run();
104 } 105 }
105 106
106 void OnTraceDataCollected( 107 void OnTraceDataCollected(
107 const scoped_refptr<base::RefCountedString>& events_str_ptr, 108 const scoped_refptr<base::RefCountedString>& events_str_ptr,
108 bool has_more_events) { 109 bool has_more_events) {
109 CHECK(!has_more_events); 110 CHECK(!has_more_events);
111 if (!message_loop_proxy_->BelongsToCurrentThread()) {
112 message_loop_proxy_->PostTask(
113 FROM_HERE,
114 Bind(&WebRtcGetUserMediaBrowserTest::OnTraceDataCollected,
115 base::Unretained(this), events_str_ptr, has_more_events));
116 return;
117 }
110 recorded_trace_data_ = events_str_ptr; 118 recorded_trace_data_ = events_str_ptr;
111 message_loop_runner_->Quit(); 119 message_loop_runner_->Quit();
112 } 120 }
113 121
114 TraceAnalyzer* CreateTraceAnalyzer() { 122 TraceAnalyzer* CreateTraceAnalyzer() {
115 return TraceAnalyzer::Create("[" + recorded_trace_data_->data() + "]"); 123 return TraceAnalyzer::Create("[" + recorded_trace_data_->data() + "]");
116 } 124 }
117 125
118 void RunGetUserMediaAndCollectMeasures(const int time_to_sample_secs, 126 void RunGetUserMediaAndCollectMeasures(const int time_to_sample_secs,
119 const std::string& measure_filter, 127 const std::string& measure_filter,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 235 }
228 } 236 }
229 ASSERT_FALSE(audio_ids->empty()); 237 ASSERT_FALSE(audio_ids->empty());
230 ASSERT_FALSE(video_ids->empty()); 238 ASSERT_FALSE(video_ids->empty());
231 } 239 }
232 240
233 private: 241 private:
234 base::debug::TraceLog* trace_log_; 242 base::debug::TraceLog* trace_log_;
235 scoped_refptr<base::RefCountedString> recorded_trace_data_; 243 scoped_refptr<base::RefCountedString> recorded_trace_data_;
236 scoped_refptr<MessageLoopRunner> message_loop_runner_; 244 scoped_refptr<MessageLoopRunner> message_loop_runner_;
245 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
237 }; 246 };
238 247
239 // These tests will all make a getUserMedia call with different constraints and 248 // These tests will all make a getUserMedia call with different constraints and
240 // see that the success callback is called. If the error callback is called or 249 // see that the success callback is called. If the error callback is called or
241 // none of the callbacks are called the tests will simply time out and fail. 250 // none of the callbacks are called the tests will simply time out and fail.
242 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, GetVideoStreamAndStop) { 251 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, GetVideoStreamAndStop) {
243 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 252 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
244 253
245 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 254 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
246 NavigateToURL(shell(), url); 255 NavigateToURL(shell(), url);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 {640, 640, 360, 360, 10, 30}, 659 {640, 640, 360, 360, 10, 30},
651 {640, 640, 480, 480, 10, 30}, 660 {640, 640, 480, 480, 10, 30},
652 {960, 960, 720, 720, 10, 30}, 661 {960, 960, 720, 720, 10, 30},
653 {1280, 1280, 720, 720, 10, 30}}; 662 {1280, 1280, 720, 720, 10, 30}};
654 663
655 INSTANTIATE_TEST_CASE_P(UserMedia, 664 INSTANTIATE_TEST_CASE_P(UserMedia,
656 WebRtcConstraintsBrowserTest, 665 WebRtcConstraintsBrowserTest,
657 testing::ValuesIn(kAllUserMediaSizes)); 666 testing::ValuesIn(kAllUserMediaSizes));
658 667
659 } // namespace content 668 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698