]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/fswatcher/fswatchertest.cpp
Resolve ambiguity between GetClientXXX() methods in wxOSX wxComboBox.
[wxWidgets.git] / tests / fswatcher / fswatchertest.cpp
index ed8268006172ce9849147385b05d62de07f07577..fc158e7162049bb04c280d830fa5a4a22b977fd5 100644 (file)
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
+#ifndef WX_PRECOMP
+    #include "wx/timer.h"
+#endif
+
 #include "wx/evtloop.h"
 #include "wx/filename.h"
 #include "wx/filefn.h"
 #include "wx/evtloop.h"
 #include "wx/filename.h"
 #include "wx/filefn.h"
@@ -248,7 +252,7 @@ public:
             break;
         case 2:
             // actual test
             break;
         case 2:
             // actual test
-            CPPUNIT_ASSERT(CheckResult());
+            CheckResult();
             Exit();
             break;
 
             Exit();
             break;
 
@@ -325,7 +329,7 @@ public:
         tested = true;
     }
 
         tested = true;
     }
 
-    virtual bool CheckResult()
+    virtual void CheckResult()
     {
         CPPUNIT_ASSERT_MESSAGE( "No events received", !m_events.empty() );
 
     {
         CPPUNIT_ASSERT_MESSAGE( "No events received", !m_events.empty() );
 
@@ -356,8 +360,6 @@ public:
 
         CPPUNIT_ASSERT_EQUAL(expected.GetPath(), e->GetPath());
         CPPUNIT_ASSERT_EQUAL(expected.GetNewPath(), e->GetNewPath());
 
         CPPUNIT_ASSERT_EQUAL(expected.GetPath(), e->GetPath());
         CPPUNIT_ASSERT_EQUAL(expected.GetNewPath(), e->GetNewPath());
-
-        return true;
     }
 
     virtual void GenerateEvent() = 0;
     }
 
     virtual void GenerateEvent() = 0;
@@ -414,6 +416,8 @@ private:
         CPPUNIT_TEST( TestEventAccess );
 #endif // __WXMSW__
 #endif // !wxHAS_KQUEUE
         CPPUNIT_TEST( TestEventAccess );
 #endif // __WXMSW__
 #endif // !wxHAS_KQUEUE
+
+        CPPUNIT_TEST( TestNoEventsAfterRemove );
     CPPUNIT_TEST_SUITE_END();
 
     void TestEventCreate();
     CPPUNIT_TEST_SUITE_END();
 
     void TestEventCreate();
@@ -422,6 +426,8 @@ private:
     void TestEventModify();
     void TestEventAccess();
 
     void TestEventModify();
     void TestEventAccess();
 
+    void TestNoEventsAfterRemove();
+
     DECLARE_NO_COPY_CLASS(FileSystemWatcherTestCase)
 };
 
     DECLARE_NO_COPY_CLASS(FileSystemWatcherTestCase)
 };
 
@@ -607,3 +613,60 @@ void FileSystemWatcherTestCase::TestEventAccess()
     EventTester tester;
     tester.Run();
 }
     EventTester tester;
     tester.Run();
 }
+
+namespace
+{
+
+// We can't define this class locally inside TestNoEventsAfterRemove() for some
+// reason with g++ 4.0 under OS X 10.5, it results in the following mysterious
+// error:
+//
+// /var/tmp//ccTkNCkc.s:unknown:Non-global symbol:
+// __ZThn80_ZN25FileSystemWatcherTestCase23TestNoEventsAfterRemoveEvEN11EventTester6NotifyEv.eh
+// can't be a weak_definition
+//
+// So define this class outside the function instead.
+class NoEventsAfterRemoveEventTester : public EventHandler,
+                                       public wxTimer
+{
+public:
+    NoEventsAfterRemoveEventTester()
+    {
+        // We need to use an inactivity timer as we never get any file
+        // system events in this test, so we consider that the test is
+        // finished when this 1s timeout expires instead of, as usual,
+        // stopping after getting the file system events.
+        Start(1000, true);
+    }
+
+    virtual void GenerateEvent()
+    {
+        m_watcher->Remove(EventGenerator::GetWatchDir());
+        CPPUNIT_ASSERT(eg.CreateFile());
+    }
+
+    virtual void CheckResult()
+    {
+        CPPUNIT_ASSERT( m_events.empty() );
+    }
+
+    virtual wxFileSystemWatcherEvent ExpectedEvent()
+    {
+        CPPUNIT_FAIL( "Shouldn't be called" );
+
+        return wxFileSystemWatcherEvent(wxFSW_EVENT_ERROR);
+    }
+
+    virtual void Notify()
+    {
+        SendIdle();
+    }
+};
+
+} // anonymous namespace
+
+void FileSystemWatcherTestCase::TestNoEventsAfterRemove()
+{
+    NoEventsAfterRemoveEventTester tester;
+    tester.Run();
+}