| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 11 | 12 |
| 12 class Browser; | 13 class Browser; |
| 13 class ToolbarActionsBar; | 14 class ToolbarActionsBar; |
| 14 class ToolbarActionsBarDelegate; | 15 class ToolbarActionsBarDelegate; |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Image; | 18 class Image; |
| 18 class Rect; | 19 class Rect; |
| 19 class Size; | 20 class Size; |
| 20 } // namespace gfx | 21 } // namespace gfx |
| 21 | 22 |
| 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() {} |
| 28 }; |
| 29 |
| 22 class BrowserActionTestUtil { | 30 class BrowserActionTestUtil { |
| 23 public: | 31 public: |
| 24 // Constructs a BrowserActionTestUtil that uses the |browser|'s default | 32 // Constructs a BrowserActionTestUtil that uses the |browser|'s default |
| 25 // browser action container. | 33 // browser action container. |
| 26 explicit BrowserActionTestUtil(Browser* browser) | 34 explicit BrowserActionTestUtil(Browser* browser); |
| 27 : browser_(browser), bar_delegate_(nullptr) {} | |
| 28 | 35 |
| 29 // Constructs a BrowserActionTestUtil that will use the |bar_delegate| as the | 36 // Constructs a BrowserActionTestUtil which, if |is_real_window| is false, |
| 30 // browser action container to test. | 37 // will create its own browser actions container. This is useful in unit |
| 31 BrowserActionTestUtil(Browser* browser, | 38 // tests, when the |browser|'s window doesn't create platform-specific views. |
| 32 ToolbarActionsBarDelegate* bar_delegate) | 39 BrowserActionTestUtil(Browser* browser, bool is_real_window); |
| 33 : browser_(browser), bar_delegate_(bar_delegate) {} | 40 |
| 41 ~BrowserActionTestUtil(); |
| 34 | 42 |
| 35 // Returns the number of browser action buttons in the window toolbar. | 43 // Returns the number of browser action buttons in the window toolbar. |
| 36 int NumberOfBrowserActions(); | 44 int NumberOfBrowserActions(); |
| 37 | 45 |
| 38 // Returns the number of browser action currently visible. | 46 // Returns the number of browser action currently visible. |
| 39 int VisibleBrowserActions(); | 47 int VisibleBrowserActions(); |
| 40 | 48 |
| 41 // Returns true if the overflow chevron is completely shown in the browser | 49 // 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 | 50 // actions container (i.e., is visible and is within the bounds of the |
| 43 // container). | 51 // container). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // to run. | 86 // to run. |
| 79 bool ActionButtonWantsToRun(size_t index); | 87 bool ActionButtonWantsToRun(size_t index); |
| 80 | 88 |
| 81 // Tests that the overflow button is displaying an overflowed action wants | 89 // Tests that the overflow button is displaying an overflowed action wants |
| 82 // to run. | 90 // to run. |
| 83 bool OverflowedActionButtonWantsToRun(); | 91 bool OverflowedActionButtonWantsToRun(); |
| 84 | 92 |
| 85 // Returns the ToolbarActionsBar. | 93 // Returns the ToolbarActionsBar. |
| 86 ToolbarActionsBar* GetToolbarActionsBar(); | 94 ToolbarActionsBar* GetToolbarActionsBar(); |
| 87 | 95 |
| 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(); |
| 99 |
| 88 // Returns the minimum allowed size of an extension popup. | 100 // Returns the minimum allowed size of an extension popup. |
| 89 static gfx::Size GetMinPopupSize(); | 101 static gfx::Size GetMinPopupSize(); |
| 90 | 102 |
| 91 // Returns the maximum allowed size of an extension popup. | 103 // Returns the maximum allowed size of an extension popup. |
| 92 static gfx::Size GetMaxPopupSize(); | 104 static gfx::Size GetMaxPopupSize(); |
| 93 | 105 |
| 94 private: | 106 private: |
| 107 // A private constructor to create an overflow version. |
| 108 BrowserActionTestUtil(Browser* browser, BrowserActionTestUtil* main_bar); |
| 109 |
| 95 Browser* browser_; // weak | 110 Browser* browser_; // weak |
| 96 | 111 |
| 97 // If non-null, this is a set view to test with, rather than using the | 112 // Our test helper, which constructs and owns the views if we don't have a |
| 98 // |browser|'s default container. | 113 // real browser window, or if this is an overflow version. |
| 99 ToolbarActionsBarDelegate* bar_delegate_; // weak | 114 scoped_ptr<TestToolbarActionsBarHelper> test_helper_; |
| 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(BrowserActionTestUtil); |
| 100 }; | 117 }; |
| 101 | 118 |
| 102 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ | 119 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_ACTION_TEST_UTIL_H_ |
| OLD | NEW |