| 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);
|
| + }
|
| + ]);
|
| + });
|
|
|