| 1 | // |
|---|---|
| 2 | // DirectoryWatcherTest.h |
| 3 | // |
| 4 | // Definition of the DirectoryWatcherTest class. |
| 5 | // |
| 6 | // Copyright (c) 2012, Applied Informatics Software Engineering GmbH. |
| 7 | // and Contributors. |
| 8 | // |
| 9 | // SPDX-License-Identifier: BSL-1.0 |
| 10 | // |
| 11 | |
| 12 | |
| 13 | #ifndef DirectoryWatcherTest_INCLUDED |
| 14 | #define DirectoryWatcherTest_INCLUDED |
| 15 | |
| 16 | |
| 17 | #include "Poco/Foundation.h" |
| 18 | |
| 19 | |
| 20 | #ifndef POCO_NO_INOTIFY |
| 21 | |
| 22 | |
| 23 | #include "Poco/DirectoryWatcher.h" |
| 24 | #include "Poco/Path.h" |
| 25 | #include "Poco/CppUnit/TestCase.h" |
| 26 | |
| 27 | |
| 28 | class DirectoryWatcherTest: public CppUnit::TestCase |
| 29 | { |
| 30 | public: |
| 31 | DirectoryWatcherTest(const std::string& name); |
| 32 | ~DirectoryWatcherTest(); |
| 33 | |
| 34 | void testAdded(); |
| 35 | void testRemoved(); |
| 36 | void testModified(); |
| 37 | void testMoved(); |
| 38 | |
| 39 | void setUp(); |
| 40 | void tearDown(); |
| 41 | |
| 42 | static CppUnit::Test* suite(); |
| 43 | |
| 44 | protected: |
| 45 | void onItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& ev); |
| 46 | void onItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& ev); |
| 47 | void onItemModified(const Poco::DirectoryWatcher::DirectoryEvent& ev); |
| 48 | void onItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& ev); |
| 49 | void onItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& ev); |
| 50 | void onError(const Poco::Exception& exc); |
| 51 | |
| 52 | Poco::Path path() const; |
| 53 | |
| 54 | private: |
| 55 | struct DirEvent |
| 56 | { |
| 57 | Poco::DirectoryWatcher::DirectoryEventType type; |
| 58 | std::string callback; |
| 59 | std::string path; |
| 60 | }; |
| 61 | std::vector<DirEvent> _events; |
| 62 | bool _error; |
| 63 | }; |
| 64 | |
| 65 | |
| 66 | #endif // POCO_NO_INOTIFY |
| 67 | |
| 68 | |
| 69 | #endif // DirectoryWatcherTest_INCLUDED |
| 70 | |
| 71 | |
| 72 |