tests/auto/qzip/tst_qzip.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    75     QZipReader zip(QString(SRCDIR) + "/testdata/test.zip", QIODevice::ReadOnly);
    75     QZipReader zip(QString(SRCDIR) + "/testdata/test.zip", QIODevice::ReadOnly);
    76     QList<QZipReader::FileInfo> files = zip.fileInfoList();
    76     QList<QZipReader::FileInfo> files = zip.fileInfoList();
    77     QCOMPARE(files.count(), 2);
    77     QCOMPARE(files.count(), 2);
    78 
    78 
    79     QZipReader::FileInfo fi = files.at(0);
    79     QZipReader::FileInfo fi = files.at(0);
       
    80     QVERIFY(fi.isValid());
    80     QCOMPARE(fi.filePath, QString("test/"));
    81     QCOMPARE(fi.filePath, QString("test/"));
    81     QCOMPARE(uint(fi.isDir), (uint) 1);
    82     QCOMPARE(uint(fi.isDir), (uint) 1);
    82     QCOMPARE(uint(fi.isFile), (uint) 0);
    83     QCOMPARE(uint(fi.isFile), (uint) 0);
    83     QCOMPARE(uint(fi.isSymLink), (uint) 0);
    84     QCOMPARE(uint(fi.isSymLink), (uint) 0);
    84 
    85 
    85     QCOMPARE(fi.permissions,QFile::Permissions(  QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner
    86     QCOMPARE(fi.permissions,QFile::Permissions(  QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner
    86                                                  | QFile::ReadUser  | QFile::WriteUser | QFile::ExeUser   ));
    87                                                  | QFile::ReadUser  | QFile::WriteUser | QFile::ExeUser   ));
    87 
    88 
       
    89     QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss"));
       
    90 
    88     fi = files.at(1);
    91     fi = files.at(1);
       
    92     QVERIFY(fi.isValid());
    89     QCOMPARE(fi.filePath, QString("test/test.txt"));
    93     QCOMPARE(fi.filePath, QString("test/test.txt"));
    90     QCOMPARE(uint(fi.isDir), (uint) 0);
    94     QCOMPARE(uint(fi.isDir), (uint) 0);
    91     QCOMPARE(uint(fi.isFile), (uint) 1);
    95     QCOMPARE(uint(fi.isFile), (uint) 1);
    92     QCOMPARE(uint(fi.isSymLink), (uint) 0);
    96     QCOMPARE(uint(fi.isSymLink), (uint) 0);
    93 
    97 
    94     QVERIFY(fi.permissions == QFile::Permissions(  QFile::ReadOwner | QFile::WriteOwner
    98     QVERIFY(fi.permissions == QFile::Permissions(  QFile::ReadOwner | QFile::WriteOwner
    95                                                  | QFile::ReadUser  | QFile::WriteUser ));
    99                                                  | QFile::ReadUser  | QFile::WriteUser ));
    96 
   100 
       
   101     QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss"));
       
   102 
    97     QCOMPARE(zip.fileData("test/test.txt"), QByteArray("content\n"));
   103     QCOMPARE(zip.fileData("test/test.txt"), QByteArray("content\n"));
       
   104 
       
   105     fi = files.at(-1);
       
   106     QVERIFY(!fi.isValid());
    98 }
   107 }
    99 
   108 
   100 void tst_QZip::symlinks()
   109 void tst_QZip::symlinks()
   101 {
   110 {
   102     QZipReader zip(QString(SRCDIR) + "/testdata/symlink.zip", QIODevice::ReadOnly);
   111     QZipReader zip(QString(SRCDIR) + "/testdata/symlink.zip", QIODevice::ReadOnly);
   103     QList<QZipReader::FileInfo> files = zip.fileInfoList();
   112     QList<QZipReader::FileInfo> files = zip.fileInfoList();
   104     QCOMPARE(files.count(), 2);
   113     QCOMPARE(files.count(), 2);
   105 
   114 
   106     QZipReader::FileInfo fi = files.at(0);
   115     QZipReader::FileInfo fi = files.at(0);
       
   116     QVERIFY(fi.isValid());
   107     QCOMPARE(fi.filePath, QString("symlink"));
   117     QCOMPARE(fi.filePath, QString("symlink"));
   108     QVERIFY(!fi.isDir);
   118     QVERIFY(!fi.isDir);
   109     QVERIFY(!fi.isFile);
   119     QVERIFY(!fi.isFile);
   110     QVERIFY(fi.isSymLink);
   120     QVERIFY(fi.isSymLink);
   111 
   121 
   112     QCOMPARE(zip.fileData("symlink"), QByteArray("destination"));
   122     QCOMPARE(zip.fileData("symlink"), QByteArray("destination"));
   113 
   123 
   114     fi = files.at(1);
   124     fi = files.at(1);
       
   125     QVERIFY(fi.isValid());
   115     QCOMPARE(fi.filePath, QString("destination"));
   126     QCOMPARE(fi.filePath, QString("destination"));
   116     QVERIFY(!fi.isDir);
   127     QVERIFY(!fi.isDir);
   117     QVERIFY(fi.isFile);
   128     QVERIFY(fi.isFile);
   118     QVERIFY(!fi.isSymLink);
   129     QVERIFY(!fi.isSymLink);
   119 }
   130 }