Commit 2cc9b571 authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Closure compile duplicate_finder_unittest.

Bug: 905932
Change-Id: Iaeb47847d3d631bd7c2633c2b8298b83e0a81e45
Reviewed-on: https://chromium-review.googlesource.com/c/1348883
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610518}
parent dac8daaa
...@@ -89,8 +89,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, TaskQueueTest) { ...@@ -89,8 +89,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, TaskQueueTest) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DuplicateFinderTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DuplicateFinderTest) {
RunTest(base::FilePath( RunGeneratedTest("/background/js/duplicate_finder_unittest.html");
FILE_PATH_LITERAL("background/js/duplicate_finder_unittest.html")));
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) {
......
...@@ -177,6 +177,17 @@ js_library("duplicate_finder") { ...@@ -177,6 +177,17 @@ js_library("duplicate_finder") {
] ]
} }
js_unittest("duplicate_finder_unittest") {
deps = [
":duplicate_finder",
":mock_volume_manager",
":test_import_history",
"//ui/file_manager/base/js:mock_chrome",
"//ui/file_manager/file_manager/common/js:mock_entry",
"//ui/file_manager/file_manager/common/js:test_importer_common",
]
}
js_library("entry_location_impl") { js_library("entry_location_impl") {
deps = [ deps = [
"//ui/file_manager/base/js:volume_manager_types", "//ui/file_manager/base/js:volume_manager_types",
...@@ -395,6 +406,7 @@ js_library("volume_manager_util") { ...@@ -395,6 +406,7 @@ js_library("volume_manager_util") {
js_unit_tests("unit_tests") { js_unit_tests("unit_tests") {
deps = [ deps = [
":crostini_unittest", ":crostini_unittest",
":duplicate_finder_unittest",
":import_history_unittest", ":import_history_unittest",
":media_scanner_unittest", ":media_scanner_unittest",
":volume_manager_unittest", ":volume_manager_unittest",
......
<!DOCTYPE html>
<!-- Copyright 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.
-->
<html>
<body>
<script src="../../../../../ui/webui/resources/js/cr.js"></script>
<script src="../../../../../ui/webui/resources/js/assert.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/event_target.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/ui/array_data_model.js"></script>
<script src="../../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="../../common/js/async_util.js"></script>
<script src="../../common/js/lru_cache.js"></script>
<script src="../../common/js/mock_entry.js"></script>
<script src="../../common/js/test_tracker.js"></script>
<script src="../../../base/js/test_error_reporting.js"></script>
<script src="../../../base/js/mock_chrome.js"></script>
<script src="../../common/js/unittest_util.js"></script>
<script src="../../common/js/files_app_entry_types.js"></script>
<script src="../../common/js/util.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../common/js/progress_center_common.js"></script>
<script src="metadata_proxy.js"></script>
<script src="entry_location_impl.js"></script>
<script src="test_import_history.js"></script>
<script src="import_history.js"></script>
<script src="duplicate_finder.js"></script>
<script src="volume_info_impl.js"></script>
<script src="volume_info_list_impl.js"></script>
<script src="volume_manager_factory.js"></script>
<script src="volume_manager_impl.js"></script>
<script src="volume_manager_util.js"></script>
<script src="mock_volume_manager.js"></script>
<script src="duplicate_finder_unittest.js"></script>
</body>
</html>
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/** @type {!importer.DuplicateFinder} */ /** @type {!importer.DriveDuplicateFinder} */
var duplicateFinder; var duplicateFinder;
/** @type {!VolumeInfo} */ /** @type {VolumeInfo} */
var drive; var drive;
/** /**
...@@ -26,8 +26,7 @@ var fileSystem; ...@@ -26,8 +26,7 @@ var fileSystem;
/** @type {!importer.TestImportHistory} */ /** @type {!importer.TestImportHistory} */
var testHistory; var testHistory;
/** @type {function(!FileEntry, !importer.Destination): /** @type {importer.DispositionChecker.CheckerFunction} */
!importer.Disposition} */
var getDisposition; var getDisposition;
// Set up string assets. // Set up string assets.
...@@ -44,16 +43,7 @@ window.metrics = { ...@@ -44,16 +43,7 @@ window.metrics = {
}; };
function setUp() { function setUp() {
new MockCommandLinePrivate(); let mockChrome = {
// importer.setupTestLogger();
fileSystem = new MockFileSystem('fake-filesystem');
var volumeManager = new MockVolumeManager();
drive = volumeManager.getCurrentProfileVolumeInfo(
VolumeManagerCommon.VolumeType.DRIVE);
MockVolumeManager.installMockSingleton(volumeManager);
chrome = {
fileManagerPrivate: { fileManagerPrivate: {
/** /**
* @param {!Entry} entry * @param {!Entry} entry
...@@ -75,13 +65,23 @@ function setUp() { ...@@ -75,13 +65,23 @@ function setUp() {
result[hash] = fileUrls[hash] || []; result[hash] = fileUrls[hash] || [];
}); });
callback(result); callback(result);
} },
}, },
runtime: { runtime: {lastError: null},
lastError: null
}
}; };
installMockChrome(mockChrome);
new MockCommandLinePrivate();
// importer.setupTestLogger();
fileSystem = new MockFileSystem('fake-filesystem');
var volumeManager = new MockVolumeManager();
drive = volumeManager.getCurrentProfileVolumeInfo(
VolumeManagerCommon.VolumeType.DRIVE);
assertTrue(drive != null);
MockVolumeManager.installMockSingleton(volumeManager);
testHistory = new importer.TestImportHistory(); testHistory = new importer.TestImportHistory();
duplicateFinder = new importer.DriveDuplicateFinder(); duplicateFinder = new importer.DriveDuplicateFinder();
getDisposition = importer.DispositionChecker.createChecker(testHistory); getDisposition = importer.DispositionChecker.createChecker(testHistory);
...@@ -111,7 +111,7 @@ function testCheckDuplicateFalse(callback) { ...@@ -111,7 +111,7 @@ function testCheckDuplicateFalse(callback) {
// Make another file. // Make another file.
var newFilePath = '/bar.txt'; var newFilePath = '/bar.txt';
fileSystem.populate([newFilePath]); fileSystem.populate([newFilePath]);
var newFile = fileSystem.entries[newFilePath]; var newFile = /** @type {!FileEntry} */ (fileSystem.entries[newFilePath]);
reportPromise( reportPromise(
duplicateFinder.isDuplicate(newFile) duplicateFinder.isDuplicate(newFile)
...@@ -128,13 +128,12 @@ function testDispositionChecker_ContentDupe(callback) { ...@@ -128,13 +128,12 @@ function testDispositionChecker_ContentDupe(callback) {
var files = setupHashes(filePaths, fileHashes); var files = setupHashes(filePaths, fileHashes);
reportPromise( reportPromise(
getDisposition(files[0], importer.Destination.GOOGLE_DRIVE) getDisposition(
.then( files[0], importer.Destination.GOOGLE_DRIVE,
function(disposition) { importer.ScanMode.CONTENT)
assertEquals( .then(function(disposition) {
importer.Disposition.CONTENT_DUPLICATE, assertEquals(importer.Disposition.CONTENT_DUPLICATE, disposition);
disposition); }),
}),
callback); callback);
} }
...@@ -147,13 +146,12 @@ function testDispositionChecker_HistoryDupe(callback) { ...@@ -147,13 +146,12 @@ function testDispositionChecker_HistoryDupe(callback) {
[importer.Destination.GOOGLE_DRIVE]; [importer.Destination.GOOGLE_DRIVE];
reportPromise( reportPromise(
getDisposition(files[0], importer.Destination.GOOGLE_DRIVE) getDisposition(
.then( files[0], importer.Destination.GOOGLE_DRIVE,
function(disposition) { importer.ScanMode.CONTENT)
assertEquals( .then(function(disposition) {
importer.Disposition.HISTORY_DUPLICATE, assertEquals(importer.Disposition.HISTORY_DUPLICATE, disposition);
disposition); }),
}),
callback); callback);
} }
...@@ -164,14 +162,14 @@ function testDispositionChecker_Original(callback) { ...@@ -164,14 +162,14 @@ function testDispositionChecker_Original(callback) {
var newFilePath = '/bar.txt'; var newFilePath = '/bar.txt';
fileSystem.populate([newFilePath]); fileSystem.populate([newFilePath]);
var newFile = fileSystem.entries[newFilePath]; var newFile = /** @type {!FileEntry} */ (fileSystem.entries[newFilePath]);
reportPromise( reportPromise(
getDisposition(newFile, importer.Destination.GOOGLE_DRIVE) getDisposition(
.then( newFile, importer.Destination.GOOGLE_DRIVE, importer.ScanMode.CONTENT)
function(disposition) { .then(function(disposition) {
assertEquals(importer.Disposition.ORIGINAL, disposition); assertEquals(importer.Disposition.ORIGINAL, disposition);
}), }),
callback); callback);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment