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

Side by Side Diff: chrome/test/data/extensions/api_test/file_system/test_util.js

Issue 10914284: Rename chrome.fileSystem apis to be expandable to directories if we wish. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo Created 8 years, 3 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/file_system/save_new_with_write/test_util.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 // This is a duplicate of the file test_util in 5 // This is a duplicate of the file test_util in
6 // chrome/test/data/extensions/api_test/file_system 6 // chrome/test/data/extensions/api_test/file_system
7 7
8 function checkEntry(entry, expectedName, isNew, shouldBeWritable) { 8 function checkEntry(entry, expectedName, isNew, shouldBeWritable) {
9 chrome.test.assertEq(expectedName, entry.name); 9 chrome.test.assertEq(expectedName, entry.name);
10 10
11 // Test that we are writable (or not), as expected. 11 // Test that we are writable (or not), as expected.
12 chrome.fileSystem.isWritableFileEntry(entry, chrome.test.callbackPass( 12 chrome.fileSystem.isWritableEntry(entry, chrome.test.callbackPass(
13 function(isWritable) { 13 function(isWritable) {
14 chrome.test.assertEq(isWritable, shouldBeWritable); 14 chrome.test.assertEq(isWritable, shouldBeWritable);
15 })); 15 }));
16 16
17 // Test that the file can be read. 17 // Test that the file can be read.
18 entry.file(chrome.test.callback(function(file) { 18 entry.file(chrome.test.callback(function(file) {
19 var reader = new FileReader(); 19 var reader = new FileReader();
20 reader.onloadend = chrome.test.callbackPass(function(e) { 20 reader.onloadend = chrome.test.callbackPass(function(e) {
21 if (isNew) 21 if (isNew)
22 chrome.test.assertEq(reader.result, ""); 22 chrome.test.assertEq(reader.result, "");
23 else 23 else
24 chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0); 24 chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0);
25 // Test that we can write to the file, or not, depending on 25 // Test that we can write to the file, or not, depending on
26 // |shouldBeWritable|. 26 // |shouldBeWritable|.
27 entry.createWriter(function(fileWriter) { 27 entry.createWriter(function(fileWriter) {
28 fileWriter.onwriteend = chrome.test.callback(function(e) { 28 fileWriter.onwriteend = chrome.test.callback(function(e) {
29 if (fileWriter.error) { 29 if (fileWriter.error) {
30 if (shouldBeWritable) { 30 if (shouldBeWritable) {
31 chrome.test.fail("Error writing to file: " + 31 chrome.test.fail("Error writing to file: " +
32 fileWriter.error.toString()); 32 fileWriter.error.toString());
33 } else { 33 } else {
34 chrome.test.succeed(); 34 chrome.test.succeed();
35 } 35 }
36 } else { 36 } else {
37 if (shouldBeWritable) { 37 if (shouldBeWritable) {
38 // Get a new entry and check the data got to disk. 38 // Get a new entry and check the data got to disk.
39 chrome.fileSystem.chooseFile(chrome.test.callbackPass( 39 chrome.fileSystem.chooseEntry(chrome.test.callbackPass(
40 function(readEntry) { 40 function(readEntry) {
41 readEntry.file(chrome.test.callback(function(readFile) { 41 readEntry.file(chrome.test.callback(function(readFile) {
42 var readReader = new FileReader(); 42 var readReader = new FileReader();
43 readReader.onloadend = function(e) { 43 readReader.onloadend = function(e) {
44 chrome.test.assertEq(readReader.result.indexOf("HoHoHo!"), 44 chrome.test.assertEq(readReader.result.indexOf("HoHoHo!"),
45 0); 45 0);
46 chrome.test.succeed(); 46 chrome.test.succeed();
47 }; 47 };
48 readReader.onerror = function(e) { 48 readReader.onerror = function(e) {
49 chrome.test.fail("Failed to read file after write."); 49 chrome.test.fail("Failed to read file after write.");
(...skipping 10 matching lines...) Expand all
60 var blob = new Blob(["HoHoHo!"], {type: "text/plain"}); 60 var blob = new Blob(["HoHoHo!"], {type: "text/plain"});
61 fileWriter.write(blob); 61 fileWriter.write(blob);
62 }); 62 });
63 }); 63 });
64 reader.onerror = chrome.test.callback(function(e) { 64 reader.onerror = chrome.test.callback(function(e) {
65 chrome.test.fail("Error reading file contents."); 65 chrome.test.fail("Error reading file contents.");
66 }); 66 });
67 reader.readAsText(file); 67 reader.readAsText(file);
68 })); 68 }));
69 } 69 }
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/file_system/save_new_with_write/test_util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698