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 = | |
420 "(function() {" | |
421 "MediaStreamTrack.getSources(function(devices) {" | |
422 "devices.forEach(function(device) {" | |
423 "if (device.kind == 'video')" | |
424 "returnToTest('has-video-input-device');" | |
mcasas
2016/09/06 23:13:12
returnToTest(), confusingly enough, doesn't
seem t
lunalu1
2016/09/07 14:30:34
Done.
| |
425 "});" | |
426 "returnToTest('no-video-input-devices');" | |
427 "});" | |
428 "})()"; | |
429 | |
411 } // namespace | 430 } // namespace |
412 | 431 |
413 bool NavigateIframeToURL(WebContents* web_contents, | 432 bool NavigateIframeToURL(WebContents* web_contents, |
414 std::string iframe_id, | 433 std::string iframe_id, |
415 const GURL& url) { | 434 const GURL& url) { |
416 std::string script = base::StringPrintf( | 435 std::string script = base::StringPrintf( |
417 "setTimeout(\"" | 436 "setTimeout(\"" |
418 "var iframes = document.getElementById('%s');iframes.src='%s';" | 437 "var iframes = document.getElementById('%s');iframes.src='%s';" |
419 "\",0)", | 438 "\",0)", |
420 iframe_id.c_str(), url.spec().c_str()); | 439 iframe_id.c_str(), url.spec().c_str()); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 if (command) { | 754 if (command) { |
736 modifiers &= ~blink::WebInputEvent::MetaKey; | 755 modifiers &= ~blink::WebInputEvent::MetaKey; |
737 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, | 756 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, |
738 ui::DomKey::META, ui::DomCode::META_LEFT, | 757 ui::DomKey::META, ui::DomCode::META_LEFT, |
739 ui::VKEY_COMMAND, modifiers); | 758 ui::VKEY_COMMAND, modifiers); |
740 } | 759 } |
741 | 760 |
742 ASSERT_EQ(modifiers, 0); | 761 ASSERT_EQ(modifiers, 0); |
743 } | 762 } |
744 | 763 |
764 bool HasWebcamAvailableOnSystem(WebContents* tab_contents) { | |
765 std::string result; | |
766 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | |
767 tab_contents, hasVideoInputDeviceOnSystem, &result)); | |
768 return result == "has-video-input-device"; | |
769 } | |
770 | |
745 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) { | 771 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) { |
746 return web_contents->GetMainFrame(); | 772 return web_contents->GetMainFrame(); |
747 } | 773 } |
748 | 774 |
749 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) { | 775 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) { |
750 return render_view_host->GetMainFrame(); | 776 return render_view_host->GetMainFrame(); |
751 } | 777 } |
752 | 778 |
753 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) { | 779 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) { |
754 return render_frame_host; | 780 return render_frame_host; |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1689 | 1715 |
1690 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) { | 1716 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) { |
1691 if (handle_ || handle->GetURL() != url_) | 1717 if (handle_ || handle->GetURL() != url_) |
1692 return false; | 1718 return false; |
1693 if (handled_navigation_) | 1719 if (handled_navigation_) |
1694 return false; | 1720 return false; |
1695 return true; | 1721 return true; |
1696 } | 1722 } |
1697 | 1723 |
1698 } // namespace content | 1724 } // namespace content |
OLD | NEW |