Fix wxFileSystemWatcher::Remove() in wxMSW.

Removing the path watched by wxFileSystemWatcher didn't do anything in wxMSW
implementation so we still continued getting events for the changes to this
path even after calling Remove().

Fix this by really implementing Remove() properly. Also add a unit test
checking that we don't get any events after calling Remove().

See #12847.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-05-03 23:31:29 +00:00
parent 17e23c0cb9
commit 51fb867819
3 changed files with 102 additions and 3 deletions

View File

@@ -412,6 +412,8 @@ private:
CPPUNIT_TEST( TestEventAccess );
#endif // __WXMSW__
#endif // !wxHAS_KQUEUE
CPPUNIT_TEST( TestNoEventsAfterRemove );
CPPUNIT_TEST_SUITE_END();
void TestEventCreate();
@@ -420,6 +422,8 @@ private:
void TestEventModify();
void TestEventAccess();
void TestNoEventsAfterRemove();
DECLARE_NO_COPY_CLASS(FileSystemWatcherTestCase)
};
@@ -605,3 +609,46 @@ void FileSystemWatcherTestCase::TestEventAccess()
EventTester tester;
tester.Run();
}
void FileSystemWatcherTestCase::TestNoEventsAfterRemove()
{
class EventTester : public EventHandler,
public wxTimer
{
public:
EventTester()
{
// 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();
}
};
EventTester tester;
tester.Run();
}