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