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

Side by Side Diff: chrome/test/data/extensions/api_test/sync_file_system/write_file_then_get_usage/test.js

Issue 11368160: Added combined test for Syncable File System to write file and then get that usage gets updated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kinuko Review #2 Created 8 years, 1 month 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/sync_file_system/write_file_then_get_usage/manifest.json ('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 var fileEntry;
6 var usageBeforeWrite;
7 var testData = "12345";
8
9 var testStep = [
10 function () {
11 chrome.syncFileSystem.requestFileSystem('drive', testStep.shift());
12 },
13 // Create empty file.
14 function(fileSystem) {
15 fileSystem.root.getFile('Test.txt', {create: true}, testStep.shift(),
16 errorHandler);
17 },
18 function(entry) {
19 fileEntry = entry;
20 testStep.shift()();
21 },
22 // Record usage before write.
23 function() {
24 chrome.syncFileSystem.getUsageAndQuota('drive', testStep.shift());
25 },
26 function(storageInfo) {
27 usageBeforeWrite = storageInfo.usage_bytes;
28 testStep.shift()();
29 },
30 // Write a known number of bytes.
31 function() {
32 fileEntry.createWriter(testStep.shift(), errorHandler);
33 },
34 function (fileWriter) {
35 fileWriter.onwriteend = function(e) {
36 testStep.shift()();
37 };
38 fileWriter.onerror = function(e) {
39 chrome.test.fail('Write failed: ' + e.toString());
40 };
41 fileWriter.seek(fileWriter.length);
42 var blob = new Blob([testData], {type: "text/plain"});
43 fileWriter.write(blob);
44 },
45 // Check the meta data for updated usage.
46 function() {
47 fileEntry.getMetadata(testStep.shift(), errorHandler);
48 },
49 function (metadata) {
50 chrome.test.assertEq(testData.length, metadata.size);
51 testStep.shift()();
52 },
53 // Check global usage was updated.
54 function() {
55 chrome.syncFileSystem.getUsageAndQuota('drive', testStep.shift());
56 },
57 function(storageInfo) {
58 var usageAfterWrite = storageInfo.usage_bytes;
59 chrome.test.assertEq(testData.length, usageAfterWrite - usageBeforeWrite);
60 chrome.test.succeed();
61 }
62 ];
63
64 function errorHandler() {
65 chrome.test.fail();
66 }
67
68 chrome.test.runTests([
69 chrome.test.callbackPass(testStep[0])
benwells 2012/11/10 10:22:56 Why are you using chrome.test.callbackPass here, t
calvinlo 2012/11/12 04:48:07 Sorry Ben. I'm kinda confused. When I was playing
70 ]);
71
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/sync_file_system/write_file_then_get_usage/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698