OLD | NEW |
---|---|
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 Loading... | |
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 static const std::string hasVideoInputDeviceOnSystem = | |
sky
2016/09/13 21:32:34
There is no need for the static as this in an anon
lunalu1
2016/09/13 21:55:02
Done.
| |
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 | |
411 } // namespace | 433 } // namespace |
412 | 434 |
413 bool NavigateIframeToURL(WebContents* web_contents, | 435 bool NavigateIframeToURL(WebContents* web_contents, |
414 std::string iframe_id, | 436 std::string iframe_id, |
415 const GURL& url) { | 437 const GURL& url) { |
416 std::string script = base::StringPrintf( | 438 std::string script = base::StringPrintf( |
417 "setTimeout(\"" | 439 "setTimeout(\"" |
418 "var iframes = document.getElementById('%s');iframes.src='%s';" | 440 "var iframes = document.getElementById('%s');iframes.src='%s';" |
419 "\",0)", | 441 "\",0)", |
420 iframe_id.c_str(), url.spec().c_str()); | 442 iframe_id.c_str(), url.spec().c_str()); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 if (command) { | 757 if (command) { |
736 modifiers &= ~blink::WebInputEvent::MetaKey; | 758 modifiers &= ~blink::WebInputEvent::MetaKey; |
737 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, | 759 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, |
738 ui::DomKey::META, ui::DomCode::META_LEFT, | 760 ui::DomKey::META, ui::DomCode::META_LEFT, |
739 ui::VKEY_COMMAND, modifiers); | 761 ui::VKEY_COMMAND, modifiers); |
740 } | 762 } |
741 | 763 |
742 ASSERT_EQ(modifiers, 0); | 764 ASSERT_EQ(modifiers, 0); |
743 } | 765 } |
744 | 766 |
767 bool HasWebcamAvailableOnSystem(WebContents* web_contents) { | |
768 std::string result; | |
769 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | |
770 web_contents, hasVideoInputDeviceOnSystem, &result)); | |
771 return result == "has-video-input-device"; | |
sky
2016/09/13 21:32:34
Can this be a constant?
lunalu1
2016/09/13 21:55:02
Done.
| |
772 } | |
773 | |
745 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) { | 774 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) { |
746 return web_contents->GetMainFrame(); | 775 return web_contents->GetMainFrame(); |
747 } | 776 } |
748 | 777 |
749 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) { | 778 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) { |
750 return render_view_host->GetMainFrame(); | 779 return render_view_host->GetMainFrame(); |
751 } | 780 } |
752 | 781 |
753 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) { | 782 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) { |
754 return render_frame_host; | 783 return render_frame_host; |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1689 | 1718 |
1690 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) { | 1719 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) { |
1691 if (handle_ || handle->GetURL() != url_) | 1720 if (handle_ || handle->GetURL() != url_) |
1692 return false; | 1721 return false; |
1693 if (handled_navigation_) | 1722 if (handled_navigation_) |
1694 return false; | 1723 return false; |
1695 return true; | 1724 return true; |
1696 } | 1725 } |
1697 | 1726 |
1698 } // namespace content | 1727 } // namespace content |
OLD | NEW |