Commit 1aefd75c authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

FilesApp closure compile crostini unittest

Bug: 860355

Change-Id: I73b7eb298cf462c5e981f0cfb3a0132499b0083c
Reviewed-on: https://chromium-review.googlesource.com/c/1312134Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604485}
parent 1f3652ef
......@@ -215,6 +215,5 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, UtilTest) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, Crostini) {
RunTest(base::FilePath(
FILE_PATH_LITERAL("foreground/js/crostini_unittest.html")));
RunGeneratedTest("/foreground/js/crostini_unittest.html");
}
......@@ -217,7 +217,19 @@ js_library("dialog_action_controller") {
}
js_library("crostini") {
deps = []
deps = [
"../../common/js:metrics",
"../../common/js:volume_manager_common",
"//ui/file_manager/externs:volume_manager",
]
}
js_unittest("crostini_unittest") {
deps = [
":crostini",
"../../common/js:mock_entry",
"//ui/webui/resources/js:webui_resource_test",
]
}
js_library("dialog_type") {
......@@ -671,6 +683,7 @@ js_library("webui_command_extender") {
js_unit_tests("unit_tests") {
deps = [
":crostini_unittest",
":thumbnail_loader_unittest",
]
}
......@@ -13,7 +13,7 @@ Crostini.IS_CROSTINI_FILES_ENABLED = false;
/**
* Keep in sync with histograms.xml:FileBrowserCrostiniSharedPathsDepth
* histogram_suffix.
* @private {!Map<VolumeManagerCommon.RootType, string>}
* @type {!Map<VolumeManagerCommon.RootType, string>}
*/
Crostini.VALID_ROOT_TYPES_FOR_SHARE = new Map([
[VolumeManagerCommon.RootType.DOWNLOADS, 'Downloads'],
......@@ -25,7 +25,7 @@ Crostini.VALID_ROOT_TYPES_FOR_SHARE = new Map([
* DriveFS flag is removed.
* Keep in sync with histograms.xml:FileBrowserCrostiniSharedPathsDepth
* histogram_suffix.
* @private {!Map<VolumeManagerCommon.RootType, string>}
* @type {!Map<VolumeManagerCommon.RootType, string>}
*/
Crostini.VALID_DRIVE_FS_ROOT_TYPES_FOR_SHARE = new Map([
[VolumeManagerCommon.RootType.COMPUTERS_GRAND_ROOT, 'DriveComputers'],
......
<!DOCTYPE html>
<!-- Copyright 2018 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.
-->
<script src="../../common/js/mock_entry.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="crostini.js"></script>
<script src="crostini_unittest.js"></script>
......@@ -9,16 +9,16 @@ window.metrics = {
window.loadTimeData = {
data: {'DRIVE_FS_ENABLED': false},
getBoolean: function(key) {
return this.data[key];
return window.loadTimeData.data[key];
}
};
let volumeManagerRootType = 'testroot';
const volumeManager = {
const volumeManager = /** @type {!VolumeManager} */ ({
getLocationInfo: (entry) => {
return {rootType: volumeManagerRootType};
},
};
});
function testIsPathShared() {
const mockFileSystem = new MockFileSystem('volumeId');
......@@ -91,8 +91,8 @@ function testCanSharePath() {
window.loadTimeData.data['DRIVE_FS_ENABLED'] = false;
const disallowed = new Map(Crostini.VALID_DRIVE_FS_ROOT_TYPES_FOR_SHARE);
disallowed['test'] = 'test';
for (let type in disallowed) {
disallowed.set('test', 'test');
for (let type of disallowed.keys()) {
volumeManagerRootType = type;
assertFalse(Crostini.canSharePath(root, true, volumeManager));
assertFalse(Crostini.canSharePath(root, false, volumeManager));
......@@ -111,7 +111,7 @@ function testCanSharePath() {
...Crostini.VALID_ROOT_TYPES_FOR_SHARE,
...Crostini.VALID_DRIVE_FS_ROOT_TYPES_FOR_SHARE
]);
for (let type in allowed) {
for (let type of allowed.keys()) {
volumeManagerRootType = type;
assertTrue(Crostini.canSharePath(root, true, volumeManager));
assertTrue(Crostini.canSharePath(root, false, volumeManager));
......@@ -126,9 +126,13 @@ function testCanSharePath() {
}
}
function task(id) {
return /** @type{!chrome.fileManagerPrivate.FileTask} */ ({taskId: id});
}
function testTaskRequiresSharing() {
assertTrue(Crostini.taskRequiresSharing({taskId: 'app|crostini|open-with'}));
assertTrue(Crostini.taskRequiresSharing(task('app|crostini|open-with')));
assertTrue(
Crostini.taskRequiresSharing({taskId: 'appId|x|install-linux-package'}));
assertFalse(Crostini.taskRequiresSharing({taskId: 'appId|x|open-with'}));
Crostini.taskRequiresSharing(task('appId|x|install-linux-package')));
assertFalse(Crostini.taskRequiresSharing(task('appId|x|open-with')));
}
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