| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 expectedGalleryEntryLength = 306; // hard-coded size of ../common/test.jpg | 10 var expectedFileSystems; |
| 11 var expectedGalleryEntryLength; |
| 11 | 12 |
| 12 function checkFinished() { | 13 function checkFinished() { |
| 13 if (testResults.length != galleries.length) | 14 if (testResults.length != galleries.length) |
| 14 return; | 15 return; |
| 15 var success = true; | 16 var success = true; |
| 16 for (var i = 0; i < testResults.length; i++) { | 17 for (var i = 0; i < testResults.length; i++) { |
| 17 if (testResults[i]) { | 18 if (testResults[i]) { |
| 18 success = false; | 19 success = false; |
| 19 } | 20 } |
| 20 } | 21 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 testResults.push("Found a gallery with more than 1 FileEntry"); | 70 testResults.push("Found a gallery with more than 1 FileEntry"); |
| 70 } | 71 } |
| 71 checkFinished(); | 72 checkFinished(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 var mediaFileSystemsDirectoryErrorCallback = function(err) { | 75 var mediaFileSystemsDirectoryErrorCallback = function(err) { |
| 75 testResults.push("Couldn't read from directory: " + err); | 76 testResults.push("Couldn't read from directory: " + err); |
| 76 checkFinished(); | 77 checkFinished(); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 function testGalleries(expectedFileSystems) { | |
| 80 chrome.test.assertEq(expectedFileSystems, galleries.length); | |
| 81 if (expectedFileSystems == 0) { | |
| 82 chrome.test.succeed(); | |
| 83 return; | |
| 84 } | |
| 85 | |
| 86 for (var i = 0; i < galleries.length; i++) { | |
| 87 var dirReader = galleries[i].root.createReader(); | |
| 88 dirReader.readEntries(mediaFileSystemsDirectoryEntryCallback, | |
| 89 mediaFileSystemsDirectoryErrorCallback); | |
| 90 } | |
| 91 }; | |
| 92 | |
| 93 var mediaFileSystemsListCallback = function(results) { | 80 var mediaFileSystemsListCallback = function(results) { |
| 94 galleries = results; | 81 galleries = results; |
| 95 }; | 82 }; |
| 96 | 83 |
| 97 chrome.test.runTests([ | 84 chrome.test.getConfig(function(config) { |
| 98 function mediaGalleriesReadAccess() { | 85 customArg = JSON.parse(config.customArg); |
| 99 mediaGalleries.getMediaFileSystems( | 86 expectedFileSystems = customArg[0]; |
| 100 chrome.test.callbackPass(mediaFileSystemsListCallback)); | 87 expectedGalleryEntryLength = customArg[1]; |
| 101 }, | 88 |
| 102 ]); | 89 chrome.test.runTests([ |
| 90 function getMediaFileSystems() { |
| 91 mediaGalleries.getMediaFileSystems( |
| 92 chrome.test.callbackPass(mediaFileSystemsListCallback)); |
| 93 }, |
| 94 function readFileSystems() { |
| 95 chrome.test.assertEq(expectedFileSystems, galleries.length); |
| 96 if (expectedFileSystems == 0) { |
| 97 chrome.test.succeed(); |
| 98 return; |
| 99 } |
| 100 |
| 101 for (var i = 0; i < galleries.length; i++) { |
| 102 var dirReader = galleries[i].root.createReader(); |
| 103 dirReader.readEntries(mediaFileSystemsDirectoryEntryCallback, |
| 104 mediaFileSystemsDirectoryErrorCallback); |
| 105 } |
| 106 }, |
| 107 ]); |
| 108 }) |
| OLD | NEW |