function notifyChanged() {
      test_util.fileSystem.root.getDirectory(
          TESTING_DIRECTORY.name,
          {create: false},
          chrome.test.callbackPass(function(fileEntry) {
            chrome.test.assertEq(TESTING_DIRECTORY.name, fileEntry.name);
            test_util.toExternalEntry(fileEntry).then(
                chrome.test.callbackPass(function(externalEntry) {
                  chrome.test.assertTrue(!!externalEntry);
                  chrome.fileManagerPrivate.addFileWatch(
                      externalEntry,
                      chrome.test.callbackPass(function(result) {
                        chrome.test.assertTrue(result);
                        // Verify closure called when an even arrives.
                        directoryChangedCallback = chrome.test.callbackPass(
                            function() {
                              chrome.test.assertEq(
                                  1, directoryChangedEvents.length);
                              chrome.test.assertEq(
                                  'changed',
                                  directoryChangedEvents[0].eventType);
                              chrome.test.assertEq(
                                  externalEntry.toURL(),
                                  directoryChangedEvents[0].entry.toURL());
                              // Confirm that the tag is updated.
                              chrome.fileSystemProvider.getAll(
                                  chrome.test.callbackPass(function(items) {
                                    chrome.test.assertEq(1, items.length);
                                    chrome.test.assertEq(
                                        1, items[0].watchers.length);
                                    var watcher = items[0].watchers[0];
                                    chrome.test.assertEq(
                                        TESTING_TAG, watcher.lastTag);
                                  }));
                            });
                        // TODO(mtomasz): Add more advanced tests, eg. for the
                        // details of changes.
                        chrome.fileSystemProvider.notify({
                          fileSystemId: test_util.FILE_SYSTEM_ID,
                          observedPath: fileEntry.fullPath,
                          recursive: false,
                          changeType: 'CHANGED',
                          tag: TESTING_TAG
                        }, chrome.test.callbackPass());
                      }));
                })).catch(chrome.test.fail);
          }), function(error) {
            chrome.test.fail(error.name);
          });
    }
// Add a watcher, and then notifies that the entry has changed.
Add a watcher, and then notifies that the entry has changed.
Add a watcher and then notifies that the entry has changed .
function notifyChanged() {
      test_util.fileSystem.root.getDirectory(
          TESTING_DIRECTORY.name,
          {create: false},
          chrome.test.callbackPass(function(fileEntry) {
            chrome.test.assertEq(TESTING_DIRECTORY.name, fileEntry.name);
            test_util.toExternalEntry(fileEntry).then(
                chrome.test.callbackPass(function(externalEntry) {
                  chrome.test.assertTrue(!!externalEntry);
                  chrome.fileManagerPrivate.addFileWatch(
                      externalEntry,
                      chrome.test.callbackPass(function(result) {
                        chrome.test.assertTrue(result);
                        directoryChangedCallback = chrome.test.callbackPass(
                            function() {
                              chrome.test.assertEq(
                                  1, directoryChangedEvents.length);
                              chrome.test.assertEq(
                                  'changed',
                                  directoryChangedEvents[0].eventType);
                              chrome.test.assertEq(
                                  externalEntry.toURL(),
                                  directoryChangedEvents[0].entry.toURL());
                              chrome.fileSystemProvider.getAll(
                                  chrome.test.callbackPass(function(items) {
                                    chrome.test.assertEq(1, items.length);
                                    chrome.test.assertEq(
                                        1, items[0].watchers.length);
                                    var watcher = items[0].watchers[0];
                                    chrome.test.assertEq(
                                        TESTING_TAG, watcher.lastTag);
                                  }));
                            });
                        chrome.fileSystemProvider.notify({
                          fileSystemId: test_util.FILE_SYSTEM_ID,
                          observedPath: fileEntry.fullPath,
                          recursive: false,
                          changeType: 'CHANGED',
                          tag: TESTING_TAG
                        }, chrome.test.callbackPass());
                      }));
                })).catch(chrome.test.fail);
          }), function(error) {
            chrome.test.fail(error.name);
          });
    }
function notifyChanged ( ) { test_util . fileSystem . root . getDirectory ( TESTING_DIRECTORY . name , { create : false } , chrome . test . callbackPass ( function ( fileEntry ) { chrome . test . assertEq ( TESTING_DIRECTORY . name , fileEntry . name ) ; test_util . toExternalEntry ( fileEntry ) . then ( chrome . test . callbackPass ( function ( externalEntry ) { chrome . test . assertTrue ( ! ! externalEntry ) ; chrome . fileManagerPrivate . addFileWatch ( externalEntry , chrome . test . callbackPass ( function ( result ) { chrome . test . assertTrue ( result ) ; directoryChangedCallback = chrome . test . callbackPass ( function ( ) { chrome . test . assertEq ( 1 , directoryChangedEvents . length ) ; chrome . test . assertEq ( 'changed' , directoryChangedEvents [ 0 ] . eventType ) ; chrome . test . assertEq ( externalEntry . toURL ( ) , directoryChangedEvents [ 0 ] . entry . toURL ( ) ) ; chrome . fileSystemProvider . getAll ( chrome . test . callbackPass ( function ( items ) { chrome . test . assertEq ( 1 , items . length ) ; chrome . test . assertEq ( 1 , items [ 0 ] . watchers . length ) ; var watcher = items [ 0 ] . watchers [ 0 ] ; chrome . test . assertEq ( TESTING_TAG , watcher . lastTag ) ; } ) ) ; } ) ; chrome . fileSystemProvider . notify ( { fileSystemId : test_util . FILE_SYSTEM_ID , observedPath : fileEntry . fullPath , recursive : false , changeType : 'CHANGED' , tag : TESTING_TAG } , chrome . test . callbackPass ( ) ) ; } ) ) ; } ) ) . catch ( chrome . test . fail ) ; } ) , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; }
Add a watcher, and then notifies that the entry has changed.
Add a watcher and then notifies that the entry has changed .
// Verify closure called when an even arrives. // Confirm that the tag is updated. // TODO(mtomasz): Add more advanced tests, eg. for the // details of changes.