| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 void SetUpOnMainThread() override { | 158 void SetUpOnMainThread() override { |
| 159 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 159 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 160 switches::kUseFakeUIForMediaStream); | 160 switches::kUseFakeUIForMediaStream); |
| 161 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( | 161 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 162 switches::kUseFakeDeviceForMediaStream)); | 162 switches::kUseFakeDeviceForMediaStream)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 protected: | 165 protected: |
| 166 bool ExecuteJavascript(const string& javascript) { | 166 bool ExecuteJavascript(const string& javascript) { |
| 167 return ExecuteScript(shell()->web_contents(), javascript); | 167 return ExecuteScript(shell(), javascript); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void ExpectTitle(const std::string& expected_title) const { | 170 void ExpectTitle(const std::string& expected_title) const { |
| 171 base::string16 expected_title16(base::ASCIIToUTF16(expected_title)); | 171 base::string16 expected_title16(base::ASCIIToUTF16(expected_title)); |
| 172 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | 172 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
| 173 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 173 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Execute the javascript of addPeerConnection. | 176 // Execute the javascript of addPeerConnection. |
| 177 void ExecuteAddPeerConnectionJs(const PeerConnectionEntry& pc) { | 177 void ExecuteAddPeerConnectionJs(const PeerConnectionEntry& pc) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 204 std::stringstream ss; | 204 std::stringstream ss; |
| 205 ss << "{rid:" << rid << "}"; | 205 ss << "{rid:" << rid << "}"; |
| 206 ASSERT_TRUE( | 206 ASSERT_TRUE( |
| 207 ExecuteJavascript("removeGetUserMediaForRenderer(" + ss.str() + ");")); | 207 ExecuteJavascript("removeGetUserMediaForRenderer(" + ss.str() + ");")); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Verifies that the DOM element with id |id| exists. | 210 // Verifies that the DOM element with id |id| exists. |
| 211 void VerifyElementWithId(const string& id) { | 211 void VerifyElementWithId(const string& id) { |
| 212 bool result = false; | 212 bool result = false; |
| 213 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 213 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
| 214 shell()->web_contents(), | 214 shell(), |
| 215 "window.domAutomationController.send($('" + id + "') != null);", | 215 "window.domAutomationController.send($('" + id + "') != null);", |
| 216 &result)); | 216 &result)); |
| 217 EXPECT_TRUE(result); | 217 EXPECT_TRUE(result); |
| 218 } | 218 } |
| 219 | 219 |
| 220 // Verifies that the DOM element with id |id| does not exist. | 220 // Verifies that the DOM element with id |id| does not exist. |
| 221 void VerifyNoElementWithId(const string& id) { | 221 void VerifyNoElementWithId(const string& id) { |
| 222 bool result = false; | 222 bool result = false; |
| 223 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 223 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
| 224 shell()->web_contents(), | 224 shell(), |
| 225 "window.domAutomationController.send($('" + id + "') == null);", | 225 "window.domAutomationController.send($('" + id + "') == null);", |
| 226 &result)); | 226 &result)); |
| 227 EXPECT_TRUE(result); | 227 EXPECT_TRUE(result); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Verifies the JS Array of userMediaRequests matches |requests|. | 230 // Verifies the JS Array of userMediaRequests matches |requests|. |
| 231 void VerifyUserMediaRequest( | 231 void VerifyUserMediaRequest( |
| 232 const std::vector<UserMediaRequestEntry>& requests) { | 232 const std::vector<UserMediaRequestEntry>& requests) { |
| 233 string json_requests; | 233 string json_requests; |
| 234 ASSERT_TRUE(ExecuteScriptAndExtractString( | 234 ASSERT_TRUE( |
| 235 shell()->web_contents(), | 235 ExecuteScriptAndExtractString(shell(), |
| 236 "window.domAutomationController.send(" | 236 "window.domAutomationController.send(" |
| 237 "JSON.stringify(userMediaRequests));", | 237 " JSON.stringify(userMediaRequests));", |
| 238 &json_requests)); | 238 &json_requests)); |
| 239 std::unique_ptr<base::Value> value_requests = | 239 std::unique_ptr<base::Value> value_requests = |
| 240 base::JSONReader::Read(json_requests); | 240 base::JSONReader::Read(json_requests); |
| 241 | 241 |
| 242 EXPECT_EQ(base::Value::TYPE_LIST, value_requests->GetType()); | 242 EXPECT_EQ(base::Value::TYPE_LIST, value_requests->GetType()); |
| 243 | 243 |
| 244 base::ListValue* list_request = | 244 base::ListValue* list_request = |
| 245 static_cast<base::ListValue*>(value_requests.get()); | 245 static_cast<base::ListValue*>(value_requests.get()); |
| 246 EXPECT_EQ(requests.size(), list_request->GetSize()); | 246 EXPECT_EQ(requests.size(), list_request->GetSize()); |
| 247 | 247 |
| 248 for (size_t i = 0; i < requests.size(); ++i) { | 248 for (size_t i = 0; i < requests.size(); ++i) { |
| 249 base::DictionaryValue* dict = NULL; | 249 base::DictionaryValue* dict = NULL; |
| 250 ASSERT_TRUE(list_request->GetDictionary(i, &dict)); | 250 ASSERT_TRUE(list_request->GetDictionary(i, &dict)); |
| 251 int pid, rid; | 251 int pid, rid; |
| 252 std::string origin, audio, video; | 252 std::string origin, audio, video; |
| 253 ASSERT_TRUE(dict->GetInteger("pid", &pid)); | 253 ASSERT_TRUE(dict->GetInteger("pid", &pid)); |
| 254 ASSERT_TRUE(dict->GetInteger("rid", &rid)); | 254 ASSERT_TRUE(dict->GetInteger("rid", &rid)); |
| 255 ASSERT_TRUE(dict->GetString("origin", &origin)); | 255 ASSERT_TRUE(dict->GetString("origin", &origin)); |
| 256 ASSERT_TRUE(dict->GetString("audio", &audio)); | 256 ASSERT_TRUE(dict->GetString("audio", &audio)); |
| 257 ASSERT_TRUE(dict->GetString("video", &video)); | 257 ASSERT_TRUE(dict->GetString("video", &video)); |
| 258 EXPECT_EQ(requests[i].pid, pid); | 258 EXPECT_EQ(requests[i].pid, pid); |
| 259 EXPECT_EQ(requests[i].rid, rid); | 259 EXPECT_EQ(requests[i].rid, rid); |
| 260 EXPECT_EQ(requests[i].origin, origin); | 260 EXPECT_EQ(requests[i].origin, origin); |
| 261 EXPECT_EQ(requests[i].audio_constraints, audio); | 261 EXPECT_EQ(requests[i].audio_constraints, audio); |
| 262 EXPECT_EQ(requests[i].video_constraints, video); | 262 EXPECT_EQ(requests[i].video_constraints, video); |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool user_media_tab_existed = false; | 265 bool user_media_tab_existed = false; |
| 266 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 266 ASSERT_TRUE( |
| 267 shell()->web_contents(), | 267 ExecuteScriptAndExtractBool(shell(), |
| 268 "window.domAutomationController.send(" | 268 "window.domAutomationController.send(" |
| 269 "$('user-media-tab-id') != null);", | 269 " $('user-media-tab-id') != null);", |
| 270 &user_media_tab_existed)); | 270 &user_media_tab_existed)); |
| 271 EXPECT_EQ(!requests.empty(), user_media_tab_existed); | 271 EXPECT_EQ(!requests.empty(), user_media_tab_existed); |
| 272 | 272 |
| 273 if (user_media_tab_existed) { | 273 if (user_media_tab_existed) { |
| 274 int user_media_request_count = -1; | 274 int user_media_request_count = -1; |
| 275 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 275 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 276 shell()->web_contents(), | 276 shell(), |
| 277 "window.domAutomationController.send(" | 277 "window.domAutomationController.send(" |
| 278 "$('user-media-tab-id').childNodes.length);", | 278 " $('user-media-tab-id').childNodes.length);", |
| 279 &user_media_request_count)); | 279 &user_media_request_count)); |
| 280 ASSERT_EQ(requests.size(), static_cast<size_t>(user_media_request_count)); | 280 ASSERT_EQ(requests.size(), static_cast<size_t>(user_media_request_count)); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 // Verifies that DOM for |pc| is correctly created with the right content. | 284 // Verifies that DOM for |pc| is correctly created with the right content. |
| 285 void VerifyPeerConnectionEntry(const PeerConnectionEntry& pc) { | 285 void VerifyPeerConnectionEntry(const PeerConnectionEntry& pc) { |
| 286 VerifyElementWithId(pc.getIdString()); | 286 VerifyElementWithId(pc.getIdString()); |
| 287 if (pc.events_.size() == 0) | 287 if (pc.events_.size() == 0) |
| 288 return; | 288 return; |
| 289 | 289 |
| 290 string log_id = pc.getLogIdString(); | 290 string log_id = pc.getLogIdString(); |
| 291 VerifyElementWithId(log_id); | 291 VerifyElementWithId(log_id); |
| 292 string result; | 292 string result; |
| 293 for (size_t i = 0; i < pc.events_.size(); ++i) { | 293 for (size_t i = 0; i < pc.events_.size(); ++i) { |
| 294 std::stringstream ss; | 294 std::stringstream ss; |
| 295 ss << "var row = $('" << log_id << "').rows[" << (i + 1) << "];" | 295 ss << "var row = $('" << log_id << "').rows[" << (i + 1) << "];" |
| 296 "var cell = row.lastChild;" | 296 "var cell = row.lastChild;" |
| 297 "window.domAutomationController.send(cell.firstChild.textContent);"; | 297 "window.domAutomationController.send(cell.firstChild.textContent);"; |
| 298 ASSERT_TRUE(ExecuteScriptAndExtractString( | 298 ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), ss.str(), &result)); |
| 299 shell()->web_contents(), ss.str(), &result)); | |
| 300 EXPECT_EQ(pc.events_[i].type + pc.events_[i].value, result); | 299 EXPECT_EQ(pc.events_[i].type + pc.events_[i].value, result); |
| 301 } | 300 } |
| 302 } | 301 } |
| 303 | 302 |
| 304 // Executes the javascript of updatePeerConnection and verifies the result. | 303 // Executes the javascript of updatePeerConnection and verifies the result. |
| 305 void ExecuteAndVerifyUpdatePeerConnection( | 304 void ExecuteAndVerifyUpdatePeerConnection( |
| 306 PeerConnectionEntry& pc, const string& type, const string& value) { | 305 PeerConnectionEntry& pc, const string& type, const string& value) { |
| 307 pc.AddEvent(type, value); | 306 pc.AddEvent(type, value); |
| 308 | 307 |
| 309 std::stringstream ss; | 308 std::stringstream ss; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 350 |
| 352 // Verifies that the row named as |name| of the stats table |table_id| has | 351 // Verifies that the row named as |name| of the stats table |table_id| has |
| 353 // the correct content as |name| : |value|. | 352 // the correct content as |name| : |value|. |
| 354 void VerifyStatsTableRow(const string& table_id, | 353 void VerifyStatsTableRow(const string& table_id, |
| 355 const string& name, | 354 const string& name, |
| 356 const string& value) { | 355 const string& value) { |
| 357 VerifyElementWithId(table_id + "-" + name); | 356 VerifyElementWithId(table_id + "-" + name); |
| 358 | 357 |
| 359 string result; | 358 string result; |
| 360 ASSERT_TRUE(ExecuteScriptAndExtractString( | 359 ASSERT_TRUE(ExecuteScriptAndExtractString( |
| 361 shell()->web_contents(), | 360 shell(), |
| 362 "var row = $('" + table_id + "-" + name + "');" | 361 "var row = $('" + table_id + "-" + name + "');" |
| 363 "var name = row.cells[0].textContent;" | 362 "var name = row.cells[0].textContent;" |
| 364 "var value = row.cells[1].textContent;" | 363 "var value = row.cells[1].textContent;" |
| 365 "window.domAutomationController.send(name + ':' + value)", | 364 "window.domAutomationController.send(name + ':' + value)", |
| 366 &result)); | 365 &result)); |
| 367 EXPECT_EQ(name + ":" + value, result); | 366 EXPECT_EQ(name + ":" + value, result); |
| 368 } | 367 } |
| 369 | 368 |
| 370 // Verifies that the graph data series consistent with pc.stats_. | 369 // Verifies that the graph data series consistent with pc.stats_. |
| 371 void VerifyStatsGraph(const PeerConnectionEntry& pc) { | 370 void VerifyStatsGraph(const PeerConnectionEntry& pc) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 388 } | 387 } |
| 389 } | 388 } |
| 390 } | 389 } |
| 391 } | 390 } |
| 392 | 391 |
| 393 // Verifies that the graph data point at index |index| has value |value|. | 392 // Verifies that the graph data point at index |index| has value |value|. |
| 394 void VerifyGraphDataPoint(const string& pc_id, const string& graph_id, | 393 void VerifyGraphDataPoint(const string& pc_id, const string& graph_id, |
| 395 int index, const string& value) { | 394 int index, const string& value) { |
| 396 bool result = false; | 395 bool result = false; |
| 397 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 396 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
| 398 shell()->web_contents(), | 397 shell(), |
| 399 "window.domAutomationController.send(" | 398 "window.domAutomationController.send(" |
| 400 "graphViews['" + pc_id + "-" + graph_id + "'] != null)", | 399 "graphViews['" + pc_id + "-" + graph_id + "'] != null)", |
| 401 &result)); | 400 &result)); |
| 402 EXPECT_TRUE(result); | 401 EXPECT_TRUE(result); |
| 403 | 402 |
| 404 std::stringstream ss; | 403 std::stringstream ss; |
| 405 ss << "var dp = peerConnectionDataStore['" << pc_id << "']" | 404 ss << "var dp = peerConnectionDataStore['" << pc_id << "']" |
| 406 ".getDataSeries('" << graph_id << "').dataPoints_[" << index << "];" | 405 ".getDataSeries('" << graph_id << "').dataPoints_[" << index << "];" |
| 407 "window.domAutomationController.send(dp.value.toString())"; | 406 "window.domAutomationController.send(dp.value.toString())"; |
| 408 string actual_value; | 407 string actual_value; |
| 409 ASSERT_TRUE(ExecuteScriptAndExtractString( | 408 ASSERT_TRUE( |
| 410 shell()->web_contents(), ss.str(), &actual_value)); | 409 ExecuteScriptAndExtractString(shell(), ss.str(), &actual_value)); |
| 411 EXPECT_EQ(value, actual_value); | 410 EXPECT_EQ(value, actual_value); |
| 412 } | 411 } |
| 413 | 412 |
| 414 // Get the JSON string of the ssrc info from the page. | 413 // Get the JSON string of the ssrc info from the page. |
| 415 string GetSsrcInfo(const string& ssrc_id) { | 414 string GetSsrcInfo(const string& ssrc_id) { |
| 416 string result; | 415 string result; |
| 417 EXPECT_TRUE(ExecuteScriptAndExtractString( | 416 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 418 shell()->web_contents(), | 417 shell(), |
| 419 "window.domAutomationController.send(JSON.stringify(" | 418 "window.domAutomationController.send(JSON.stringify(" |
| 420 "ssrcInfoManager.streamInfoContainer_['" + ssrc_id + "']))", | 419 "ssrcInfoManager.streamInfoContainer_['" + ssrc_id + "']))", |
| 421 &result)); | 420 &result)); |
| 422 return result; | 421 return result; |
| 423 } | 422 } |
| 424 | 423 |
| 425 int GetSsrcInfoBlockCount(Shell* shell) { | 424 int GetSsrcInfoBlockCount(Shell* shell) { |
| 426 int count = 0; | 425 int count = 0; |
| 427 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 426 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 428 shell->web_contents(), | 427 shell, |
| 429 "window.domAutomationController.send(" | 428 "window.domAutomationController.send(" |
| 430 "document.getElementsByClassName(" | 429 " document.getElementsByClassName(" |
| 431 "ssrcInfoManager.SSRC_INFO_BLOCK_CLASS).length);", | 430 " ssrcInfoManager.SSRC_INFO_BLOCK_CLASS).length);", |
| 432 &count)); | 431 &count)); |
| 433 return count; | 432 return count; |
| 434 } | 433 } |
| 435 | 434 |
| 436 // Verifies |dump| contains |peer_connection_number| peer connection dumps, | 435 // Verifies |dump| contains |peer_connection_number| peer connection dumps, |
| 437 // each containing |update_number| updates and |stats_number| stats tables. | 436 // each containing |update_number| updates and |stats_number| stats tables. |
| 438 void VerifyPageDumpStructure(base::Value* dump, | 437 void VerifyPageDumpStructure(base::Value* dump, |
| 439 int peer_connection_number, | 438 int peer_connection_number, |
| 440 int update_number, | 439 int update_number, |
| 441 int stats_number) { | 440 int stats_number) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 stats.values["googTransmitBitrate"] = "1000000"; | 614 stats.values["googTransmitBitrate"] = "1000000"; |
| 616 const string stats_type = "bwe"; | 615 const string stats_type = "bwe"; |
| 617 const string stats_id = "videobwe"; | 616 const string stats_id = "videobwe"; |
| 618 ExecuteAndVerifyAddStats(pc, stats_type, stats_id, stats); | 617 ExecuteAndVerifyAddStats(pc, stats_type, stats_id, stats); |
| 619 | 618 |
| 620 string graph_id = | 619 string graph_id = |
| 621 pc.getIdString() + "-" + stats_id + "-bweCompound"; | 620 pc.getIdString() + "-" + stats_id + "-bweCompound"; |
| 622 bool result = false; | 621 bool result = false; |
| 623 // Verify that the bweCompound graph exists. | 622 // Verify that the bweCompound graph exists. |
| 624 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 623 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
| 625 shell()->web_contents(), | 624 shell(), |
| 626 "window.domAutomationController.send(" | 625 "window.domAutomationController.send(" |
| 627 " graphViews['" + graph_id + "'] != null)", | 626 " graphViews['" + graph_id + "'] != null)", |
| 628 &result)); | 627 &result)); |
| 629 EXPECT_TRUE(result); | 628 EXPECT_TRUE(result); |
| 630 | 629 |
| 631 // Verify that the bweCompound graph contains multiple dataSeries. | 630 // Verify that the bweCompound graph contains multiple dataSeries. |
| 632 int count = 0; | 631 int count = 0; |
| 633 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 632 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 634 shell()->web_contents(), | 633 shell(), |
| 635 "window.domAutomationController.send(" | 634 "window.domAutomationController.send(" |
| 636 " graphViews['" + graph_id + "'].getDataSeriesCount())", | 635 " graphViews['" + graph_id + "'].getDataSeriesCount())", |
| 637 &count)); | 636 &count)); |
| 638 EXPECT_EQ((int)stats.values.size(), count); | 637 EXPECT_EQ((int)stats.values.size(), count); |
| 639 } | 638 } |
| 640 | 639 |
| 641 // Tests that the total packet/byte count is converted to count per second, | 640 // Tests that the total packet/byte count is converted to count per second, |
| 642 // and the converted data is drawn. | 641 // and the converted data is drawn. |
| 643 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcInternalsBrowserTest, ConvertedGraphs) { | 642 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcInternalsBrowserTest, ConvertedGraphs) { |
| 644 GURL url("chrome://webrtc-internals"); | 643 GURL url("chrome://webrtc-internals"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 // Open webrtc-internals in the second window. | 693 // Open webrtc-internals in the second window. |
| 695 GURL url2("chrome://webrtc-internals"); | 694 GURL url2("chrome://webrtc-internals"); |
| 696 Shell* shell2 = CreateBrowser(); | 695 Shell* shell2 = CreateBrowser(); |
| 697 NavigateToURL(shell2, url2); | 696 NavigateToURL(shell2, url2); |
| 698 | 697 |
| 699 const int NUMBER_OF_PEER_CONNECTIONS = 2; | 698 const int NUMBER_OF_PEER_CONNECTIONS = 2; |
| 700 | 699 |
| 701 // Verifies the number of peerconnections. | 700 // Verifies the number of peerconnections. |
| 702 int count = 0; | 701 int count = 0; |
| 703 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 702 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 704 shell2->web_contents(), | 703 shell2, |
| 705 "window.domAutomationController.send(" | 704 "window.domAutomationController.send(" |
| 706 "$('peer-connections-list').getElementsByTagName('li').length);", | 705 " $('peer-connections-list').getElementsByTagName('li').length);", |
| 707 &count)); | 706 &count)); |
| 708 EXPECT_EQ(NUMBER_OF_PEER_CONNECTIONS, count); | 707 EXPECT_EQ(NUMBER_OF_PEER_CONNECTIONS, count); |
| 709 | 708 |
| 710 // Verifies the the event tables. | 709 // Verifies the the event tables. |
| 711 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 710 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 712 shell2->web_contents(), | 711 shell2, |
| 713 "window.domAutomationController.send($('peer-connections-list')" | 712 "window.domAutomationController.send($('peer-connections-list')" |
| 714 ".getElementsByClassName('update-log-table').length);", | 713 " .getElementsByClassName('update-log-table').length);", |
| 715 &count)); | 714 &count)); |
| 716 EXPECT_EQ(NUMBER_OF_PEER_CONNECTIONS, count); | 715 EXPECT_EQ(NUMBER_OF_PEER_CONNECTIONS, count); |
| 717 | 716 |
| 718 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 717 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 719 shell2->web_contents(), | 718 shell2, |
| 720 "window.domAutomationController.send($('peer-connections-list')" | 719 "window.domAutomationController.send($('peer-connections-list')" |
| 721 ".getElementsByClassName('update-log-table')[0].rows.length);", | 720 " .getElementsByClassName('update-log-table')[0].rows.length);", |
| 722 &count)); | 721 &count)); |
| 723 EXPECT_GT(count, 1); | 722 EXPECT_GT(count, 1); |
| 724 | 723 |
| 725 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 724 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 726 shell2->web_contents(), | 725 shell2, |
| 727 "window.domAutomationController.send($('peer-connections-list')" | 726 "window.domAutomationController.send($('peer-connections-list')" |
| 728 ".getElementsByClassName('update-log-table')[1].rows.length);", | 727 " .getElementsByClassName('update-log-table')[1].rows.length);", |
| 729 &count)); | 728 &count)); |
| 730 EXPECT_GT(count, 1); | 729 EXPECT_GT(count, 1); |
| 731 | 730 |
| 732 // Wait until the stats table containers are created. | 731 // Wait until the stats table containers are created. |
| 733 count = 0; | 732 count = 0; |
| 734 while (count != NUMBER_OF_PEER_CONNECTIONS) { | 733 while (count != NUMBER_OF_PEER_CONNECTIONS) { |
| 735 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 734 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 736 shell2->web_contents(), | 735 shell2, |
| 737 "window.domAutomationController.send(" | 736 "window.domAutomationController.send(" |
| 738 "$('peer-connections-list').getElementsByClassName(" | 737 " $('peer-connections-list').getElementsByClassName(" |
| 739 "'stats-table-container').length);", | 738 " 'stats-table-container').length);", |
| 740 &count)); | 739 &count)); |
| 741 } | 740 } |
| 742 | 741 |
| 743 // Verifies each stats table having more than one rows. | 742 // Verifies each stats table having more than one rows. |
| 744 bool result = false; | 743 bool result = false; |
| 745 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 744 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
| 746 shell2->web_contents(), | 745 shell2, |
| 747 "var tableContainers = $('peer-connections-list')" | 746 "var tableContainers = $('peer-connections-list')" |
| 748 ".getElementsByClassName('stats-table-container');" | 747 " .getElementsByClassName('stats-table-container');" |
| 749 "var result = true;" | 748 "var result = true;" |
| 750 "for (var i = 0; i < tableContainers.length && result; ++i) {" | 749 "for (var i = 0; i < tableContainers.length && result; ++i) {" |
| 751 "var tables = tableContainers[i].getElementsByTagName('table');" | 750 " var tables = tableContainers[i].getElementsByTagName('table');" |
| 752 "for (var j = 0; j < tables.length && result; ++j) {" | 751 " for (var j = 0; j < tables.length && result; ++j) {" |
| 753 "result = (tables[j].rows.length > 1);" | 752 " result = (tables[j].rows.length > 1);" |
| 754 "}" | 753 " }" |
| 755 "if (!result) {" | 754 " if (!result) {" |
| 756 "console.log(tableContainers[i].innerHTML);" | 755 " console.log(tableContainers[i].innerHTML);" |
| 757 "}" | 756 " }" |
| 758 "}" | 757 "}" |
| 759 "window.domAutomationController.send(result);", | 758 "window.domAutomationController.send(result);", |
| 760 &result)); | 759 &result)); |
| 761 | 760 |
| 762 EXPECT_TRUE(result); | 761 EXPECT_TRUE(result); |
| 763 | 762 |
| 764 count = GetSsrcInfoBlockCount(shell2); | 763 count = GetSsrcInfoBlockCount(shell2); |
| 765 EXPECT_GT(count, 0); | 764 EXPECT_GT(count, 0); |
| 766 } | 765 } |
| 767 | 766 |
| 768 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcInternalsBrowserTest, CreatePageDump) { | 767 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcInternalsBrowserTest, CreatePageDump) { |
| 769 GURL url("chrome://webrtc-internals"); | 768 GURL url("chrome://webrtc-internals"); |
| 770 NavigateToURL(shell(), url); | 769 NavigateToURL(shell(), url); |
| 771 | 770 |
| 772 PeerConnectionEntry pc_0(1, 0); | 771 PeerConnectionEntry pc_0(1, 0); |
| 773 pc_0.AddEvent("e1", "v1"); | 772 pc_0.AddEvent("e1", "v1"); |
| 774 pc_0.AddEvent("e2", "v2"); | 773 pc_0.AddEvent("e2", "v2"); |
| 775 PeerConnectionEntry pc_1(1, 1); | 774 PeerConnectionEntry pc_1(1, 1); |
| 776 pc_1.AddEvent("e3", "v3"); | 775 pc_1.AddEvent("e3", "v3"); |
| 777 pc_1.AddEvent("e4", "v4"); | 776 pc_1.AddEvent("e4", "v4"); |
| 778 string pc_array = | 777 string pc_array = |
| 779 "[" + pc_0.getAllUpdateString() + ", " + pc_1.getAllUpdateString() + "]"; | 778 "[" + pc_0.getAllUpdateString() + ", " + pc_1.getAllUpdateString() + "]"; |
| 780 EXPECT_TRUE(ExecuteJavascript("updateAllPeerConnections(" + pc_array + ");")); | 779 EXPECT_TRUE(ExecuteJavascript("updateAllPeerConnections(" + pc_array + ");")); |
| 781 | 780 |
| 782 // Verifies the peer connection data store can be created without stats. | 781 // Verifies the peer connection data store can be created without stats. |
| 783 string dump_json; | 782 string dump_json; |
| 784 ASSERT_TRUE(ExecuteScriptAndExtractString( | 783 ASSERT_TRUE(ExecuteScriptAndExtractString( |
| 785 shell()->web_contents(), | 784 shell(), |
| 786 "window.domAutomationController.send(" | 785 "window.domAutomationController.send(" |
| 787 "JSON.stringify(peerConnectionDataStore));", | 786 " JSON.stringify(peerConnectionDataStore));", |
| 788 &dump_json)); | 787 &dump_json)); |
| 789 std::unique_ptr<base::Value> dump = base::JSONReader::Read(dump_json); | 788 std::unique_ptr<base::Value> dump = base::JSONReader::Read(dump_json); |
| 790 VerifyPageDumpStructure(dump.get(), | 789 VerifyPageDumpStructure(dump.get(), |
| 791 2 /*peer_connection_number*/, | 790 2 /*peer_connection_number*/, |
| 792 2 /*update_number*/, | 791 2 /*update_number*/, |
| 793 0 /*stats_number*/); | 792 0 /*stats_number*/); |
| 794 | 793 |
| 795 // Adds a stats report. | 794 // Adds a stats report. |
| 796 const string type = "dummy"; | 795 const string type = "dummy"; |
| 797 const string id = "1234"; | 796 const string id = "1234"; |
| 798 StatsUnit stats = { FAKE_TIME_STAMP }; | 797 StatsUnit stats = { FAKE_TIME_STAMP }; |
| 799 stats.values["bitrate"] = "2000"; | 798 stats.values["bitrate"] = "2000"; |
| 800 stats.values["framerate"] = "30"; | 799 stats.values["framerate"] = "30"; |
| 801 ExecuteAndVerifyAddStats(pc_0, type, id, stats); | 800 ExecuteAndVerifyAddStats(pc_0, type, id, stats); |
| 802 | 801 |
| 803 ASSERT_TRUE(ExecuteScriptAndExtractString( | 802 ASSERT_TRUE(ExecuteScriptAndExtractString( |
| 804 shell()->web_contents(), | 803 shell(), |
| 805 "window.domAutomationController.send(" | 804 "window.domAutomationController.send(" |
| 806 "JSON.stringify(peerConnectionDataStore));", | 805 " JSON.stringify(peerConnectionDataStore));", |
| 807 &dump_json)); | 806 &dump_json)); |
| 808 dump = base::JSONReader::Read(dump_json); | 807 dump = base::JSONReader::Read(dump_json); |
| 809 VerifyStatsDump(dump.get(), pc_0, type, id, stats); | 808 VerifyStatsDump(dump.get(), pc_0, type, id, stats); |
| 810 } | 809 } |
| 811 | 810 |
| 812 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcInternalsBrowserTest, UpdateGetUserMedia) { | 811 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcInternalsBrowserTest, UpdateGetUserMedia) { |
| 813 GURL url("chrome://webrtc-internals"); | 812 GURL url("chrome://webrtc-internals"); |
| 814 NavigateToURL(shell(), url); | 813 NavigateToURL(shell(), url); |
| 815 | 814 |
| 816 UserMediaRequestEntry request1(1, 1, "origin", "ac", "vc"); | 815 UserMediaRequestEntry request1(1, 1, "origin", "ac", "vc"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 const string stats_id = "videobwe"; | 850 const string stats_id = "videobwe"; |
| 852 ExecuteAndVerifyAddStats(pc, stats_type, stats_id, stats); | 851 ExecuteAndVerifyAddStats(pc, stats_type, stats_id, stats); |
| 853 | 852 |
| 854 string graph_id = pc.getIdString() + "-" + stats_id + | 853 string graph_id = pc.getIdString() + "-" + stats_id + |
| 855 "-googReceivedPacketGroupPropagationDeltaDebug"; | 854 "-googReceivedPacketGroupPropagationDeltaDebug"; |
| 856 string data_series_id = | 855 string data_series_id = |
| 857 stats_id + "-googReceivedPacketGroupPropagationDeltaDebug"; | 856 stats_id + "-googReceivedPacketGroupPropagationDeltaDebug"; |
| 858 bool result = false; | 857 bool result = false; |
| 859 // Verify that the graph exists. | 858 // Verify that the graph exists. |
| 860 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 859 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
| 861 shell()->web_contents(), | 860 shell(), |
| 862 "window.domAutomationController.send(" | 861 "window.domAutomationController.send(" |
| 863 " graphViews['" + graph_id + "'] != null)", | 862 " graphViews['" + graph_id + "'] != null)", |
| 864 &result)); | 863 &result)); |
| 865 EXPECT_TRUE(result); | 864 EXPECT_TRUE(result); |
| 866 | 865 |
| 867 // Verify that the graph contains multiple data points. | 866 // Verify that the graph contains multiple data points. |
| 868 int count = 0; | 867 int count = 0; |
| 869 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 868 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 870 shell()->web_contents(), | 869 shell(), |
| 871 "window.domAutomationController.send(" | 870 "window.domAutomationController.send(" |
| 872 " graphViews['" + graph_id + "'].getDataSeriesCount())", | 871 " graphViews['" + graph_id + "'].getDataSeriesCount())", |
| 873 &count)); | 872 &count)); |
| 874 EXPECT_EQ(1, count); | 873 EXPECT_EQ(1, count); |
| 875 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 874 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 876 shell()->web_contents(), | 875 shell(), |
| 877 "window.domAutomationController.send(" | 876 "window.domAutomationController.send(" |
| 878 " peerConnectionDataStore['" + pc.getIdString() + "']" + | 877 " peerConnectionDataStore['" + pc.getIdString() + "']" + |
| 879 " .getDataSeries('" + data_series_id + "').getCount())", | 878 " .getDataSeries('" + data_series_id + "').getCount())", |
| 880 &count)); | 879 &count)); |
| 881 EXPECT_EQ(3, count); | 880 EXPECT_EQ(3, count); |
| 882 } | 881 } |
| 883 | 882 |
| 884 } // namespace content | 883 } // namespace content |
| OLD | NEW |