| OLD | NEW |
| 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 "content/public/test/render_widget_test.h" | 5 #include "content/public/test/render_widget_test.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 tmp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 67 tmp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 68 size.width(), size.height()); | 68 size.width(), size.height()); |
| 69 tmp_bitmap.setPixels(mapped_pixels->memory()); | 69 tmp_bitmap.setPixels(mapped_pixels->memory()); |
| 70 // Copy the pixels from the TransportDIB object to the given snapshot. | 70 // Copy the pixels from the TransportDIB object to the given snapshot. |
| 71 ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); | 71 ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void RenderWidgetTest::TestResizeAndPaint() { | 74 void RenderWidgetTest::TestResizeAndPaint() { |
| 75 // Hello World message is only visible if the view size is at least | 75 // Hello World message is only visible if the view size is at least |
| 76 // kTextPositionX x kTextPositionY | 76 // kTextPositionX x kTextPositionY |
| 77 LoadHTML(StringPrintf( | 77 LoadHTML(base::StringPrintf( |
| 78 "<html><body><div style='position: absolute; top: %d; left: " | 78 "<html><body><div style='position: absolute; top: %d; left: " |
| 79 "%d; background-color: red;'>Hello World</div></body></html>", | 79 "%d; background-color: red;'>Hello World</div></body></html>", |
| 80 kTextPositionY, kTextPositionX).c_str()); | 80 kTextPositionY, kTextPositionX).c_str()); |
| 81 WebKit::WebSize old_size = view_->GetWebView()->size(); | 81 WebKit::WebSize old_size = view_->GetWebView()->size(); |
| 82 | 82 |
| 83 SkBitmap bitmap; | 83 SkBitmap bitmap; |
| 84 // If we re-size the view to something smaller than where the 'Hello World' | 84 // If we re-size the view to something smaller than where the 'Hello World' |
| 85 // text is displayed we won't see any text in the snapshot. Hence, | 85 // text is displayed we won't see any text in the snapshot. Hence, |
| 86 // the snapshot should not contain any red. | 86 // the snapshot should not contain any red. |
| 87 gfx::Size size(kSmallWidth, kSmallHeight); | 87 gfx::Size size(kSmallWidth, kSmallHeight); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 static_cast<int>(bitmap.rowBytes()), | 142 static_cast<int>(bitmap.rowBytes()), |
| 143 90 /* quality */, | 143 90 /* quality */, |
| 144 &bitmap_data->data())); | 144 &bitmap_data->data())); |
| 145 ASSERT_LT(0, file_util::WriteFile( | 145 ASSERT_LT(0, file_util::WriteFile( |
| 146 file_path, | 146 file_path, |
| 147 reinterpret_cast<const char*>(bitmap_data->front()), | 147 reinterpret_cast<const char*>(bitmap_data->front()), |
| 148 bitmap_data->size())); | 148 bitmap_data->size())); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace content | 151 } // namespace content |
| OLD | NEW |