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

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: Fix after rebase 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 fileSystem;
7 var usageBeforeWrite;
8 var testData = "12345";
9
10 var testStep = [
11 function () {
12 chrome.syncFileSystem.requestFileSystem('drive', testStep.shift());
13 },
14 // Create empty file.
15 function(fs) {
16 fileSystem = fs;
17 fileSystem.root.getFile('Test.txt', {create: true}, testStep.shift(),
18 errorHandler);
19 },
20 function(entry) {
21 fileEntry = entry;
22 testStep.shift()();
23 },
24 // Record usage before write.
25 function() {
26 chrome.syncFileSystem.getUsageAndQuota(fileSystem, testStep.shift());
27 },
28 function(storageInfo) {
29 usageBeforeWrite = storageInfo.usage_bytes;
30 testStep.shift()();
31 },
32 // Write a known number of bytes.
33 function() {
34 fileEntry.createWriter(testStep.shift(), errorHandler);
35 },
36 function (fileWriter) {
37 fileWriter.onwriteend = function(e) {
38 testStep.shift()();
39 };
40 fileWriter.onerror = function(e) {
41 chrome.test.fail('Write failed: ' + e.toString());
42 };
43 fileWriter.seek(fileWriter.length);
44 var blob = new Blob([testData], {type: "text/plain"});
45 fileWriter.write(blob);
46 },
47 // Check the meta data for updated usage.
48 function() {
49 fileEntry.getMetadata(testStep.shift(), errorHandler);
50 },
51 function (metadata) {
52 chrome.test.assertEq(testData.length, metadata.size);
53 testStep.shift()();
54 },
55 // Check global usage was updated.
56 function() {
57 chrome.syncFileSystem.getUsageAndQuota(fileSystem, testStep.shift());
58 },
59 function(storageInfo) {
60 var usageAfterWrite = storageInfo.usage_bytes;
61 chrome.test.assertEq(testData.length, usageAfterWrite - usageBeforeWrite);
62 chrome.test.succeed();
63 }
64 ];
65
66 function errorHandler() {
67 chrome.test.fail();
68 }
69
70 chrome.test.runTests([
71 testStep[0]
72 ]);
73
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