Change in kio[master]: Tests: check sanity of QMimeDatabase

Jan Kundrát (Code Review) noreply at kde.org
Sun Dec 7 15:07:18 UTC 2014


Jan Kundrát has uploaded a new change for review.

  https://gerrit.vesnicky.cesnet.cz/r/205

Change subject: Tests: check sanity of QMimeDatabase
......................................................................

Tests: check sanity of QMimeDatabase

Change-Id: I77573391b065250770c057a00bb5bf276bce8129
---
M autotests/kurlnavigatortest.cpp
M autotests/kurlnavigatortest.h
2 files changed, 21 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.vesnicky.cesnet.cz:29418/kio refs/changes/05/205/1

diff --git a/autotests/kurlnavigatortest.cpp b/autotests/kurlnavigatortest.cpp
index e09944a..60a407d 100644
--- a/autotests/kurlnavigatortest.cpp
+++ b/autotests/kurlnavigatortest.cpp
@@ -164,6 +164,25 @@
 }
 
 /**
+ * Test preconditions for bug251553_goUpFromArchive which relies upon reasonable detection of the ZIP MIME type
+ */
+void KUrlNavigatorTest::testMimeDatabaseZip()
+{
+    // First of all, make sure that the MIME database itself provides reasonable data
+    QMimeDatabase db;
+
+    // Simple lookup of a MIME type for a non-existing file
+    QMimeType mime1 = db.mimeTypeForFile(QLatin1String("/test/archive.zip"));
+    QCOMPARE(mime1.name(), QLatin1String("application/zip"));
+    QVERIFY(mime1.inherits("application/zip"));
+
+    // This test mimics the operation of KUrlNaviagtor
+    QMimeType mime2 = db.mimeTypeForUrl(QUrl(QUrl("zip:/test/archive.zip").toString(QUrl::StripTrailingSlash)));
+    QCOMPARE(mime2.name(), QLatin1String("application/zip"));
+    QVERIFY(mime2.inherits("application/zip"));
+}
+
+/**
  * When the current URL is inside an archive and the user goes "up", it is expected
  * that the new URL is that of the folder containing the archive (unless the URL was
  * in a subfolder inside the archive). Furthermore, the protocol should be "file".
diff --git a/autotests/kurlnavigatortest.h b/autotests/kurlnavigatortest.h
index e65e8ef..5cd8d14 100644
--- a/autotests/kurlnavigatortest.h
+++ b/autotests/kurlnavigatortest.h
@@ -36,6 +36,8 @@
     void testGoForward();
     void testHistoryInsert();
 
+    void testMimeDatabaseZip();
+
     void bug251553_goUpFromArchive();
 
     void testUrlParsing_data();

-- 
To view, visit https://gerrit.vesnicky.cesnet.cz/r/205
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77573391b065250770c057a00bb5bf276bce8129
Gerrit-PatchSet: 1
Gerrit-Project: kio
Gerrit-Branch: master
Gerrit-Owner: Jan Kundrát <jkt at kde.org>


More information about the Kde-frameworks-devel mailing list