Commit dec0985d authored by tfarina@chromium.org's avatar tfarina@chromium.org

test_runner: Rename WebTestThemeEngineMock to MockWebThemeEngine.

Plus some minor style fixes, mainly clang-format the header. Source file
was not fully converted to Chromium C++ style, because it is too big to
be done manually and to be fun :/

BUG=331299
TEST=content_unittests, content_shell. No functional changes
TBR=dpranke@chromium.org

Review URL: https://codereview.chromium.org/393983009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284345 0039d316-1c4b-4281-b951-d872f2087c98
parent 382614dd
...@@ -197,8 +197,6 @@ ...@@ -197,8 +197,6 @@
'shell/renderer/test_runner/WebTestInterfaces.h', 'shell/renderer/test_runner/WebTestInterfaces.h',
'shell/renderer/test_runner/WebTestThemeEngineMac.h', 'shell/renderer/test_runner/WebTestThemeEngineMac.h',
'shell/renderer/test_runner/WebTestThemeEngineMac.mm', 'shell/renderer/test_runner/WebTestThemeEngineMac.mm',
'shell/renderer/test_runner/WebTestThemeEngineMock.cpp',
'shell/renderer/test_runner/WebTestThemeEngineMock.h',
'shell/renderer/test_runner/accessibility_controller.cc', 'shell/renderer/test_runner/accessibility_controller.cc',
'shell/renderer/test_runner/accessibility_controller.h', 'shell/renderer/test_runner/accessibility_controller.h',
'shell/renderer/test_runner/event_sender.cc', 'shell/renderer/test_runner/event_sender.cc',
...@@ -215,6 +213,8 @@ ...@@ -215,6 +213,8 @@
'shell/renderer/test_runner/mock_web_audio_device.h', 'shell/renderer/test_runner/mock_web_audio_device.h',
'shell/renderer/test_runner/mock_web_push_client.cc', 'shell/renderer/test_runner/mock_web_push_client.cc',
'shell/renderer/test_runner/mock_web_push_client.h', 'shell/renderer/test_runner/mock_web_push_client.h',
'shell/renderer/test_runner/mock_web_theme_engine.cc',
'shell/renderer/test_runner/mock_web_theme_engine.h',
'shell/renderer/test_runner/mock_web_user_media_client.cc', 'shell/renderer/test_runner/mock_web_user_media_client.cc',
'shell/renderer/test_runner/mock_web_user_media_client.h', 'shell/renderer/test_runner/mock_web_user_media_client.h',
'shell/renderer/test_runner/mock_webrtc_data_channel_handler.cc', 'shell/renderer/test_runner/mock_webrtc_data_channel_handler.cc',
......
...@@ -195,7 +195,7 @@ WebThemeEngine* TestInterfaces::themeEngine() ...@@ -195,7 +195,7 @@ WebThemeEngine* TestInterfaces::themeEngine()
m_themeEngine.reset(new WebTestThemeEngineMac()); m_themeEngine.reset(new WebTestThemeEngineMac());
#else #else
if (!m_themeEngine.get()) if (!m_themeEngine.get())
m_themeEngine.reset(new WebTestThemeEngineMock()); m_themeEngine.reset(new MockWebThemeEngine());
#endif #endif
return m_themeEngine.get(); return m_themeEngine.get();
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#if defined(__APPLE__) #if defined(__APPLE__)
#include "content/shell/renderer/test_runner/WebTestThemeEngineMac.h" #include "content/shell/renderer/test_runner/WebTestThemeEngineMac.h"
#else #else
#include "content/shell/renderer/test_runner/WebTestThemeEngineMock.h" #include "content/shell/renderer/test_runner/mock_web_theme_engine.h"
#endif #endif
namespace blink { namespace blink {
...@@ -71,7 +71,7 @@ private: ...@@ -71,7 +71,7 @@ private:
#if defined(__APPLE__) #if defined(__APPLE__)
scoped_ptr<WebTestThemeEngineMac> m_themeEngine; scoped_ptr<WebTestThemeEngineMac> m_themeEngine;
#else #else
scoped_ptr<WebTestThemeEngineMock> m_themeEngine; scoped_ptr<MockWebThemeEngine> m_themeEngine;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(TestInterfaces); DISALLOW_COPY_AND_ASSIGN(TestInterfaces);
......
// Copyright 2013 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.
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMEENGINEMOCK_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMEENGINEMOCK_H_
#include "third_party/WebKit/public/platform/WebRect.h"
#include "third_party/WebKit/public/platform/WebThemeEngine.h"
namespace content {
class WebTestThemeEngineMock : public blink::WebThemeEngine {
public:
virtual ~WebTestThemeEngineMock() { }
// WebThemeEngine methods:
virtual blink::WebSize getSize(blink::WebThemeEngine::Part);
virtual void paint(blink::WebCanvas*,
blink::WebThemeEngine::Part,
blink::WebThemeEngine::State,
const blink::WebRect&,
const blink::WebThemeEngine::ExtraParams*);
};
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMEENGINEMOCK_H_
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/shell/renderer/test_runner/WebTestThemeEngineMock.h" #include "content/shell/renderer/test_runner/mock_web_theme_engine.h"
#include "base/logging.h" #include "base/logging.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
...@@ -17,8 +17,12 @@ using blink::WebThemeEngine; ...@@ -17,8 +17,12 @@ using blink::WebThemeEngine;
namespace content { namespace content {
static const SkColor edgeColor = SK_ColorBLACK; namespace {
static const SkColor readOnlyColor = SkColorSetRGB(0xe9, 0xc2, 0xa6);
const SkColor edgeColor = SK_ColorBLACK;
const SkColor readOnlyColor = SkColorSetRGB(0xe9, 0xc2, 0xa6);
} // namespace
SkColor bgColors(WebThemeEngine::State state) { SkColor bgColors(WebThemeEngine::State state) {
switch (state) { switch (state) {
...@@ -40,8 +44,7 @@ SkColor bgColors(WebThemeEngine::State state) { ...@@ -40,8 +44,7 @@ SkColor bgColors(WebThemeEngine::State state) {
return SkColorSetRGB(0x00, 0x00, 0xff); return SkColorSetRGB(0x00, 0x00, 0xff);
} }
blink::WebSize WebTestThemeEngineMock::getSize(WebThemeEngine::Part part) blink::WebSize MockWebThemeEngine::getSize(WebThemeEngine::Part part) {
{
// FIXME: We use this constant to indicate we are being asked for the size of // FIXME: We use this constant to indicate we are being asked for the size of
// a part that we don't expect to be asked about. We return a garbage value // a part that we don't expect to be asked about. We return a garbage value
// rather than just asserting because this code doesn't have access to either // rather than just asserting because this code doesn't have access to either
...@@ -77,16 +80,14 @@ blink::WebSize WebTestThemeEngineMock::getSize(WebThemeEngine::Part part) ...@@ -77,16 +80,14 @@ blink::WebSize WebTestThemeEngineMock::getSize(WebThemeEngine::Part part)
} }
} }
static SkIRect webRectToSkIRect(const WebRect& webRect) static SkIRect webRectToSkIRect(const WebRect& webRect) {
{
SkIRect irect; SkIRect irect;
irect.set(webRect.x, webRect.y, irect.set(webRect.x, webRect.y,
webRect.x + webRect.width - 1, webRect.y + webRect.height - 1); webRect.x + webRect.width - 1, webRect.y + webRect.height - 1);
return irect; return irect;
} }
static SkIRect validate(const SkIRect& rect, WebThemeEngine::Part part) static SkIRect validate(const SkIRect& rect, WebThemeEngine::Part part) {
{
switch (part) { switch (part) {
case WebThemeEngine::PartCheckbox: case WebThemeEngine::PartCheckbox:
case WebThemeEngine::PartRadio: { case WebThemeEngine::PartRadio: {
...@@ -110,9 +111,7 @@ static SkIRect validate(const SkIRect& rect, WebThemeEngine::Part part) ...@@ -110,9 +111,7 @@ static SkIRect validate(const SkIRect& rect, WebThemeEngine::Part part)
} }
} }
void box(SkCanvas* canvas, const SkIRect& rect, SkColor fillColor) {
void box(SkCanvas *canvas, const SkIRect& rect, SkColor fillColor)
{
SkPaint paint; SkPaint paint;
paint.setStyle(SkPaint::kFill_Style); paint.setStyle(SkPaint::kFill_Style);
...@@ -124,20 +123,24 @@ void box(SkCanvas *canvas, const SkIRect& rect, SkColor fillColor) ...@@ -124,20 +123,24 @@ void box(SkCanvas *canvas, const SkIRect& rect, SkColor fillColor)
canvas->drawIRect(rect, paint); canvas->drawIRect(rect, paint);
} }
void line(SkCanvas *canvas, int x0, int y0, int x1, int y1, SkColor color) void line(SkCanvas* canvas, int x0, int y0, int x1, int y1, SkColor color) {
{
SkPaint paint; SkPaint paint;
paint.setColor(color); paint.setColor(color);
canvas->drawLine(SkIntToScalar(x0), SkIntToScalar(y0), canvas->drawLine(SkIntToScalar(x0),
SkIntToScalar(x1), SkIntToScalar(y1), paint); SkIntToScalar(y0),
SkIntToScalar(x1),
SkIntToScalar(y1),
paint);
} }
void triangle(SkCanvas *canvas, void triangle(SkCanvas* canvas,
int x0, int y0, int x0,
int x1, int y1, int y0,
int x2, int y2, int x1,
SkColor color) int y1,
{ int x2,
int y2,
SkColor color) {
SkPath path; SkPath path;
SkPaint paint; SkPaint paint;
...@@ -155,8 +158,7 @@ void triangle(SkCanvas *canvas, ...@@ -155,8 +158,7 @@ void triangle(SkCanvas *canvas,
canvas->drawPath(path, paint); canvas->drawPath(path, paint);
} }
void roundRect(SkCanvas *canvas, SkIRect irect, SkColor color) void roundRect(SkCanvas* canvas, SkIRect irect, SkColor color) {
{
SkRect rect; SkRect rect;
SkScalar radius = SkIntToScalar(5); SkScalar radius = SkIntToScalar(5);
SkPaint paint; SkPaint paint;
...@@ -171,8 +173,7 @@ void roundRect(SkCanvas *canvas, SkIRect irect, SkColor color) ...@@ -171,8 +173,7 @@ void roundRect(SkCanvas *canvas, SkIRect irect, SkColor color)
canvas->drawRoundRect(rect, radius, radius, paint); canvas->drawRoundRect(rect, radius, radius, paint);
} }
void oval(SkCanvas* canvas, SkIRect irect, SkColor color) void oval(SkCanvas* canvas, SkIRect irect, SkColor color) {
{
SkRect rect; SkRect rect;
SkPaint paint; SkPaint paint;
...@@ -186,8 +187,7 @@ void oval(SkCanvas* canvas, SkIRect irect, SkColor color) ...@@ -186,8 +187,7 @@ void oval(SkCanvas* canvas, SkIRect irect, SkColor color)
canvas->drawOval(rect, paint); canvas->drawOval(rect, paint);
} }
void circle(SkCanvas *canvas, SkIRect irect, SkScalar radius, SkColor color) void circle(SkCanvas* canvas, SkIRect irect, SkScalar radius, SkColor color) {
{
int left = irect.fLeft; int left = irect.fLeft;
int width = irect.width(); int width = irect.width();
int height = irect.height(); int height = irect.height();
...@@ -206,15 +206,14 @@ void circle(SkCanvas *canvas, SkIRect irect, SkScalar radius, SkColor color) ...@@ -206,15 +206,14 @@ void circle(SkCanvas *canvas, SkIRect irect, SkScalar radius, SkColor color)
canvas->drawCircle(cx, cy, radius, paint); canvas->drawCircle(cx, cy, radius, paint);
} }
void nestedBoxes(SkCanvas *canvas, void nestedBoxes(SkCanvas* canvas,
SkIRect irect, SkIRect irect,
int indentLeft, int indentLeft,
int indentTop, int indentTop,
int indentRight, int indentRight,
int indentBottom, int indentBottom,
SkColor outerColor, SkColor outerColor,
SkColor innerColor) SkColor innerColor) {
{
SkIRect lirect; SkIRect lirect;
box(canvas, irect, outerColor); box(canvas, irect, outerColor);
lirect.set(irect.fLeft + indentLeft, lirect.set(irect.fLeft + indentLeft,
...@@ -239,8 +238,7 @@ void insetBox(SkCanvas* canvas, ...@@ -239,8 +238,7 @@ void insetBox(SkCanvas* canvas,
box(canvas, lirect, color); box(canvas, lirect, color);
} }
void markState(SkCanvas *canvas, SkIRect irect, WebThemeEngine::State state) void markState(SkCanvas* canvas, SkIRect irect, WebThemeEngine::State state) {
{
int left = irect.fLeft; int left = irect.fLeft;
int right = irect.fRight; int right = irect.fRight;
int top = irect.fTop; int top = irect.fTop;
...@@ -298,13 +296,11 @@ void markState(SkCanvas *canvas, SkIRect irect, WebThemeEngine::State state) ...@@ -298,13 +296,11 @@ void markState(SkCanvas *canvas, SkIRect irect, WebThemeEngine::State state)
} }
} }
void WebTestThemeEngineMock::paint( void MockWebThemeEngine::paint(blink::WebCanvas* canvas,
blink::WebCanvas* canvas, WebThemeEngine::Part part,
WebThemeEngine::Part part, WebThemeEngine::State state,
WebThemeEngine::State state, const blink::WebRect& rect,
const blink::WebRect& rect, const WebThemeEngine::ExtraParams* extraParams) {
const WebThemeEngine::ExtraParams* extraParams)
{
SkIRect irect = webRectToSkIRect(rect); SkIRect irect = webRectToSkIRect(rect);
SkPaint paint; SkPaint paint;
......
// Copyright 2014 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.
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_WEB_THEME_ENGINE_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_WEB_THEME_ENGINE_H_
#include "third_party/WebKit/public/platform/WebThemeEngine.h"
namespace content {
class MockWebThemeEngine : public blink::WebThemeEngine {
public:
virtual ~MockWebThemeEngine() {}
// blink::WebThemeEngine:
virtual blink::WebSize getSize(blink::WebThemeEngine::Part);
virtual void paint(blink::WebCanvas*,
blink::WebThemeEngine::Part,
blink::WebThemeEngine::State,
const blink::WebRect&,
const blink::WebThemeEngine::ExtraParams*);
};
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_WEB_THEME_ENGINE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment