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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc

Issue 734853003: Misc clean-up of TabCaptureApiTests; and re-enable more tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 18 matching lines...) Expand all
29 #endif 29 #endif
30 30
31 namespace extensions { 31 namespace extensions {
32 32
33 namespace { 33 namespace {
34 34
35 const char kExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; 35 const char kExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf";
36 36
37 class TabCaptureApiTest : public ExtensionApiTest { 37 class TabCaptureApiTest : public ExtensionApiTest {
38 public: 38 public:
39 void SetUpCommandLine(CommandLine* command_line) override {
40 ExtensionApiTest::SetUpCommandLine(command_line);
41 // Specify smallish window size to make testing of tab capture less CPU
42 // intensive.
43 command_line->AppendSwitchASCII(::switches::kWindowSize, "300,300");
miu 2014/11/19 01:15:54 Many of the Tab Capture API tests could be slow ru
44 }
45
39 void AddExtensionToCommandLineWhitelist() { 46 void AddExtensionToCommandLineWhitelist() {
40 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 47 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
41 switches::kWhitelistedExtensionID, kExtensionId); 48 switches::kWhitelistedExtensionID, kExtensionId);
42 } 49 }
43 }; 50 };
44 51
45 class TabCaptureApiPixelTest : public TabCaptureApiTest { 52 class TabCaptureApiPixelTest : public TabCaptureApiTest {
46 public: 53 public:
47 void SetUpCommandLine(CommandLine* command_line) override {
48 TabCaptureApiTest::SetUpCommandLine(command_line);
49 command_line->AppendSwitchASCII(::switches::kWindowSize, "300,300");
50 }
51
52 void SetUp() override { 54 void SetUp() override {
53 if (!IsTooIntensiveForThisPlatform()) 55 if (!IsTooIntensiveForThisPlatform())
54 EnablePixelOutput(); 56 EnablePixelOutput();
55 TabCaptureApiTest::SetUp(); 57 TabCaptureApiTest::SetUp();
56 } 58 }
57 59
58 protected: 60 protected:
59 bool IsTooIntensiveForThisPlatform() const { 61 bool IsTooIntensiveForThisPlatform() const {
60 #if defined(OS_WIN) 62 #if defined(OS_WIN)
61 if (base::win::GetVersion() < base::win::VERSION_VISTA) 63 if (base::win::GetVersion() < base::win::VERSION_VISTA)
62 return true; 64 return true;
63 #endif 65 #endif
64 66
65 // The tests are too slow to succeed with OSMesa on the bots. 67 // The tests are too slow to succeed with OSMesa on the bots.
66 if (UsingOSMesa()) 68 if (UsingOSMesa())
67 return true; 69 return true;
68 70
69 #if defined(NDEBUG) 71 #if defined(NDEBUG)
70 return false; 72 return false;
71 #else 73 #else
72 // TODO(miu): Look into enabling these tests for the Debug build bots once 74 // TODO(miu): Look into enabling these tests for the Debug build bots once
73 // they prove to be stable again on the Release bots. 75 // they prove to be stable again on the Release bots.
74 // http://crbug.com/396413 76 // http://crbug.com/396413
75 return !CommandLine::ForCurrentProcess()->HasSwitch( 77 return !CommandLine::ForCurrentProcess()->HasSwitch(
76 "run-tab-capture-api-pixel-tests"); 78 "run-tab-capture-api-pixel-tests");
77 #endif 79 #endif
78 } 80 }
79 }; 81 };
80 82
83 // Tests API behaviors, including info queries, and constraints violations.
81 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTests) { 84 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTests) {
82 #if defined(OS_WIN)
83 // TODO(justinlin): Disabled for WinXP due to timeout issues.
miu 2014/11/19 01:15:54 I think these isWinXP() checks are just left-overs
84 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
85 return;
86 }
87 #endif
88
89 AddExtensionToCommandLineWhitelist(); 85 AddExtensionToCommandLineWhitelist();
90 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "api_tests.html")) << message_; 86 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "api_tests.html")) << message_;
91 } 87 }
92 88
93 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTestsAudio) {
miu 2014/11/19 01:15:54 Merged into TabCaptureApiTest.ApiTests.
94 #if defined(OS_WIN)
95 // TODO(justinlin): Disabled for WinXP due to timeout issues.
96 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
97 return;
98 }
99 #endif
100
101 AddExtensionToCommandLineWhitelist();
102 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "api_tests_audio.html"))
103 << message_;
104 }
105
106 // Tests that tab capture video frames can be received in a VIDEO element. 89 // Tests that tab capture video frames can be received in a VIDEO element.
107 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndWithoutRemoting) { 90 IN_PROC_BROWSER_TEST_F(TabCaptureApiPixelTest, EndToEndWithoutRemoting) {
108 if (IsTooIntensiveForThisPlatform()) { 91 if (IsTooIntensiveForThisPlatform()) {
109 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build."; 92 LOG(WARNING) << "Skipping this CPU-intensive test on this platform/build.";
110 return; 93 return;
111 } 94 }
112 AddExtensionToCommandLineWhitelist(); 95 AddExtensionToCommandLineWhitelist();
113 ASSERT_TRUE(RunExtensionSubtest( 96 ASSERT_TRUE(RunExtensionSubtest(
114 "tab_capture", "end_to_end.html?method=local&colorDeviation=10")) 97 "tab_capture", "end_to_end.html?method=local&colorDeviation=10"))
115 << message_; 98 << message_;
(...skipping 13 matching lines...) Expand all
129 "tab_capture", "end_to_end.html?method=webrtc&colorDeviation=50")) 112 "tab_capture", "end_to_end.html?method=webrtc&colorDeviation=50"))
130 << message_; 113 << message_;
131 } 114 }
132 115
133 // http://crbug.com/177163 116 // http://crbug.com/177163
134 #if defined(OS_WIN) && !defined(NDEBUG) 117 #if defined(OS_WIN) && !defined(NDEBUG)
135 #define MAYBE_GetUserMediaTest DISABLED_GetUserMediaTest 118 #define MAYBE_GetUserMediaTest DISABLED_GetUserMediaTest
136 #else 119 #else
137 #define MAYBE_GetUserMediaTest GetUserMediaTest 120 #define MAYBE_GetUserMediaTest GetUserMediaTest
138 #endif 121 #endif
139 // Test that we can't get tabCapture streams using GetUserMedia directly. 122 // Tests that getUserMedia() is NOT a way to start tab capture.
140 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) { 123 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) {
141 ExtensionTestMessageListener listener("ready", true); 124 ExtensionTestMessageListener listener("ready", true);
142 125
143 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "get_user_media_test.html")) 126 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "get_user_media_test.html"))
144 << message_; 127 << message_;
145 128
146 EXPECT_TRUE(listener.WaitUntilSatisfied()); 129 EXPECT_TRUE(listener.WaitUntilSatisfied());
147 130
148 content::OpenURLParams params(GURL("about:blank"), content::Referrer(), 131 content::OpenURLParams params(GURL("about:blank"), content::Referrer(),
149 NEW_FOREGROUND_TAB, 132 NEW_FOREGROUND_TAB,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 #elif defined(USE_AURA) || defined(OS_MACOSX) 200 #elif defined(USE_AURA) || defined(OS_MACOSX)
218 // These don't always fire fullscreen events when run in tests. Tested manually. 201 // These don't always fire fullscreen events when run in tests. Tested manually.
219 #define MAYBE_FullscreenEvents DISABLED_FullscreenEvents 202 #define MAYBE_FullscreenEvents DISABLED_FullscreenEvents
220 #elif defined(OS_LINUX) 203 #elif defined(OS_LINUX)
221 // Flaky to get out of fullscreen in tests. Tested manually. 204 // Flaky to get out of fullscreen in tests. Tested manually.
222 #define MAYBE_FullscreenEvents DISABLED_FullscreenEvents 205 #define MAYBE_FullscreenEvents DISABLED_FullscreenEvents
223 #else 206 #else
224 #define MAYBE_FullscreenEvents FullscreenEvents 207 #define MAYBE_FullscreenEvents FullscreenEvents
225 #endif 208 #endif
226 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_FullscreenEvents) { 209 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_FullscreenEvents) {
227 #if defined(OS_WIN)
228 // TODO(justinlin): Disabled for WinXP due to timeout issues.
229 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
230 return;
231 }
232 #endif
233
234 AddExtensionToCommandLineWhitelist(); 210 AddExtensionToCommandLineWhitelist();
235 211
236 content::OpenURLParams params(GURL("chrome://version"), 212 content::OpenURLParams params(GURL("chrome://version"),
237 content::Referrer(), 213 content::Referrer(),
238 CURRENT_TAB, 214 CURRENT_TAB,
239 ui::PAGE_TRANSITION_LINK, false); 215 ui::PAGE_TRANSITION_LINK, false);
240 content::WebContents* web_contents = browser()->OpenURL(params); 216 content::WebContents* web_contents = browser()->OpenURL(params);
241 217
242 ExtensionTestMessageListener listeners_setup("ready1", true); 218 ExtensionTestMessageListener listeners_setup("ready1", true);
243 ExtensionTestMessageListener fullscreen_entered("ready2", true); 219 ExtensionTestMessageListener fullscreen_entered("ready2", true);
(...skipping 11 matching lines...) Expand all
255 EXPECT_TRUE(fullscreen_entered.WaitUntilSatisfied()); 231 EXPECT_TRUE(fullscreen_entered.WaitUntilSatisfied());
256 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(web_contents, 232 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(web_contents,
257 false); 233 false);
258 fullscreen_entered.Reply(""); 234 fullscreen_entered.Reply("");
259 235
260 ResultCatcher catcher; 236 ResultCatcher catcher;
261 catcher.RestrictToBrowserContext(browser()->profile()); 237 catcher.RestrictToBrowserContext(browser()->profile());
262 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 238 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
263 } 239 }
264 240
265 // Times out on Win dbg bots: http://crbug.com/177163 241 // http://crbug.com/177163
266 // #if defined(OS_WIN) && !defined(NDEBUG) 242 #if defined(OS_WIN) && !defined(NDEBUG)
267 // Times out on all Win bots, flaky on MSan bots: http://crbug.com/294431
268 #if defined(OS_WIN) || defined(MEMORY_SANITIZER)
269 #define MAYBE_GrantForChromePages DISABLED_GrantForChromePages 243 #define MAYBE_GrantForChromePages DISABLED_GrantForChromePages
270 #else 244 #else
271 #define MAYBE_GrantForChromePages GrantForChromePages 245 #define MAYBE_GrantForChromePages GrantForChromePages
272 #endif 246 #endif
273 // Make sure tabCapture API can be granted for Chrome:// pages. 247 // Make sure tabCapture API can be granted for Chrome:// pages.
274 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GrantForChromePages) { 248 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GrantForChromePages) {
275 ExtensionTestMessageListener before_open_tab("ready1", true); 249 ExtensionTestMessageListener before_open_tab("ready1", true);
276 ASSERT_TRUE(RunExtensionSubtest("tab_capture", 250 ASSERT_TRUE(RunExtensionSubtest("tab_capture",
277 "active_tab_chrome_pages.html")) 251 "active_tab_chrome_pages.html"))
278 << message_; 252 << message_;
(...skipping 10 matching lines...) Expand all
289 TabHelper::FromWebContents(web_contents) 263 TabHelper::FromWebContents(web_contents)
290 ->active_tab_permission_granter()->GrantIfRequested(extension); 264 ->active_tab_permission_granter()->GrantIfRequested(extension);
291 before_open_tab.Reply(""); 265 before_open_tab.Reply("");
292 266
293 ResultCatcher catcher; 267 ResultCatcher catcher;
294 catcher.RestrictToBrowserContext(browser()->profile()); 268 catcher.RestrictToBrowserContext(browser()->profile());
295 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 269 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
296 } 270 }
297 271
298 // http://crbug.com/177163 272 // http://crbug.com/177163
299 #if (defined(OS_WIN) && !defined(NDEBUG)) || defined(OS_MACOSX) 273 #if defined(OS_WIN) && !defined(NDEBUG)
300 // http://crbug.com/326319
301 #define MAYBE_CaptureInSplitIncognitoMode DISABLED_CaptureInSplitIncognitoMode 274 #define MAYBE_CaptureInSplitIncognitoMode DISABLED_CaptureInSplitIncognitoMode
302 #else 275 #else
303 #define MAYBE_CaptureInSplitIncognitoMode CaptureInSplitIncognitoMode 276 #define MAYBE_CaptureInSplitIncognitoMode CaptureInSplitIncognitoMode
304 #endif 277 #endif
305 // Test that a tab can be captured in split incognito mode. 278 // Tests that a tab in incognito mode can be captured.
306 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_CaptureInSplitIncognitoMode) { 279 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_CaptureInSplitIncognitoMode) {
307 AddExtensionToCommandLineWhitelist(); 280 AddExtensionToCommandLineWhitelist();
308 ASSERT_TRUE(RunExtensionSubtest("tab_capture", 281 ASSERT_TRUE(RunExtensionSubtest("tab_capture",
309 "incognito.html", 282 "start_tab_capture.html",
310 kFlagEnableIncognito | kFlagUseIncognito)) 283 kFlagEnableIncognito | kFlagUseIncognito))
311 << message_; 284 << message_;
312 } 285 }
313 286
314 // http://crbug.com/177163 287 // http://crbug.com/177163
315 #if defined(OS_WIN) && !defined(NDEBUG) 288 #if defined(OS_WIN) && !defined(NDEBUG)
316 #define MAYBE_Constraints DISABLED_Constraints 289 #define MAYBE_Constraints DISABLED_Constraints
317 #else 290 #else
318 #define MAYBE_Constraints Constraints 291 #define MAYBE_Constraints Constraints
319 #endif 292 #endif
293 // Tests that valid constraints allow tab capture to start, while invalid ones
294 // do not.
320 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_Constraints) { 295 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_Constraints) {
321 AddExtensionToCommandLineWhitelist(); 296 AddExtensionToCommandLineWhitelist();
322 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "constraints.html")) 297 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "constraints.html"))
323 << message_; 298 << message_;
324 } 299 }
325 300
326 // http://crbug.com/177163 301 // http://crbug.com/177163
327 #if defined(OS_WIN) && !defined(NDEBUG) 302 #if defined(OS_WIN) && !defined(NDEBUG)
328 #define MAYBE_TabIndicator DISABLED_TabIndicator 303 #define MAYBE_TabIndicator DISABLED_TabIndicator
329 #else 304 #else
330 #define MAYBE_TabIndicator TabIndicator 305 #define MAYBE_TabIndicator TabIndicator
331 #endif 306 #endif
307 // Tests that the tab indicator (in the tab strip) is shown during tab capture.
332 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) { 308 IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) {
333 ASSERT_EQ(TAB_MEDIA_STATE_NONE, 309 ASSERT_EQ(TAB_MEDIA_STATE_NONE,
334 chrome::GetTabMediaStateForContents( 310 chrome::GetTabMediaStateForContents(
335 browser()->tab_strip_model()->GetActiveWebContents())); 311 browser()->tab_strip_model()->GetActiveWebContents()));
336 312
337 // Run an extension test that just turns on tab capture, which should cause 313 // Run an extension test that just turns on tab capture, which should cause
338 // the indicator to turn on. 314 // the indicator to turn on.
339 AddExtensionToCommandLineWhitelist(); 315 AddExtensionToCommandLineWhitelist();
340 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "start_tab_capture.html")) 316 ASSERT_TRUE(RunExtensionSubtest("tab_capture", "start_tab_capture.html"))
341 << message_; 317 << message_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return; 355 return;
380 } 356 }
381 content::RunMessageLoop(); 357 content::RunMessageLoop();
382 } 358 }
383 browser()->tab_strip_model()->RemoveObserver(&observer); 359 browser()->tab_strip_model()->RemoveObserver(&observer);
384 } 360 }
385 361
386 } // namespace 362 } // namespace
387 363
388 } // namespace extensions 364 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698