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

Unified Diff: chrome/test/data/webui/md_history/history_overflow_menu_test.js

Issue 1572383006: MD History: Hook all elements into the page and add tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch
Patch Set: Rebase. Created 4 years, 11 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_history/history_overflow_menu_test.js
diff --git a/chrome/test/data/webui/md_history/history_overflow_menu_test.js b/chrome/test/data/webui/md_history/history_overflow_menu_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..894bf857df241e10f72f46702e061195a97a4313
--- /dev/null
+++ b/chrome/test/data/webui/md_history/history_overflow_menu_test.js
@@ -0,0 +1,69 @@
+// Copyright 2016 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.
+
+cr.define('md_history.history_overflow_menu_test', function() {
+ // Menu button event.
+ var MENU_EVENT = {
+ detail: {
+ accessTime: 1
+ }
+ };
+
+ var ADDITIONAL_MENU_EVENT = {
+ detail: {
+ accessTime: 2
+ }
+ };
+
+ function registerTests() {
+ suite('#overflow-menu', function() {
+ var element;
+
+ suiteSetup(function() {
+ element = $('history-card-manager');
+ });
+
+ test('opening and closing menu', function() {
+ element.toggleMenu_(MENU_EVENT);
+ assertEquals(true, element.menuOpen);
+ assertEquals(1, element.menuIdentifier);
+
+ // Test having the same menu event (pressing the same button) closes the
+ // overflow menu.
+ element.toggleMenu_(MENU_EVENT);
+ assertEquals(false, element.menuOpen);
+
+ // Test having consecutive distinct menu events moves the menu to the
+ // new button.
+ element.toggleMenu_(MENU_EVENT);
+ element.toggleMenu_(ADDITIONAL_MENU_EVENT);
+ assertEquals(2, element.menuIdentifier);
+ assertEquals(true, element.menuOpen);
+ element.toggleMenu_(MENU_EVENT);
+ assertEquals(true, element.menuOpen);
+ assertEquals(1, element.menuIdentifier);
+
+ element.closeMenu();
+ assertEquals(false, element.menuOpen);
+ assertEquals(1, element.menuIdentifier);
+ });
+
+ test('keyboard input for closing menu', function() {
+ // Test that pressing escape on the document closes the menu. In the
+ // actual page, it will take two presses to close the menu due to focus.
+ // TODO(yingran): Fix this behavior to only require one key press.
+ element.toggleMenu_(MENU_EVENT);
+ MockInteractions.pressAndReleaseKeyOn(document, 27);
+ assertEquals(false, element.menuOpen);
+ });
+
+ teardown(function() {
+ element.menuIdentifier = 0;
+ });
+ });
+ }
+ return {
+ registerTests: registerTests
+ };
+});
« no previous file with comments | « chrome/test/data/webui/md_history/history_card_test.js ('k') | chrome/test/data/webui/md_history/history_toolbar_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698