| OLD | NEW |
| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 "startDetection('%s', 'frame-buffer', 320, 240)", | 85 "startDetection('%s', 'frame-buffer', 320, 240)", |
| 86 video_element.c_str()); | 86 video_element.c_str()); |
| 87 EXPECT_EQ("ok-started", ExecuteJavascript(javascript, tab_contents)); | 87 EXPECT_EQ("ok-started", ExecuteJavascript(javascript, tab_contents)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void WaitForVideoToPlay(content::WebContents* tab_contents) { | 90 void WaitForVideoToPlay(content::WebContents* tab_contents) { |
| 91 EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-playing", | 91 EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-playing", |
| 92 tab_contents)); | 92 tab_contents)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void WaitForVideoToStopPlaying(content::WebContents* tab_contents) { | |
| 96 EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-not-playing", | |
| 97 tab_contents)); | |
| 98 } | |
| 99 | |
| 100 void HangUp(content::WebContents* from_tab) { | 95 void HangUp(content::WebContents* from_tab) { |
| 101 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab)); | 96 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab)); |
| 102 } | 97 } |
| 103 | 98 |
| 104 void WaitUntilHangupVerified(content::WebContents* tab_contents) { | 99 void WaitUntilHangupVerified(content::WebContents* tab_contents) { |
| 105 EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", | 100 EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", |
| 106 "no-peer-connection", tab_contents)); | 101 "no-peer-connection", tab_contents)); |
| 107 } | 102 } |
| 108 | 103 |
| 109 std::string ToggleLocalVideoTrack(content::WebContents* tab_contents) { | |
| 110 // Toggle the only video track in the page (e.g. video track 0). | |
| 111 return ExecuteJavascript("toggleLocalStream(" | |
| 112 "function(local) { return local.getVideoTracks()[0]; }, " | |
| 113 "'video');", tab_contents); | |
| 114 } | |
| 115 | |
| 116 std::string ToggleRemoteVideoTrack(content::WebContents* tab_contents) { | |
| 117 // Toggle the only video track in the page (e.g. video track 0). | |
| 118 return ExecuteJavascript("toggleRemoteStream(" | |
| 119 "function(local) { return local.getVideoTracks()[0]; }, " | |
| 120 "'video');", tab_contents); | |
| 121 } | |
| 122 | |
| 123 void PrintProcessMetrics(base::ProcessMetrics* process_metrics, | 104 void PrintProcessMetrics(base::ProcessMetrics* process_metrics, |
| 124 const std::string& suffix) { | 105 const std::string& suffix) { |
| 125 perf_test::PrintResult("cpu", "", "cpu" + suffix, | 106 perf_test::PrintResult("cpu", "", "cpu" + suffix, |
| 126 process_metrics->GetCPUUsage(), | 107 process_metrics->GetCPUUsage(), |
| 127 "%", true); | 108 "%", true); |
| 128 perf_test::PrintResult("memory", "", "ws_peak" + suffix, | 109 perf_test::PrintResult("memory", "", "ws_peak" + suffix, |
| 129 process_metrics->GetPeakWorkingSetSize(), | 110 process_metrics->GetPeakWorkingSetSize(), |
| 130 "bytes", true); | 111 "bytes", true); |
| 131 perf_test::PrintResult("memory", "", "ws_final" + suffix, | 112 perf_test::PrintResult("memory", "", "ws_final" + suffix, |
| 132 process_metrics->GetWorkingSetSize(), | 113 process_metrics->GetWorkingSetSize(), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 WaitUntilHangupVerified(right_tab); | 223 WaitUntilHangupVerified(right_tab); |
| 243 | 224 |
| 244 #if !defined(OS_MACOSX) | 225 #if !defined(OS_MACOSX) |
| 245 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); | 226 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); |
| 246 #endif | 227 #endif |
| 247 PrintProcessMetrics(browser_process_metrics.get(), "_b"); | 228 PrintProcessMetrics(browser_process_metrics.get(), "_b"); |
| 248 | 229 |
| 249 ASSERT_TRUE(peerconnection_server_.Stop()); | 230 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 250 } | 231 } |
| 251 | 232 |
| 252 #if defined(OS_WIN) | |
| 253 // Timing out on Windows: http://crbug.com/331045 | |
| 254 #define MAYBE_TestMediaStreamTrackEnableDisable DISABLED_TestMediaStreamTrackEna
bleDisable | |
| 255 #else | |
| 256 #define MAYBE_TestMediaStreamTrackEnableDisable MANUAL_TestMediaStreamTrackEnabl
eDisable | |
| 257 #endif | |
| 258 | |
| 259 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | |
| 260 MAYBE_TestMediaStreamTrackEnableDisable) { | |
| 261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 262 ASSERT_TRUE(peerconnection_server_.Start()); | |
| 263 | |
| 264 content::WebContents* left_tab = OpenTestPageAndGetUserMediaInNewTab(); | |
| 265 content::WebContents* right_tab = OpenTestPageAndGetUserMediaInNewTab(); | |
| 266 | |
| 267 EstablishCall(left_tab, right_tab); | |
| 268 | |
| 269 StartDetectingVideo(left_tab, "remote-view"); | |
| 270 StartDetectingVideo(right_tab, "remote-view"); | |
| 271 | |
| 272 WaitForVideoToPlay(left_tab); | |
| 273 WaitForVideoToPlay(right_tab); | |
| 274 | |
| 275 EXPECT_EQ("ok-video-toggled-to-false", ToggleLocalVideoTrack(left_tab)); | |
| 276 | |
| 277 WaitForVideoToStopPlaying(right_tab); | |
| 278 | |
| 279 EXPECT_EQ("ok-video-toggled-to-true", ToggleLocalVideoTrack(left_tab)); | |
| 280 | |
| 281 WaitForVideoToPlay(right_tab); | |
| 282 | |
| 283 HangUp(left_tab); | |
| 284 WaitUntilHangupVerified(left_tab); | |
| 285 WaitUntilHangupVerified(right_tab); | |
| 286 | |
| 287 ASSERT_TRUE(peerconnection_server_.Stop()); | |
| 288 } | |
| 289 | |
| 290 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 233 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, |
| 291 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { | 234 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { |
| 292 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 235 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 293 ASSERT_TRUE(peerconnection_server_.Start()); | 236 ASSERT_TRUE(peerconnection_server_.Start()); |
| 294 | 237 |
| 295 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 80) << | 238 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 80) << |
| 296 "This is a long-running test; you must specify " | 239 "This is a long-running test; you must specify " |
| 297 "--ui-test-action-max-timeout to have a value of at least 80000."; | 240 "--ui-test-action-max-timeout to have a value of at least 80000."; |
| 298 | 241 |
| 299 content::WebContents* left_tab = OpenTestPageAndGetUserMediaInNewTab(); | 242 content::WebContents* left_tab = OpenTestPageAndGetUserMediaInNewTab(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 282 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 340 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); | 283 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); |
| 341 ui_test_utils::NavigateToURL(browser(), url); | 284 ui_test_utils::NavigateToURL(browser(), url); |
| 342 content::WebContents* tab = | 285 content::WebContents* tab = |
| 343 browser()->tab_strip_model()->GetActiveWebContents(); | 286 browser()->tab_strip_model()->GetActiveWebContents(); |
| 344 // A sleep is necessary to be able to detect the crash. | 287 // A sleep is necessary to be able to detect the crash. |
| 345 SleepInJavascript(tab, 1000); | 288 SleepInJavascript(tab, 1000); |
| 346 | 289 |
| 347 ASSERT_FALSE(tab->IsCrashed()); | 290 ASSERT_FALSE(tab->IsCrashed()); |
| 348 } | 291 } |
| OLD | NEW |