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

Unified Diff: chrome/test/data/extensions/api_test/file_system/open_existing/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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/file_system/open_existing/test.js
diff --git a/chrome/test/data/extensions/api_test/file_system/open_existing/test.js b/chrome/test/data/extensions/api_test/file_system/open_existing/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0cb41e9dcaa1da57a7c8b69b1af50ba22975289e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/file_system/open_existing/test.js
@@ -0,0 +1,33 @@
+// 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.
+
+chrome.test.runTests([
+ function openFile() {
+ chrome.fileSystem.chooseFile(chrome.test.callbackPass(function(entry) {
+ chrome.test.assertEq('open_existing.txt', entry.name);
+ // Test that the file can be read.
+ entry.file(chrome.test.callback(function(file) {
+ var reader = new FileReader();
+ reader.onloadend = chrome.test.callback(function(e) {
+ chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0);
+ // Test that we cannot write to the file.
+ entry.createWriter(chrome.test.callback(function(fileWriter) {
+ fileWriter.onwriteend = chrome.test.callback(function(e) {
+ if (fileWriter.error)
+ chrome.test.succeed();
+ else
+ chrome.test.fail("No error while writing without write access");
+ });
+ var blob = new Blob(['HoHoHo!'], {type: 'text/plain'});
+ fileWriter.write(blob);
+ }));
+ });
+ reader.onerror = chrome.test.callback(function(e) {
+ chrome.test.fail("Error reading file contents.");
+ });
+ reader.readAsText(file);
+ }));
+ }));
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698