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

Unified Diff: content/browser/renderer_host/render_widget_host_view_browsertest.cc

Issue 12220024: Fix CopyFromBackingStore giving back empty SkBitmaps on mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ifdef Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/compositing_iosurface_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_browsertest.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_browsertest.cc
index 066ba35cfd0f9478d13ab8e051bc19cd6715e4fd..7b360acc96aa95f5c3ac7d40f0ecda1e0597b671 100644
--- a/content/browser/renderer_host/render_widget_host_view_browsertest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_browsertest.cc
@@ -23,7 +23,7 @@ namespace content {
class RenderWidgetHostViewBrowserTest : public ContentBrowserTest {
public:
- RenderWidgetHostViewBrowserTest() : finish_called_(false) {}
+ RenderWidgetHostViewBrowserTest() : finish_called_(false), size_(400, 300) {}
virtual void SetUpInProcessBrowserTestFixture() {
ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir_));
@@ -33,15 +33,46 @@ class RenderWidgetHostViewBrowserTest : public ContentBrowserTest {
ui::DisableTestCompositor();
}
- void FinishCopyFromBackingStore(bool expected_result, bool result,
+#if defined(OS_MACOSX)
+ void SetupCompositingSurface() {
+ NavigateToURL(shell(), net::FilePathToFileURL(
+ test_dir_.AppendASCII("rwhv_compositing_static.html")));
+
+ RenderViewHost* const rwh =
+ shell()->web_contents()->GetRenderViewHost();
+ RenderWidgetHostViewPort* rwhvp =
+ static_cast<RenderWidgetHostViewPort*>(rwh->GetView());
+
+ // Wait until an IoSurface is created by repeatedly resizing the window.
+ // TODO(justinlin): Find a better way to force an IoSurface when possible.
+ int increment = 0;
+ while (!rwhvp->HasAcceleratedSurface(gfx::Size())) {
+ base::RunLoop run_loop;
+ SetWindowBounds(shell()->window(), gfx::Rect(size_.width() + increment,
+ size_.height()));
+ // Wait for any ViewHostMsg_CompositorSurfaceBuffersSwapped message.
+ run_loop.RunUntilIdle();
+ increment++;
+ ASSERT_LT(increment, 50);
+ }
+ }
+#endif
+
+ void FinishCopyFromBackingStore(bool expected_result,
+ const base::Callback<void ()> quit_closure,
+ bool result,
const SkBitmap& bitmap) {
+ quit_closure.Run();
ASSERT_EQ(expected_result, result);
+ if (expected_result)
+ ASSERT_FALSE(bitmap.empty());
finish_called_ = true;
}
protected:
FilePath test_dir_;
bool finish_called_;
+ gfx::Size size_;
};
#if defined(OS_MACOSX)
@@ -52,40 +83,45 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewBrowserTest,
if (!IOSurfaceSupport::Initialize())
return;
- NavigateToURL(shell(), net::FilePathToFileURL(
- test_dir_.AppendASCII("rwhv_compositing_static.html")));
+ SetupCompositingSurface();
+
+ base::RunLoop run_loop;
RenderViewHost* const rwh =
shell()->web_contents()->GetRenderViewHost();
RenderWidgetHostViewPort* rwhvp =
static_cast<RenderWidgetHostViewPort*>(rwh->GetView());
- // Wait until an IoSurface is created by repeatedly resizing the window.
- // TODO(justinlin): Find a better way to force an IoSurface when possible.
- gfx::Size size(400, 300);
- int increment = 0;
- while (!rwhvp->HasAcceleratedSurface(gfx::Size())) {
- base::RunLoop run_loop;
- SetWindowBounds(shell()->window(), gfx::Rect(size.width() + increment,
- size.height()));
- // Wait for any ViewHostMsg_CompositorSurfaceBuffersSwapped message to post.
- run_loop.RunUntilIdle();
- increment++;
- ASSERT_LT(increment, 50);
- }
-
rwh->CopyFromBackingStore(
gfx::Rect(),
- size,
+ size_,
base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore,
- base::Unretained(this), false));
+ base::Unretained(this), false, run_loop.QuitClosure()));
// Delete the surface before the callback is run. This is synchronous until
// we get to the copy_timer_, so we will always end up in the destructor
// before the timer fires.
rwhvp->AcceleratedSurfaceRelease();
+ run_loop.Run();
+
+ ASSERT_TRUE(finish_called_);
+}
+
+// TODO(justinlin): Enable this test for other platforms.
+IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewBrowserTest,
+ MacAsyncCopyFromBackingStoreTest) {
+ if (!IOSurfaceSupport::Initialize())
+ return;
+
+ SetupCompositingSurface();
+
base::RunLoop run_loop;
- run_loop.RunUntilIdle();
+ shell()->web_contents()->GetRenderViewHost()->CopyFromBackingStore(
+ gfx::Rect(),
+ size_,
+ base::Bind(&RenderWidgetHostViewBrowserTest::FinishCopyFromBackingStore,
+ base::Unretained(this), true, run_loop.QuitClosure()));
+ run_loop.Run();
ASSERT_TRUE(finish_called_);
}
« no previous file with comments | « content/browser/renderer_host/compositing_iosurface_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698