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

test_runner: Rename WebTestThemeEngineMac to MockWebThemeEngineMac.

Plus some minor style fixes, mainly clang-format the header.

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

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285811 0039d316-1c4b-4281-b951-d872f2087c98
parent 9b028c32
......@@ -192,8 +192,6 @@
'shell/renderer/test_runner/WebTestDelegate.h',
'shell/renderer/test_runner/WebTestInterfaces.cpp',
'shell/renderer/test_runner/WebTestInterfaces.h',
'shell/renderer/test_runner/WebTestThemeEngineMac.h',
'shell/renderer/test_runner/WebTestThemeEngineMac.mm',
'shell/renderer/test_runner/accessibility_controller.cc',
'shell/renderer/test_runner/accessibility_controller.h',
'shell/renderer/test_runner/event_sender.cc',
......@@ -216,6 +214,8 @@
'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_theme_engine_mac.h',
'shell/renderer/test_runner/mock_web_theme_engine_mac.mm',
'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',
......
......@@ -142,8 +142,6 @@ static_library("content_shell_lib") {
"renderer/test_runner/WebTestDelegate.h",
"renderer/test_runner/WebTestInterfaces.cpp",
"renderer/test_runner/WebTestInterfaces.h",
"renderer/test_runner/WebTestThemeEngineMac.h",
"renderer/test_runner/WebTestThemeEngineMac.mm",
"renderer/test_runner/accessibility_controller.cc",
"renderer/test_runner/accessibility_controller.h",
"renderer/test_runner/event_sender.cc",
......@@ -164,6 +162,8 @@ static_library("content_shell_lib") {
"renderer/test_runner/mock_web_push_client.h",
"renderer/test_runner/mock_web_theme_engine.cc",
"renderer/test_runner/mock_web_theme_engine.h",
"renderer/test_runner/mock_web_theme_engine_mac.h",
"renderer/test_runner/mock_web_theme_engine_mac.mm",
"renderer/test_runner/mock_web_user_media_client.cc",
"renderer/test_runner/mock_web_user_media_client.h",
"renderer/test_runner/mock_webrtc_data_channel_handler.cc",
......
......@@ -192,7 +192,7 @@ WebThemeEngine* TestInterfaces::themeEngine()
return 0;
#if defined(__APPLE__)
if (!m_themeEngine.get())
m_themeEngine.reset(new WebTestThemeEngineMac());
m_themeEngine.reset(new MockWebThemeEngineMac());
#else
if (!m_themeEngine.get())
m_themeEngine.reset(new MockWebThemeEngine());
......
......@@ -12,7 +12,7 @@
#include "third_party/WebKit/public/platform/WebNonCopyable.h"
#if defined(__APPLE__)
#include "content/shell/renderer/test_runner/WebTestThemeEngineMac.h"
#include "content/shell/renderer/test_runner/mock_web_theme_engine_mac.h"
#else
#include "content/shell/renderer/test_runner/mock_web_theme_engine.h"
#endif
......@@ -69,7 +69,7 @@ private:
std::vector<WebTestProxyBase*> m_windowList;
#if defined(__APPLE__)
scoped_ptr<WebTestThemeEngineMac> m_themeEngine;
scoped_ptr<MockWebThemeEngineMac> m_themeEngine;
#else
scoped_ptr<MockWebThemeEngine> m_themeEngine;
#endif
......
// 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.
// This implements the WebThemeEngine API in such a way that we match the Mac
// port rendering more than usual Chromium path, thus allowing us to share
// more pixel baselines.
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMEENGINEMAC_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMEENGINEMAC_H_
#include "base/basictypes.h"
#include "third_party/WebKit/public/platform/WebThemeEngine.h"
namespace content {
class WebTestThemeEngineMac : public blink::WebThemeEngine {
public:
WebTestThemeEngineMac() { }
virtual ~WebTestThemeEngineMac() { }
virtual void paintScrollbarThumb(
blink::WebCanvas*,
blink::WebThemeEngine::State,
blink::WebThemeEngine::Size,
const blink::WebRect&,
const blink::WebThemeEngine::ScrollbarInfo&);
private:
virtual void paintHIThemeScrollbarThumb(
blink::WebCanvas*,
blink::WebThemeEngine::State,
blink::WebThemeEngine::Size,
const blink::WebRect&,
const blink::WebThemeEngine::ScrollbarInfo&);
virtual void paintNSScrollerScrollbarThumb(
blink::WebCanvas*,
blink::WebThemeEngine::State,
blink::WebThemeEngine::Size,
const blink::WebRect&,
const blink::WebThemeEngine::ScrollbarInfo&);
DISALLOW_COPY_AND_ASSIGN(WebTestThemeEngineMac);
};
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMEENGINEMAC_H_
// 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_MAC_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_WEB_THEME_ENGINE_MAC_H_
#include "base/macros.h"
#include "third_party/WebKit/public/platform/WebThemeEngine.h"
namespace content {
// This implements the WebThemeEngine API in such a way that we match the Mac
// port rendering more than usual Chromium path, thus allowing us to share
// more pixel baselines.
class MockWebThemeEngineMac : public blink::WebThemeEngine {
public:
MockWebThemeEngineMac() {}
virtual ~MockWebThemeEngineMac() {}
virtual void paintScrollbarThumb(blink::WebCanvas*,
blink::WebThemeEngine::State,
blink::WebThemeEngine::Size,
const blink::WebRect&,
const blink::WebThemeEngine::ScrollbarInfo&);
private:
virtual void paintHIThemeScrollbarThumb(
blink::WebCanvas*,
blink::WebThemeEngine::State,
blink::WebThemeEngine::Size,
const blink::WebRect&,
const blink::WebThemeEngine::ScrollbarInfo&);
virtual void paintNSScrollerScrollbarThumb(
blink::WebCanvas*,
blink::WebThemeEngine::State,
blink::WebThemeEngine::Size,
const blink::WebRect&,
const blink::WebThemeEngine::ScrollbarInfo&);
DISALLOW_COPY_AND_ASSIGN(MockWebThemeEngineMac);
};
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_WEB_THEME_ENGINE_MAC_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
// found in the LICENSE file.
#include "content/shell/renderer/test_runner/WebTestThemeEngineMac.h"
#include "content/shell/renderer/test_runner/mock_web_theme_engine_mac.h"
#import <AppKit/NSAffineTransform.h>
#import <AppKit/NSGraphicsContext.h>
......@@ -35,22 +35,19 @@ using blink::WebThemeEngine;
static NSWindow* alwaysActiveWindow = nil;
static NSWindow* alwaysInactiveWindow = nil;
+ (NSWindow*)alwaysActiveWindow
{
+ (NSWindow*)alwaysActiveWindow {
if (alwaysActiveWindow == nil)
alwaysActiveWindow = [[self alloc] initWithActiveControls:YES];
return alwaysActiveWindow;
}
+ (NSWindow*)alwaysInactiveWindow
{
+ (NSWindow*)alwaysInactiveWindow {
if (alwaysInactiveWindow == nil)
alwaysInactiveWindow = [[self alloc] initWithActiveControls:NO];
return alwaysInactiveWindow;
}
- (id)initWithActiveControls:(BOOL)_hasActiveControls
{
- (id)initWithActiveControls:(BOOL)_hasActiveControls {
if ((self = [super initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:0
backing:NSBackingStoreBuffered
......@@ -71,27 +68,25 @@ namespace content {
namespace {
ThemeTrackEnableState stateToHIEnableState(WebThemeEngine::State state)
{
switch (state) {
ThemeTrackEnableState stateToHIEnableState(WebThemeEngine::State state) {
switch (state) {
case WebThemeEngine::StateDisabled:
return kThemeTrackDisabled;
return kThemeTrackDisabled;
case WebThemeEngine::StateInactive:
return kThemeTrackInactive;
return kThemeTrackInactive;
default:
return kThemeTrackActive;
}
return kThemeTrackActive;
}
}
} // namespace
void WebTestThemeEngineMac::paintScrollbarThumb(
void MockWebThemeEngineMac::paintScrollbarThumb(
WebCanvas* canvas,
WebThemeEngine::State state,
WebThemeEngine::Size size,
const WebRect& rect,
const WebThemeEngine::ScrollbarInfo& scrollbarInfo)
{
const WebThemeEngine::ScrollbarInfo& scrollbarInfo) {
// To match the Mac port, we still use HITheme for inner scrollbars.
if (scrollbarInfo.parent == WebThemeEngine::ScrollbarParentRenderLayer)
paintHIThemeScrollbarThumb(canvas, state, size, rect, scrollbarInfo);
......@@ -101,13 +96,12 @@ void WebTestThemeEngineMac::paintScrollbarThumb(
// Duplicated from webkit/glue/webthemeengine_impl_mac.cc in the downstream
// Chromium WebThemeEngine implementation.
void WebTestThemeEngineMac::paintHIThemeScrollbarThumb(
void MockWebThemeEngineMac::paintHIThemeScrollbarThumb(
WebCanvas* canvas,
WebThemeEngine::State state,
WebThemeEngine::Size size,
const WebRect& rect,
const WebThemeEngine::ScrollbarInfo& scrollbarInfo)
{
const WebThemeEngine::ScrollbarInfo& scrollbarInfo) {
HIThemeTrackDrawInfo trackInfo;
trackInfo.version = 0;
trackInfo.kind = size == WebThemeEngine::SizeRegular ? kThemeMediumScrollBar : kThemeSmallScrollBar;
......@@ -130,13 +124,12 @@ void WebTestThemeEngineMac::paintHIThemeScrollbarThumb(
HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
}
void WebTestThemeEngineMac::paintNSScrollerScrollbarThumb(
void MockWebThemeEngineMac::paintNSScrollerScrollbarThumb(
WebCanvas* canvas,
WebThemeEngine::State state,
WebThemeEngine::Size size,
const WebRect& rect,
const WebThemeEngine::ScrollbarInfo& scrollbarInfo)
{
const WebThemeEngine::ScrollbarInfo& scrollbarInfo) {
[NSGraphicsContext saveGraphicsState];
NSScroller* scroller = [[NSScroller alloc] initWithFrame:NSMakeRect(rect.x, rect.y, rect.width, rect.height)];
[scroller setEnabled:state != WebThemeEngine::StateDisabled];
......
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