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