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

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: Address reviewer comments. 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..28f4925b36108009e316988803f119a6b4090875
--- /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 pressing escape on the document closes the menu. However, if
+ // the key is pressed on the menu, it will take 2 presses to close the
+ // menu.
tsergeant 2016/01/22 02:37:11 Can we reword the comment to include a todo? (I th
hsampson 2016/01/22 05:05:03 Done.
+ element.toggleMenu_(MENU_EVENT);
+ MockInteractions.pressAndReleaseKeyOn(document, 27);
+ assertEquals(false, element.menuOpen);
+ });
+
+ teardown(function() {
+ element.menuIdentifier = 0;
+ });
+ });
+ }
+ return {
+ registerTests: registerTests
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698