Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1527)

Unified Diff: chrome/test/data/webui/md_bookmarks/command_manager_test.js

Issue 2834493006: MD Bookmarks: Pull context menu into separate element (Closed)
Patch Set: Switch back to using a Command enum Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_bookmarks/command_manager_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/command_manager_test.js b/chrome/test/data/webui/md_bookmarks/command_manager_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..8fb3c766f6713f3da066caa5ef784de9a7b074ed
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/command_manager_test.js
@@ -0,0 +1,47 @@
+// Copyright 2017 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.
+
+suite('<bookmarks-command-manager>', function() {
+ var commandManager;
+ var store;
+
+ setup(function() {
+ store = new bookmarks.TestStore({
+ nodes: testTree(createFolder(
+ '1',
+ [
+ createFolder('11', []),
+ createFolder('12', []),
+ createItem('13'),
+ ])),
+ });
+ bookmarks.Store.instance_ = store;
+
+ commandManager = document.createElement('bookmarks-command-manager');
+ replaceBody(commandManager);
+ });
+
+ test('can only copy single URL items', function() {
+ assertFalse(commandManager.canExecute(Command.COPY, new Set(['11'])));
+ assertFalse(commandManager.canExecute(Command.COPY, new Set(['11', '13'])));
+ assertTrue(commandManager.canExecute(Command.COPY, new Set(['13'])));
+ });
+
+ test('context menu hides invalid commands', function() {
+ store.data.selection.items = new Set(['11', '13']);
+ store.notifyObservers();
+
+ commandManager.openCommandMenuAtPosition(0, 0);
+ var commandHidden = {};
+ commandManager.root.querySelectorAll('.dropdown-item').forEach(element => {
+ commandHidden[element.getAttribute('command')] = element.hidden;
+ });
+
+ // With a folder and an item selected, the only available context menu item
+ // is 'Delete'.
+ assertTrue(commandHidden['edit']);
+ assertTrue(commandHidden['copy']);
+ assertFalse(commandHidden['delete']);
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698