Exemplo n.º 1
0
 public void testExportPrefs() {
   DartKeyBindingPersistence persist = getBindingPersist();
   File file = new File("testExportPrefs");
   try {
     try {
       persist.writeFile(file, "UTF-8");
     } catch (CoreException ex) {
       fail(ex.getMessage());
     }
     assertTrue(file.exists() && file.canRead());
     assertTrue(file.length() > 0L);
   } finally {
     file.delete();
   }
 }
Exemplo n.º 2
0
 public void testResetPrefs() {
   DartKeyBindingPersistence persist = getBindingPersist();
   assertTrue(hasKeyBinding(persist, "Close", "COMMAND+W"));
   persist = getBindingPersist();
   try {
     Reader reader = new StringReader("<dartKeyBindings/>");
     persist.readFrom(reader);
   } catch (CoreException ex) {
     fail(ex.getMessage());
   }
   assertFalse(hasKeyBinding(persist, "Close", "COMMAND+W"));
   persist = getBindingPersist();
   try {
     persist.resetBindings();
   } catch (CoreException ex) {
     fail(ex.getMessage());
   }
   assertTrue(hasKeyBinding(persist, "Close", "COMMAND+W"));
 }
Exemplo n.º 3
0
 private boolean hasKeyBinding(
     DartKeyBindingPersistence persist, String commandName, String keySequence) {
   try {
     Binding bind = persist.findBinding(commandName, null);
     if (bind == null) {
       return false;
     }
     return keySequence.equals(bind.getTriggerSequence().toString());
   } catch (NotDefinedException ex) {
     // fall through
   }
   return false;
 }