| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" | 26 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" |
| 27 #include "content/public/common/features.h" | 27 #include "content/public/common/features.h" |
| 28 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
| 29 #include "media/base/media_switches.h" | 29 #include "media/base/media_switches.h" |
| 30 #include "net/test/embedded_test_server/embedded_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 31 #include "testing/perf/perf_test.h" | 31 #include "testing/perf/perf_test.h" |
| 32 | 32 |
| 33 static const char kMainWebrtcTestHtmlPage[] = | 33 static const char kMainWebrtcTestHtmlPage[] = |
| 34 "/webrtc/webrtc_jsep01_test.html"; | 34 "/webrtc/webrtc_jsep01_test.html"; |
| 35 | 35 |
| 36 std::string MakePerfTestLabel(std::string base, bool opus_dtx) { | |
| 37 if (opus_dtx) { | |
| 38 return base + "_with_opus_dtx"; | |
| 39 } | |
| 40 return base; | |
| 41 } | |
| 42 | |
| 43 // Performance browsertest for WebRTC. This test is manual since it takes long | 36 // Performance browsertest for WebRTC. This test is manual since it takes long |
| 44 // to execute and requires the reference files provided by the webrtc.DEPS | 37 // to execute and requires the reference files provided by the webrtc.DEPS |
| 45 // solution (which is only available on WebRTC internal bots). | 38 // solution (which is only available on WebRTC internal bots). |
| 46 class WebRtcPerfBrowserTest : public WebRtcTestBase { | 39 class WebRtcPerfBrowserTest : public WebRtcTestBase { |
| 47 public: | 40 public: |
| 48 void SetUpInProcessBrowserTestFixture() override { | 41 void SetUpInProcessBrowserTestFixture() override { |
| 49 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 42 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
| 50 } | 43 } |
| 51 | 44 |
| 52 void SetUpCommandLine(base::CommandLine* command_line) override { | 45 void SetUpCommandLine(base::CommandLine* command_line) override { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 "--ui-test-action-max-timeout to have a value of at least 100000."; | 115 "--ui-test-action-max-timeout to have a value of at least 100000."; |
| 123 | 116 |
| 124 content::WebContents* left_tab = | 117 content::WebContents* left_tab = |
| 125 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 118 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 126 content::WebContents* right_tab = | 119 content::WebContents* right_tab = |
| 127 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 120 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 128 | 121 |
| 129 SetupPeerconnectionWithLocalStream(left_tab); | 122 SetupPeerconnectionWithLocalStream(left_tab); |
| 130 SetupPeerconnectionWithLocalStream(right_tab); | 123 SetupPeerconnectionWithLocalStream(right_tab); |
| 131 | 124 |
| 132 if (!video_codec.empty()) { | 125 NegotiateCall(left_tab, right_tab, video_codec); |
| 133 SetDefaultVideoCodec(left_tab, video_codec); | |
| 134 SetDefaultVideoCodec(right_tab, video_codec); | |
| 135 } | |
| 136 NegotiateCall(left_tab, right_tab); | |
| 137 | 126 |
| 138 StartDetectingVideo(left_tab, "remote-view"); | 127 StartDetectingVideo(left_tab, "remote-view"); |
| 139 StartDetectingVideo(right_tab, "remote-view"); | 128 StartDetectingVideo(right_tab, "remote-view"); |
| 140 | 129 |
| 141 WaitForVideoToPlay(left_tab); | 130 WaitForVideoToPlay(left_tab); |
| 142 WaitForVideoToPlay(right_tab); | 131 WaitForVideoToPlay(right_tab); |
| 143 | 132 |
| 144 // Let values stabilize, bandwidth ramp up, etc. | 133 // Let values stabilize, bandwidth ramp up, etc. |
| 145 test::SleepInJavascript(left_tab, 60000); | 134 test::SleepInJavascript(left_tab, 60000); |
| 146 | 135 |
| 147 // Start measurements. | 136 // Start measurements. |
| 148 std::unique_ptr<base::DictionaryValue> all_data = | 137 std::unique_ptr<base::DictionaryValue> all_data = |
| 149 MeasureWebRtcInternalsData(10000); | 138 MeasureWebRtcInternalsData(10000); |
| 150 ASSERT_TRUE(all_data.get() != NULL); | 139 ASSERT_TRUE(all_data.get() != NULL); |
| 151 | 140 |
| 152 const base::DictionaryValue* first_pc_dict = | 141 const base::DictionaryValue* first_pc_dict = |
| 153 GetDataOnPeerConnection(all_data.get(), 0); | 142 GetDataOnPeerConnection(all_data.get(), 0); |
| 154 ASSERT_TRUE(first_pc_dict != NULL); | 143 ASSERT_TRUE(first_pc_dict != NULL); |
| 155 test::PrintBweForVideoMetrics(*first_pc_dict, "", video_codec); | 144 test::PrintBweForVideoMetrics(*first_pc_dict, "", video_codec); |
| 156 test::PrintMetricsForAllStreams(*first_pc_dict, "", video_codec); | 145 test::PrintMetricsForAllStreams(*first_pc_dict, "", video_codec); |
| 157 | 146 |
| 158 HangUp(left_tab); | 147 HangUp(left_tab); |
| 159 HangUp(right_tab); | 148 HangUp(right_tab); |
| 160 } | 149 } |
| 161 | 150 |
| 162 void RunsOneWayCall60SecsAndLogsInternalMetrics( | 151 void RunsOneWayCall60SecsAndLogsInternalMetrics( |
| 163 const std::string& video_codec, | 152 const std::string& video_codec) { |
| 164 bool opus_dtx) { | |
| 165 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 153 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 166 ASSERT_TRUE(embedded_test_server()->Start()); | 154 ASSERT_TRUE(embedded_test_server()->Start()); |
| 167 | 155 |
| 168 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) | 156 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) |
| 169 << "This is a long-running test; you must specify " | 157 << "This is a long-running test; you must specify " |
| 170 "--ui-test-action-max-timeout to have a value of at least 100000."; | 158 "--ui-test-action-max-timeout to have a value of at least 100000."; |
| 171 | 159 |
| 172 content::WebContents* left_tab = | 160 content::WebContents* left_tab = |
| 173 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 161 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 174 content::WebContents* right_tab = | 162 content::WebContents* right_tab = |
| 175 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 163 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 176 | 164 |
| 177 SetupPeerconnectionWithLocalStream(left_tab); | 165 SetupPeerconnectionWithLocalStream(left_tab); |
| 178 SetupPeerconnectionWithoutLocalStream(right_tab); | 166 SetupPeerconnectionWithoutLocalStream(right_tab); |
| 179 | 167 |
| 180 if (!video_codec.empty()) { | 168 NegotiateCall(left_tab, right_tab, video_codec); |
| 181 SetDefaultVideoCodec(left_tab, video_codec); | |
| 182 SetDefaultVideoCodec(right_tab, video_codec); | |
| 183 } | |
| 184 if (opus_dtx) { | |
| 185 EnableOpusDtx(left_tab); | |
| 186 EnableOpusDtx(right_tab); | |
| 187 } | |
| 188 NegotiateCall(left_tab, right_tab); | |
| 189 | 169 |
| 190 // Remote video will only play in one tab since the call is one-way. | 170 // Remote video will only play in one tab since the call is one-way. |
| 191 StartDetectingVideo(right_tab, "remote-view"); | 171 StartDetectingVideo(right_tab, "remote-view"); |
| 192 WaitForVideoToPlay(right_tab); | 172 WaitForVideoToPlay(right_tab); |
| 193 | 173 |
| 194 // Let values stabilize, bandwidth ramp up, etc. | 174 // Let values stabilize, bandwidth ramp up, etc. |
| 195 test::SleepInJavascript(left_tab, 60000); | 175 test::SleepInJavascript(left_tab, 60000); |
| 196 | 176 |
| 197 std::unique_ptr<base::DictionaryValue> all_data = | 177 std::unique_ptr<base::DictionaryValue> all_data = |
| 198 MeasureWebRtcInternalsData(10000); | 178 MeasureWebRtcInternalsData(10000); |
| 199 ASSERT_TRUE(all_data.get() != NULL); | 179 ASSERT_TRUE(all_data.get() != NULL); |
| 200 | 180 |
| 201 // This assumes the sending peer connection is always listed first in the | 181 // This assumes the sending peer connection is always listed first in the |
| 202 // data store, and the receiving second. | 182 // data store, and the receiving second. |
| 203 const base::DictionaryValue* first_pc_dict = | 183 const base::DictionaryValue* first_pc_dict = |
| 204 GetDataOnPeerConnection(all_data.get(), 0); | 184 GetDataOnPeerConnection(all_data.get(), 0); |
| 205 ASSERT_TRUE(first_pc_dict != NULL); | 185 ASSERT_TRUE(first_pc_dict != NULL); |
| 206 test::PrintBweForVideoMetrics( | 186 test::PrintBweForVideoMetrics(*first_pc_dict, "_sendonly", video_codec); |
| 207 *first_pc_dict, MakePerfTestLabel("_sendonly", opus_dtx), video_codec); | 187 test::PrintMetricsForSendStreams(*first_pc_dict, "_sendonly", video_codec); |
| 208 test::PrintMetricsForSendStreams( | |
| 209 *first_pc_dict, MakePerfTestLabel("_sendonly", opus_dtx), video_codec); | |
| 210 | 188 |
| 211 const base::DictionaryValue* second_pc_dict = | 189 const base::DictionaryValue* second_pc_dict = |
| 212 GetDataOnPeerConnection(all_data.get(), 1); | 190 GetDataOnPeerConnection(all_data.get(), 1); |
| 213 ASSERT_TRUE(second_pc_dict != NULL); | 191 ASSERT_TRUE(second_pc_dict != NULL); |
| 214 test::PrintBweForVideoMetrics( | 192 test::PrintBweForVideoMetrics(*second_pc_dict, "_recvonly", video_codec); |
| 215 *second_pc_dict, MakePerfTestLabel("_recvonly", opus_dtx), video_codec); | 193 test::PrintMetricsForRecvStreams(*second_pc_dict, "_recvonly", video_codec); |
| 216 test::PrintMetricsForRecvStreams( | |
| 217 *second_pc_dict, MakePerfTestLabel("_recvonly", opus_dtx), video_codec); | |
| 218 | 194 |
| 219 HangUp(left_tab); | 195 HangUp(left_tab); |
| 220 HangUp(right_tab); | 196 HangUp(right_tab); |
| 221 } | 197 } |
| 222 }; | 198 }; |
| 223 | 199 |
| 224 // This is manual for its long execution time. | 200 // This is manual for its long execution time. |
| 225 | 201 |
| 226 IN_PROC_BROWSER_TEST_F( | 202 IN_PROC_BROWSER_TEST_F( |
| 227 WebRtcPerfBrowserTest, | 203 WebRtcPerfBrowserTest, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 248 return; | 224 return; |
| 249 } | 225 } |
| 250 RunsAudioVideoCall60SecsAndLogsInternalMetrics("H264"); | 226 RunsAudioVideoCall60SecsAndLogsInternalMetrics("H264"); |
| 251 } | 227 } |
| 252 | 228 |
| 253 #endif // BUILDFLAG(RTC_USE_H264) | 229 #endif // BUILDFLAG(RTC_USE_H264) |
| 254 | 230 |
| 255 IN_PROC_BROWSER_TEST_F( | 231 IN_PROC_BROWSER_TEST_F( |
| 256 WebRtcPerfBrowserTest, | 232 WebRtcPerfBrowserTest, |
| 257 MANUAL_RunsOneWayCall60SecsAndLogsInternalMetricsDefault) { | 233 MANUAL_RunsOneWayCall60SecsAndLogsInternalMetricsDefault) { |
| 258 RunsOneWayCall60SecsAndLogsInternalMetrics("", false); | 234 RunsOneWayCall60SecsAndLogsInternalMetrics(""); |
| 259 } | 235 } |
| 260 | |
| 261 IN_PROC_BROWSER_TEST_F( | |
| 262 WebRtcPerfBrowserTest, | |
| 263 MANUAL_RunsOneWayCall60SecsAndLogsInternalMetricsWithOpusDtx) { | |
| 264 RunsOneWayCall60SecsAndLogsInternalMetrics("", true); | |
| 265 } | |
| OLD | NEW |