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

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

Issue 10663014: Add tests for chrome.fileSystem app API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added licenses to js files Created 8 years, 6 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/test.html ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 chrome.test.runTests([
6 function saveFile() {
7 chrome.fileSystem.chooseFile({type: 'saveFile'}, chrome.test.callbackPass(
8 function(entry) {
9 chrome.test.assertEq('save_new.txt', entry.name);
10 // Test that the file can be read but has nothing in it.
11 entry.file(chrome.test.callback(function(file) {
12 var reader = new FileReader();
13 reader.onloadend = chrome.test.callbackPass(function(e) {
14 chrome.test.assertEq(reader.result, "");
15 // Test that we can write to the file.
16 entry.createWriter(function(fileWriter) {
17 fileWriter.onwriteend = chrome.test.callback(function(e) {
18 if (fileWriter.error) {
19 chrome.test.fail("Error writing to file: " +
20 fileWriter.error.toString());
21 } else {
22 // Get a new entry and check the data got to disk.
23 chrome.fileSystem.chooseFile(chrome.test.callbackPass(
24 function(readEntry) {
25 readEntry.file(chrome.test.callback(function(readFile) {
26 var readReader = new FileReader();
27 readReader.onloadend = function(e) {
28 chrome.test.assertEq(readReader.result.indexOf("HoHoHo!"),
29 0);
30 chrome.test.succeed();
31 };
32 readReader.onerror = function(e) {
33 chrome.test.fail('Failed to read file after write.');
34 };
35 readReader.readAsText(readFile);
36 }));
37 }));
38 }
39 });
40 var blob = new Blob(['HoHoHo!'], {type: 'text/plain'});
41 fileWriter.write(blob);
42 });
43 });
44 reader.onerror = chrome.test.callback(function(e) {
45 chrome.test.fail("Error reading file contents.");
46 });
47 reader.readAsText(file);
48 }));
49 }));
50 }
51 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/file_system/save_new/test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698