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

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

Issue 2334223012: Fix failures on content_browser tests on Windows 7. (Closed)
Patch Set: don't use the webrtc sendToTest method, and compare to 'video-input' (and not 'video') 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-input') {"
425 "window.domAutomationController.send('has-video-input-device');"
426 "return;"
427 "}"
428 "});"
429 "window.domAutomationController.send('no-video-input-devices');"
430 "});"
431 "})()";
432
433 const char kHasVideoInputDevice[] = "has-video-input-device";
434
411 } // namespace 435 } // namespace
412 436
413 bool NavigateIframeToURL(WebContents* web_contents, 437 bool NavigateIframeToURL(WebContents* web_contents,
414 std::string iframe_id, 438 std::string iframe_id,
415 const GURL& url) { 439 const GURL& url) {
416 std::string script = base::StringPrintf( 440 std::string script = base::StringPrintf(
417 "setTimeout(\"" 441 "setTimeout(\""
418 "var iframes = document.getElementById('%s');iframes.src='%s';" 442 "var iframes = document.getElementById('%s');iframes.src='%s';"
419 "\",0)", 443 "\",0)",
420 iframe_id.c_str(), url.spec().c_str()); 444 iframe_id.c_str(), url.spec().c_str());
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (command) { 759 if (command) {
736 modifiers &= ~blink::WebInputEvent::MetaKey; 760 modifiers &= ~blink::WebInputEvent::MetaKey;
737 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, 761 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp,
738 ui::DomKey::META, ui::DomCode::META_LEFT, 762 ui::DomKey::META, ui::DomCode::META_LEFT,
739 ui::VKEY_COMMAND, modifiers); 763 ui::VKEY_COMMAND, modifiers);
740 } 764 }
741 765
742 ASSERT_EQ(modifiers, 0); 766 ASSERT_EQ(modifiers, 0);
743 } 767 }
744 768
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
745 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) { 776 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) {
746 return web_contents->GetMainFrame(); 777 return web_contents->GetMainFrame();
747 } 778 }
748 779
749 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) { 780 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host) {
750 return render_view_host->GetMainFrame(); 781 return render_view_host->GetMainFrame();
751 } 782 }
752 783
753 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) { 784 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) {
754 return render_frame_host; 785 return render_frame_host;
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 1720
1690 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) { 1721 bool TestNavigationManager::ShouldMonitorNavigation(NavigationHandle* handle) {
1691 if (handle_ || handle->GetURL() != url_) 1722 if (handle_ || handle->GetURL() != url_)
1692 return false; 1723 return false;
1693 if (handled_navigation_) 1724 if (handled_navigation_)
1694 return false; 1725 return false;
1695 return true; 1726 return true;
1696 } 1727 }
1697 1728
1698 } // namespace content 1729 } // 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