diff options
author | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-28 16:24:44 +0000 |
---|---|---|
committer | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-28 16:24:44 +0000 |
commit | 65322af9e9db711565d324f9e1668119afdd66a9 (patch) | |
tree | af0ec3959a7f05f7b33dfb9b5d133447ba7b3a2c /chrome/renderer | |
parent | 4d6a6d9441faebcb32e47a7e834b265d11227397 (diff) | |
download | chromium_src-65322af9e9db711565d324f9e1668119afdd66a9.zip chromium_src-65322af9e9db711565d324f9e1668119afdd66a9.tar.gz chromium_src-65322af9e9db711565d324f9e1668119afdd66a9.tar.bz2 |
This removes the render_widget_browsertest.cc that is missed in http://codereview.chromium.org/3439026/show. This file was toughed after http://codereview.chromium.org/3380001 is submitted. So, drover did not revert it.
Review URL: http://codereview.chromium.org/3441036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_widget_browsertest.cc | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/chrome/renderer/render_widget_browsertest.cc b/chrome/renderer/render_widget_browsertest.cc deleted file mode 100644 index 34d6c26..0000000 --- a/chrome/renderer/render_widget_browsertest.cc +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "app/surface/transport_dib.h" -#include "base/basictypes.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/ref_counted_memory.h" -#include "base/stringprintf.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" -#include "chrome/renderer/render_widget_browsertest.h" -#include "gfx/codec/jpeg_codec.h" -#include "gfx/size.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" -#include "third_party/WebKit/WebKit/chromium/public/WebView.h" - -const int RenderWidgetTest::kNumBytesPerPixel = 4; -const int RenderWidgetTest::kLargeWidth = 1024; -const int RenderWidgetTest::kLargeHeight = 768; -const int RenderWidgetTest::kSmallWidth = 600; -const int RenderWidgetTest::kSmallHeight = 450; -const int RenderWidgetTest::kTextPositionX = 800; -const int RenderWidgetTest::kTextPositionY = 600; -const int RenderWidgetTest::kSequenceNum = 1; -const uint32 RenderWidgetTest::kRedARGB = 0xFFFF0000; - -RenderWidgetTest::RenderWidgetTest() {} - -void RenderWidgetTest::ResizeAndPaint(const gfx::Size& page_size, - const gfx::Size& desired_size, - SkBitmap* snapshot) { - ASSERT_TRUE(snapshot); - scoped_ptr<TransportDIB> pixels( - TransportDIB::Create( - page_size.width() * page_size.height() * kNumBytesPerPixel, - kSequenceNum)); - view_->OnMsgPaintAtSize(pixels->handle(), kSequenceNum, page_size, - desired_size); - ProcessPendingMessages(); - const IPC::Message* msg = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_PaintAtSize_ACK::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), msg); - ViewHostMsg_PaintAtSize_ACK::Param params; - ViewHostMsg_PaintAtSize_ACK::Read(msg, ¶ms); - render_thread_.sink().ClearMessages(); - EXPECT_EQ(kSequenceNum, params.a); - gfx::Size size = params.b; - EXPECT_EQ(desired_size, size); - - SkBitmap tmp_bitmap; - tmp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, - size.width(), size.height()); - tmp_bitmap.setPixels(pixels->memory()); - // Copy the pixels from the TransportDIB object to the given snapshot. - ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); -} - -void RenderWidgetTest::TestResizeAndPaint() { - // Hello World message is only visible if the view size is at least - // kTextPositionX x kTextPositionY - LoadHTML(StringPrintf( - "<html><body><div style='position: absolute; top: %d; left: " - "%d; background-color: red;'>Hello World</div></body></html>", - kTextPositionY, kTextPositionX).c_str()); - WebKit::WebSize old_size = view_->webview()->size(); - - SkBitmap bitmap; - // If we re-size the view to something smaller than where the 'Hello World' - // text is displayed we won't see any text in the snapshot. Hence, - // the snapshot should not contain any red. - gfx::Size size(kSmallWidth, kSmallHeight); - ResizeAndPaint(size, size, &bitmap); - // Make sure that the view has been re-sized to its old size. - EXPECT_EQ(old_size, view_->webview()->size()); - EXPECT_EQ(kSmallWidth, bitmap.width()); - EXPECT_EQ(kSmallHeight, bitmap.height()); - EXPECT_FALSE(ImageContainsColor(bitmap, kRedARGB)); - - // Since we ask for the view to be re-sized to something larger than where the - // 'Hello World' text is written the text should be visible in the snapshot. - // Hence, the snapshot should contain some red. - size.SetSize(kLargeWidth, kLargeHeight); - ResizeAndPaint(size, size, &bitmap); - EXPECT_EQ(old_size, view_->webview()->size()); - EXPECT_EQ(kLargeWidth, bitmap.width()); - EXPECT_EQ(kLargeHeight, bitmap.height()); - EXPECT_TRUE(ImageContainsColor(bitmap, kRedARGB)); - - // Even if the desired size is smaller than where the text is located we - // should still see the 'Hello World' message since the view size is - // still large enough. - ResizeAndPaint(size, gfx::Size(kSmallWidth, kSmallHeight), &bitmap); - EXPECT_EQ(old_size, view_->webview()->size()); - EXPECT_EQ(kSmallWidth, bitmap.width()); - EXPECT_EQ(kSmallHeight, bitmap.height()); - EXPECT_TRUE(ImageContainsColor(bitmap, kRedARGB)); -} - -bool RenderWidgetTest::ImageContainsColor(const SkBitmap& bitmap, - uint32 argb_color) { - SkAutoLockPixels lock(bitmap); - bool ready = bitmap.readyToDraw(); - EXPECT_TRUE(ready); - if (!ready) { - return false; - } - for (int x = 0; x < bitmap.width(); ++x) { - for (int y = 0; y < bitmap.height(); ++y) { - if (argb_color == *bitmap.getAddr32(x, y)) { - return true; - } - } - } - return false; -} - -void RenderWidgetTest::OutputBitmapToFile(const SkBitmap& bitmap, - const FilePath& file_path) { - scoped_refptr<RefCountedBytes> bitmap_data = new RefCountedBytes(); - SkAutoLockPixels lock(bitmap); - ASSERT_TRUE(gfx::JPEGCodec::Encode( - reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), - gfx::JPEGCodec::FORMAT_BGRA, - bitmap.width(), - bitmap.height(), - static_cast<int>(bitmap.rowBytes()), - 90 /* quality */, - &bitmap_data->data)); - ASSERT_LT(0, file_util::WriteFile( - file_path, - reinterpret_cast<const char*>(bitmap_data->front()), - bitmap_data->size())); -} - -TEST_F(RenderWidgetTest, FAILS_OnMsgPaintAtSize) { - TestResizeAndPaint(); -} |