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

Unified Diff: chrome/test/data/extensions/api_test/file_browser/content_checksum_test/test.js

Issue 840843002: Expose computation of md5 content checksums for files via a file manager private API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync with master. Created 5 years, 11 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_browser/content_checksum_test/test.js
diff --git a/chrome/test/data/extensions/api_test/file_browser/content_checksum_test/test.js b/chrome/test/data/extensions/api_test/file_browser/content_checksum_test/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..3e3c34e025aaf9f3c56c6f5cd4f0ded71d7be343
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/file_browser/content_checksum_test/test.js
@@ -0,0 +1,54 @@
+// Copyright (c) 2015 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.
+
+/**
+ * The test file system should be created and populated before running the test
+ * extension.
+ *
+ * The only file used right now is <root>/test_dir/test_file.txt.
+ */
+
+// This is a golden value computed using the md5sum command line tool.
+var kExpectedHash = 'a3dfffb5a580272fb8986611a9dbd166';
+
+function getTestFilesystem() {
+ return new Promise(function(resolve, reject) {
+ chrome.fileManagerPrivate.getVolumeMetadataList(
+ function(volumeMetadataList) {
+ var testVolume = volumeMetadataList.filter(function(volume) {
+ return volume.volumeType === 'testing';
+ })[0];
+
+ chrome.fileManagerPrivate.requestFileSystem(
+ testVolume.volumeId,
+ function(fileSystem) {
+ if (!fileSystem) {
+ reject(new Error('Failed to acquire the testing volume.'));
+ }
+ resolve(fileSystem);
+ });
+ });
+ });
+}
+
+// Run the tests.
+getTestFilesystem().then(
+ function(fileSystem) {
+ chrome.test.runTests([
+ // Checks the checksum code using a golden file.
+ function testGoldenChecksum() {
+ fileSystem.root.getFile(
+ 'test_dir/test_file.txt',
+ {create: false},
+ function(entry) {
+ chrome.fileManagerPrivate.computeChecksum(
+ entry.toURL(),
+ chrome.test.callbackPass(function(result) {
+ chrome.test.assertEq(kExpectedHash, result);
+ }));
+ },
+ chrome.test.fail);
+ }
+ ]);
+ });

Powered by Google App Engine
This is Rietveld 408576698