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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 2347473004: Revert of Removed duplicated JS hasVideoInputDeviceOnSystem() test helper (Closed)
Patch Set: Created 4 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 net::Filter::FilterStatus status; 402 net::Filter::FilterStatus status;
403 do { 403 do {
404 int read_size = kBufferSize; 404 int read_size = kBufferSize;
405 status = filter->ReadData(dest_buffer, &read_size); 405 status = filter->ReadData(dest_buffer, &read_size);
406 ASSERT_NE(status, net::Filter::FILTER_ERROR); 406 ASSERT_NE(status, net::Filter::FILTER_ERROR);
407 to_append->append(dest_buffer, read_size); 407 to_append->append(dest_buffer, read_size);
408 } while (status != net::Filter::FILTER_DONE); 408 } while (status != net::Filter::FILTER_DONE);
409 } 409 }
410 410
411 // Queries for video input devices on the current system using the getSources
412 // API.
413 //
414 // This does not guarantee that a getUserMedia with video will succeed, as the
415 // camera could be busy for instance.
416 //
417 // Returns has-video-input-device to the test if there is a webcam available,
418 // no-video-input-devices otherwise.
419 const char kHasVideoInputDeviceOnSystem[] =
420 "(function() {"
421 "navigator.mediaDevices.enumerateDevices()"
422 ".then(function(devices) {"
423 "devices.forEach(function(device) {"
424 "if (device.kind == 'video') {"
425 "returnToTest('has-video-input-device');"
426 "return;"
427 "}"
428 "});"
429 "returnToTest('no-video-input-devices');"
430 "});"
431 "})()";
432
433 const char kHasVideoInputDevice[] = "has-video-input-device";
434
435 } // namespace 411 } // namespace
436 412
437 bool NavigateIframeToURL(WebContents* web_contents, 413 bool NavigateIframeToURL(WebContents* web_contents,
438 std::string iframe_id, 414 std::string iframe_id,
439 const GURL& url) { 415 const GURL& url) {
440 std::string script = base::StringPrintf( 416 std::string script = base::StringPrintf(
441 "setTimeout(\"" 417 "setTimeout(\""
442 "var iframes = document.getElementById('%s');iframes.src='%s';" 418 "var iframes = document.getElementById('%s');iframes.src='%s';"
443 "\",0)", 419 "\",0)",
444 iframe_id.c_str(), url.spec().c_str()); 420 iframe_id.c_str(), url.spec().c_str());
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 if (command) { 735 if (command) {
760 modifiers &= ~blink::WebInputEvent::MetaKey; 736 modifiers &= ~blink::WebInputEvent::MetaKey;
761 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, 737 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp,
762 ui::DomKey::META, ui::DomCode::META_LEFT, 738 ui::DomKey::META, ui::DomCode::META_LEFT,
763 ui::VKEY_COMMAND, modifiers); 739 ui::VKEY_COMMAND, modifiers);
764 } 740 }
765 741
766 ASSERT_EQ(modifiers, 0); 742 ASSERT_EQ(modifiers, 0);
767 } 743 }
768 744
769 bool IsWebcamAvailableOnSystem(WebContents* web_contents) {
770 std::string result;
771 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
772 web_contents, kHasVideoInputDeviceOnSystem, &result));
773 return result == kHasVideoInputDevice;
774 }
775
776 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) { 745 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) {
777 return web_contents->GetMainFrame(); 746 return web_contents->GetMainFrame();
778 } 747 }
779 748
780 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) { 749 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) {
781 return render_view_host->GetMainFrame(); 750 return render_view_host->GetMainFrame();
782 } 751 }
783 752
784 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) { 753 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) {
785 return render_frame_host; 754 return render_frame_host;
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 1689
1721 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) { 1690 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) {
1722 if (handle_ || handle->GetURL() != url_) 1691 if (handle_ || handle->GetURL() != url_)
1723 return false; 1692 return false;
1724 if (handled_navigation_) 1693 if (handled_navigation_)
1725 return false; 1694 return false;
1726 return true; 1695 return true;
1727 } 1696 }
1728 1697
1729 } // namespace content 1698 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/test/data/media/webrtc_test_utilities.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698