OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" |
| 7 #include "base/path_service.h" |
| 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/test/browser_test_utils.h" |
| 19 #include "media/base/media_switches.h" |
| 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "testing/perf/perf_test.h" |
| 22 #include "ui/gl/gl_switches.h" |
| 23 |
| 24 static const char kCanvasTestHtmlPage[] = "/media/canvas_capture_test.html"; |
| 25 |
| 26 // Canvas Capture browser test. |
| 27 // At this time this browser test verifies that the frame rate of a stream |
| 28 // originated from a captured canvas is as expected. |
| 29 class WebRtcCanvasCaptureBrowserTest : public InProcessBrowserTest { |
| 30 public: |
| 31 |
| 32 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 33 // The video playback will not work without a GPU, so force its use here. |
| 34 command_line->AppendSwitch(switches::kUseGpuInTests); |
| 35 |
| 36 command_line->AppendSwitch( |
| 37 switches::kEnableExperimentalWebPlatformFeatures); |
| 38 } |
| 39 |
| 40 protected: |
| 41 WebRtcCanvasCaptureBrowserTest() {} |
| 42 ~WebRtcCanvasCaptureBrowserTest() override {}; |
| 43 |
| 44 std::string ExecuteJavascript( |
| 45 const std::string& javascript, |
| 46 content::WebContents* tab_contents) const { |
| 47 std::string result; |
| 48 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 49 tab_contents, javascript, &result)); |
| 50 return result; |
| 51 } |
| 52 |
| 53 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(WebRtcCanvasCaptureBrowserTest); |
| 55 }; |
| 56 |
| 57 // Tests that the frame rate of the canvas capture is as expected. |
| 58 IN_PROC_BROWSER_TEST_F(WebRtcCanvasCaptureBrowserTest, |
| 59 VerifyCanvasCaptureFrameRate) { |
| 60 ASSERT_TRUE(embedded_test_server()->Start()); |
| 61 |
| 62 ui_test_utils::NavigateToURL( |
| 63 browser(), embedded_test_server()->GetURL(kCanvasTestHtmlPage)); |
| 64 |
| 65 content::WebContents* tab_contents = |
| 66 browser()->tab_strip_model()->GetActiveWebContents(); |
| 67 |
| 68 ASSERT_EQ("OK", ExecuteJavascript("testFrameRateOfCanvasCapture();", |
| 69 tab_contents)); |
| 70 } |
OLD | NEW |