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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/sync_file_system/write_file_then_get_usage/test.js
diff --git a/chrome/test/data/extensions/api_test/sync_file_system/write_file_then_get_usage/test.js b/chrome/test/data/extensions/api_test/sync_file_system/write_file_then_get_usage/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..4813dbdc285dfb07217bac2ed584ff9eae3e7478
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/sync_file_system/write_file_then_get_usage/test.js
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var fileEntry;
+var fileSystem;
+var usageBeforeWrite;
+var testData = "12345";
+
+var testStep = [
+ function () {
+ chrome.syncFileSystem.requestFileSystem('drive', testStep.shift());
+ },
+ // Create empty file.
+ function(fs) {
+ fileSystem = fs;
+ fileSystem.root.getFile('Test.txt', {create: true}, testStep.shift(),
+ errorHandler);
+ },
+ function(entry) {
+ fileEntry = entry;
+ testStep.shift()();
+ },
+ // Record usage before write.
+ function() {
+ chrome.syncFileSystem.getUsageAndQuota(fileSystem, testStep.shift());
+ },
+ function(storageInfo) {
+ usageBeforeWrite = storageInfo.usage_bytes;
+ testStep.shift()();
+ },
+ // Write a known number of bytes.
+ function() {
+ fileEntry.createWriter(testStep.shift(), errorHandler);
+ },
+ function (fileWriter) {
+ fileWriter.onwriteend = function(e) {
+ testStep.shift()();
+ };
+ fileWriter.onerror = function(e) {
+ chrome.test.fail('Write failed: ' + e.toString());
+ };
+ fileWriter.seek(fileWriter.length);
+ var blob = new Blob([testData], {type: "text/plain"});
+ fileWriter.write(blob);
+ },
+ // Check the meta data for updated usage.
+ function() {
+ fileEntry.getMetadata(testStep.shift(), errorHandler);
+ },
+ function (metadata) {
+ chrome.test.assertEq(testData.length, metadata.size);
+ testStep.shift()();
+ },
+ // Check global usage was updated.
+ function() {
+ chrome.syncFileSystem.getUsageAndQuota(fileSystem, testStep.shift());
+ },
+ function(storageInfo) {
+ var usageAfterWrite = storageInfo.usage_bytes;
+ chrome.test.assertEq(testData.length, usageAfterWrite - usageBeforeWrite);
+ chrome.test.succeed();
+ }
+];
+
+function errorHandler() {
+ chrome.test.fail();
+}
+
+chrome.test.runTests([
+ testStep[0]
+]);
+
« 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