1 // Copyright (c) 2010 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_
10 #include "ui/gfx/native_widget_types.h"
13 class ToolbarActionsBar
;
14 class ToolbarActionsBarDelegate
;
22 class BrowserActionTestUtil
{
24 // Constructs a BrowserActionTestUtil that uses the |browser|'s default
25 // browser action container.
26 explicit BrowserActionTestUtil(Browser
* browser
)
27 : browser_(browser
), bar_delegate_(nullptr) {}
29 // Constructs a BrowserActionTestUtil that will use the |bar_delegate| as the
30 // browser action container to test.
31 BrowserActionTestUtil(Browser
* browser
,
32 ToolbarActionsBarDelegate
* bar_delegate
)
33 : browser_(browser
), bar_delegate_(bar_delegate
) {}
35 // Returns the number of browser action buttons in the window toolbar.
36 int NumberOfBrowserActions();
38 // Returns the number of browser action currently visible.
39 int VisibleBrowserActions();
41 // Returns true if the overflow chevron is completely shown in the browser
42 // actions container (i.e., is visible and is within the bounds of the
44 bool IsChevronShowing();
46 // Inspects the extension popup for the action at the given index.
47 void InspectPopup(int index
);
49 // Returns whether the browser action at |index| has a non-null icon. Note
50 // that the icon is loaded asynchronously, in which case you can wait for it
51 // to load by calling WaitForBrowserActionUpdated.
52 bool HasIcon(int index
);
54 // Returns icon for the browser action at |index|.
55 gfx::Image
GetIcon(int index
);
57 // Simulates a user click on the browser action button at |index|.
58 void Press(int index
);
60 // Returns the extension id of the extension at |index|.
61 std::string
GetExtensionId(int index
);
63 // Returns the current tooltip for the browser action button.
64 std::string
GetTooltip(int index
);
66 gfx::NativeView
GetPopupNativeView();
68 // Returns whether a browser action popup is being shown currently.
71 // Returns the size of the current browser action popup.
72 gfx::Size
GetPopupSize();
74 // Hides the given popup and returns whether the hide was successful.
77 // Tests that the button at the given |index| is displaying that it wants
79 bool ActionButtonWantsToRun(size_t index
);
81 // Tests that the overflow button is displaying an overflowed action wants
83 bool OverflowedActionButtonWantsToRun();
85 // Returns the ToolbarActionsBar.
86 ToolbarActionsBar
* GetToolbarActionsBar();
88 // Returns the minimum allowed size of an extension popup.
89 static gfx::Size
GetMinPopupSize();
91 // Returns the maximum allowed size of an extension popup.
92 static gfx::Size
GetMaxPopupSize();
95 Browser
* browser_
; // weak
97 // If non-null, this is a set view to test with, rather than using the
98 // |browser|'s default container.
99 ToolbarActionsBarDelegate
* bar_delegate_
; // weak
102 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_