Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: webkit/tools/test_shell/test_shell_platform_delegate_win.cc

Issue 15028002: Delete test_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add dummy test_shell build target. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #include <string>
6 #include <list>
7 #include <windows.h>
8 #include <commctrl.h>
9
10 #include "base/command_line.h"
11 #include "base/event_recorder.h"
12 #include "base/win/win_util.h"
13 #include "ui/base/win/foreground_helper.h"
14 #include "ui/native_theme/native_theme_win.h"
15 #include "webkit/tools/test_shell/test_shell.h"
16 #include "webkit/tools/test_shell/test_shell_platform_delegate.h"
17
18 TestShellPlatformDelegate::TestShellPlatformDelegate(
19 const CommandLine& command_line)
20 : command_line_(command_line) {
21 #ifdef _CRTDBG_MAP_ALLOC
22 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
23 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
24 #endif
25 }
26
27 TestShellPlatformDelegate::~TestShellPlatformDelegate() {
28 #ifdef _CRTDBG_MAP_ALLOC
29 _CrtDumpMemoryLeaks();
30 #endif
31 }
32
33 void TestShellPlatformDelegate::PreflightArgs(int *argc, char ***argv) {
34 }
35
36
37
38 // This test approximates whether you are running the default themes for
39 // your platform by inspecting a couple of metrics.
40 // It does not catch all cases, but it does pick up on classic vs xp,
41 // and normal vs large fonts. Something it misses is changes to the color
42 // scheme (which will infact cause pixel test failures).
43 bool TestShellPlatformDelegate::CheckLayoutTestSystemDependencies() {
44 std::list<std::string> errors;
45
46 OSVERSIONINFOEX osvi;
47 ::ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
48 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
49 ::GetVersionEx((OSVERSIONINFO *)&osvi);
50
51 // Default to XP metrics, override if on Vista or win 7.
52 int requiredVScrollSize = 17;
53 int requiredFontSize = -11; // 8 pt
54 const wchar_t* requiredFont = L"Tahoma";
55 bool isVista = false;
56 bool isWin7 = false;
57 if (osvi.dwMajorVersion == 6
58 && osvi.dwMinorVersion == 1
59 && osvi.wProductType == VER_NT_WORKSTATION) {
60 requiredFont = L"Segoe UI";
61 requiredFontSize = -12;
62 isWin7 = true;
63 } else if (osvi.dwMajorVersion == 6
64 && osvi.dwMinorVersion == 0
65 && osvi.wProductType == VER_NT_WORKSTATION) {
66 requiredFont = L"Segoe UI";
67 requiredFontSize = -12; // 9 pt
68 isVista = true;
69 } else if (!(osvi.dwMajorVersion == 5
70 && osvi.dwMinorVersion == 1
71 && osvi.wProductType == VER_NT_WORKSTATION)) {
72 // The above check is for XP, so that means ...
73 errors.push_back("Unsupported Operating System version "
74 "(must use XP, Vista, or Windows 7).");
75 }
76
77 // This metric will be 17 when font size is "Normal".
78 // The size of drop-down menus depends on it.
79 int vScrollSize = ::GetSystemMetrics(SM_CXVSCROLL);
80 if (vScrollSize != requiredVScrollSize) {
81 errors.push_back("Must use normal size fonts (96 dpi).");
82 }
83
84 // ClearType must be disabled, because the rendering is unpredictable.
85 BOOL bFontSmoothing;
86 SystemParametersInfo(SPI_GETFONTSMOOTHING, (UINT)0,
87 (PVOID)&bFontSmoothing, (UINT)0);
88 int fontSmoothingType;
89 SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, (UINT)0,
90 (PVOID)&fontSmoothingType, (UINT)0);
91 if (bFontSmoothing && (fontSmoothingType == FE_FONTSMOOTHINGCLEARTYPE)) {
92 errors.push_back("ClearType must be disabled.");
93 }
94
95 // Check that we're using the default system fonts
96 NONCLIENTMETRICS metrics;
97 base::win::GetNonClientMetrics(&metrics);
98 LOGFONTW* system_fonts[] =
99 { &metrics.lfStatusFont, &metrics.lfMenuFont, &metrics.lfSmCaptionFont };
100
101 for (size_t i = 0; i < arraysize(system_fonts); ++i) {
102 if (system_fonts[i]->lfHeight != requiredFontSize ||
103 wcscmp(requiredFont, system_fonts[i]->lfFaceName)) {
104 if (isVista || isWin7)
105 errors.push_back("Must use either the Aero or Basic theme.");
106 else
107 errors.push_back("Must use the default XP theme (Luna).");
108 break;
109 }
110 }
111
112 if (!errors.empty()) {
113 fprintf(stderr, "%s",
114 "##################################################################\n"
115 "## Layout test system dependencies check failed.\n"
116 "##\n");
117 for (std::list<std::string>::iterator it = errors.begin();
118 it != errors.end();
119 ++it) {
120 fprintf(stderr, "## %s\n", it->c_str());
121 }
122 fprintf(stderr, "%s",
123 "##\n"
124 "##################################################################\n");
125 }
126 return errors.empty();
127 }
128
129 void TestShellPlatformDelegate::SuppressErrorReporting() {
130 _set_abort_behavior(0, _WRITE_ABORT_MSG);
131 }
132
133 void TestShellPlatformDelegate::InitializeGUI() {
134 INITCOMMONCONTROLSEX InitCtrlEx;
135
136 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
137 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
138 InitCommonControlsEx(&InitCtrlEx);
139 TestShell::RegisterWindowClass();
140 }
141
142 void TestShellPlatformDelegate::SelectUnifiedTheme() {
143 ui::NativeThemeWin::instance()->DisableTheming();
144 }
145
146 void TestShellPlatformDelegate::SetWindowPositionForRecording(
147 TestShell *shell) {
148 // Move the window to the upper left corner for consistent
149 // record/playback mode. For automation, we want this to work
150 // on build systems where the script invoking us is a background
151 // process. So for this case, make our window the topmost window
152 // as well.
153 CHECK(ui::ForegroundHelper::SetForeground(shell->mainWnd()) == S_OK);
154 ::SetWindowPos(shell->mainWnd(), HWND_TOP, 0, 0, 600, 800, 0);
155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698