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