// Copyright 2016 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_VIEWS_TEST_MENU_TEST_UTILS_H_ #define UI_VIEWS_TEST_MENU_TEST_UTILS_H_ #include <memory> #include <utility> #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "ui/compositor/layer_tree_owner.h" #include "ui/views/controls/menu/menu_delegate.h" #include "ui/views/test/test_views_delegate.h" #include "ui/views/view.h" namespace views { class MenuController; namespace test { // Test implementation of MenuDelegate that tracks calls to MenuDelegate, along // with the provided parameters. class TestMenuDelegate : public MenuDelegate { … }; // Test api which caches the currently active MenuController. Can be used to // toggle visibility, and to clear seletion states, without performing full // shutdown. This is used to simulate menus with varing states, such as during // drags, without performing the entire operation. Used to test strange shutdown // ordering. class MenuControllerTestApi { … }; // On platforms which have menu closure animations, these functions are // necessary to: // 1) Disable those animations (make them take zero time) to avoid slowing // down tests; // 2) Wait for maybe-asynchronous menu closure to finish. // On platforms without menu closure animations, these do nothing. void DisableMenuClosureAnimations(); void WaitForMenuClosureAnimation(); // An implementation of TestViewsDelegate which overrides ReleaseRef in order to // call a provided callback. class ReleaseRefTestViewsDelegate : public TestViewsDelegate { … }; } // namespace test } // namespace views #endif // UI_VIEWS_TEST_MENU_TEST_UTILS_H_