From dec0985d3a70ac6dc3df93bf63aa153778f6a0c4 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Sat, 19 Jul 2014 21:07:52 +0000 Subject: [PATCH] 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 --- content/content_shell.gypi | 4 +- .../shell/renderer/test_runner/TestInterfaces.cpp | 2 +- .../shell/renderer/test_runner/TestInterfaces.h | 4 +- .../renderer/test_runner/WebTestThemeEngineMock.h | 29 ------- ...hemeEngineMock.cpp => mock_web_theme_engine.cc} | 90 +++++++++++----------- .../renderer/test_runner/mock_web_theme_engine.h | 27 +++++++ 6 files changed, 75 insertions(+), 81 deletions(-) delete mode 100644 content/shell/renderer/test_runner/WebTestThemeEngineMock.h rename content/shell/renderer/test_runner/{WebTestThemeEngineMock.cpp => mock_web_theme_engine.cc} (91%) create mode 100644 content/shell/renderer/test_runner/mock_web_theme_engine.h diff --git a/content/content_shell.gypi b/content/content_shell.gypi index da2ec9027ab7..0dd42b80fa63 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -197,8 +197,6 @@ 'shell/renderer/test_runner/WebTestInterfaces.h', 'shell/renderer/test_runner/WebTestThemeEngineMac.h', '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.h', 'shell/renderer/test_runner/event_sender.cc', @@ -215,6 +213,8 @@ '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.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.h', 'shell/renderer/test_runner/mock_webrtc_data_channel_handler.cc', diff --git a/content/shell/renderer/test_runner/TestInterfaces.cpp b/content/shell/renderer/test_runner/TestInterfaces.cpp index 0b0d8dfcb731..560a58d47437 100644 --- a/content/shell/renderer/test_runner/TestInterfaces.cpp +++ b/content/shell/renderer/test_runner/TestInterfaces.cpp @@ -195,7 +195,7 @@ WebThemeEngine* TestInterfaces::themeEngine() m_themeEngine.reset(new WebTestThemeEngineMac()); #else if (!m_themeEngine.get()) - m_themeEngine.reset(new WebTestThemeEngineMock()); + m_themeEngine.reset(new MockWebThemeEngine()); #endif return m_themeEngine.get(); } diff --git a/content/shell/renderer/test_runner/TestInterfaces.h b/content/shell/renderer/test_runner/TestInterfaces.h index 0a6639afe44d..ea91fed332be 100644 --- a/content/shell/renderer/test_runner/TestInterfaces.h +++ b/content/shell/renderer/test_runner/TestInterfaces.h @@ -14,7 +14,7 @@ #if defined(__APPLE__) #include "content/shell/renderer/test_runner/WebTestThemeEngineMac.h" #else -#include "content/shell/renderer/test_runner/WebTestThemeEngineMock.h" +#include "content/shell/renderer/test_runner/mock_web_theme_engine.h" #endif namespace blink { @@ -71,7 +71,7 @@ private: #if defined(__APPLE__) scoped_ptr m_themeEngine; #else - scoped_ptr m_themeEngine; + scoped_ptr m_themeEngine; #endif DISALLOW_COPY_AND_ASSIGN(TestInterfaces); diff --git a/content/shell/renderer/test_runner/WebTestThemeEngineMock.h b/content/shell/renderer/test_runner/WebTestThemeEngineMock.h deleted file mode 100644 index 5ea721dbace0..000000000000 --- a/content/shell/renderer/test_runner/WebTestThemeEngineMock.h +++ /dev/null @@ -1,29 +0,0 @@ -// 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_ diff --git a/content/shell/renderer/test_runner/WebTestThemeEngineMock.cpp b/content/shell/renderer/test_runner/mock_web_theme_engine.cc similarity index 91% rename from content/shell/renderer/test_runner/WebTestThemeEngineMock.cpp rename to content/shell/renderer/test_runner/mock_web_theme_engine.cc index 15f6c1cebda9..4e19a9e381dd 100644 --- a/content/shell/renderer/test_runner/WebTestThemeEngineMock.cpp +++ b/content/shell/renderer/test_runner/mock_web_theme_engine.cc @@ -1,8 +1,8 @@ -// 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 // 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 "skia/ext/platform_canvas.h" @@ -17,8 +17,12 @@ using blink::WebThemeEngine; namespace content { -static const SkColor edgeColor = SK_ColorBLACK; -static const SkColor readOnlyColor = SkColorSetRGB(0xe9, 0xc2, 0xa6); +namespace { + +const SkColor edgeColor = SK_ColorBLACK; +const SkColor readOnlyColor = SkColorSetRGB(0xe9, 0xc2, 0xa6); + +} // namespace SkColor bgColors(WebThemeEngine::State state) { switch (state) { @@ -40,8 +44,7 @@ SkColor bgColors(WebThemeEngine::State state) { 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 // 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 @@ -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; irect.set(webRect.x, webRect.y, webRect.x + webRect.width - 1, webRect.y + webRect.height - 1); return irect; } -static SkIRect validate(const SkIRect& rect, WebThemeEngine::Part part) -{ +static SkIRect validate(const SkIRect& rect, WebThemeEngine::Part part) { switch (part) { case WebThemeEngine::PartCheckbox: case WebThemeEngine::PartRadio: { @@ -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; paint.setStyle(SkPaint::kFill_Style); @@ -124,20 +123,24 @@ void box(SkCanvas *canvas, const SkIRect& rect, SkColor fillColor) 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; paint.setColor(color); - canvas->drawLine(SkIntToScalar(x0), SkIntToScalar(y0), - SkIntToScalar(x1), SkIntToScalar(y1), paint); + canvas->drawLine(SkIntToScalar(x0), + SkIntToScalar(y0), + SkIntToScalar(x1), + SkIntToScalar(y1), + paint); } -void triangle(SkCanvas *canvas, - int x0, int y0, - int x1, int y1, - int x2, int y2, - SkColor color) -{ +void triangle(SkCanvas* canvas, + int x0, + int y0, + int x1, + int y1, + int x2, + int y2, + SkColor color) { SkPath path; SkPaint paint; @@ -155,8 +158,7 @@ void triangle(SkCanvas *canvas, canvas->drawPath(path, paint); } -void roundRect(SkCanvas *canvas, SkIRect irect, SkColor color) -{ +void roundRect(SkCanvas* canvas, SkIRect irect, SkColor color) { SkRect rect; SkScalar radius = SkIntToScalar(5); SkPaint paint; @@ -171,8 +173,7 @@ void roundRect(SkCanvas *canvas, SkIRect irect, SkColor color) canvas->drawRoundRect(rect, radius, radius, paint); } -void oval(SkCanvas* canvas, SkIRect irect, SkColor color) -{ +void oval(SkCanvas* canvas, SkIRect irect, SkColor color) { SkRect rect; SkPaint paint; @@ -186,8 +187,7 @@ void oval(SkCanvas* canvas, SkIRect irect, SkColor color) 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 width = irect.width(); int height = irect.height(); @@ -206,15 +206,14 @@ void circle(SkCanvas *canvas, SkIRect irect, SkScalar radius, SkColor color) canvas->drawCircle(cx, cy, radius, paint); } -void nestedBoxes(SkCanvas *canvas, - SkIRect irect, - int indentLeft, - int indentTop, - int indentRight, - int indentBottom, - SkColor outerColor, - SkColor innerColor) -{ +void nestedBoxes(SkCanvas* canvas, + SkIRect irect, + int indentLeft, + int indentTop, + int indentRight, + int indentBottom, + SkColor outerColor, + SkColor innerColor) { SkIRect lirect; box(canvas, irect, outerColor); lirect.set(irect.fLeft + indentLeft, @@ -239,8 +238,7 @@ void insetBox(SkCanvas* canvas, 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 right = irect.fRight; int top = irect.fTop; @@ -298,13 +296,11 @@ void markState(SkCanvas *canvas, SkIRect irect, WebThemeEngine::State state) } } -void WebTestThemeEngineMock::paint( - blink::WebCanvas* canvas, - WebThemeEngine::Part part, - WebThemeEngine::State state, - const blink::WebRect& rect, - const WebThemeEngine::ExtraParams* extraParams) -{ +void MockWebThemeEngine::paint(blink::WebCanvas* canvas, + WebThemeEngine::Part part, + WebThemeEngine::State state, + const blink::WebRect& rect, + const WebThemeEngine::ExtraParams* extraParams) { SkIRect irect = webRectToSkIRect(rect); SkPaint paint; diff --git a/content/shell/renderer/test_runner/mock_web_theme_engine.h b/content/shell/renderer/test_runner/mock_web_theme_engine.h new file mode 100644 index 000000000000..14c39065e125 --- /dev/null +++ b/content/shell/renderer/test_runner/mock_web_theme_engine.h @@ -0,0 +1,27 @@ +// 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_ -- 2.11.4.GIT