| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 const char kExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; | 37 const char kExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; |
| 38 | 38 |
| 39 class TabCaptureApiTest : public ExtensionApiTest { | 39 class TabCaptureApiTest : public ExtensionApiTest { |
| 40 public: | 40 public: |
| 41 void SetUpCommandLine(base::CommandLine* command_line) override { | 41 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 42 ExtensionApiTest::SetUpCommandLine(command_line); | 42 ExtensionApiTest::SetUpCommandLine(command_line); |
| 43 // Specify smallish window size to make testing of tab capture less CPU | 43 // Specify smallish window size to make testing of tab capture less CPU |
| 44 // intensive. | 44 // intensive. |
| 45 command_line->AppendSwitchASCII(::switches::kWindowSize, "300,300"); | 45 command_line->AppendSwitchASCII(::switches::kWindowSize, "300,300"); |
| 46 // Enable tabCapture.capturePresentation API for testing. |
| 47 command_line->AppendSwitch(::switches::kEnableCapturePresentationApi); |
| 46 } | 48 } |
| 47 | 49 |
| 48 void AddExtensionToCommandLineWhitelist() { | 50 void AddExtensionToCommandLineWhitelist() { |
| 49 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 51 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 50 switches::kWhitelistedExtensionID, kExtensionId); | 52 switches::kWhitelistedExtensionID, kExtensionId); |
| 51 } | 53 } |
| 52 | 54 |
| 53 protected: | 55 protected: |
| 54 void SimulateMouseClickInCurrentTab() { | 56 void SimulateMouseClickInCurrentTab() { |
| 55 content::SimulateMouseClick( | 57 content::SimulateMouseClick( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #endif | 91 #endif |
| 90 } | 92 } |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 // Tests API behaviors, including info queries, and constraints violations. | 95 // Tests API behaviors, including info queries, and constraints violations. |
| 94 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTests) { | 96 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTests) { |
| 95 AddExtensionToCommandLineWhitelist(); | 97 AddExtensionToCommandLineWhitelist(); |
| 96 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "api_tests.html")) << message_; | 98 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "api_tests.html")) << message_; |
| 97 } | 99 } |
| 98 | 100 |
| 101 // Tests that there is a maximum limitation to the number of simultaneous |
| 102 // offscreen presentation sessions. |
| 103 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MaxOffscreenPresentations) { |
| 104 AddExtensionToCommandLineWhitelist(); |
| 105 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "max_presentations.html")) |
| 106 << message_; |
| 107 } |
| 108 |
| 99 // Tests that tab capture video frames can be received in a VIDEO element. | 109 // Tests that tab capture video frames can be received in a VIDEO element. |
| 100 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndWithoutRemoting) { | 110 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndWithoutRemoting) { |
| 101 if (IsTooIntensiveForThisPlatform()) { | 111 if (IsTooIntensiveForThisPlatform()) { |
| 102 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build."; | 112 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build."; |
| 103 return; | 113 return; |
| 104 } | 114 } |
| 105 AddExtensionToCommandLineWhitelist(); | 115 AddExtensionToCommandLineWhitelist(); |
| 106 ASSERT_TRUE(RunExtensionSubtest( | 116 ASSERT_TRUE(RunExtensionSubtest( |
| 107 "tab_capture", "end_to_end.html?method=local&colorDeviation=10")) | 117 "tab_capture", "end_to_end.html?method=local&colorDeviation=10")) |
| 108 << message_; | 118 << message_; |
| 109 } | 119 } |
| 110 | 120 |
| 111 // Tests that video frames are captured, transported via WebRTC, and finally | 121 // Tests that video frames are captured, transported via WebRTC, and finally |
| 112 // received in a VIDEO element. More allowance is provided for color deviation | 122 // received in a VIDEO element. More allowance is provided for color deviation |
| 113 // because of the additional layers of video processing performed within | 123 // because of the additional layers of video processing performed within |
| 114 // WebRTC. | 124 // WebRTC. |
| 115 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndThroughWebRTC) { | 125 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndThroughWebRTC) { |
| 116 if (IsTooIntensiveForThisPlatform()) { | 126 if (IsTooIntensiveForThisPlatform()) { |
| 117 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build."; | 127 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build."; |
| 118 return; | 128 return; |
| 119 } | 129 } |
| 120 AddExtensionToCommandLineWhitelist(); | 130 AddExtensionToCommandLineWhitelist(); |
| 121 ASSERT_TRUE(RunExtensionSubtest( | 131 ASSERT_TRUE(RunExtensionSubtest( |
| 122 "tab_capture", "end_to_end.html?method=webrtc&colorDeviation=50")) | 132 "tab_capture", "end_to_end.html?method=webrtc&colorDeviation=50")) |
| 123 << message_; | 133 << message_; |
| 124 } | 134 } |
| 125 | 135 |
| 136 // Tests that tab capture video frames can be received in a VIDEO element from |
| 137 // an offscreen presentation tab. |
| 138 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndOffscreenPresentation) { |
| 139 if (IsTooIntensiveForThisPlatform()) { |
| 140 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build."; |
| 141 return; |
| 142 } |
| 143 AddExtensionToCommandLineWhitelist(); |
| 144 ASSERT_TRUE(RunExtensionSubtest( |
| 145 "tab_capture", "presentation.html?colorDeviation=10")) |
| 146 << message_; |
| 147 } |
| 148 |
| 126 // http://crbug.com/177163 | 149 // http://crbug.com/177163 |
| 127 #if defined(OS_WIN) && !defined(NDEBUG) | 150 #if defined(OS_WIN) && !defined(NDEBUG) |
| 128 #define MAYBE_GetUserMediaTest DISABLED_GetUserMediaTest | 151 #define MAYBE_GetUserMediaTest DISABLED_GetUserMediaTest |
| 129 #else | 152 #else |
| 130 #define MAYBE_GetUserMediaTest GetUserMediaTest | 153 #define MAYBE_GetUserMediaTest GetUserMediaTest |
| 131 #endif | 154 #endif |
| 132 // Tests that getUserMedia() is NOT a way to start tab capture. | 155 // Tests that getUserMedia() is NOT a way to start tab capture. |
| 133 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) { | 156 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) { |
| 134 ExtensionTestMessageListener listener("ready", true); | 157 ExtensionTestMessageListener listener("ready", true); |
| 135 | 158 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 return; | 379 return; |
| 357 } | 380 } |
| 358 content::RunMessageLoop(); | 381 content::RunMessageLoop(); |
| 359 } | 382 } |
| 360 browser()->tab_strip_model()->RemoveObserver(&observer); | 383 browser()->tab_strip_model()->RemoveObserver(&observer); |
| 361 } | 384 } |
| 362 | 385 |
| 363 } // namespace | 386 } // namespace |
| 364 | 387 |
| 365 } // namespace extensions | 388 } // namespace extensions |
| OLD | NEW |