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
3 // found in the LICENSE file.
5 var mediaGalleries
= chrome
.mediaGalleries
;
9 var foundGalleryWithEntry
= false;
10 var expectedFileSystems
;
12 function checkFinished() {
13 if (testResults
.length
!= galleries
.length
)
16 for (var i
= 0; i
< testResults
.length
; i
++) {
21 if (!foundGalleryWithEntry
) {
22 testResults
.push("Did not find gallery with 1 FileEntry");
26 chrome
.test
.succeed();
29 chrome
.test
.fail(testResults
);
32 var deleteFileCallback = function(file
) {
37 var deleteFileFailedCallback = function(err
) {
38 testResults
.push("Couldn't delete file: " + err
.name
);
42 var mediaFileSystemsDirectoryEntryCallback = function(entries
) {
43 if (entries
.length
== 0) {
45 } else if (entries
.length
== 1) {
46 if (foundGalleryWithEntry
) {
47 testResults
.push("Found multiple galleries with 1 FileEntry");
49 foundGalleryWithEntry
= true;
50 entries
[0].remove(deleteFileCallback
, deleteFileFailedCallback
);
53 testResults
.push("Found a gallery with more than 1 FileEntry");
58 var mediaFileSystemsDirectoryErrorCallback = function(err
) {
59 testResults
.push("Couldn't read from directory: " + err
.name
);
63 var mediaFileSystemsListCallback = function(results
) {
67 chrome
.test
.getConfig(function(config
) {
68 customArg
= JSON
.parse(config
.customArg
);
69 expectedFileSystems
= customArg
[0];
71 chrome
.test
.runTests([
72 function getMediaFileSystems() {
73 mediaGalleries
.getMediaFileSystems(
74 chrome
.test
.callbackPass(mediaFileSystemsListCallback
));
76 function readFileSystemsAndDeleteFile() {
77 chrome
.test
.assertEq(expectedFileSystems
, galleries
.length
);
78 if (expectedFileSystems
== 0) {
79 chrome
.test
.succeed();
83 for (var i
= 0; i
< galleries
.length
; i
++) {
84 var dirReader
= galleries
[i
].root
.createReader();
85 dirReader
.readEntries(mediaFileSystemsDirectoryEntryCallback
,
86 mediaFileSystemsDirectoryErrorCallback
);