menu_test_observer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_BASE_TEST_MENU_TEST_OBSERVER_H_
  5. #define UI_BASE_TEST_MENU_TEST_OBSERVER_H_
  6. #import <Cocoa/Cocoa.h>
  7. @class MenuTestObserver;
  8. using MenuTestObserverOpenCallback = void (^)(MenuTestObserver*);
  9. // The MenuTestObserver is a helper class for testing around NSMenu. It can
  10. // be used to verify that a menu has or has not been opened, as well as to
  11. // perform some action while the menu is tracking.
  12. @interface MenuTestObserver : NSObject
  13. @property(readonly, nonatomic) NSMenu* menu;
  14. // A flag to indicate whether the menu is currently open.
  15. @property(assign, nonatomic) BOOL isOpen;
  16. // A flag to indicate if the menu has ever been opened.
  17. @property(assign, nonatomic) BOOL didOpen;
  18. // If YES, this test observer will close the menu after it is opened.
  19. @property(assign, nonatomic) BOOL closeAfterOpening;
  20. // An optional block callback to run after the menu has been opened. This will
  21. // be called before closing the menu if |closeAfterOpening| is YES.
  22. @property(copy, nonatomic) MenuTestObserverOpenCallback openCallback;
  23. // Designated initializer. This does not retain the |menu|.
  24. - (instancetype)initWithMenu:(NSMenu*)menu;
  25. @end
  26. #endif // UI_BASE_TEST_MENU_TEST_OBSERVER_H_