• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

qca

filewatchunittest.cpp

Go to the documentation of this file.
00001 
00025 #include "filewatchunittest.h"
00026 
00027 void FileWatchUnitTest::initTestCase()
00028 {
00029     m_init = new QCA::Initializer;
00030 #include "../fixpaths.include"
00031 }
00032 
00033 void FileWatchUnitTest::cleanupTestCase()
00034 {
00035     delete m_init;
00036 }
00037 
00038 void FileWatchUnitTest::filewatchTest()
00039 {
00040     QCA::FileWatch watcher;
00041     QCOMPARE( watcher.fileName(), QString() );
00042 
00043     QSignalSpy spy( &watcher, SIGNAL(changed()) );
00044     QVERIFY( spy.isValid() );
00045     QCOMPARE( spy.count(), 0 );
00046 
00047     QTemporaryFile *tempFile = new QTemporaryFile;
00048 
00049     tempFile->open();
00050 
00051     watcher.setFileName( tempFile->fileName() );
00052     QCOMPARE( watcher.fileName(), tempFile->fileName() );
00053     QTest::qWait(7000);
00054     QCOMPARE( spy.count(), 0 );
00055     tempFile->close();
00056     QTest::qWait(7000);
00057     QCOMPARE( spy.count(), 0 );
00058 
00059     tempFile->open();
00060     tempFile->write("foo");
00061     tempFile->flush();
00062     QTest::qWait(7000);
00063     QCOMPARE( spy.count(), 1 );
00064 
00065     tempFile->close();
00066     QTest::qWait(7000);
00067 
00068     QCOMPARE( spy.count(), 1 );
00069 
00070     tempFile->open();
00071     tempFile->write("foo");
00072     tempFile->flush();
00073     QTest::qWait(7000);
00074     QCOMPARE( spy.count(), 2 );
00075 
00076     tempFile->write("bar");
00077     tempFile->flush();
00078     QTest::qWait(7000);
00079     QCOMPARE( spy.count(), 3 );
00080 
00081     tempFile->close();
00082     QTest::qWait(7000);
00083 
00084     QCOMPARE( spy.count(), 3 );
00085 
00086     delete tempFile;
00087     QTest::qWait(7000);
00088     QCOMPARE( spy.count(), 4 );
00089     
00090 }
00091 
00092 QTEST_MAIN(FileWatchUnitTest)

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal