| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Sets up the tests. Called once per all test cases. In case of a failure, | 8 * Sets up the tests. Called once per all test cases. In case of a failure, |
| 9 * the callback is not called. | 9 * the callback is not called. |
| 10 * | 10 * |
| 11 * @param {function()} callback Success callback. | 11 * @param {function()} callback Success callback. |
| 12 */ | 12 */ |
| 13 function setUp(callback) { | 13 function setUp(callback) { |
| 14 test_util.mountFileSystem(callback); | 14 test_util.mountFileSystem(callback); |
| 15 } | 15 } |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Runs all of the test cases, one by one. | 18 * Runs all of the test cases, one by one. |
| 19 */ | 19 */ |
| 20 function runTests() { | 20 function runTests() { |
| 21 chrome.test.runTests([ | 21 chrome.test.runTests([ |
| 22 // Verify that the configuration flag is propagated properly. | 22 // Verify that the configuration flag is propagated properly. |
| 23 function configureNotConfigurable() { | |
| 24 chrome.fileManagerPrivate.getProvidingExtensions( | |
| 25 chrome.test.callbackPass(function(extensions) { | |
| 26 chrome.test.assertEq(extensions.length, 1); | |
| 27 chrome.test.assertEq(chrome.runtime.id, extensions[0].extensionId); | |
| 28 chrome.test.assertEq( | |
| 29 chrome.runtime.getManifest().name, extensions[0].name); | |
| 30 chrome.test.assertFalse(extensions[0].canConfigure); | |
| 31 chrome.test.assertFalse(extensions[0].canAdd); | |
| 32 })); | |
| 33 | |
| 34 chrome.fileManagerPrivate.configureProvidedFileSystem(test_util.volumeId, | |
| 35 chrome.test.callbackFail('Failed to complete configuration.')); | |
| 36 }, | |
| 37 | |
| 38 // Verify that the configuration flag is propagated properly. | |
| 39 function configureConfigurable() { | 23 function configureConfigurable() { |
| 40 var onConfigureRequested = chrome.test.callbackPass( | 24 var onConfigureRequested = chrome.test.callbackPass( |
| 41 function(options, onSuccess, onError) { | 25 function(options, onSuccess, onError) { |
| 42 chrome.fileSystemProvider.onConfigureRequested.removeListener( | 26 chrome.fileSystemProvider.onConfigureRequested.removeListener( |
| 43 onConfigureRequested); | 27 onConfigureRequested); |
| 44 onSuccess(); | 28 onSuccess(); |
| 45 }); | 29 }); |
| 46 chrome.fileSystemProvider.onConfigureRequested.addListener( | 30 chrome.fileSystemProvider.onConfigureRequested.addListener( |
| 47 onConfigureRequested); | 31 onConfigureRequested); |
| 48 | 32 |
| 49 chrome.fileManagerPrivate.getProvidingExtensions( | 33 chrome.fileManagerPrivate.getProvidingExtensions( |
| 50 chrome.test.callbackPass(function(extensions) { | 34 chrome.test.callbackPass(function(extensions) { |
| 51 chrome.test.assertEq(extensions.length, 1); | 35 chrome.test.assertEq(extensions.length, 1); |
| 52 chrome.test.assertEq(chrome.runtime.id, extensions[0].extensionId); | 36 chrome.test.assertEq(chrome.runtime.id, extensions[0].extensionId); |
| 53 chrome.test.assertEq( | 37 chrome.test.assertEq( |
| 54 chrome.runtime.getManifest().name, extensions[0].name); | 38 chrome.runtime.getManifest().name, extensions[0].name); |
| 55 chrome.test.assertTrue(extensions[0].canConfigure); | 39 chrome.test.assertTrue(extensions[0].configurable); |
| 56 chrome.test.assertFalse(extensions[0].canAdd); | 40 chrome.test.assertFalse(extensions[0].multipleMounts); |
| 41 chrome.test.assertEq(chrome.fileSystemProvider.Source.DEVICE, |
| 42 extensions[0].source); |
| 57 })); | 43 })); |
| 58 | 44 |
| 59 chrome.fileManagerPrivate.configureProvidedFileSystem(test_util.volumeId, | 45 chrome.fileManagerPrivate.configureProvidedFileSystem(test_util.volumeId, |
| 60 chrome.test.callbackPass(function() {})); | 46 chrome.test.callbackPass(function() {})); |
| 61 }, | 47 }, |
| 62 | 48 |
| 63 // Verify that chrome.fileManager.configureProvidedFileSystem is well wired | 49 // Verify that chrome.fileManager.configureProvidedFileSystem is well wired |
| 64 // to onConfigureRequested(). | 50 // to onConfigureRequested(). |
| 65 function configureSuccess() { | 51 function configureSuccess() { |
| 66 var configured = false; | 52 var configured = false; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 | 80 |
| 95 chrome.fileManagerPrivate.configureProvidedFileSystem(test_util.volumeId, | 81 chrome.fileManagerPrivate.configureProvidedFileSystem(test_util.volumeId, |
| 96 chrome.test.callbackFail('Failed to complete configuration.')); | 82 chrome.test.callbackFail('Failed to complete configuration.')); |
| 97 }, | 83 }, |
| 98 | 84 |
| 99 ]); | 85 ]); |
| 100 } | 86 } |
| 101 | 87 |
| 102 // Setup and run all of the test cases. | 88 // Setup and run all of the test cases. |
| 103 setUp(runTests); | 89 setUp(runTests); |
| OLD | NEW |