Commit 03635067 authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Move actions_submenu_unittest to be closure compiled.

Added BUILD target for mock_actions_model.js that is testonly.

Bug: 860355
Change-Id: Idb81f1e2bdcbda7ba4164b502e4b81f551f2b0bb
Reviewed-on: https://chromium-review.googlesource.com/c/1292660
Commit-Queue: Stuart Langley <slangley@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601485}
parent d50b8f5c
...@@ -11,8 +11,7 @@ class FileManagerJsTest : public FileManagerJsTestBase { ...@@ -11,8 +11,7 @@ class FileManagerJsTest : public FileManagerJsTestBase {
}; };
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ActionsSubmenuTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ActionsSubmenuTest) {
RunTest(base::FilePath( RunGeneratedTest("/foreground/js/ui/actions_submenu_unittest.html");
FILE_PATH_LITERAL("foreground/js/ui/actions_submenu_unittest.html")));
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ActionsModelTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ActionsModelTest) {
......
...@@ -59,6 +59,7 @@ group("unit_test_data") { ...@@ -59,6 +59,7 @@ group("unit_test_data") {
"file_manager/background/js:unit_tests", "file_manager/background/js:unit_tests",
"file_manager/common/js:unit_tests", "file_manager/common/js:unit_tests",
"file_manager/foreground/js:unit_tests", "file_manager/foreground/js:unit_tests",
"file_manager/foreground/js/ui:unit_tests",
"gallery/js:unit_tests", "gallery/js:unit_tests",
"gallery/js/image_editor:unit_tests", "gallery/js/image_editor:unit_tests",
"image_loader:unit_tests", "image_loader:unit_tests",
......
...@@ -10,6 +10,16 @@ visibility = [ ...@@ -10,6 +10,16 @@ visibility = [
"//ui/file_manager/file_manager/test/*", "//ui/file_manager/file_manager/test/*",
] ]
group("closure_compile") {
testonly = true
visibility += [ "//ui/file_manager:closure_compile" ]
deps = [
":closure_compile_module",
":test_support_type_check",
":unit_tests_type_check",
]
}
js_type_check("closure_compile_module") { js_type_check("closure_compile_module") {
deps = [ deps = [
":actions_controller", ":actions_controller",
...@@ -78,8 +88,6 @@ js_library("closure_compile_externs") { ...@@ -78,8 +88,6 @@ js_library("closure_compile_externs") {
"../../../externs/background/file_browser_background.js", "../../../externs/background/file_browser_background.js",
"../../../externs/background/file_browser_background_full.js", "../../../externs/background/file_browser_background_full.js",
"../../../externs/background/file_operation_manager.js", "../../../externs/background/file_operation_manager.js",
"../../../externs/background/import_history.js",
"../../../externs/background/import_history_enum.js",
"../../../externs/background/import_runner.js", "../../../externs/background/import_runner.js",
"../../../externs/background/media_import_handler.js", "../../../externs/background/media_import_handler.js",
"../../../externs/background/media_scanner.js", "../../../externs/background/media_scanner.js",
...@@ -90,7 +98,6 @@ js_library("closure_compile_externs") { ...@@ -90,7 +98,6 @@ js_library("closure_compile_externs") {
"../../../externs/command_handler_deps.js", "../../../externs/command_handler_deps.js",
"../../../externs/css_rule.js", "../../../externs/css_rule.js",
"../../../externs/directory_change_event.js", "../../../externs/directory_change_event.js",
"../../../externs/drag_target.js",
"../../../externs/entries_changed_event.js", "../../../externs/entries_changed_event.js",
"../../../externs/gallery_foreground.js", "../../../externs/gallery_foreground.js",
"../../../externs/menu_item_update_event.js", "../../../externs/menu_item_update_event.js",
...@@ -100,6 +107,13 @@ js_library("closure_compile_externs") { ...@@ -100,6 +107,13 @@ js_library("closure_compile_externs") {
] ]
} }
js_type_check("test_support_type_check") {
testonly = true
deps = [
":mock_actions_model",
]
}
js_library("actions_controller") { js_library("actions_controller") {
deps = [ deps = [
":actions_model", ":actions_model",
...@@ -122,6 +136,15 @@ js_library("actions_model") { ...@@ -122,6 +136,15 @@ js_library("actions_model") {
"ui:list_container", "ui:list_container",
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr",
] ]
externs_list = [ "../../../externs/background/drive_sync_handler.js" ]
}
js_library("mock_actions_model") {
testonly = true
deps = [
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js/cr:event_target",
]
} }
js_library("app_state_controller") { js_library("app_state_controller") {
...@@ -187,6 +210,10 @@ js_library("directory_model") { ...@@ -187,6 +210,10 @@ js_library("directory_model") {
"../../common/js:metrics_events", "../../common/js:metrics_events",
"ui:file_list_selection_model", "ui:file_list_selection_model",
] ]
externs_list = [
"../../../externs/background/file_operation_manager.js",
"../../../externs/entries_changed_event.js",
]
} }
js_library("navigation_uma") { js_library("navigation_uma") {
...@@ -612,12 +639,3 @@ js_unit_tests("unit_tests") { ...@@ -612,12 +639,3 @@ js_unit_tests("unit_tests") {
":thumbnail_loader_unittest", ":thumbnail_loader_unittest",
] ]
} }
group("closure_compile") {
testonly = true
visibility += [ "*" ]
deps = [
":closure_compile_module",
":unit_tests_type_check",
]
}
...@@ -789,7 +789,7 @@ DirectoryModel.prototype.replaceDirectoryContents_ = function(dirContents) { ...@@ -789,7 +789,7 @@ DirectoryModel.prototype.replaceDirectoryContents_ = function(dirContents) {
/** /**
* Callback when an entry is changed. * Callback when an entry is changed.
* @param {Event} event Entry change event. * @param {EntriesChangedEvent} event Entry change event.
* @private * @private
*/ */
DirectoryModel.prototype.onEntriesChanged_ = function(event) { DirectoryModel.prototype.onEntriesChanged_ = function(event) {
......
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
// 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.
/**
* @param {string} title
* @param {Array<!Entry>} entries
* @constructor
* @struct
*/
function MockActionModel(title, entries) { function MockActionModel(title, entries) {
this.title = title; this.title = title;
this.entries = entries; this.entries = entries;
this.actionsModel = null; this.actionsModel = null;
}; }
MockActionModel.prototype.getTitle = function() { MockActionModel.prototype.getTitle = function() {
return this.title; return this.title;
...@@ -16,22 +22,25 @@ MockActionModel.prototype.onCanExecute = function() { ...@@ -16,22 +22,25 @@ MockActionModel.prototype.onCanExecute = function() {
}; };
MockActionModel.prototype.onExecute = function() { MockActionModel.prototype.onExecute = function() {
cr.ui.dispatchSimpleEvent('invalidated', this.actionsModel); cr.dispatchSimpleEvent('invalidated', this.actionsModel);
}; };
/**
* @constructor
*/
function MockActionsModel(actions) { function MockActionsModel(actions) {
this.actions_ = actions; this.actions_ = actions;
Object.keys(actions).forEach(function(key) { Object.keys(actions).forEach(function(key) {
actions[key].actionsModel = this; actions[key].actionsModel = this;
}); });
}; }
MockActionsModel.prototype = { MockActionsModel.prototype = {
__proto__: cr.EventTarget.prototype __proto__: cr.EventTarget.prototype
}; };
MockActionsModel.prototype.initialize = function() { MockActionsModel.prototype.initialize = function() {
return new Promise.resolve(); return Promise.resolve();
}; };
MockActionsModel.prototype.getActions = function() { MockActionsModel.prototype.getActions = function() {
......
...@@ -3,10 +3,20 @@ ...@@ -3,10 +3,20 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/closure_compiler/js_unit_tests.gni")
visibility = [ "//ui/file_manager/file_manager/foreground/*" ] visibility = [ "//ui/file_manager/file_manager/foreground/*" ]
js_type_check("closure_compile") { group("closure_compile") {
testonly = true
visibility += [ "//ui/file_manager:closure_compile" ]
deps = [
":closure_compile_module",
":unit_tests_type_check",
]
}
js_type_check("closure_compile_module") {
deps = [ deps = [
":actions_submenu", ":actions_submenu",
":banners", ":banners",
...@@ -77,6 +87,14 @@ js_library("actions_submenu") { ...@@ -77,6 +87,14 @@ js_library("actions_submenu") {
] ]
} }
js_unittest("actions_submenu_unittest") {
deps = [
":actions_submenu",
"..:mock_actions_model",
"//ui/webui/resources/js:webui_resource_test",
]
}
js_library("banners") { js_library("banners") {
deps = [ deps = [
"..:directory_model", "..:directory_model",
...@@ -141,6 +159,7 @@ js_library("drag_selector") { ...@@ -141,6 +159,7 @@ js_library("drag_selector") {
"//ui/webui/resources/js/cr:ui", "//ui/webui/resources/js/cr:ui",
"//ui/webui/resources/js/cr/ui:list", "//ui/webui/resources/js/cr/ui:list",
] ]
externs_list = [ "../../../../externs/drag_target.js" ]
} }
js_library("empty_folder") { js_library("empty_folder") {
...@@ -167,6 +186,10 @@ js_library("file_grid") { ...@@ -167,6 +186,10 @@ js_library("file_grid") {
"../metadata:metadata_model", "../metadata:metadata_model",
"//ui/webui/resources/js/cr/ui:grid", "//ui/webui/resources/js/cr/ui:grid",
] ]
externs_list = [
"../../../../externs/background/import_history.js",
"../../../../externs/background/import_history_enum.js",
]
} }
js_library("file_list_selection_model") { js_library("file_list_selection_model") {
...@@ -365,3 +388,9 @@ js_library("suggest_apps_dialog") { ...@@ -365,3 +388,9 @@ js_library("suggest_apps_dialog") {
"../../../cws_widget:cws_widget_container", "../../../cws_widget:cws_widget_container",
] ]
} }
js_unit_tests("unit_tests") {
deps = [
":actions_submenu_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.
-->
<script>
function queryRequiredElement(selectors, opt_context) {
var element = (opt_context || document).querySelector(selectors);
return assertInstanceof(element, HTMLElement,
'Missing required element: ' + selectors);
}
</script>
<command id="share" label="Share"></command>
<command id="manage-in-drive" i18n-values="Manage in Drive"></command>
<command id="toggle-pinned" label="Toggle pinned"></command>
<command id="create-folder-shortcut" label="Create folder shortcut"></command>
<command id="remove-folder-shortcut" label="Remove folder shortcut"></command>
<cr-menu id="menu">
<hr id="actions-separator" hidden>
</cr-menu>
<script src="../../../../../../ui/webui/resources/js/assert.js"></script>
<script src="../../../../../../ui/webui/resources/js/cr.js"></script>
<script src="../../../../../../ui/webui/resources/js/cr/event_target.js"></script>
<script src="../../../../../../ui/webui/resources/js/cr/ui.js"></script>
<script src="../../../../../../ui/webui/resources/js/cr/ui/command.js"></script>
<script src="../../../../../../ui/webui/resources/js/cr/ui/menu_item.js"></script>
<script src="../../../../../../ui/webui/resources/js/cr/ui/menu.js"></script>
<script src="../../../common/js/util.js"></script>
<script src="../actions_model.js"></script>
<script src="../mock_actions_model.js"></script>
<script src="actions_submenu.js"></script>
<script src="actions_submenu_unittest.js"></script>
// Copyright 2015 The Chromium Authors. All rights reserved. // Copyright 2015 The Chromium Authors. All rights reserved.
// 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.
'use strict';
var menu = null; var menu = null;
var submenu = null; var submenu = null;
var separator = null; var separator = null;
document.write(`
<command id="share" label="Share"></command>
<command id="manage-in-drive" i18n-values="Manage in Drive"></command>
<command id="toggle-pinned" label="Toggle pinned"></command>
<command id="create-folder-shortcut" label="Create folder shortcut">
</command>
<command id="remove-folder-shortcut" label="Remove folder shortcut">
</command>
<cr-menu id="menu">
<hr id="actions-separator" hidden>
</cr-menu>`);
function queryRequiredElement(selectors, opt_context) {
const element = (opt_context || document).querySelector(selectors);
return assertInstanceof(
element, HTMLElement, 'Missing required element: ' + selectors);
}
function setUp() { function setUp() {
menu = util.queryDecoratedElement('#menu', cr.ui.Menu); menu = util.queryDecoratedElement('#menu', cr.ui.Menu);
separator = queryRequiredElement('#actions-separator', menu); separator = queryRequiredElement('#actions-separator', menu);
......
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