Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / browser_action_test_util.h
blobbbad3e2145dfc6d823630e4d4fa91be79b5b4724
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/native_widget_types.h"
13 class Browser;
14 class ToolbarActionsBar;
15 class ToolbarActionsBarDelegate;
17 namespace gfx {
18 class Image;
19 class Rect;
20 class Size;
21 } // namespace gfx
23 // A class that creates and owns the platform-specific views for the browser
24 // actions container. Specific implementations are in the .cc/.mm files.
25 class TestToolbarActionsBarHelper {
26 public:
27 virtual ~TestToolbarActionsBarHelper() {}
30 class BrowserActionTestUtil {
31 public:
32 // Constructs a BrowserActionTestUtil that uses the |browser|'s default
33 // browser action container.
34 explicit BrowserActionTestUtil(Browser* browser);
36 // Constructs a BrowserActionTestUtil which, if |is_real_window| is false,
37 // will create its own browser actions container. This is useful in unit
38 // tests, when the |browser|'s window doesn't create platform-specific views.
39 BrowserActionTestUtil(Browser* browser, bool is_real_window);
41 ~BrowserActionTestUtil();
43 // Returns the number of browser action buttons in the window toolbar.
44 int NumberOfBrowserActions();
46 // Returns the number of browser action currently visible.
47 int VisibleBrowserActions();
49 // Returns true if the overflow chevron is completely shown in the browser
50 // actions container (i.e., is visible and is within the bounds of the
51 // container).
52 bool IsChevronShowing();
54 // Inspects the extension popup for the action at the given index.
55 void InspectPopup(int index);
57 // Returns whether the browser action at |index| has a non-null icon. Note
58 // that the icon is loaded asynchronously, in which case you can wait for it
59 // to load by calling WaitForBrowserActionUpdated.
60 bool HasIcon(int index);
62 // Returns icon for the browser action at |index|.
63 gfx::Image GetIcon(int index);
65 // Simulates a user click on the browser action button at |index|.
66 void Press(int index);
68 // Returns the extension id of the extension at |index|.
69 std::string GetExtensionId(int index);
71 // Returns the current tooltip for the browser action button.
72 std::string GetTooltip(int index);
74 gfx::NativeView GetPopupNativeView();
76 // Returns whether a browser action popup is being shown currently.
77 bool HasPopup();
79 // Returns the size of the current browser action popup.
80 gfx::Size GetPopupSize();
82 // Hides the given popup and returns whether the hide was successful.
83 bool HidePopup();
85 // Tests that the button at the given |index| is displaying that it wants
86 // to run.
87 bool ActionButtonWantsToRun(size_t index);
89 // Tests that the overflow button is displaying an overflowed action wants
90 // to run.
91 bool OverflowedActionButtonWantsToRun();
93 // Returns the ToolbarActionsBar.
94 ToolbarActionsBar* GetToolbarActionsBar();
96 // Creates and returns a BrowserActionTestUtil with an "overflow" container,
97 // with this object's container as the main bar.
98 scoped_ptr<BrowserActionTestUtil> CreateOverflowBar();
100 // Returns the minimum allowed size of an extension popup.
101 static gfx::Size GetMinPopupSize();
103 // Returns the maximum allowed size of an extension popup.
104 static gfx::Size GetMaxPopupSize();
106 private:
107 // A private constructor to create an overflow version.
108 BrowserActionTestUtil(Browser* browser, BrowserActionTestUtil* main_bar);
110 Browser* browser_; // weak
112 // Our test helper, which constructs and owns the views if we don't have a
113 // real browser window, or if this is an overflow version.
114 scoped_ptr<TestToolbarActionsBarHelper> test_helper_;
116 DISALLOW_COPY_AND_ASSIGN(BrowserActionTestUtil);
119 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_