Source/WebKit2/ChangeLog

 12012-04-23 Balazs Kelemen <kbalazs@webkit.org>
 2
 3 [Qt] Add test specific platform plugin to achieve unified layout test results
 4 https://bugs.webkit.org/show_bug.cgi?id=80996
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Initialize the test platform plugin before initializing
 9 the web process if we are in a WTR run.
 10 It is necessary to place this initialization here as we
 11 cannot control wich platform plugin will be used after
 12 the instantiation of the QApplication.
 13
 14 * qt/MainQt.cpp:
 15 (initializeTestPlatformPluginForWTRIfRequired):
 16 (main):
 17
1182012-04-23 Zalan Bujtas <zbujtas@gmail.com>
219
320 [Qt][WK2] Move non-api classes to WebKit namespace at WebKit2/UiProcess/qt

Source/WebKit2/qt/MainQt.cpp

2525 */
2626
2727#include <QApplication>
28 
 28#include <QByteArray>
 29#include <QFile>
 30#include <QPlatformIntegration>
 31#include <QPlatformIntegrationPlugin>
 32#include <QPluginLoader>
2933#include <stdio.h>
3034
3135namespace WebKit {

@@static void messageHandler(QtMsgType type, const char* message)
4347 // Do nothing
4448}
4549
 50static void initializeTestPlatformPluginForWTRIfRequired()
 51{
 52 QByteArray pluginPath = qgetenv("QT_WEBKIT2_TEST_PLATFORM_PLUGIN_PATH");
 53 if (pluginPath.isEmpty())
 54 return;
 55
 56 QPluginLoader loader(QFile::decodeName(pluginPath.data()));
 57 QPlatformIntegrationPlugin* plugin = qobject_cast<QPlatformIntegrationPlugin*>(loader.instance());
 58 if (!plugin)
 59 qFatal("cannot initialize test platform plugin\n");
 60
 61 qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", pluginPath);
 62 qputenv("QT_QPA_PLATFORM", "testplatform");
 63}
 64
4665// The framework entry point.
4766// We call our platform specific entry point directly rather than WebKitMain because it makes little sense
4867// to reimplement the handling of command line arguments from QApplication.
4968int main(int argc, char** argv)
5069{
 70 initializeTestPlatformPluginForWTRIfRequired();
5171 WebKit::initializeWebKit2Theme();
5272
5373 // Has to be done before QApplication is constructed in case

Tools/ChangeLog

 12012-04-23 Balazs Kelemen <kbalazs@webkit.org>
 2
 3 [Qt] Add test specific platform plugin to achieve unified layout test results
 4 https://bugs.webkit.org/show_bug.cgi?id=80996
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added QtTestPlatformPlugin as a new project under Tools.
 9 This is a Qt5-ish platform plugin that can be used to tweak the
 10 platform support interfaces in order to unify layout test results.
 11 For now it only overrides the font database on Mac and redirects
 12 everything else to the real platform plugin. The font database it
 13 provides mimics the way how we set up test fonts with fontconfig on Linux.
 14 Make DumpRenderTree and WebKitTestRunner use this platform plugin.
 15
 16 * DumpRenderTree/qt/DumpRenderTree.pro:
 17 * DumpRenderTree/qt/main.cpp:
 18 (initializeTestPlatformPlugin):
 19 (main):
 20 * QtTestPlatformPlugin/QtTestPlatformPlugin.pro: Added.
 21 * QtTestPlatformPlugin/TestIntegration.cpp: Added.
 22 (TestIntegration::TestIntegration):
 23 (TestIntegration::fontDatabase):
 24 * QtTestPlatformPlugin/TestIntegration.h: Added.
 25 (TestIntegration):
 26 (TestIntegration::hasCapability):
 27 (TestIntegration::createPlatformPixmap):
 28 (TestIntegration::createPlatformWindow):
 29 (TestIntegration::createPlatformBackingStore):
 30 (TestIntegration::createPlatformOpenGLContext):
 31 (TestIntegration::createPlatformSharedGraphicsCache):
 32 (TestIntegration::guiThreadEventDispatcher):
 33 (TestIntegration::clipboard):
 34 (TestIntegration::drag):
 35 (TestIntegration::inputContext):
 36 (TestIntegration::accessibility):
 37 (TestIntegration::nativeInterface):
 38 (TestIntegration::services):
 39 (TestIntegration::styleHint):
 40 (TestIntegration::platformTheme):
 41 * QtTestPlatformPlugin/mac/TestFontDatabase.h: Added.
 42 (TestFontDatabase):
 43 * QtTestPlatformPlugin/mac/TestFontDatabase.mm: Added.
 44 (TestFontDatabase::populateFontDatabase):
 45 * QtTestPlatformPlugin/mac/TestIntegrationMac.mm: Added.
 46 (TestIntegration::fontDatabase):
 47 * QtTestPlatformPlugin/main.cpp: Added.
 48 (TestIntegrationPlugin::keys):
 49 (TestIntegrationPlugin::create):
 50 (TestIntegrationPlugin::initialize):
 51 * QtTestPlatformPlugin/testplatform.json: Added.
 52 * Tools.pro:
 53 * WebKitTestRunner/Target.pri:
 54 * WebKitTestRunner/qt/main.cpp:
 55 (main):
 56
1572012-04-23 Csaba Osztrogonác <ossy@webkit.org>
258
359 Unreviewed rolling out r114881, because it broke upload buildstep.

Tools/DumpRenderTree/qt/DumpRenderTree.pro

@@wince*: {
5757DEFINES -= USE_SYSTEM_MALLOC=0
5858DEFINES += USE_SYSTEM_MALLOC=1
5959
 60mac: LIB_SUFFIX=.dylib
 61win: LIB_SUFFIX=.dll
 62unix:!mac: LIB_SUFFIX=.so
 63DEFINES += TEST_PLATFORM_PLUGIN_PATH=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}lib$${QMAKE_DIR_SEP}libtestplatform$${LIB_SUFFIX}\\\"\"
 64
6065RESOURCES = DumpRenderTree.qrc

Tools/DumpRenderTree/qt/main.cpp

3131
3232#include "QtInitializeTestFonts.h"
3333
 34#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 35#include <QPlatformIntegration>
 36#include <QPlatformIntegrationPlugin>
 37#include <QPluginLoader>
 38#endif
 39
3440#include <wtf/AlwaysInline.h>
3541
3642#include <qstringlist.h>

@@static void WTFCrashHook()
123129}
124130#endif
125131
 132static void initializeTestPlatformPlugin(int argc, char* argv[])
 133{
 134#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 135 QPluginLoader loader(TEST_PLATFORM_PLUGIN_PATH);
 136 QPlatformIntegrationPlugin* plugin = qobject_cast<QPlatformIntegrationPlugin*>(loader.instance());
 137 if (!plugin)
 138 qFatal("cannot initialize test platform plugin\n");
 139
 140 QByteArray platform = qgetenv("QT_QPA_PLATFORM");
 141 QByteArray platformPluginPath = qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH");
 142 for (int i = 0; i < argc; ++i) {
 143 if (QByteArray(argv[i]) == "-platform" && i + 1 < argc)
 144 platform = argv[i + 1];
 145 else if (QByteArray(argv[i]) == "-platformpluginpath" && i + 1 < argc)
 146 platformPluginPath = argv[i + 1];
 147 }
 148 if (!platform.isEmpty())
 149 qputenv("QT_WEBKIT_ORIGINAL_PLATFORM", platform);
 150 if (!platformPluginPath.isEmpty())
 151 qputenv("QT_WEBKIT_ORIGINAL_PLATFORM_PLUGIN_PATH", platformPluginPath);
 152
 153 qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", TEST_PLATFORM_PLUGIN_PATH);
 154 qputenv("QT_QPA_PLATFORM", "testplatform");
 155#endif
 156}
 157
126158int main(int argc, char* argv[])
127159{
128160#ifdef Q_OS_WIN

@@int main(int argc, char* argv[])
146178
147179 WebKit::initializeTestFonts();
148180
 181 initializeTestPlatformPlugin(argc, argv);
 182
149183 QApplication::setGraphicsSystem("raster");
150184 QApplication::setStyle(new QWindowsStyle);
151185

Tools/QtTestPlatformPlugin/QtTestPlatformPlugin.pro

 1TARGET = testplatform
 2DESTDIR = $$ROOT_BUILD_DIR/lib
 3
 4load(qt_plugin)
 5QT = core gui core-private gui-private platformsupport-private
 6
 7HEADERS = \
 8 TestIntegration.h \
 9
 10SOURCES = \
 11 main.cpp \
 12 TestIntegration.cpp \
 13
 14mac {
 15 LIBS += -framework Foundation
 16 OBJECTIVE_HEADERS += mac/TestFontDatabase.h
 17 OBJECTIVE_SOURCES += \
 18 mac/TestFontDatabase.mm \
 19 mac/TestIntegrationMac.mm \
 20}

Tools/QtTestPlatformPlugin/TestIntegration.cpp

 1/*
 2 * Copyright (C) 2012 University of Szeged. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "TestIntegration.h"
 27#include <QCoreApplication>
 28#include <QStringList>
 29#include <QtGlobal>
 30#include <QtGui/private/qplatformintegrationfactory_qpa_p.h>
 31#include <qsystemdetection.h>
 32
 33TestIntegration::TestIntegration()
 34{
 35 QString defaultPlatform =
 36#if defined(Q_OS_MAC)
 37 QLatin1String("cocoa");
 38#elif defined (Q_OS_WIN)
 39 QLatin1String("windows");
 40#elif !defined (QT_NO_XCB)
 41 QLatin1String("xcb");
 42#elif !defined (QT_NO_WAYLAND)
 43 QLatin1String("wayland");
 44#else
 45 QLatin1String("minimal");
 46#endif
 47
 48 QByteArray originalPlatform = qgetenv("QT_WEBKIT_ORIGINAL_PLATFORM");
 49 QByteArray originalPluginPath = qgetenv("QT_WEBKIT_ORIGINAL_PLATFORM_PLUGIN_PATH");
 50 QString platform = originalPlatform.isEmpty() ? defaultPlatform : QString::fromLatin1(originalPlatform.data());
 51 QString pluginPath = originalPluginPath.isEmpty() ? QString() : QString::fromLatin1(originalPluginPath.data());
 52
 53 m_integration.reset(QPlatformIntegrationFactory::create(platform, pluginPath));
 54}
 55
 56#if !defined(Q_OS_MAC)
 57QPlatformFontDatabase* TestIntegration::fontDatabase() const
 58{
 59 return m_integration->fontDatabase();
 60}
 61#endif

Tools/QtTestPlatformPlugin/TestIntegration.h

 1/*
 2 * Copyright (C) 2012 University of Szeged. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef TestIntegration_h
 27#define TestIntegration_h
 28
 29#include <QPlatformFontDatabase>
 30#include <QPlatformIntegration>
 31#include <QPlatformScreen>
 32
 33class TestIntegration : public QPlatformIntegration {
 34public:
 35 TestIntegration();
 36private:
 37 virtual QPlatformFontDatabase *fontDatabase() const;
 38
 39 // Redirecting everything else.
 40 virtual bool hasCapability(Capability cap) { return m_integration->hasCapability(cap); }
 41 virtual QPlatformPixmap* createPlatformPixmap(QPlatformPixmap::PixelType type) const { return m_integration->createPlatformPixmap(type); }
 42 virtual QPlatformWindow* createPlatformWindow(QWindow *window) const { return m_integration->createPlatformWindow(window); }
 43 virtual QPlatformBackingStore* createPlatformBackingStore(QWindow *window) const { return m_integration->createPlatformBackingStore(window); }
 44#ifndef QT_NO_OPENGL
 45 virtual QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext *context) const { return m_integration->createPlatformOpenGLContext(context); }
 46#endif
 47 virtual QPlatformSharedGraphicsCache* createPlatformSharedGraphicsCache(const char *cacheId) const { return m_integration->createPlatformSharedGraphicsCache(cacheId); }
 48 virtual QAbstractEventDispatcher* guiThreadEventDispatcher() const { return m_integration->guiThreadEventDispatcher(); }
 49#ifndef QT_NO_CLIPBOARD
 50 virtual QPlatformClipboard* clipboard() const { return m_integration->clipboard(); }
 51#endif
 52#ifndef QT_NO_DRAGANDDROP
 53 virtual QPlatformDrag* drag() const { return m_integration->drag(); }
 54#endif
 55 virtual QPlatformInputContext* inputContext() const { return m_integration->inputContext(); }
 56 virtual QPlatformAccessibility* accessibility() const { return m_integration->accessibility(); }
 57 virtual QPlatformNativeInterface* nativeInterface() const { return m_integration->nativeInterface(); }
 58 virtual QPlatformServices* services() const { return m_integration->services(); }
 59 virtual QVariant styleHint(StyleHint hint) const { return m_integration->styleHint(hint); }
 60 virtual QPlatformTheme* createPlatformTheme(const QString& name) const { return m_integration->createPlatformTheme(name); }
 61
 62 QScopedPointer<QPlatformIntegration> m_integration;
 63#if defined(Q_OS_MAC)
 64 mutable QScopedPointer<QPlatformFontDatabase> m_fontDatabase;
 65#endif
 66};
 67
 68#endif

Tools/QtTestPlatformPlugin/mac/TestFontDatabase.h

 1/*
 2 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 3 * Copyright (C) 2012 University of Szeged. All rights reserved.
 4 *
 5 * GNU Lesser General Public License Usage
 6 * This file may be used under the terms of the GNU Lesser General Public
 7 * License version 2.1 as published by the Free Software Foundation.
 8 * Please review the following information to ensure the GNU Lesser
 9 * General Public License version 2.1 requirements will be met:
 10 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 11 *
 12 * GNU General Public License Usage
 13 * Alternatively, this file may be used under the terms of the GNU General
 14 * Public License version 3.0 as published by the Free Software Foundation.
 15 * Please review the following information to ensure the GNU General Public
 16 * License version 3.0 requirements will be met:
 17 * http://www.gnu.org/copyleft/gpl.html.
 18 *
 19 */
 20
 21#ifndef TestFontDatabase_h
 22#define TestFontDatabase_h
 23
 24#include <QFont>
 25#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
 26
 27class TestFontDatabase : public QCoreTextFontDatabase {
 28private:
 29 virtual void populateFontDatabase();
 30 virtual QFont defaultFont() const;
 31};
 32
 33#endif

Tools/QtTestPlatformPlugin/mac/TestFontDatabase.mm

 1/*
 2 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 3 * Copyright (C) 2012 University of Szeged. All rights reserved.
 4 *
 5 * GNU Lesser General Public License Usage
 6 * This file may be used under the terms of the GNU Lesser General Public
 7 * License version 2.1 as published by the Free Software Foundation.
 8 * Please review the following information to ensure the GNU Lesser
 9 * General Public License version 2.1 requirements will be met:
 10 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 11 *
 12 * GNU General Public License Usage
 13 * Alternatively, this file may be used under the terms of the GNU General
 14 * Public License version 3.0 as published by the Free Software Foundation.
 15 * Please review the following information to ensure the GNU General Public
 16 * License version 3.0 requirements will be met:
 17 * http://www.gnu.org/copyleft/gpl.html.
 18 *
 19 */
 20
 21#include "TestFontDatabase.h"
 22#include <QtCore/QDir>
 23#include <QtCore/QFileInfo>
 24#include <QtCore/private/qcore_mac_p.h>
 25#include <QtPlatformSupport/private/qfontengine_coretext_p.h>
 26#import <Foundation/Foundation.h>
 27
 28// From Qt.
 29static const char *languageForWritingSystem[] = {
 30 0, // Any
 31 "en", // Latin
 32 "el", // Greek
 33 "ru", // Cyrillic
 34 "hy", // Armenian
 35 "he", // Hebrew
 36 "ar", // Arabic
 37 "syr", // Syriac
 38 "div", // Thaana
 39 "hi", // Devanagari
 40 "bn", // Bengali
 41 "pa", // Gurmukhi
 42 "gu", // Gujarati
 43 "or", // Oriya
 44 "ta", // Tamil
 45 "te", // Telugu
 46 "kn", // Kannada
 47 "ml", // Malayalam
 48 "si", // Sinhala
 49 "th", // Thai
 50 "lo", // Lao
 51 "bo", // Tibetan
 52 "my", // Myanmar
 53 "ka", // Georgian
 54 "km", // Khmer
 55 "zh-cn", // SimplifiedChinese
 56 "zh-tw", // TraditionalChinese
 57 "ja", // Japanese
 58 "ko", // Korean
 59 "vi", // Vietnamese
 60 0, // Symbol
 61 0, // Ogham
 62 0, // Runic
 63 0 // N'Ko
 64};
 65enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char*) };
 66
 67QFont TestFontDatabase::defaultFont() const
 68{
 69 return QFont(QStringLiteral("Nimbus Sans L"));
 70}
 71
 72void TestFontDatabase::populateFontDatabase()
 73{
 74 // Determine the set of default system fonts in order to filter them out.
 75 QCFType<CTFontCollectionRef> systemCollection(CTFontCollectionCreateFromAvailableFonts(0));
 76 QCFType<CFArrayRef> systemFonts = systemCollection ? CTFontCollectionCreateMatchingFontDescriptors(systemCollection) : 0;
 77 if (!systemFonts)
 78 qFatal("Cannot get system fonts\n");
 79
 80 QByteArray testFontsVar = getenv("WEBKIT_TESTFONTS");
 81 QDir fontsDir(QString::fromLatin1(testFontsVar));
 82 if (testFontsVar.isEmpty() || !fontsDir.exists()) {
 83 qFatal("\n\n"
 84 "----------------------------------------------------------------------\n"
 85 "QCoreTextFontDatabaseWKTest:\n"
 86 "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
 87 "This variable has to point to the directory containing the fonts\n"
 88 "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"
 89 "----------------------------------------------------------------------\n"
 90 );
 91 }
 92
 93 QCFType<CFMutableSetRef> systemFontSet(CFSetCreateMutable(0, 0, &kCFTypeSetCallBacks));
 94 for (int i = 0; i < CFArrayGetCount(systemFonts); ++i) {
 95 CTFontDescriptorRef font = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(systemFonts, i));
 96 CFSetAddValue(systemFontSet, font);
 97 }
 98
 99 // Add the test fonts to the set.
 100 QStringList filters;
 101 filters << QStringLiteral("*.ttf");
 102 QFileInfoList files = fontsDir.entryInfoList(filters, QDir::Files);
 103 foreach (QFileInfo file, files) {
 104 QByteArray path = QFile::encodeName(file.canonicalFilePath());
 105 QCFType<CFURLRef> fontFile(CFURLCreateFromFileSystemRepresentation(0, reinterpret_cast<const UInt8*>(path.constData()), path.length(), false));
 106 CFErrorRef error;
 107 if (!CTFontManagerRegisterFontsForURL(fontFile, kCTFontManagerScopeProcess, &error)) {
 108 CFRelease(error);
 109 qFatal("Failed registering font file: %s\n", path.constData());
 110 }
 111 }
 112
 113 // This substitution is done via fonts.conf on Linux.
 114 QFont::insertSubstitution(QStringLiteral("Helvetica"), QString::fromLatin1(defaultWebKitTestFontFamily));
 115
 116 // ----------------------------------------------------------------------------
 117 // This is a copy of QCoretextFontDatabase::populateFontDatabase from Qt except
 118 // we filter out the system fonts.
 119
 120 QCFType<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
 121 QCFType<CFArrayRef> fonts = CTFontCollectionCreateMatchingFontDescriptors(collection);
 122
 123 QString foundryName = QLatin1String("CoreText");
 124 const int numFonts = CFArrayGetCount(fonts);
 125 QHash<QString, QString> psNameToFamily;
 126 for (int i = 0; i < numFonts; ++i) {
 127 CTFontDescriptorRef font = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(fonts, i));
 128 if (CFSetGetCountOfValue(systemFontSet, font))
 129 continue;
 130 QCFString familyName = static_cast<CFStringRef>(CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL));
 131 QCFType<CFDictionaryRef> styles = static_cast<CFDictionaryRef>(CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute));
 132 QFont::Weight weight = QFont::Normal;
 133 QFont::Style style = QFont::StyleNormal;
 134 QFont::Stretch stretch = QFont::Unstretched;
 135 bool fixedPitch = false;
 136
 137 if (styles) {
 138 if (CFNumberRef weightValue = static_cast<CFNumberRef>(CFDictionaryGetValue(styles, kCTFontWeightTrait))) {
 139 Q_ASSERT(CFNumberIsFloatType(weightValue));
 140 double d;
 141 if (CFNumberGetValue(weightValue, kCFNumberDoubleType, &d))
 142 weight = (d > 0.0) ? QFont::Bold : QFont::Normal;
 143 }
 144 if (CFNumberRef italic = static_cast<CFNumberRef>(CFDictionaryGetValue(styles, kCTFontSlantTrait))) {
 145 Q_ASSERT(CFNumberIsFloatType(italic));
 146 double d;
 147 if (CFNumberGetValue(italic, kCFNumberDoubleType, &d)) {
 148 if (d > 0.0)
 149 style = QFont::StyleItalic;
 150 }
 151 }
 152 if (CFNumberRef symbolic = static_cast<CFNumberRef>(CFDictionaryGetValue(styles, kCTFontSymbolicTrait))) {
 153 int d;
 154 if (CFNumberGetValue(symbolic, kCFNumberSInt32Type, &d)) {
 155 if (d & kCTFontMonoSpaceTrait)
 156 fixedPitch = true;
 157 if (d & kCTFontExpandedTrait)
 158 stretch = QFont::Expanded;
 159 else if (d & kCTFontCondensedTrait)
 160 stretch = QFont::Condensed;
 161 }
 162 }
 163 }
 164
 165 int pixelSize = 0;
 166 if (QCFType<CFNumberRef> size = static_cast<CFNumberRef>(CTFontDescriptorCopyAttribute(font, kCTFontSizeAttribute))) {
 167 if (CFNumberIsFloatType(size)) {
 168 double d;
 169 CFNumberGetValue(size, kCFNumberDoubleType, &d);
 170 pixelSize = d;
 171 } else {
 172 CFNumberGetValue(size, kCFNumberIntType, &pixelSize);
 173 }
 174 }
 175
 176 QSupportedWritingSystems writingSystems;
 177 if (QCFType<CFArrayRef> languages = static_cast<CFArrayRef>(CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute))) {
 178 CFIndex length = CFArrayGetCount(languages);
 179 for (int i = 1; i < LanguageCount; ++i) {
 180 if (!languageForWritingSystem[i])
 181 continue;
 182 QCFString lang = CFStringCreateWithCString(NULL, languageForWritingSystem[i], kCFStringEncodingASCII);
 183 if (CFArrayContainsValue(languages, CFRangeMake(0, length), lang))
 184 writingSystems.setSupported(QFontDatabase::WritingSystem(i));
 185 }
 186 }
 187
 188 CFRetain(font);
 189 QPlatformFontDatabase::registerFont(familyName, foundryName, weight, style, stretch,
 190 true /* antialiased */, true /* scalable */,
 191 pixelSize, fixedPitch, writingSystems, (void *) font);
 192 CFStringRef psName = static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(font, kCTFontNameAttribute));
 193 // we need PostScript Name to family name mapping for fallback list construction
 194 psNameToFamily[QCFString::toQString((NSString *) psName)] = familyName;
 195 CFRelease(psName);
 196 }
 197 // ----------------------------------------------------------------------------
 198}

Tools/QtTestPlatformPlugin/mac/TestIntegrationMac.mm

 1/*
 2 * Copyright (C) 2012 University of Szeged. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "../TestIntegration.h"
 27#include "TestFontDatabase.h"
 28
 29QPlatformFontDatabase* TestIntegration::fontDatabase() const
 30{
 31 if (!m_fontDatabase)
 32 m_fontDatabase.reset(new TestFontDatabase);
 33 return m_fontDatabase.data();
 34}

Tools/QtTestPlatformPlugin/main.cpp

 1/*
 2 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 3 * Copyright (C) 2012 University of Szeged. All rights reserved.
 4 *
 5 * GNU Lesser General Public License Usage
 6 * This file may be used under the terms of the GNU Lesser General Public
 7 * License version 2.1 as published by the Free Software Foundation.
 8 * Please review the following information to ensure the GNU Lesser
 9 * General Public License version 2.1 requirements will be met:
 10 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 11 *
 12 * GNU General Public License Usage
 13 * Alternatively, this file may be used under the terms of the GNU General
 14 * Public License version 3.0 as published by the Free Software Foundation.
 15 * Please review the following information to ensure the GNU General Public
 16 * License version 3.0 requirements will be met:
 17 * http://www.gnu.org/copyleft/gpl.html.
 18 *
 19 */
 20
 21#include "TestIntegration.h"
 22#include <QPlatformIntegrationPlugin>
 23#include <QtGlobal>
 24
 25class Q_DECL_EXPORT TestIntegrationPlugin : public QPlatformIntegrationPlugin {
 26 Q_OBJECT
 27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformIntegrationFactoryInterface" FILE "testplatform.json")
 28public:
 29 QStringList keys() const;
 30 QPlatformIntegration* create(const QString&, const QStringList&);
 31
 32 static void initialize();
 33};
 34
 35QStringList TestIntegrationPlugin::keys() const
 36{
 37 QStringList list;
 38 list << QStringLiteral("testplatform");
 39 return list;
 40}
 41
 42QPlatformIntegration* TestIntegrationPlugin::create(const QString& system, const QStringList& parameters)
 43{
 44 if (!system.compare(QStringLiteral("testplatform"), Qt::CaseInsensitive))
 45 return new TestIntegration();
 46
 47 return 0;
 48}
 49
 50#include "main.moc"
 51
 52void TestIntegrationPlugin::initialize()
 53{
 54 QStaticPlugin plugin;
 55 plugin.instance = &qt_plugin_instance;
 56 plugin.metaData = &qt_plugin_query_metadata;
 57 qRegisterStaticPluginFunction(plugin);
 58}
 59
 60static void constructorFunction()
 61{
 62 TestIntegrationPlugin::initialize();
 63}
 64
 65Q_CONSTRUCTOR_FUNCTION(constructorFunction);

Tools/QtTestPlatformPlugin/testplatform.json

 1{
 2 "Keys": [ "testplatform" ]
 3}

Tools/Tools.pro

@@SUBDIRS += QtTestBrowser/QtTestBrowser.pro
1313SUBDIRS += DumpRenderTree/qt/DumpRenderTree.pro
1414SUBDIRS += DumpRenderTree/qt/ImageDiff.pro
1515
 16haveQt(5): SUBDIRS += QtTestPlatformPlugin/QtTestPlatformPlugin.pro
 17
1618!no_webkit2 {
1719 SUBDIRS += MiniBrowser/qt/MiniBrowser.pro \
1820 WebKitTestRunner/WebKitTestRunner.pro

Tools/WebKitTestRunner/Target.pri

@@PREFIX_HEADER = WebKitTestRunnerPrefix.h
3737*-g++*:QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER"
3838*-clang*:QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER"
3939
 40mac: LIB_SUFFIX=.dylib
 41win: LIB_SUFFIX=.dll
 42unix:!mac: LIB_SUFFIX=.so
 43DEFINES += TEST_PLATFORM_PLUGIN_PATH=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}lib$${QMAKE_DIR_SEP}libtestplatform$${LIB_SUFFIX}\\\"\"
 44
4045RESOURCES = qt/WebKitTestRunner.qrc

Tools/WebKitTestRunner/qt/main.cpp

@@int main(int argc, char** argv)
9494
9595 qputenv("QT_WEBKIT_THEME_NAME", "qstyle");
9696
 97 QByteArray platform = qgetenv("QT_QPA_PLATFORM");
 98 QByteArray platformPluginPath = qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH");
 99 for (int i = 0; i < argc; ++i) {
 100 if (QByteArray(argv[i]) == "-platform" && i + 1 < argc)
 101 platform = argv[i + 1];
 102 else if (QByteArray(argv[i]) == "-platformpluginpath" && i + 1 < argc)
 103 platformPluginPath = argv[i + 1];
 104 }
 105 if (!platform.isEmpty())
 106 qputenv("QT_WEBKIT_ORIGINAL_PLATFORM", platform);
 107 if (!platformPluginPath.isEmpty())
 108 qputenv("QT_WEBKIT_ORIGINAL_PLATFORM_PLUGIN_PATH", platformPluginPath);
 109
 110 // Tell the web process that we want to use the test platform plugin.
 111 qputenv("QT_WEBKIT2_TEST_PLATFORM_PLUGIN_PATH", TEST_PLATFORM_PLUGIN_PATH);
 112
97113 QQuickWebViewExperimental::setFlickableViewportEnabled(false);
98114 QApplication app(argc, argv);
99115 Launcher launcher(argc, argv);