Title: [135602] trunk/Source/WebKit/qt
Revision
135602
Author
[email protected]
Date
2012-11-23 06:05:11 -0800 (Fri, 23 Nov 2012)

Log Message

tst_qwebpage fails after QMimeDatabase patch
https://bugs.webkit.org/show_bug.cgi?id=103125

Reviewed by Simon Hausmann.

Replace the static extension->mimetype table with a QMimeDatabase lookup

* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::findText):
(tst_QWebPage::supportedContentType):

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/ChangeLog (135601 => 135602)


--- trunk/Source/WebKit/qt/ChangeLog	2012-11-23 13:44:29 UTC (rev 135601)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-11-23 14:05:11 UTC (rev 135602)
@@ -1,3 +1,16 @@
+2012-11-23  Allan Sandfeld Jensen  <[email protected]>
+
+        tst_qwebpage fails after QMimeDatabase patch
+        https://bugs.webkit.org/show_bug.cgi?id=103125
+
+        Reviewed by Simon Hausmann.
+
+        Replace the static extension->mimetype table with a QMimeDatabase lookup
+
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::findText):
+        (tst_QWebPage::supportedContentType):
+
 2012-11-23  Simon Hausmann  <[email protected]>
 
         [Qt] Compiling against QtWebkit API requires QT_DLL to be defined

Modified: trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp (135601 => 135602)


--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2012-11-23 13:44:29 UTC (rev 135601)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2012-11-23 14:05:11 UTC (rev 135602)
@@ -27,6 +27,7 @@
 #include <QLineEdit>
 #include <QMainWindow>
 #include <QMenu>
+#include <QMimeDatabase>
 #include <QPushButton>
 #include <QStateMachine>
 #include <QStyle>
@@ -2969,79 +2970,43 @@
     }
 }
 
-struct ImageExtensionMap {
-    const char* extension;
-    const char* mimeType;
-};
-
-static const ImageExtensionMap extensionMap[] = {
-    { "bmp", "image/bmp" },
-    { "css", "text/css" },
-    { "gif", "image/gif" },
-    { "html", "text/html" },
-    { "htm", "text/html" },
-    { "ico", "image/x-icon" },
-    { "jpeg", "image/jpeg" },
-    { "jpg", "image/jpeg" },
-    { "js", "application/x-_javascript_" },
-    { "mng", "video/x-mng" },
-    { "pbm", "image/x-portable-bitmap" },
-    { "pgm", "image/x-portable-graymap" },
-    { "pdf", "application/pdf" },
-    { "png", "image/png" },
-    { "ppm", "image/x-portable-pixmap" },
-    { "rss", "application/rss+xml" },
-    { "svg", "image/svg+xml" },
-    { "text", "text/plain" },
-    { "tif", "image/tiff" },
-    { "tiff", "image/tiff" },
-    { "txt", "text/plain" },
-    { "xbm", "image/x-xbitmap" },
-    { "xml", "text/xml" },
-    { "xpm", "image/x-xpm" },
-    { "xsl", "text/xsl" },
-    { "xhtml", "application/xhtml+xml" },
-    { "wml", "text/vnd.wap.wml" },
-    { "wmlc", "application/vnd.wap.wmlc" },
-    { 0, 0 }
-};
-
 static QString getMimeTypeForExtension(const QString &ext)
 {
-    const ImageExtensionMap *e = extensionMap;
-    while (e->extension) {
-        if (ext.compare(QLatin1String(e->extension), Qt::CaseInsensitive) == 0)
-            return QLatin1String(e->mimeType);
-        ++e;
-    }
+    QMimeType mimeType = QMimeDatabase().mimeTypeForFile(QStringLiteral("filename.") + ext.toLower(), QMimeDatabase::MatchExtension);
+    if (mimeType.isValid() && !mimeType.isDefault())
+        return mimeType.name();
 
     return QString();
 }
 
 void tst_QWebPage::supportedContentType()
 {
-   QStringList contentTypes;
+    QStringList contentTypes;
 
-   // Add supported non image types...
-   contentTypes << "text/html" << "text/xml" << "text/xsl" << "text/plain" << "text/"
-                << "application/xml" << "application/xhtml+xml" << "application/vnd.wap.xhtml+xml"
-                << "application/rss+xml" << "application/atom+xml" << "application/json";
+    // Add supported non image types...
+    contentTypes << "text/html" << "text/xml" << "text/xsl" << "text/plain" << "text/"
+                 << "application/xml" << "application/xhtml+xml" << "application/vnd.wap.xhtml+xml"
+                 << "application/rss+xml" << "application/atom+xml" << "application/json";
 
-   // Add supported image types...
-   Q_FOREACH(const QByteArray& imageType, QImageWriter::supportedImageFormats()) {
-      const QString mimeType = getMimeTypeForExtension(imageType);
-      if (!mimeType.isEmpty())
-          contentTypes << mimeType;
-   }
+#if ENABLE_MHTML
+    contentTypes << "application/x-mimearchive";
+#endif
 
-   // Get the mime types supported by webkit...
-   const QStringList supportedContentTypes = m_page->supportedContentTypes();
+    // Add supported image types...
+    Q_FOREACH(const QByteArray& imageType, QImageWriter::supportedImageFormats()) {
+        const QString mimeType = getMimeTypeForExtension(imageType);
+        if (!mimeType.isEmpty())
+            contentTypes << mimeType;
+    }
 
-   Q_FOREACH(const QString& mimeType, contentTypes)
-      QVERIFY2(supportedContentTypes.contains(mimeType), QString("'%1' is not a supported content type!").arg(mimeType).toLatin1());
+    // Get the mime types supported by webkit...
+    const QStringList supportedContentTypes = m_page->supportedContentTypes();
+
+    Q_FOREACH(const QString& mimeType, contentTypes)
+        QVERIFY2(supportedContentTypes.contains(mimeType), QString("'%1' is not a supported content type!").arg(mimeType).toLatin1());
       
-   Q_FOREACH(const QString& mimeType, contentTypes)
-      QVERIFY2(m_page->supportsContentType(mimeType), QString("Cannot handle content types '%1'!").arg(mimeType).toLatin1());
+    Q_FOREACH(const QString& mimeType, contentTypes)
+        QVERIFY2(m_page->supportsContentType(mimeType), QString("Cannot handle content types '%1'!").arg(mimeType).toLatin1());
 }
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to