[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kget
From:       Matthias Fuchs <mat69 () gmx ! net>
Date:       2011-03-15 11:12:06
Message-ID: 20110315111206.CE90AAC8C7 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1224970 by mfuchs:

Do not hardcode dirs in TestTransfers, uses KTempDir instead.

 M  +2 -2      kget-test.xml  
 M  +18 -5     tests/testtransfers.cpp  
 M  +6 -2      tests/testtransfers.h  


--- trunk/KDE/kdenetwork/kget/kget-test.xml #1224969:1224970
@@ -43,7 +43,7 @@
       <arg>50</arg>
     </command>
     <command type="SetDirectory">
-      <arg>/tmp/downloads2</arg>
+      <arg>${DIR}/downloads2</arg>
       <arg>true</arg>
     </command>
     <command type="Verified">  
@@ -99,7 +99,7 @@
       <arg>10</arg>
     </command>
     <command type="SetDirectory">
-      <arg>/tmp/downloads2</arg>
+      <arg>${DIR}/downloads2</arg>
       <arg>true</arg>
     </command>
     <command type="Verified">
--- trunk/KDE/kdenetwork/kget/tests/testtransfers.cpp #1224969:1224970
@@ -23,7 +23,8 @@
 #include <QDBusPendingReply>
 #include <QList>
 
-#include <krun.h>
+#include <KRun>
+#include <KTempDir>
 #include <qtest_kde.h>
 
 //FIXME not working fine if files or transfers are existing already
@@ -72,7 +73,7 @@
     }
 }
 
-QList<QPair<int, QVariant> > Commands::parseCommands(const QDomElement &e)
+QList<QPair<int, QVariant> > Commands::parseCommands(const QDomElement& e, \
TestTransfers *transfer)  {
     QList<QPair<int, QVariant> > commands;
 
@@ -190,7 +191,10 @@
             case SetDirectory:
                 if (args.count() == 2) {
                     data = args.last();
-                    const QString newDirectory = args.first();
+                    QString newDirectory = args.first();
+                    if (transfer) {
+                        newDirectory.replace("${DIR}/", transfer->tempDir());
+                    }
                     if (!newDirectory.isEmpty() && data.canConvert(QVariant::Bool)) \
{  const bool shouldWork = data.toBool();
                         QList<QVariant> list;
@@ -539,6 +543,9 @@
         KRun::runCommand("kget --showDropTarget --hideMainWindow", "kget", "kget", \
0);  }
 
+    m_dir.reset(new KTempDir());
+    kDebug(5001) << "Using temp dir:" << tempDir();
+
 //TODO add a signal to check if the move worked!!
 
 //                << \
"http://mirrors.isc.org/pub/kde/stable/4.3.1/src/kdeedu-4.3.1.tar.bz2" @@ -573,6 \
+580,12 @@  //                << "28580c6f283fa7a6405f6a4415ebe9a4167f0992"
 //                << "75a82d2e80d946333f63e32db56767c3ed17ba33";
 }
+
+QString TestTransfers::tempDir() const
+{
+    return m_dir->name();
+}
+
 void TestTransfers::parseFile()
 {
     QFile file(QString::fromLocal8Bit(KDESRCDIR) + "/kget-test.xml");
@@ -594,7 +607,7 @@
             return;
         }
         Commands *transfer = new Commands(source, this);
-        transfer->setCommands(Commands::parseCommands(elem));
+        transfer->setCommands(Commands::parseCommands(elem, this));
         m_commands.append(transfer);
     }
 }
@@ -616,7 +629,7 @@
     OrgKdeKgetMainInterface kgetInterface("org.kde.kget", "/KGet", \
QDBusConnection::sessionBus());  
     foreach (Commands *command, m_commands) {
-        QDBusPendingReply<QStringList> reply = \
kgetInterface.addTransfer(command->source(), "/tmp/downloads/" + \
KUrl(command->source()).fileName(), false); +        QDBusPendingReply<QStringList> \
reply = kgetInterface.addTransfer(command->source(), tempDir() + \
KUrl(command->source()).fileName(), false);  reply.waitForFinished();
 
         if (reply.value().size()) {
--- trunk/KDE/kdenetwork/kget/tests/testtransfers.h #1224969:1224970
@@ -16,6 +16,7 @@
 #include <QtTest/QtTest>
 #include <QtXml/QDomElement>
 
+class KTempDir;
 class OrgKdeKgetTransferInterface;
 class OrgKdeKgetVerifierInterface;
 class TestTransfers;
@@ -25,7 +26,7 @@
     Q_OBJECT
 
     public:
-        Commands(const QString &source, QObject *parent = 0);
+        Commands(const QString &source, QObject *parent);
 
         QString source() const;
         bool hasCommands() const;
@@ -33,7 +34,7 @@
         void executeCommands();
         void associateTransfer(OrgKdeKgetTransferInterface *transfer);
 
-        static QList<QPair<int, QVariant> > parseCommands(const QDomElement &e);
+        static QList<QPair<int, QVariant> > parseCommands(const QDomElement &e, \
TestTransfers *transfer);  
     enum Action {
         Start,
@@ -87,6 +88,8 @@
     public:
         TestTransfers();
 
+        QString tempDir() const;
+
     public slots:
         void createTransfer();
 
@@ -99,6 +102,7 @@
     private:
         QList<OrgKdeKgetTransferInterface *> m_transferIfaces;
         QList<Commands*> m_commands;
+        QScopedPointer<KTempDir> m_dir;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic