Commit c1ee9186 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

CrOS Files: Move volume_manager_common to file_manager/base/js/volume_manager_types

Also add a unit test to seed the base folder for testing.

Bug: 879035
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I031545c083f7dab84a1d0605cda16fc02f7367b6
Reviewed-on: https://chromium-review.googlesource.com/c/1306959
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605224}
parent 0d633b3b
// 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.
#include "chrome/browser/chromeos/file_manager/file_manager_jstest_base.h"
class FileManagerBaseJsTest : public FileManagerJsTestBase {
protected:
FileManagerBaseJsTest()
: FileManagerJsTestBase(
base::FilePath(FILE_PATH_LITERAL("ui/file_manager/base/js"))) {}
};
IN_PROC_BROWSER_TEST_F(FileManagerBaseJsTest, VolumeManagerTypesTest) {
RunGeneratedTest("/volume_manager_types_unittest.html");
}
......@@ -1638,6 +1638,7 @@ test("browser_tests") {
"../browser/chromeos/extensions/wallpaper_private_apitest.cc",
"../browser/chromeos/file_manager/audio_player_browsertest.cc",
"../browser/chromeos/file_manager/external_filesystem_apitest.cc",
"../browser/chromeos/file_manager/file_manager_base_jstest.cc",
"../browser/chromeos/file_manager/file_manager_browsertest.cc",
"../browser/chromeos/file_manager/file_manager_browsertest_base.cc",
"../browser/chromeos/file_manager/file_manager_browsertest_base.h",
......
......@@ -56,6 +56,7 @@ group("closure_compile") {
group("unit_test_data") {
testonly = true
deps = [
"base/js:unit_tests",
"file_manager/background/js:unit_tests",
"file_manager/common/js:unit_tests",
"file_manager/foreground/js:unit_tests",
......
......@@ -25,7 +25,7 @@ if (!('allowsEval' in document.securityPolicy))
// <include src="../../file_manager/common/js/async_util.js">
// <include src="../../file_manager/common/js/file_type.js">
// <include src="../../file_manager/common/js/util.js">
// <include src="../../file_manager/common/js/volume_manager_common.js">
// <include src="../../base/js/volume_manager_types.js">
// <include src="../../base/js/filtered_volume_manager.js">
// <include src="../../file_manager/foreground/js/metadata/content_metadata_provider.js">
......
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/closure_compiler/js_unit_tests.gni")
visibility = [ "//ui/file_manager/*" ]
......@@ -34,11 +35,11 @@ js_library("error_counter") {
js_library("filtered_volume_manager") {
deps = [
"//ui/file_manager/base/js:volume_manager_types",
"//ui/file_manager/externs:file_manager_private",
"//ui/file_manager/externs:volume_manager",
"//ui/file_manager/file_manager/common/js:async_util",
"//ui/file_manager/file_manager/common/js:files_app_entry_types",
"//ui/file_manager/file_manager/common/js:volume_manager_common",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js/cr/ui:array_data_model",
]
......@@ -58,3 +59,22 @@ js_library("test_error_reporting") {
"//ui/webui/resources/js:webui_resource_test",
]
}
js_library("volume_manager_types") {
deps = [
"//ui/webui/resources/js:assert",
]
}
js_unittest("volume_manager_types_unittest") {
deps = [
":volume_manager_types",
"//ui/webui/resources/js:webui_resource_test",
]
}
js_unit_tests("unit_tests") {
deps = [
":volume_manager_types_unittest",
]
}
......@@ -363,10 +363,10 @@ VolumeManagerCommon.getMediaViewRootTypeFromVolumeId = function(volumeId) {
};
/**
* An event name trigerred when a user tries to mount the volume which is
* already mounted. The event object must have a volumeId property.
* @const {string}
*/
* An event name trigerred when a user tries to mount the volume which is
* already mounted. The event object must have a volumeId property.
* @const {string}
*/
VolumeManagerCommon.VOLUME_ALREADY_MOUNTED = 'volume_already_mounted';
VolumeManagerCommon.TEAM_DRIVES_DIRECTORY_NAME = 'team_drives';
......
// 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.
// Test that every volumeType has a rootType, and that it maps back to the same
// volumeType.
function testRootTypeFromVolumeTypeBijection() {
Object.keys(VolumeManagerCommon.VolumeType).forEach((key) => {
const volumeType = VolumeManagerCommon.VolumeType[key];
assertTrue(volumeType !== undefined);
// The enum is decorated with an isNative() helper. Skip it for the purposes
// of this test, since it is not a valid enum value. (This helper breaks the
// ability to iterate over enum values, so should probably be removed).
if (volumeType === VolumeManagerCommon.VolumeType.isNative)
return;
const rootType = VolumeManagerCommon.getRootTypeFromVolumeType(volumeType);
assertTrue(
volumeType == VolumeManagerCommon.getVolumeTypeFromRootType(rootType));
});
}
// Test that all rootType have a corresponding volumeType, except for "fake"
// root types that do not have a volume of their own.
function testEveryRootTypeHasAVolumeType() {
Object.keys(VolumeManagerCommon.RootType).forEach((key) => {
const rootType = VolumeManagerCommon.RootType[key];
assertTrue(rootType !== undefined);
// The "Recent" view and "Google Drive" parent entry are not handled in the
// switch because they do not have a corresponding volume.
// TODO(tapted): Validate this against util.isFakeEntry(..) when
// files_app_entry_types is moved to file_manager/base.
if (rootType === VolumeManagerCommon.RootType.RECENT ||
rootType === VolumeManagerCommon.RootType.DRIVE_FAKE_ROOT) {
return;
}
const volumeType = VolumeManagerCommon.getVolumeTypeFromRootType(rootType);
assertTrue(volumeType !== undefined);
});
}
......@@ -33,7 +33,7 @@ js_library("volume_manager") {
sources = []
# Encapsulate volume_manager.js and its dependencies. Note this should really
# depend on volume_manager_common.js as well, but that's not an extern.
# depend on volume_manager_types.js as well, but that's not an extern.
externs_list = [
"entry_location.js",
"volume_info.js",
......
......@@ -108,7 +108,7 @@ js_library("background") {
"../../common/js:files_app_entry_types",
"../../common/js:metrics",
"../../common/js:util",
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......@@ -151,7 +151,7 @@ js_library("duplicate_finder") {
js_library("entry_location_impl") {
deps = [
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
externs_list = [ "../../../externs/entry_location.js" ]
}
......@@ -274,7 +274,7 @@ js_library("test_util_base") {
js_library("volume_info_impl") {
deps = [
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
externs_list = [ "../../../externs/volume_info.js" ]
}
......@@ -321,7 +321,7 @@ js_library("volume_manager_util") {
"../../common/js:metrics",
"../../common/js:metrics_events",
"../../common/js:util",
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......
......@@ -15,7 +15,7 @@
// <include src="../../common/js/metrics_base.js">
// <include src="../../common/js/files_app_entry_types.js">
// <include src="../../common/js/util.js">
// <include src="../../common/js/volume_manager_common.js">
// <include src="../../../base/js/volume_manager_types.js">
// <include src="app_window_wrapper.js">
// <include src="app_windows.js">
// <include src="background_base.js">
......
......@@ -19,7 +19,7 @@
<script src="../../../base/js/mock_chrome.js"></script>
<script src="../../common/js/unittest_util.js"></script>
<script src="../../common/js/mock_entry.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../common/js/files_app_entry_types.js"></script>
<script src="../../common/js/util.js"></script>
......
......@@ -21,7 +21,7 @@
<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="../../common/js/volume_manager_common.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>
......
......@@ -9,7 +9,7 @@
<script src="../../../../../third_party/analytics/google-analytics-bundle.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../common/js/lru_cache.js"></script>
<script src="../../common/js/test_importer_common.js"></script>
......
......@@ -22,7 +22,7 @@
<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="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../common/js/test_importer_common.js"></script>
<script src="../../common/js/progress_center_common.js"></script>
......
......@@ -11,7 +11,7 @@
<script src="../../../../../ui/webui/resources/js/cr/event_target.js"></script>
<script src="../../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/file_type.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../common/js/lru_cache.js"></script>
......
......@@ -10,7 +10,7 @@
<script src="../../../../../ui/webui/resources/js/assert.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/event_target.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../../base/js/test_error_reporting.js"></script>
<script src="task_queue.js"></script>
......
......@@ -30,7 +30,7 @@ js_type_check("closure_compile_module") {
":mock_entry",
":progress_center_common",
":util",
":volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......@@ -63,15 +63,15 @@ js_unittest("files_app_entry_types_unittest") {
deps = [
":files_app_entry_types",
":util",
":volume_manager_common",
"//ui/file_manager/base/js:test_error_reporting",
"//ui/file_manager/base/js:volume_manager_types",
]
}
js_library("file_type") {
deps = [
":files_app_entry_types",
":volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......@@ -83,8 +83,8 @@ js_library("importer_common") {
visibility = [ "//ui/file_manager/file_manager/*" ]
deps = [
":file_type",
":volume_manager_common",
"../../../externs:volume_manager",
"//ui/file_manager/base/js:volume_manager_types",
]
externs_list = [
"//third_party/analytics/externs.js",
......@@ -172,8 +172,8 @@ js_unittest("unittest_util") {
js_library("util") {
deps = [
":files_app_entry_types",
":volume_manager_common",
"../../../externs:file_manager_private",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:util",
"//ui/webui/resources/js/cr:event_target",
......@@ -195,12 +195,6 @@ js_unittest("util_unittest") {
]
}
js_library("volume_manager_common") {
deps = [
"//ui/webui/resources/js:assert",
]
}
js_unit_tests("unit_tests") {
deps = [
":async_util_unittest",
......
......@@ -193,8 +193,8 @@ js_library("app_state_controller") {
js_library("column_visibility_controller") {
deps = [
":directory_model",
"../../common/js:volume_manager_common",
"ui:file_manager_ui",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......@@ -219,7 +219,7 @@ js_library("dialog_action_controller") {
js_library("crostini") {
deps = [
"../../common/js:metrics",
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/file_manager/externs:volume_manager",
]
}
......@@ -242,8 +242,8 @@ js_library("directory_contents") {
"../../common/js:async_util",
"../../common/js:metrics",
"../../common/js:util",
"../../common/js:volume_manager_common",
"metadata:metadata_model",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js/cr/ui:array_data_model",
]
......@@ -366,9 +366,9 @@ js_library("file_selection") {
":directory_model",
"../../common/js:file_type",
"../../common/js:util",
"../../common/js:volume_manager_common",
"metadata:metadata_model",
"ui:list_container",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr",
]
......@@ -405,7 +405,7 @@ js_library("file_watcher") {
deps = [
"../../common/js:async_util",
"../../common/js:util",
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/webui/resources/js:assert",
]
}
......@@ -413,10 +413,10 @@ js_library("file_watcher") {
js_library("folder_shortcuts_data_model") {
deps = [
"//ui/file_manager/base/js:filtered_volume_manager",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/file_manager/file_manager/common/js:async_util",
"//ui/file_manager/file_manager/common/js:metrics",
"//ui/file_manager/file_manager/common/js:util",
"//ui/file_manager/file_manager/common/js:volume_manager_common",
]
}
......@@ -457,7 +457,7 @@ js_library("last_modified_controller") {
js_library("launch_param") {
deps = [
":dialog_type",
"../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......@@ -466,8 +466,8 @@ js_library("list_thumbnail_loader") {
":directory_model",
":file_list_model",
":thumbnail_loader",
"../../common/js:volume_manager_common",
"metadata:thumbnail_model",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......
......@@ -18,7 +18,7 @@
<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="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../background/js/entry_location_impl.js"></script>
<script src="../../background/js/volume_info_impl.js"></script>
......
......@@ -7,7 +7,7 @@
<script src="../../../../../ui/webui/resources/js/assert.js"></script>
<script src="../../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/mock_entry.js"></script>
<script src="../../common/js/file_type.js"></script>
<script src="../../../base/js/test_error_reporting.js"></script>
......
......@@ -24,7 +24,7 @@
<script src="../../common/js/metrics_base.js"></script>
<script src="../../common/js/metrics_events.js"></script>
<script src="../../common/js/test_tracker.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../common/js/file_type.js"></script>
<script src="../../common/js/importer_common.js"></script>
......
......@@ -14,7 +14,7 @@
<script src="../../common/js/util.js"></script>
<script src="../../common/js/mock_entry.js"></script>
<script src="../../../base/js/test_error_reporting.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="directory_contents.js"></script>
<script src="file_list_model.js"></script>
<script src="thumbnail_loader.js"></script>
......
......@@ -85,7 +85,7 @@
// <include src="../../common/js/async_util.js">
// <include src="../../common/js/file_type.js">
// <include src="../../common/js/files_app_entry_types.js">
// <include src="../../common/js/volume_manager_common.js">
// <include src="../../../base/js/volume_manager_types.js">
// <include src="../../common/js/util.js">
// <include src="../../common/js/progress_center_common.js">
// <include src="../../common/js/importer_common.js">
......
......@@ -14,7 +14,7 @@
<script src="../../../../../webui/resources/js/assert.js"></script>
<script src="../../../common/js/lru_cache.js"></script>
<script src="../../../../base/js/test_error_reporting.js"></script>
<script src="../../../common/js/volume_manager_common.js"></script>
<script src="../../../../base/js/volume_manager_types.js"></script>
<script src="content_metadata_provider.js"></script>
<script src="external_metadata_provider.js"></script>
<script src="file_system_metadata_provider.js"></script>
......
......@@ -14,7 +14,7 @@
<script src="../../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="../../common/js/files_app_entry_types.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../background/js/volume_info_impl.js"></script>
<script src="../../background/js/volume_info_list_impl.js"></script>
<script src="../../background/js/volume_manager_factory.js"></script>
......
......@@ -19,7 +19,7 @@
<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="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="../../background/js/volume_info_impl.js"></script>
<script src="../../background/js/volume_info_list_impl.js"></script>
......
......@@ -19,7 +19,7 @@
<script src="../../common/js/mock_entry.js"></script>
<script src="../../../base/js/test_error_reporting.js"></script>
<script src="../../common/js/util.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../../base/js/volume_manager_types.js"></script>
<script src="crostini.js"></script>
<script src="dialog_type.js"></script>
<script src="file_selection.js"></script>
......
......@@ -99,7 +99,7 @@ js_library("banners") {
deps = [
"..:directory_model",
"../../../common/js:util",
"../../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js/cr:event_target",
]
......@@ -145,8 +145,8 @@ js_library("directory_tree") {
"..:directory_model",
"..:navigation_list_model",
"../../../common/js:util",
"../../../common/js:volume_manager_common",
"../metadata:metadata_model",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/webui/resources/js/cr/ui:context_menu_button",
"//ui/webui/resources/js/cr/ui:context_menu_handler",
"//ui/webui/resources/js/cr/ui:menu",
......@@ -355,7 +355,7 @@ js_library("location_line") {
"../../../common/js:files_app_entry_types",
"../../../common/js:metrics",
"../../../common/js:util",
"../../../common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/file_manager/externs:volume_manager",
]
}
......@@ -410,8 +410,8 @@ js_library("suggest_apps_dialog") {
"..:web_store_utils",
"../../../common/js:metrics",
"../../../common/js:util",
"../../../common/js:volume_manager_common",
"../../../cws_widget:cws_widget_container",
"//ui/file_manager/base/js:volume_manager_types",
]
}
......
......@@ -22,7 +22,7 @@
<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="../../../common/js/volume_manager_common.js"></script>
<script src="../../../../base/js/volume_manager_types.js"></script>
<script src="../../../background/js/entry_location_impl.js"></script>
<script src="../../../background/js/volume_info_impl.js"></script>
......
......@@ -128,7 +128,7 @@ scripts += ['<script src="%s%s"></script>' % (ROOT, s) for s in [
'common/js/files_app_entry_types.js',
'common/js/util.js',
'common/js/mock_entry.js',
'common/js/volume_manager_common.js',
'../base/js/volume_manager_types.js',
'background/js/volume_info_impl.js',
'background/js/volume_info_list_impl.js',
'background/js/volume_manager_impl.js',
......
......@@ -138,7 +138,7 @@ js_library("gallery_util") {
deps = [
"../../file_manager/common/js:file_type",
"../../file_manager/common/js:util",
"../../file_manager/common/js:volume_manager_common",
"//ui/file_manager/base/js:volume_manager_types",
"//ui/file_manager/externs:volume_manager",
]
}
......
......@@ -45,18 +45,24 @@
// <include src="../../file_manager/common/js/async_util.js">
// <include src="../../file_manager/common/js/file_type.js">
// <include src="../../file_manager/common/js/util.js">
// <include src="../../file_manager/common/js/volume_manager_common.js">
// <include src="../../file_manager/foreground/js/metadata/content_metadata_provider.js">
// <include src="../../base/js/volume_manager_types.js">
// <include
// src="../../file_manager/foreground/js/metadata/content_metadata_provider.js">
// <include src="../../file_manager/foreground/js/metadata/exif_constants.js">
// <include src="../../file_manager/foreground/js/metadata/external_metadata_provider.js">
// <include src="../../file_manager/foreground/js/metadata/file_system_metadata_provider.js">
// <include src="../../file_manager/foreground/js/metadata/metadata_cache_item.js">
// <include
// src="../../file_manager/foreground/js/metadata/external_metadata_provider.js">
// <include
// src="../../file_manager/foreground/js/metadata/file_system_metadata_provider.js">
// <include
// src="../../file_manager/foreground/js/metadata/metadata_cache_item.js">
// <include src="../../file_manager/foreground/js/metadata/metadata_item.js">
// <include src="../../file_manager/foreground/js/metadata/metadata_model.js">
// <include src="../../file_manager/foreground/js/metadata/multi_metadata_provider.js">
// <include
// src="../../file_manager/foreground/js/metadata/multi_metadata_provider.js">
// <include src="../../file_manager/foreground/js/metadata/thumbnail_model.js">
// <include src="../../file_manager/foreground/js/thumbnail_loader.js">
// <include src="../../file_manager/foreground/js/ui/file_manager_dialog_base.js">
// <include
// src="../../file_manager/foreground/js/ui/file_manager_dialog_base.js">
// <include src="../../file_manager/foreground/js/ui/files_alert_dialog.js">
// <include src="../../file_manager/foreground/js/ui/files_confirm_dialog.js">
// <include src="../../base/js/filtered_volume_manager.js">
......
......@@ -42,7 +42,7 @@
// <include src="../../file_manager/common/js/async_util.js">
// <include src="../../file_manager/common/js/file_type.js">
// <include src="../../file_manager/common/js/util.js">
// <include src="../../file_manager/common/js/volume_manager_common.js">
// <include src="../../base/js/volume_manager_types.js">
// <include src="../../base/js/filtered_volume_manager.js">
// <include src="cast/cast_extension_discoverer.js">
......
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