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

Side by Side Diff: content/browser/media/webrtc_internals_browsertest.cc

Issue 405683003: Adds the UserMedia requests to the UI of chrome://webrtc-internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | content/browser/resources/media/tab_view.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/json/json_reader.h" 6 #include "base/json/json_reader.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 EXPECT_TRUE(result); 225 EXPECT_TRUE(result);
226 } 226 }
227 227
228 // Verifies the JS Array of userMediaRequests matches |requests|. 228 // Verifies the JS Array of userMediaRequests matches |requests|.
229 void VerifyUserMediaRequest( 229 void VerifyUserMediaRequest(
230 const std::vector<UserMediaRequestEntry>& requests) { 230 const std::vector<UserMediaRequestEntry>& requests) {
231 string json_requests; 231 string json_requests;
232 ASSERT_TRUE(ExecuteScriptAndExtractString( 232 ASSERT_TRUE(ExecuteScriptAndExtractString(
233 shell()->web_contents(), 233 shell()->web_contents(),
234 "window.domAutomationController.send(" 234 "window.domAutomationController.send("
235 "JSON.stringify(userMediaRequests));", 235 "JSON.stringify(userMediaRequests));",
236 &json_requests)); 236 &json_requests));
237 scoped_ptr<base::Value> value_requests; 237 scoped_ptr<base::Value> value_requests;
238 value_requests.reset(base::JSONReader::Read(json_requests)); 238 value_requests.reset(base::JSONReader::Read(json_requests));
239 239
240 EXPECT_EQ(base::Value::TYPE_LIST, value_requests->GetType()); 240 EXPECT_EQ(base::Value::TYPE_LIST, value_requests->GetType());
241 241
242 base::ListValue* list_request = 242 base::ListValue* list_request =
243 static_cast<base::ListValue*>(value_requests.get()); 243 static_cast<base::ListValue*>(value_requests.get());
244 EXPECT_EQ(requests.size(), list_request->GetSize()); 244 EXPECT_EQ(requests.size(), list_request->GetSize());
245 245
246 for (size_t i = 0; i < requests.size(); ++i) { 246 for (size_t i = 0; i < requests.size(); ++i) {
247 base::DictionaryValue* dict = NULL; 247 base::DictionaryValue* dict = NULL;
248 ASSERT_TRUE(list_request->GetDictionary(i, &dict)); 248 ASSERT_TRUE(list_request->GetDictionary(i, &dict));
249 int pid, rid; 249 int pid, rid;
250 std::string origin, audio, video; 250 std::string origin, audio, video;
251 ASSERT_TRUE(dict->GetInteger("pid", &pid)); 251 ASSERT_TRUE(dict->GetInteger("pid", &pid));
252 ASSERT_TRUE(dict->GetInteger("rid", &rid)); 252 ASSERT_TRUE(dict->GetInteger("rid", &rid));
253 ASSERT_TRUE(dict->GetString("origin", &origin)); 253 ASSERT_TRUE(dict->GetString("origin", &origin));
254 ASSERT_TRUE(dict->GetString("audio", &audio)); 254 ASSERT_TRUE(dict->GetString("audio", &audio));
255 ASSERT_TRUE(dict->GetString("video", &video)); 255 ASSERT_TRUE(dict->GetString("video", &video));
256 EXPECT_EQ(requests[i].pid, pid); 256 EXPECT_EQ(requests[i].pid, pid);
257 EXPECT_EQ(requests[i].rid, rid); 257 EXPECT_EQ(requests[i].rid, rid);
258 EXPECT_EQ(requests[i].origin, origin); 258 EXPECT_EQ(requests[i].origin, origin);
259 EXPECT_EQ(requests[i].audio_constraints, audio); 259 EXPECT_EQ(requests[i].audio_constraints, audio);
260 EXPECT_EQ(requests[i].video_constraints, video); 260 EXPECT_EQ(requests[i].video_constraints, video);
261 } 261 }
262
263 bool user_media_tab_existed = false;
264 ASSERT_TRUE(ExecuteScriptAndExtractBool(
265 shell()->web_contents(),
266 "window.domAutomationController.send("
267 "$('user-media-tab-id') != null);",
268 &user_media_tab_existed));
269 EXPECT_EQ(!requests.empty(), user_media_tab_existed);
270
271 if (user_media_tab_existed) {
272 int user_media_request_count = -1;
273 ASSERT_TRUE(ExecuteScriptAndExtractInt(
274 shell()->web_contents(),
275 "window.domAutomationController.send("
276 "$('user-media-tab-id').childNodes.length);",
277 &user_media_request_count));
278 ASSERT_EQ(requests.size(), static_cast<size_t>(user_media_request_count));
279 }
262 } 280 }
263 281
264 // Verifies that DOM for |pc| is correctly created with the right content. 282 // Verifies that DOM for |pc| is correctly created with the right content.
265 void VerifyPeerConnectionEntry(const PeerConnectionEntry& pc) { 283 void VerifyPeerConnectionEntry(const PeerConnectionEntry& pc) {
266 VerifyElementWithId(pc.getIdString()); 284 VerifyElementWithId(pc.getIdString());
267 if (pc.events_.size() == 0) 285 if (pc.events_.size() == 0)
268 return; 286 return;
269 287
270 string log_id = pc.getLogIdString(); 288 string log_id = pc.getLogIdString();
271 VerifyElementWithId(log_id); 289 VerifyElementWithId(log_id);
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 ASSERT_TRUE(ExecuteScriptAndExtractInt( 874 ASSERT_TRUE(ExecuteScriptAndExtractInt(
857 shell()->web_contents(), 875 shell()->web_contents(),
858 "window.domAutomationController.send(" 876 "window.domAutomationController.send("
859 " peerConnectionDataStore['" + pc.getIdString() + "']" + 877 " peerConnectionDataStore['" + pc.getIdString() + "']" +
860 " .getDataSeries('" + data_series_id + "').getCount())", 878 " .getDataSeries('" + data_series_id + "').getCount())",
861 &count)); 879 &count));
862 EXPECT_EQ(3, count); 880 EXPECT_EQ(3, count);
863 } 881 }
864 882
865 } // namespace content 883 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/resources/media/tab_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698