| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 var mediaGalleries = chrome.mediaGalleries; | 5 var mediaGalleries = chrome.mediaGalleries; |
| 6 | 6 |
| 7 var galleries; | 7 var galleries; |
| 8 var testResults = []; | 8 var testResults = []; |
| 9 var foundGalleryWithEntry = false; | 9 var foundGalleryWithEntry = false; |
| 10 var expectedFileSystems; | 10 var expectedFileSystems; |
| 11 | 11 |
| 12 function checkFinished() { | 12 function checkFinished() { |
| 13 if (testResults.length != galleries.length) | 13 if (testResults.length != galleries.length) |
| 14 return; | 14 return; |
| 15 var success = true; | 15 var success = true; |
| 16 for (var i = 0; i < testResults.length; i++) { | 16 for (var i = 0; i < testResults.length; i++) { |
| 17 if (testResults[i]) { | 17 if (testResults[i]) { |
| 18 success = false; | 18 success = false; |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 if (!foundGalleryWithEntry) { | 21 if (!foundGalleryWithEntry) { |
| 22 testResults.push("Did not find gallery with 1 FileEntry"); | 22 testResults.push("Did not find gallery with 1 FileSystemFileEntry"); |
| 23 success = false; | 23 success = false; |
| 24 } | 24 } |
| 25 if (success) { | 25 if (success) { |
| 26 chrome.test.succeed(); | 26 chrome.test.succeed(); |
| 27 return; | 27 return; |
| 28 } | 28 } |
| 29 chrome.test.fail(testResults); | 29 chrome.test.fail(testResults); |
| 30 } | 30 } |
| 31 | 31 |
| 32 var deleteFileCallback = function(file) { | 32 var deleteFileCallback = function(file) { |
| 33 testResults.push(""); | 33 testResults.push(""); |
| 34 checkFinished(); | 34 checkFinished(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 var deleteFileFailedCallback = function(err) { | 37 var deleteFileFailedCallback = function(err) { |
| 38 testResults.push("Couldn't delete file: " + err.name); | 38 testResults.push("Couldn't delete file: " + err.name); |
| 39 checkFinished(); | 39 checkFinished(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 var mediaFileSystemsDirectoryEntryCallback = function(entries) { | 42 var mediaFileSystemsDirectoryEntryCallback = function(entries) { |
| 43 if (entries.length == 0) { | 43 if (entries.length == 0) { |
| 44 testResults.push(""); | 44 testResults.push(""); |
| 45 } else if (entries.length == 1) { | 45 } else if (entries.length == 1) { |
| 46 if (foundGalleryWithEntry) { | 46 if (foundGalleryWithEntry) { |
| 47 testResults.push("Found multiple galleries with 1 FileEntry"); | 47 testResults.push("Found multiple galleries with 1 FileSystemFileEntry"); |
| 48 } else { | 48 } else { |
| 49 foundGalleryWithEntry = true; | 49 foundGalleryWithEntry = true; |
| 50 entries[0].remove(deleteFileCallback, deleteFileFailedCallback); | 50 entries[0].remove(deleteFileCallback, deleteFileFailedCallback); |
| 51 } | 51 } |
| 52 } else { | 52 } else { |
| 53 testResults.push("Found a gallery with more than 1 FileEntry"); | 53 testResults.push("Found a gallery with more than 1 FileSystemFileEntry"); |
| 54 } | 54 } |
| 55 checkFinished(); | 55 checkFinished(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 var mediaFileSystemsDirectoryErrorCallback = function(err) { | 58 var mediaFileSystemsDirectoryErrorCallback = function(err) { |
| 59 testResults.push("Couldn't read from directory: " + err.name); | 59 testResults.push("Couldn't read from directory: " + err.name); |
| 60 checkFinished(); | 60 checkFinished(); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 var mediaFileSystemsListCallback = function(results) { | 63 var mediaFileSystemsListCallback = function(results) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 for (var i = 0; i < galleries.length; i++) { | 83 for (var i = 0; i < galleries.length; i++) { |
| 84 var dirReader = galleries[i].root.createReader(); | 84 var dirReader = galleries[i].root.createReader(); |
| 85 dirReader.readEntries(mediaFileSystemsDirectoryEntryCallback, | 85 dirReader.readEntries(mediaFileSystemsDirectoryEntryCallback, |
| 86 mediaFileSystemsDirectoryErrorCallback); | 86 mediaFileSystemsDirectoryErrorCallback); |
| 87 } | 87 } |
| 88 }, | 88 }, |
| 89 ]); | 89 ]); |
| 90 }) | 90 }) |
| OLD | NEW |