blob: 42ae02d81dfab64e6c638524738c336d717961d2 [file] [log] [blame]
[email protected]7339cd22010-10-27 00:11:201// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_RENDERER_RENDER_WIDGET_BROWSERTEST_H_
6#define CHROME_RENDERER_RENDER_WIDGET_BROWSERTEST_H_
7#pragma once
8
9#include "base/basictypes.h"
10#include "base/file_path.h"
11#include "chrome/test/render_view_test.h"
12
13namespace gfx {
14class Size;
15}
16
17class SkBitmap;
18class TransportDIB;
19
20class RenderWidgetTest : public RenderViewTest {
21 public:
22 RenderWidgetTest();
23
24 protected:
25 static const int kNumBytesPerPixel;
26 static const int kLargeWidth;
27 static const int kLargeHeight;
28 static const int kSmallWidth;
29 static const int kSmallHeight;
30 static const int kTextPositionX;
31 static const int kTextPositionY;
32 static const uint32 kRedARGB;
33
34 // Helper function which calls OnMsgPaintAtSize and also paints the result
35 // in the given bitmap. The widget is resized to |page_size| before we paint
36 // and the final image is resized to |desired_size|. This method is virtual so
37 // that TestResizeAndPaint() can be reused by subclasses of this test class.
38 virtual void ResizeAndPaint(const gfx::Size& page_size,
39 const gfx::Size& desired_size,
40 SkBitmap* snapshot);
41
42 // Test for ResizeAndPaint.
43 void TestResizeAndPaint();
44
45 // Helper function which returns true if the given bitmap contains the given
46 // ARGB color and false otherwise.
47 bool ImageContainsColor(const SkBitmap& bitmap, uint32 argb_color);
48
49 // This can be used for debugging if you want to output a bitmap
50 // image to a file.
51 // FilePath tmp_path;
52 // file_util::CreateTemporaryFile(&tmp_path);
53 // OutputBitmapToFile(bitmap, tmp_path);
54 // LOG(INFO) << "Bitmap image stored at: " << tmp_path.value();
55 void OutputBitmapToFile(const SkBitmap& bitmap, const FilePath& file_path);
56};
57
58#endif // CHROME_RENDERER_RENDER_WIDGET_BROWSERTEST_H_