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

Side by Side Diff: chrome/browser/ui/exclusive_access/flash_fullscreen_interactive_browsertest.cc

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 15 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/test/base/interactive_test_utils.h" 17 #include "chrome/test/base/interactive_test_utils.h"
18 #include "chrome/test/ppapi/ppapi_test.h" 18 #include "chrome/test/ppapi/ppapi_test.h"
19 #include "content/public/browser/render_widget_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 19 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
25 24
26 namespace { 25 namespace {
27 26
28 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
29 const bool kIsMacUI = true; 28 const bool kIsMacUI = true;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 240 }
242 241
243 bool IsObservingActiveWebContents(content::WebContents* contents, 242 bool IsObservingActiveWebContents(content::WebContents* contents,
244 bool expected_active_contents) const { 243 bool expected_active_contents) const {
245 return (contents == GetActiveWebContents()) == expected_active_contents; 244 return (contents == GetActiveWebContents()) == expected_active_contents;
246 } 245 }
247 246
248 bool IsObservingFlashFillColor(SkColor expected_color) const { 247 bool IsObservingFlashFillColor(SkColor expected_color) const {
249 content::RenderWidgetHostView* const flash_fs_view = 248 content::RenderWidgetHostView* const flash_fs_view =
250 GetActiveWebContents()->GetFullscreenRenderWidgetHostView(); 249 GetActiveWebContents()->GetFullscreenRenderWidgetHostView();
251 content::RenderWidgetHost* const flash_fs_host = 250 if (!flash_fs_view) {
252 flash_fs_view ? flash_fs_view->GetRenderWidgetHost() : nullptr; 251 ADD_FAILURE() << "Flash fullscreen RenderWidgetHostView is gone.";
253 if (!flash_fs_host) {
254 ADD_FAILURE() << "Flash fullscreen RenderWidgetHost is gone.";
255 return false; 252 return false;
256 } 253 }
257 254
258 // When a widget is first shown, it can take some time before it is ready 255 // When a widget is first shown, it can take some time before it is ready
259 // for copying from its backing store. This is a transient condition, and 256 // for copying from its backing store. This is a transient condition, and
260 // so it is not being treated as a test failure. 257 // so it is not being treated as a test failure.
261 if (!flash_fs_host->CanCopyFromBackingStore()) 258 if (!flash_fs_view->IsSurfaceAvailableForCopy())
262 return false; 259 return false;
263 260
264 // Copy and examine the upper-left pixel of the widget and compare it to the 261 // Copy and examine the upper-left pixel of the widget and compare it to the
265 // |expected_color|. 262 // |expected_color|.
266 bool is_expected_color = false; 263 bool is_expected_color = false;
267 flash_fs_host->CopyFromBackingStore( 264 flash_fs_view->CopyFromSurface(
268 gfx::Rect(0, 0, 1, 1), gfx::Size(1, 1), 265 gfx::Rect(0, 0, 1, 1), gfx::Size(1, 1),
269 base::Bind( 266 base::Bind(
270 &FlashFullscreenInteractiveBrowserTest::CheckBitmapForFillColor, 267 &FlashFullscreenInteractiveBrowserTest::CheckBitmapForFillColor,
271 expected_color, &is_expected_color, 268 expected_color, &is_expected_color,
272 base::MessageLoop::QuitWhenIdleClosure()), 269 base::MessageLoop::QuitWhenIdleClosure()),
273 kN32_SkColorType); 270 kN32_SkColorType);
274 content::RunMessageLoop(); 271 content::RunMessageLoop();
275 272
276 return is_expected_color; 273 return is_expected_color;
277 } 274 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); 394 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED));
398 PressSpacebar(); 395 PressSpacebar();
399 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); 396 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE));
400 397
401 // Test that the Escape key is handled as an exit fullscreen command while the 398 // Test that the Escape key is handled as an exit fullscreen command while the
402 // Flash widget has the focus. 399 // Flash widget has the focus.
403 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); 400 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true));
404 PressEscape(); 401 PressEscape();
405 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); 402 EXPECT_TRUE(ObserveTabIsInFullscreen(false));
406 } 403 }
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_tab_helper.cc ('k') | content/browser/devtools/devtools_frame_trace_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698