• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_
7 
8 #include <string>
9 
10 #include "build/build_config.h"
11 #include "ui/gfx/native_widget_types.h"
12 
13 class Browser;
14 class ExtensionAction;
15 
16 namespace gfx {
17 class Image;
18 class Rect;
19 class Size;
20 }  // namespace gfx
21 
22 class BrowserActionTestUtil {
23  public:
BrowserActionTestUtil(Browser * browser)24   explicit BrowserActionTestUtil(Browser* browser) : browser_(browser) {}
25 
26   // Returns the number of browser action buttons in the window toolbar.
27   int NumberOfBrowserActions();
28 
29   // Returns the number of browser action currently visible.
30   int VisibleBrowserActions();
31 
32 #if defined(TOOLKIT_VIEWS)
33   // Returns the ExtensionAction for the given index.
34   ExtensionAction* GetExtensionAction(int index);
35 
36   // Inspects the extension popup for the action at the given index.
37   void InspectPopup(int index);
38 #endif
39 
40   // Returns whether the browser action at |index| has a non-null icon. Note
41   // that the icon is loaded asynchronously, in which case you can wait for it
42   // to load by calling WaitForBrowserActionUpdated.
43   bool HasIcon(int index);
44 
45   // Returns icon for the browser action at |index|.
46   gfx::Image GetIcon(int index);
47 
48   // Simulates a user click on the browser action button at |index|.
49   void Press(int index);
50 
51   // Returns the extension id of the extension at |index|.
52   std::string GetExtensionId(int index);
53 
54   // Returns the current tooltip for the browser action button.
55   std::string GetTooltip(int index);
56 
57   gfx::NativeView GetPopupNativeView();
58 
59   // Returns whether a browser action popup is being shown currently.
60   bool HasPopup();
61 
62   // Returns the bounds of the current browser action popup.
63   gfx::Rect GetPopupBounds();
64 
65   // Hides the given popup and returns whether the hide was successful.
66   bool HidePopup();
67 
68   // Set how many icons should be visible.
69   void SetIconVisibilityCount(size_t icons);
70 
71   // Returns the minimum allowed size of an extension popup.
72   static gfx::Size GetMinPopupSize();
73 
74   // Returns the maximum allowed size of an extension popup.
75   static gfx::Size GetMaxPopupSize();
76 
77  private:
78   Browser* browser_;  // weak
79 };
80 
81 #endif  // CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_
82