| OLD | NEW |
| 1 <script> | 1 <!-- |
| 2 // These have to be sync'd with extension_file_browser_private_apitest.cc | 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this |
| 3 var expectedVolume1 = { | 3 * source code is governed by a BSD-style license that can be found in the |
| 4 devicePath: 'device_path1', | 4 * LICENSE file. |
| 5 mountPath: 'removable/mount_path1', | 5 --> |
| 6 systemPath: 'system_path1', | 6 <script src="test.js"></script> |
| 7 filePath: 'file_path1', | |
| 8 deviceLabel: 'device_label1', | |
| 9 driveLabel: 'drive_label1', | |
| 10 deviceType: 'flash', | |
| 11 totalSize: 1073741824, | |
| 12 isParent: false, | |
| 13 isReadOnly: false, | |
| 14 hasMedia: false, | |
| 15 isOnBootDevice: false | |
| 16 }; | |
| 17 | |
| 18 var expectedVolume2 = { | |
| 19 devicePath: 'device_path2', | |
| 20 mountPath: 'mount_path2', | |
| 21 mountPath: 'removable/mount_path2', | |
| 22 systemPath: 'system_path2', | |
| 23 filePath: 'file_path2', | |
| 24 deviceLabel: 'device_label2', | |
| 25 driveLabel: 'drive_label2', | |
| 26 deviceType: 'hdd', | |
| 27 totalSize: 47723, | |
| 28 isParent: true, | |
| 29 isReadOnly: true, | |
| 30 hasMedia: true, | |
| 31 isOnBootDevice: true | |
| 32 }; | |
| 33 | |
| 34 var expectedVolume3 = { | |
| 35 devicePath: 'device_path3', | |
| 36 mountPath: 'mount_path3', | |
| 37 mountPath: 'removable/mount_path3', | |
| 38 systemPath: 'system_path3', | |
| 39 filePath: 'file_path3', | |
| 40 deviceLabel: 'device_label3', | |
| 41 driveLabel: 'drive_label3', | |
| 42 deviceType: 'optical', | |
| 43 totalSize: 0, | |
| 44 isParent: true, | |
| 45 isReadOnly: false, | |
| 46 hasMedia: false, | |
| 47 isOnBootDevice: true | |
| 48 }; | |
| 49 | |
| 50 function validateVolume(volume, expected) { | |
| 51 for (var key in expected) { | |
| 52 if (volume[key] != expected[key]) { | |
| 53 console.log('Expected "' + key + '" volume property to be: "' + | |
| 54 expected[key] + '"' + ', but got: "' + volume[key] + | |
| 55 '" instead.'); | |
| 56 return false; | |
| 57 } | |
| 58 } | |
| 59 if (Object.keys(expected).length != Object.keys(volume).length) { | |
| 60 console.log("Unexpected property found in returned volume"); | |
| 61 return false; | |
| 62 } | |
| 63 return true; | |
| 64 }; | |
| 65 | |
| 66 chrome.test.runTests([ | |
| 67 function removeMount() { | |
| 68 // The ID of this extension. | |
| 69 var fileBrowserExtensionId = "ddammdhioacbehjngdmkjcjbnfginlla"; | |
| 70 var testFileName = "tmp/test_file.zip"; | |
| 71 var fileUrl = "filesystem:chrome-extension://" + fileBrowserExtensionId + | |
| 72 "/external/" + testFileName; | |
| 73 | |
| 74 chrome.fileBrowserPrivate.removeMount(fileUrl); | |
| 75 | |
| 76 // We actually check this one on C++ side. If MountLibrary.RemoveMount | |
| 77 // doesn't get called, test will fail. | |
| 78 chrome.test.succeed(); | |
| 79 }, | |
| 80 | |
| 81 function getVolumeMetadataValid1() { | |
| 82 chrome.fileBrowserPrivate.getVolumeMetadata( | |
| 83 "device_path1", | |
| 84 chrome.test.callbackPass(function(result) { | |
| 85 chrome.test.assertTrue(validateVolume(result, expectedVolume1), | |
| 86 "getVolumeMetadata result for first volume not as expected"); | |
| 87 })); | |
| 88 }, | |
| 89 | |
| 90 function getVolumeMetadataValid2() { | |
| 91 chrome.fileBrowserPrivate.getVolumeMetadata( | |
| 92 "device_path2", | |
| 93 chrome.test.callbackPass(function(result) { | |
| 94 chrome.test.assertTrue(validateVolume(result, expectedVolume2), | |
| 95 "getVolumeMetadata result for second volume not as expected"); | |
| 96 })); | |
| 97 }, | |
| 98 | |
| 99 function getVolumeMetadataValid3() { | |
| 100 chrome.fileBrowserPrivate.getVolumeMetadata( | |
| 101 "device_path3", | |
| 102 chrome.test.callbackPass(function(result) { | |
| 103 chrome.test.assertTrue(validateVolume(result, expectedVolume3), | |
| 104 "getVolumeMetadata result for third volume not as expected"); | |
| 105 })); | |
| 106 }, | |
| 107 | |
| 108 function getVolumeMetadataNonExistentPath() { | |
| 109 chrome.fileBrowserPrivate.getVolumeMetadata( | |
| 110 "non_existent_device_path", | |
| 111 chrome.test.callbackFail("Device path not found")); | |
| 112 }, | |
| 113 | |
| 114 function getVolumeMetadataBlankPath() { | |
| 115 chrome.fileBrowserPrivate.getVolumeMetadata( | |
| 116 "", | |
| 117 chrome.test.callbackFail("Device path not found")); | |
| 118 } | |
| 119 ]); | |
| 120 </script> | |
| 121 <html> | 7 <html> |
| 122 <body> | 8 <body> |
| 123 FileBrowserMounting tests... | 9 FileBrowserMounting tests... |
| 124 </body> | 10 </body> |
| 125 </html> | 11 </html> |
| OLD | NEW |