chromium/chrome/browser/ui/views/menu_controller_interactive_uitest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/ui/views/menu_test_base.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/submenu_view.h"

template<ui::KeyboardCode KEYCODE, int EXPECTED_COMMAND>
class MenuControllerMnemonicTest : public MenuTestBase {};

// Pressing the mnemonic for a menu item should execute the command for that
// menu item.
MenuControllerMnemonicTestMnemonicMatch;

#if BUILDFLAG(IS_MAC)
// Mnemonics and activation by title match aren't used on macOS.
#define MAYBE_MnemonicMatch
#define MAYBE_TitleMatch
#else
#define MAYBE_MnemonicMatch
#define MAYBE_TitleMatch
#endif

VIEW_TEST(MenuControllerMnemonicTestMnemonicMatch, MAYBE_MnemonicMatch)

// Pressing a key which matches the first letter of the menu item's title
// should execute the command for that menu item.
MenuControllerMnemonicTestTitleMatch;

VIEW_TEST(MenuControllerMnemonicTestTitleMatch, MAYBE_TitleMatch)

// Pressing an arbitrary key should not execute any commands.
MenuControllerMnemonicTestNoMatch;

VIEW_TEST(MenuControllerMnemonicTestNoMatch, NoMatch)