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) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DuplicateFinderTest) {
RunTest(base::FilePath(
FILE_PATH_LITERAL("background/js/duplicate_finder_unittest.html")));
RunGeneratedTest("/background/js/duplicate_finder_unittest.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) {
......
......@@ -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") {
deps = [
"//ui/file_manager/base/js:volume_manager_types",
......@@ -395,6 +406,7 @@ js_library("volume_manager_util") {
js_unit_tests("unit_tests") {
deps = [
":crostini_unittest",
":duplicate_finder_unittest",
":import_history_unittest",
":media_scanner_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 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @type {!importer.DuplicateFinder} */
/** @type {!importer.DriveDuplicateFinder} */
var duplicateFinder;
/** @type {!VolumeInfo} */
/** @type {VolumeInfo} */
var drive;
/**
......@@ -26,8 +26,7 @@ var fileSystem;
/** @type {!importer.TestImportHistory} */
var testHistory;
/** @type {function(!FileEntry, !importer.Destination):
!importer.Disposition} */
/** @type {importer.DispositionChecker.CheckerFunction} */
var getDisposition;
// Set up string assets.
......@@ -44,16 +43,7 @@ window.metrics = {
};
function setUp() {
new MockCommandLinePrivate();
// importer.setupTestLogger();
fileSystem = new MockFileSystem('fake-filesystem');
var volumeManager = new MockVolumeManager();
drive = volumeManager.getCurrentProfileVolumeInfo(
VolumeManagerCommon.VolumeType.DRIVE);
MockVolumeManager.installMockSingleton(volumeManager);
chrome = {
let mockChrome = {
fileManagerPrivate: {
/**
* @param {!Entry} entry
......@@ -75,13 +65,23 @@ function setUp() {
result[hash] = fileUrls[hash] || [];
});
callback(result);
}
},
runtime: {
lastError: null
}
},
runtime: {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();
duplicateFinder = new importer.DriveDuplicateFinder();
getDisposition = importer.DispositionChecker.createChecker(testHistory);
......@@ -111,7 +111,7 @@ function testCheckDuplicateFalse(callback) {
// Make another file.
var newFilePath = '/bar.txt';
fileSystem.populate([newFilePath]);
var newFile = fileSystem.entries[newFilePath];
var newFile = /** @type {!FileEntry} */ (fileSystem.entries[newFilePath]);
reportPromise(
duplicateFinder.isDuplicate(newFile)
......@@ -128,12 +128,11 @@ function testDispositionChecker_ContentDupe(callback) {
var files = setupHashes(filePaths, fileHashes);
reportPromise(
getDisposition(files[0], importer.Destination.GOOGLE_DRIVE)
.then(
function(disposition) {
assertEquals(
importer.Disposition.CONTENT_DUPLICATE,
disposition);
getDisposition(
files[0], importer.Destination.GOOGLE_DRIVE,
importer.ScanMode.CONTENT)
.then(function(disposition) {
assertEquals(importer.Disposition.CONTENT_DUPLICATE, disposition);
}),
callback);
}
......@@ -147,12 +146,11 @@ function testDispositionChecker_HistoryDupe(callback) {
[importer.Destination.GOOGLE_DRIVE];
reportPromise(
getDisposition(files[0], importer.Destination.GOOGLE_DRIVE)
.then(
function(disposition) {
assertEquals(
importer.Disposition.HISTORY_DUPLICATE,
disposition);
getDisposition(
files[0], importer.Destination.GOOGLE_DRIVE,
importer.ScanMode.CONTENT)
.then(function(disposition) {
assertEquals(importer.Disposition.HISTORY_DUPLICATE, disposition);
}),
callback);
}
......@@ -164,12 +162,12 @@ function testDispositionChecker_Original(callback) {
var newFilePath = '/bar.txt';
fileSystem.populate([newFilePath]);
var newFile = fileSystem.entries[newFilePath];
var newFile = /** @type {!FileEntry} */ (fileSystem.entries[newFilePath]);
reportPromise(
getDisposition(newFile, importer.Destination.GOOGLE_DRIVE)
.then(
function(disposition) {
getDisposition(
newFile, importer.Destination.GOOGLE_DRIVE, importer.ScanMode.CONTENT)
.then(function(disposition) {
assertEquals(importer.Disposition.ORIGINAL, disposition);
}),
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