Changeset 86154 in webkit


Ignore:
Timestamp:
May 10, 2011 8:32:44 AM (13 years ago)
Author:
Ademar Reis
Message:

2011-05-10 Ademar de Souza Reis Jr. <Ademar Reis>

Reviewed by Csaba Osztrogonác.

[Qt] tst_QWebPage creates temporary files in the current working dir
https://bugs.webkit.org/show_bug.cgi?id=60497

tst_QWebPage was using QDir::currentPath when creating temporary dirs
and leaving them after the test was run. I basically borrowed the fix
from tst_QDeclarativeWebView.

  • tests/qwebpage/tst_qwebpage.cpp: (removeRecursive): (tst_QWebPage::tmpDirPath): (tst_QWebPage::cleanupFiles): (tst_QWebPage::database): (tst_QWebPage::multiplePageGroupsAndLocalStorage):
Location:
trunk/Source/WebKit/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/ChangeLog

    r86124 r86154  
     12011-05-10  Ademar de Souza Reis Jr.  <ademar.reis@openbossa.org>
     2
     3        Reviewed by Csaba Osztrogonác.
     4
     5        [Qt] tst_QWebPage creates temporary files in the current working dir
     6        https://bugs.webkit.org/show_bug.cgi?id=60497
     7
     8        tst_QWebPage was using QDir::currentPath when creating temporary dirs
     9        and leaving them after the test was run. I basically borrowed the fix
     10        from tst_QDeclarativeWebView.
     11
     12        * tests/qwebpage/tst_qwebpage.cpp:
     13        (removeRecursive):
     14        (tst_QWebPage::tmpDirPath):
     15        (tst_QWebPage::cleanupFiles):
     16        (tst_QWebPage::database):
     17        (tst_QWebPage::multiplePageGroupsAndLocalStorage):
     18
    1192011-05-09  Chang Shu  <cshu@webkit.org>
    220
  • trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r85799 r86154  
    4545#include <qwebview.h>
    4646#include <qimagewriter.h>
     47
     48static void removeRecursive(const QString& dirname)
     49{
     50    QDir dir(dirname);
     51    QFileInfoList entries(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot));
     52    for (int i = 0; i < entries.count(); ++i)
     53        if (entries[i].isDir())
     54            removeRecursive(entries[i].filePath());
     55        else
     56            dir.remove(entries[i].fileName());
     57    QDir().rmdir(dirname);
     58}
    4759
    4860class EventSpy : public QObject, public QList<QEvent::Type>
     
    146158    void macCopyUnicodeToClipboard();
    147159#endif
    148    
     160
    149161private:
    150162    QWebView* m_view;
    151163    QWebPage* m_page;
     164    QString tmpDirPath() const
     165    {
     166        static QString tmpd = QDir::tempPath() + "/tst_qwebpage-"
     167            + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
     168        return tmpd;
     169    }
    152170};
    153171
     
    173191void tst_QWebPage::cleanupFiles()
    174192{
    175     QFile::remove("Databases.db");
    176     QDir::current().rmdir("http_www.myexample.com_0");
    177     QFile::remove("http_www.myexample.com_0.localstorage");
     193    removeRecursive(tmpDirPath());
    178194}
    179195
     
    554570void tst_QWebPage::database()
    555571{
    556     QString path = QDir::currentPath();
     572    QString path = tmpDirPath();
    557573    m_page->settings()->setOfflineStoragePath(path);
    558574    QVERIFY(m_page->settings()->offlineStoragePath() == path);
     
    908924void tst_QWebPage::multiplePageGroupsAndLocalStorage()
    909925{
    910     QDir dir(QDir::currentPath());
     926    QDir dir(tmpDirPath());
    911927    dir.mkdir("path1");
    912928    dir.mkdir("path2");
     
    916932
    917933    view1.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    918     view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(QDir::currentPath() + "/path1"));
     934    view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path1"));
    919935    DumpRenderTreeSupportQt::webPageSetGroupName(view1.page(), "group1");
    920936    view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);   
    921     view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(QDir::currentPath() + "/path2"));
     937    view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path2"));
    922938    DumpRenderTreeSupportQt::webPageSetGroupName(view2.page(), "group2");
    923939    QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view1.page()), QString("group1"));
     
    942958    QTest::qWait(1000);
    943959
    944     QFile::remove(QDir::toNativeSeparators(QDir::currentPath() + "/path1/http_www.myexample.com_0.localstorage"));
    945     QFile::remove(QDir::toNativeSeparators(QDir::currentPath() + "/path2/http_www.myexample.com_0.localstorage"));
     960    QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path1/http_www.myexample.com_0.localstorage"));
     961    QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path2/http_www.myexample.com_0.localstorage"));
    946962    dir.rmdir(QDir::toNativeSeparators("./path1"));
    947963    dir.rmdir(QDir::toNativeSeparators("./path2"));
Note: See TracChangeset for help on using the changeset viewer.