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