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

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

Issue 2131133002: Reenable the WebRTC EventLog API Tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 20 matching lines...) Expand all
31 #endif 31 #endif
32 32
33 using extensions::WebrtcLoggingPrivateStartWebRtcEventLoggingFunction; 33 using extensions::WebrtcLoggingPrivateStartWebRtcEventLoggingFunction;
34 using extensions::WebrtcLoggingPrivateStopWebRtcEventLoggingFunction; 34 using extensions::WebrtcLoggingPrivateStopWebRtcEventLoggingFunction;
35 35
36 namespace utils = extension_function_test_utils; 36 namespace utils = extension_function_test_utils;
37 37
38 namespace { 38 namespace {
39 39
40 // Get the expected EventLog file name. The name will be 40 // Get the expected EventLog file name. The name will be
41 // <temporary path>.<render process id>.event_log.<consumer id>, for example 41 // <temporary path>.<render process id>.event_log.<consumer id>, for example
terelius1 2016/07/08 10:58:37 Please update the comment.
Ivo-OOO until feb 6 2016/07/08 11:24:35 Done. I renamed the variable below as well.
42 // /tmp/.org.chromium.Chromium.vsygNQ/dnFW8ch/Default/WebRTC 42 // /tmp/.org.chromium.Chromium.vsygNQ/dnFW8ch/Default/WebRTC
43 // Logs/WebRtcEventLog.1.29113.event_log.1 43 // Logs/WebRtcEventLog.1.6.1
44 base::FilePath GetExpectedEventLogFileName(const base::FilePath& base_file, 44 base::FilePath GetExpectedEventLogFileName(const base::FilePath& base_file,
45 int render_process_id) { 45 int render_process_id) {
46 static const int kExpectedConsumerId = 1; 46 static const int kExpectedConsumerId = 1;
47 return base_file.AddExtension(IntToStringType(render_process_id)) 47 return base_file.AddExtension(IntToStringType(render_process_id))
48 .AddExtension(FILE_PATH_LITERAL("event_log"))
49 .AddExtension(IntToStringType(kExpectedConsumerId)); 48 .AddExtension(IntToStringType(kExpectedConsumerId));
50 } 49 }
51 50
52 static const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html"; 51 static const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html";
53 52
54 std::string ParamsToString(const base::ListValue& parameters) { 53 std::string ParamsToString(const base::ListValue& parameters) {
55 std::string parameter_string; 54 std::string parameter_string;
56 EXPECT_TRUE(base::JSONWriter::Write(parameters, &parameter_string)); 55 EXPECT_TRUE(base::JSONWriter::Write(parameters, &parameter_string));
57 return parameter_string; 56 return parameter_string;
58 } 57 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 parameters->Append(std::move(request_info)); 99 parameters->Append(std::move(request_info));
101 parameters->AppendString(tab->GetURL().GetOrigin().spec()); 100 parameters->AppendString(tab->GetURL().GetOrigin().spec());
102 } 101 }
103 102
104 private: 103 private:
105 scoped_refptr<extensions::Extension> extension_; 104 scoped_refptr<extensions::Extension> extension_;
106 }; 105 };
107 106
108 } // namespace 107 } // namespace
109 108
110 // TODO(ivoc): Reenable when the event log functionality in Chrome is updated. 109 IN_PROC_BROWSER_TEST_F(WebrtcEventLogApiTest, TestStartStopWebRtcEventLogging) {
111 IN_PROC_BROWSER_TEST_F(WebrtcEventLogApiTest,
112 DISABLED_TestStartStopWebRtcEventLogging) {
113 ASSERT_TRUE(embedded_test_server()->Start()); 110 ASSERT_TRUE(embedded_test_server()->Start());
114 111
115 content::WebContents* left_tab = 112 content::WebContents* left_tab =
116 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); 113 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
117 content::WebContents* right_tab = 114 content::WebContents* right_tab =
118 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); 115 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
119 116
120 SetupPeerconnectionWithLocalStream(left_tab); 117 SetupPeerconnectionWithLocalStream(left_tab);
121 SetupPeerconnectionWithLocalStream(right_tab); 118 SetupPeerconnectionWithLocalStream(right_tab);
122 119
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 ASSERT_TRUE(recordings_info_stop.get()); 168 ASSERT_TRUE(recordings_info_stop.get());
172 base::FilePath file_name_stop( 169 base::FilePath file_name_stop(
173 base::FilePath::FromUTF8Unsafe(recordings_info_stop->prefix_path)); 170 base::FilePath::FromUTF8Unsafe(recordings_info_stop->prefix_path));
174 171
175 HangUp(left_tab); 172 HangUp(left_tab);
176 HangUp(right_tab); 173 HangUp(right_tab);
177 174
178 EXPECT_EQ(file_name_start, file_name_stop); 175 EXPECT_EQ(file_name_start, file_name_stop);
179 176
180 // Check that the file exists and is non-empty. 177 // Check that the file exists and is non-empty.
181 base::ProcessId render_process_id = 178 content::RenderProcessHost* render_process_host =
182 base::GetProcId(left_tab->GetRenderProcessHost()->GetHandle()); 179 left_tab->GetRenderProcessHost();
183 EXPECT_NE(render_process_id, base::kNullProcessId); 180 ASSERT_NE(render_process_host, nullptr);
181 int render_process_id = render_process_host->GetID();
184 base::FilePath full_file_name = 182 base::FilePath full_file_name =
185 GetExpectedEventLogFileName(file_name_stop, render_process_id); 183 GetExpectedEventLogFileName(file_name_stop, render_process_id);
186 int64_t file_size = 0; 184 int64_t file_size = 0;
185 int timeout_counter = 0;
187 while (!(base::PathExists(full_file_name) && 186 while (!(base::PathExists(full_file_name) &&
188 base::GetFileSize(full_file_name, &file_size) && file_size > 0)) { 187 base::GetFileSize(full_file_name, &file_size) && file_size > 0)) {
189 // This should normally not happen, but is here to prevent the test 188 // This should normally not happen, but is here to prevent the test
190 // from becoming flaky on devices with weird timings or when the 189 // from becoming flaky on devices with weird timings or when the
191 // /webrtc/webrtc_jsep01_test.html changes. 190 // /webrtc/webrtc_jsep01_test.html changes.
192 VLOG(1) << "Waiting for logfile to become available..."; 191 VLOG(1) << "Waiting for logfile to become available...";
193 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 192 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
193 if (timeout_counter++ >= 50) {
194 VLOG(1) << "Giving up on waiting for logfile.";
195 break;
196 }
194 } 197 }
195 ASSERT_TRUE(base::PathExists(full_file_name)); 198 ASSERT_TRUE(base::PathExists(full_file_name));
196 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size)); 199 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size));
197 EXPECT_GT(file_size, 0); 200 EXPECT_GT(file_size, 0);
198 201
199 // Clean up. 202 // Clean up.
200 base::DeleteFile(full_file_name, false); 203 base::DeleteFile(full_file_name, false);
201 } 204 }
202 205
203 // TODO(ivoc): Reenable when the event log functionality in Chrome is updated.
204 IN_PROC_BROWSER_TEST_F(WebrtcEventLogApiTest, 206 IN_PROC_BROWSER_TEST_F(WebrtcEventLogApiTest,
205 DISABLED_TestStartTimedWebRtcEventLogging) { 207 TestStartTimedWebRtcEventLogging) {
206 ASSERT_TRUE(embedded_test_server()->Start()); 208 ASSERT_TRUE(embedded_test_server()->Start());
207 209
208 content::WebContents* left_tab = 210 content::WebContents* left_tab =
209 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); 211 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
210 content::WebContents* right_tab = 212 content::WebContents* right_tab =
211 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); 213 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
212 214
213 SetupPeerconnectionWithLocalStream(left_tab); 215 SetupPeerconnectionWithLocalStream(left_tab);
214 SetupPeerconnectionWithLocalStream(right_tab); 216 SetupPeerconnectionWithLocalStream(right_tab);
215 217
(...skipping 29 matching lines...) Expand all
245 // Video is choppy on Mac OS X. http://crbug.com/443542. 247 // Video is choppy on Mac OS X. http://crbug.com/443542.
246 WaitForVideoToPlay(left_tab); 248 WaitForVideoToPlay(left_tab);
247 WaitForVideoToPlay(right_tab); 249 WaitForVideoToPlay(right_tab);
248 #endif 250 #endif
249 251
250 HangUp(left_tab); 252 HangUp(left_tab);
251 HangUp(right_tab); 253 HangUp(right_tab);
252 254
253 // The log has stopped automatically. Check that the file exists and is 255 // The log has stopped automatically. Check that the file exists and is
254 // non-empty. 256 // non-empty.
255 base::ProcessId render_process_id = 257 content::RenderProcessHost* render_process_host =
256 base::GetProcId(left_tab->GetRenderProcessHost()->GetHandle()); 258 left_tab->GetRenderProcessHost();
257 EXPECT_NE(render_process_id, base::kNullProcessId); 259 ASSERT_NE(render_process_host, nullptr);
260 int render_process_id = render_process_host->GetID();
258 base::FilePath full_file_name = 261 base::FilePath full_file_name =
259 GetExpectedEventLogFileName(file_name_start, render_process_id); 262 GetExpectedEventLogFileName(file_name_start, render_process_id);
260 int64_t file_size = 0; 263 int64_t file_size = 0;
264 int timeout_counter = 0;
261 while (!(base::PathExists(full_file_name) && 265 while (!(base::PathExists(full_file_name) &&
262 base::GetFileSize(full_file_name, &file_size) && file_size > 0)) { 266 base::GetFileSize(full_file_name, &file_size) && file_size > 0)) {
263 // This should normally not happen, but is here to prevent the test 267 // This should normally not happen, but is here to prevent the test
264 // from becoming flaky on devices with weird timings or when the 268 // from becoming flaky on devices with weird timings or when the
265 // /webrtc/webrtc_jsep01_test.html changes. 269 // /webrtc/webrtc_jsep01_test.html changes.
266 VLOG(1) << "Waiting for logfile to become available..."; 270 VLOG(1) << "Waiting for logfile to become available...";
267 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 271 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
272 if (timeout_counter++ >= 50) {
273 VLOG(1) << "Giving up on waiting for logfile.";
274 break;
275 }
268 } 276 }
269 ASSERT_TRUE(base::PathExists(full_file_name)); 277 ASSERT_TRUE(base::PathExists(full_file_name));
270 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size)); 278 EXPECT_TRUE(base::GetFileSize(full_file_name, &file_size));
271 EXPECT_GT(file_size, 0); 279 EXPECT_GT(file_size, 0);
272 280
273 // Clean up. 281 // Clean up.
274 base::DeleteFile(full_file_name, false); 282 base::DeleteFile(full_file_name, false);
275 } 283 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698