| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/test/render_widget_browsertest.h" | 5 #include "content/test/render_widget_browsertest.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Go ahead and map the DIB into memory, so that we can use it below | 44 // Go ahead and map the DIB into memory, so that we can use it below |
| 45 // to fill tmp_bitmap. Note that we need to do this before calling | 45 // to fill tmp_bitmap. Note that we need to do this before calling |
| 46 // OnMsgPaintAtSize, or the last reference to the shared memory will | 46 // OnMsgPaintAtSize, or the last reference to the shared memory will |
| 47 // be closed and the handle will no longer be valid. | 47 // be closed and the handle will no longer be valid. |
| 48 scoped_ptr<TransportDIB> mapped_pixels(TransportDIB::Map(pixels->handle())); | 48 scoped_ptr<TransportDIB> mapped_pixels(TransportDIB::Map(pixels->handle())); |
| 49 | 49 |
| 50 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 50 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 51 impl->OnMsgPaintAtSize(pixels->handle(), g_sequence_num, page_size, | 51 impl->OnMsgPaintAtSize(pixels->handle(), g_sequence_num, page_size, |
| 52 desired_size); | 52 desired_size); |
| 53 ProcessPendingMessages(); | 53 ProcessPendingMessages(); |
| 54 const IPC::Message* msg = render_thread_.sink().GetUniqueMessageMatching( | 54 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 55 ViewHostMsg_PaintAtSize_ACK::ID); | 55 ViewHostMsg_PaintAtSize_ACK::ID); |
| 56 ASSERT_NE(static_cast<IPC::Message*>(NULL), msg); | 56 ASSERT_NE(static_cast<IPC::Message*>(NULL), msg); |
| 57 ViewHostMsg_PaintAtSize_ACK::Param params; | 57 ViewHostMsg_PaintAtSize_ACK::Param params; |
| 58 ViewHostMsg_PaintAtSize_ACK::Read(msg, ¶ms); | 58 ViewHostMsg_PaintAtSize_ACK::Read(msg, ¶ms); |
| 59 render_thread_.sink().ClearMessages(); | 59 render_thread_->sink().ClearMessages(); |
| 60 EXPECT_EQ(g_sequence_num, params.a); | 60 EXPECT_EQ(g_sequence_num, params.a); |
| 61 gfx::Size size = params.b; | 61 gfx::Size size = params.b; |
| 62 EXPECT_EQ(desired_size, size); | 62 EXPECT_EQ(desired_size, size); |
| 63 | 63 |
| 64 SkBitmap tmp_bitmap; | 64 SkBitmap tmp_bitmap; |
| 65 tmp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 65 tmp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 66 size.width(), size.height()); | 66 size.width(), size.height()); |
| 67 tmp_bitmap.setPixels(mapped_pixels->memory()); | 67 tmp_bitmap.setPixels(mapped_pixels->memory()); |
| 68 // Copy the pixels from the TransportDIB object to the given snapshot. | 68 // Copy the pixels from the TransportDIB object to the given snapshot. |
| 69 ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); | 69 ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 &bitmap_data->data())); | 142 &bitmap_data->data())); |
| 143 ASSERT_LT(0, file_util::WriteFile( | 143 ASSERT_LT(0, file_util::WriteFile( |
| 144 file_path, | 144 file_path, |
| 145 reinterpret_cast<const char*>(bitmap_data->front()), | 145 reinterpret_cast<const char*>(bitmap_data->front()), |
| 146 bitmap_data->size())); | 146 bitmap_data->size())); |
| 147 } | 147 } |
| 148 | 148 |
| 149 TEST_F(RenderWidgetTest, OnMsgPaintAtSize) { | 149 TEST_F(RenderWidgetTest, OnMsgPaintAtSize) { |
| 150 TestResizeAndPaint(); | 150 TestResizeAndPaint(); |
| 151 } | 151 } |
| OLD | NEW |