Removable drive monitor for OS X 10.4 (JNotify requires at least 10.5).

This commit is contained in:
akwizgran
2011-11-19 18:09:10 +00:00
parent b2226067e1
commit 214b274ee5
4 changed files with 36 additions and 5 deletions

View File

@@ -41,9 +41,12 @@ public class PluginManagerImplTest extends TestCase {
Poller poller = new PollerImpl();
PluginManagerImpl p = new PluginManagerImpl(db, executor, poller,
dispatcher, uiCallback);
// The Bluetooth plugin will not start without a Bluetooth device, so
// we expect two plugins to be started
assertEquals(2, p.startPlugins());
assertEquals(2, p.stopPlugins());
// We expect either 2 or 3 plugins to be started, depending on whether
// the test machine has a Bluetooth device
int started = p.startPlugins();
int stopped = p.stopPlugins();
assertEquals(started, stopped);
assertTrue(started >= 2);
assertTrue(started <= 3);
}
}

View File

@@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit;
import junit.framework.TestCase;
import net.sf.briar.TestUtils;
import net.sf.briar.plugins.file.RemovableDriveMonitor.Callback;
import net.sf.briar.util.OsUtils;
import org.junit.After;
import org.junit.Before;
@@ -25,6 +26,10 @@ public class UnixRemovableDriveMonitorTest extends TestCase {
@Test
public void testNonexistentDir() throws Exception {
if(!OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer()) {
System.err.println("Warning: Skipping test");
return;
}
File doesNotExist = new File(testDir, "doesNotExist");
RemovableDriveMonitor monitor = createMonitor(doesNotExist);
monitor.start(null);
@@ -33,6 +38,10 @@ public class UnixRemovableDriveMonitorTest extends TestCase {
@Test
public void testOneCallbackPerFile() throws Exception {
if(!OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer()) {
System.err.println("Warning: Skipping test");
return;
}
// Create a callback that will wait for two files before stopping
final List<File> detected = new ArrayList<File>();
final CountDownLatch latch = new CountDownLatch(2);