Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/test/data/extensions/api_test/media_galleries/read_access/test.js

Issue 24242010: Media Galleries: Refactor test to not need RunSecondPhase(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/api_test/media_galleries/no_access/test.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 })
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/media_galleries/no_access/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698