From e0a17af1b2b2b0d7eb5f4ffd9b3aeea9ec94e501 Mon Sep 17 00:00:00 2001 From: "cpu@chromium.org" Date: Thu, 28 Jul 2011 23:43:22 +0000 Subject: Add a shared memory blit test To ensure skia does the right thing when we close the section handle after the PlatformCanvas is created. This is part of the fix for a section leak (see bug). BUG=31173 TEST=yes Review URL: http://codereview.chromium.org/7492074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94590 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/gfx/blit_unittest.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'ui') diff --git a/ui/gfx/blit_unittest.cc b/ui/gfx/blit_unittest.cc index 0a3217b..72e1c26 100644 --- a/ui/gfx/blit_unittest.cc +++ b/ui/gfx/blit_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/basictypes.h" +#include "base/shared_memory.h" #include "skia/ext/platform_canvas.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/blit.h" @@ -133,3 +134,30 @@ TEST(Blit, ScrollCanvas) { { 0x40, 0x41, 0x42, 0x43, 0x44 }}; VerifyCanvasValues<5, 5>(&canvas, scroll_diagonal_expected); } + +#if defined(OS_WIN) + +TEST(Blit, WithSharedMemory) { + const int kCanvasWidth = 5; + const int kCanvasHeight = 5; + skia::PlatformCanvas canvas; + base::SharedMemory shared_mem; + ASSERT_TRUE(shared_mem.CreateAnonymous(kCanvasWidth * kCanvasHeight)); + base::SharedMemoryHandle section = shared_mem.handle(); + ASSERT_TRUE(canvas.initialize(kCanvasWidth, kCanvasHeight, true, section)); + shared_mem.Close(); + + uint8 initial_values[kCanvasHeight][kCanvasWidth] = { + { 0x00, 0x01, 0x02, 0x03, 0x04 }, + { 0x10, 0x11, 0x12, 0x13, 0x14 }, + { 0x20, 0x21, 0x22, 0x23, 0x24 }, + { 0x30, 0x31, 0x32, 0x33, 0x34 }, + { 0x40, 0x41, 0x42, 0x43, 0x44 }}; + SetToCanvas<5, 5>(&canvas, initial_values); + + // Sanity check on input. + VerifyCanvasValues<5, 5>(&canvas, initial_values); +} + +#endif + -- cgit v1.1