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

Side by Side Diff: chrome/browser/media/chrome_webrtc_perf_browsertest.cc

Issue 1762413002: Cleanup: remove prefix chrome_ of chrome/browser/media/chrome* files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reran the commands Created 4 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/files/file_util.h"
7 #include "base/json/json_reader.h"
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_split.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/test/test_timeouts.h"
13 #include "base/time/time.h"
14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/media/webrtc_browsertest_base.h"
16 #include "chrome/browser/media/webrtc_browsertest_common.h"
17 #include "chrome/browser/media/webrtc_browsertest_perf.h"
18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_tabstrip.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h"
26 #include "content/public/common/features.h"
27 #include "content/public/test/browser_test_utils.h"
28 #include "media/base/media_switches.h"
29 #include "net/test/embedded_test_server/embedded_test_server.h"
30 #include "testing/perf/perf_test.h"
31
32 static const char kMainWebrtcTestHtmlPage[] =
33 "/webrtc/webrtc_jsep01_test.html";
34
35 // Performance browsertest for WebRTC. This test is manual since it takes long
36 // to execute and requires the reference files provided by the webrtc.DEPS
37 // solution (which is only available on WebRTC internal bots).
38 class WebRtcPerfBrowserTest : public WebRtcTestBase {
39 public:
40 void SetUpInProcessBrowserTestFixture() override {
41 DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
42 }
43
44 void SetUpCommandLine(base::CommandLine* command_line) override {
45 // Ensure the infobar is enabled, since we expect that in this test.
46 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream));
47
48 // Play a suitable, somewhat realistic video file.
49 base::FilePath input_video = test::GetReferenceFilesDir()
50 .Append(test::kReferenceFileName360p)
51 .AddExtension(test::kY4mFileExtension);
52 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture,
53 input_video);
54 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
55 }
56
57 // Tries to extract data from peerConnectionDataStore in the webrtc-internals
58 // tab. The caller owns the parsed data. Returns NULL on failure.
59 base::DictionaryValue* GetWebrtcInternalsData(
60 content::WebContents* webrtc_internals_tab) {
61 std::string all_stats_json = ExecuteJavascript(
62 "window.domAutomationController.send("
63 " JSON.stringify(peerConnectionDataStore));",
64 webrtc_internals_tab);
65
66 scoped_ptr<base::Value> parsed_json =
67 base::JSONReader::Read(all_stats_json);
68 base::DictionaryValue* result;
69 if (parsed_json.get() && parsed_json->GetAsDictionary(&result)) {
70 ignore_result(parsed_json.release());
71 return result;
72 }
73
74 return NULL;
75 }
76
77 const base::DictionaryValue* GetDataOnPeerConnection(
78 const base::DictionaryValue* all_data,
79 int peer_connection_index) {
80 base::DictionaryValue::Iterator iterator(*all_data);
81
82 for (int i = 0; i < peer_connection_index && !iterator.IsAtEnd();
83 --peer_connection_index) {
84 iterator.Advance();
85 }
86
87 const base::DictionaryValue* result;
88 if (!iterator.IsAtEnd() && iterator.value().GetAsDictionary(&result))
89 return result;
90
91 return NULL;
92 }
93
94 scoped_ptr<base::DictionaryValue> MeasureWebRtcInternalsData(
95 int duration_msec) {
96 chrome::AddTabAt(browser(), GURL(), -1, true);
97 ui_test_utils::NavigateToURL(browser(), GURL("chrome://webrtc-internals"));
98 content::WebContents* webrtc_internals_tab =
99 browser()->tab_strip_model()->GetActiveWebContents();
100
101 test::SleepInJavascript(webrtc_internals_tab, duration_msec);
102
103 return scoped_ptr<base::DictionaryValue>(
104 GetWebrtcInternalsData(webrtc_internals_tab));
105 }
106
107 void RunsAudioVideoCall60SecsAndLogsInternalMetrics(
108 const std::string& video_codec) {
109 ASSERT_TRUE(test::HasReferenceFilesInCheckout());
110 ASSERT_TRUE(embedded_test_server()->Start());
111
112 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100)
113 << "This is a long-running test; you must specify "
114 "--ui-test-action-max-timeout to have a value of at least 100000.";
115
116 content::WebContents* left_tab =
117 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
118 content::WebContents* right_tab =
119 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
120
121 SetupPeerconnectionWithLocalStream(left_tab);
122 SetupPeerconnectionWithLocalStream(right_tab);
123
124 NegotiateCall(left_tab, right_tab, video_codec);
125
126 StartDetectingVideo(left_tab, "remote-view");
127 StartDetectingVideo(right_tab, "remote-view");
128
129 WaitForVideoToPlay(left_tab);
130 WaitForVideoToPlay(right_tab);
131
132 // Let values stabilize, bandwidth ramp up, etc.
133 test::SleepInJavascript(left_tab, 60000);
134
135 // Start measurements.
136 scoped_ptr<base::DictionaryValue> all_data =
137 MeasureWebRtcInternalsData(10000);
138 ASSERT_TRUE(all_data.get() != NULL);
139
140 const base::DictionaryValue* first_pc_dict =
141 GetDataOnPeerConnection(all_data.get(), 0);
142 ASSERT_TRUE(first_pc_dict != NULL);
143 test::PrintBweForVideoMetrics(*first_pc_dict, "", video_codec);
144 test::PrintMetricsForAllStreams(*first_pc_dict, "", video_codec);
145
146 HangUp(left_tab);
147 HangUp(right_tab);
148 }
149
150 void RunsOneWayCall60SecsAndLogsInternalMetrics(
151 const std::string& video_codec) {
152 ASSERT_TRUE(test::HasReferenceFilesInCheckout());
153 ASSERT_TRUE(embedded_test_server()->Start());
154
155 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100)
156 << "This is a long-running test; you must specify "
157 "--ui-test-action-max-timeout to have a value of at least 100000.";
158
159 content::WebContents* left_tab =
160 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
161 content::WebContents* right_tab =
162 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
163
164 SetupPeerconnectionWithLocalStream(left_tab);
165 SetupPeerconnectionWithoutLocalStream(right_tab);
166
167 NegotiateCall(left_tab, right_tab, video_codec);
168
169 // Remote video will only play in one tab since the call is one-way.
170 StartDetectingVideo(right_tab, "remote-view");
171 WaitForVideoToPlay(right_tab);
172
173 // Let values stabilize, bandwidth ramp up, etc.
174 test::SleepInJavascript(left_tab, 60000);
175
176 scoped_ptr<base::DictionaryValue> all_data =
177 MeasureWebRtcInternalsData(10000);
178 ASSERT_TRUE(all_data.get() != NULL);
179
180 // This assumes the sending peer connection is always listed first in the
181 // data store, and the receiving second.
182 const base::DictionaryValue* first_pc_dict =
183 GetDataOnPeerConnection(all_data.get(), 0);
184 ASSERT_TRUE(first_pc_dict != NULL);
185 test::PrintBweForVideoMetrics(*first_pc_dict, "_sendonly", video_codec);
186 test::PrintMetricsForAllStreams(*first_pc_dict, "_sendonly", video_codec);
187
188 const base::DictionaryValue* second_pc_dict =
189 GetDataOnPeerConnection(all_data.get(), 1);
190 ASSERT_TRUE(second_pc_dict != NULL);
191 test::PrintBweForVideoMetrics(*second_pc_dict, "_recvonly", video_codec);
192 test::PrintMetricsForAllStreams(*second_pc_dict, "_recvonly", video_codec);
193
194 HangUp(left_tab);
195 HangUp(right_tab);
196 }
197 };
198
199 // This is manual for its long execution time.
200
201 // The video codec name is now appended to result bucket (e.g. 'video_tx_VP8').
202 // TODO(asapersson): Keep test below using the default video codec (which do
203 // not have the codec name appended ('video_tx')) until new tests have been
204 // running for some time.
205 IN_PROC_BROWSER_TEST_F(
206 WebRtcPerfBrowserTest,
207 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetricsDefault) {
208 RunsAudioVideoCall60SecsAndLogsInternalMetrics("");
209 }
210
211 IN_PROC_BROWSER_TEST_F(
212 WebRtcPerfBrowserTest,
213 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetricsVp8) {
214 RunsAudioVideoCall60SecsAndLogsInternalMetrics("VP8");
215 }
216
217 IN_PROC_BROWSER_TEST_F(
218 WebRtcPerfBrowserTest,
219 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetricsVp9) {
220 RunsAudioVideoCall60SecsAndLogsInternalMetrics("VP9");
221 }
222
223 #if BUILDFLAG(RTC_USE_H264)
224
225 IN_PROC_BROWSER_TEST_F(
226 WebRtcPerfBrowserTest,
227 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetricsH264) {
228 // Only run test if run-time feature corresponding to |rtc_use_h264| is on.
229 if (!base::FeatureList::IsEnabled(content::kWebRtcH264WithOpenH264FFmpeg)) {
230 LOG(WARNING) << "Run-time feature WebRTC-H264WithOpenH264FFmpeg disabled. "
231 "Skipping WebRtcPerfBrowserTest.MANUAL_RunsAudioVideoCall60SecsAndLogs"
232 "InternalMetricsH264 (test \"OK\")";
233 return;
234 }
235 RunsAudioVideoCall60SecsAndLogsInternalMetrics("H264");
236 }
237
238 #endif // BUILDFLAG(RTC_USE_H264)
239
240 IN_PROC_BROWSER_TEST_F(
241 WebRtcPerfBrowserTest,
242 MANUAL_RunsOneWayCall60SecsAndLogsInternalMetricsDefault) {
243 RunsOneWayCall60SecsAndLogsInternalMetrics("");
244 }
245
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698