| 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 // 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 |
| 11 // Test that we are writable (or not), as expected. |
| 12 chrome.fileSystem.isWritableFileEntry(entry, chrome.test.callbackPass( |
| 13 function(isWritable) { |
| 14 chrome.test.assertEq(isWritable, shouldBeWritable); |
| 15 })); |
| 16 |
| 10 // Test that the file can be read. | 17 // Test that the file can be read. |
| 11 entry.file(chrome.test.callback(function(file) { | 18 entry.file(chrome.test.callback(function(file) { |
| 12 var reader = new FileReader(); | 19 var reader = new FileReader(); |
| 13 reader.onloadend = chrome.test.callbackPass(function(e) { | 20 reader.onloadend = chrome.test.callbackPass(function(e) { |
| 14 if (isNew) | 21 if (isNew) |
| 15 chrome.test.assertEq(reader.result, ""); | 22 chrome.test.assertEq(reader.result, ""); |
| 16 else | 23 else |
| 17 chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0); | 24 chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0); |
| 18 // 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 |
| 19 // |shouldBeWritable|. | 26 // |shouldBeWritable|. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 var blob = new Blob(["HoHoHo!"], {type: "text/plain"}); | 60 var blob = new Blob(["HoHoHo!"], {type: "text/plain"}); |
| 54 fileWriter.write(blob); | 61 fileWriter.write(blob); |
| 55 }); | 62 }); |
| 56 }); | 63 }); |
| 57 reader.onerror = chrome.test.callback(function(e) { | 64 reader.onerror = chrome.test.callback(function(e) { |
| 58 chrome.test.fail("Error reading file contents."); | 65 chrome.test.fail("Error reading file contents."); |
| 59 }); | 66 }); |
| 60 reader.readAsText(file); | 67 reader.readAsText(file); |
| 61 })); | 68 })); |
| 62 } | 69 } |
| OLD | NEW |