OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/extensions/browser_action_test_util.h" | 5 #include "chrome/browser/extensions/browser_action_test_util.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_action_manager.h" | 8 #include "chrome/browser/extensions/extension_action_manager.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 11 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
12 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" | 12 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" |
13 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 13 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
14 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 14 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 BrowserActionsContainer* GetContainer(Browser* browser) { | 21 BrowserActionsContainer* GetContainer(Browser* browser) { |
22 BrowserActionsContainer* container = | 22 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> |
23 browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> | 23 browser_actions(); |
24 browser_actions(); | |
25 return container; | |
26 } | 24 } |
27 | 25 |
28 } // namespace | 26 } // namespace |
29 | 27 |
30 int BrowserActionTestUtil::NumberOfBrowserActions() { | 28 int BrowserActionTestUtil::NumberOfBrowserActions() { |
31 return GetContainer(browser_)->num_browser_actions(); | 29 return GetContainer(browser_)->num_browser_actions(); |
32 } | 30 } |
33 | 31 |
34 int BrowserActionTestUtil::VisibleBrowserActions() { | 32 int BrowserActionTestUtil::VisibleBrowserActions() { |
35 return GetContainer(browser_)->VisibleBrowserActions(); | 33 return GetContainer(browser_)->VisibleBrowserActions(); |
36 } | 34 } |
37 | 35 |
38 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { | 36 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { |
39 return extensions::ExtensionActionManager::Get(browser_->profile())-> | 37 return extensions::ExtensionActionManager::Get(browser_->profile())-> |
40 GetBrowserAction(*GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 38 GetBrowserAction(*GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
41 button()->extension()); | 39 button()->extension()); |
42 } | 40 } |
43 | 41 |
| 42 void BrowserActionTestUtil::InspectPopup(int index) { |
| 43 GetContainer(browser_)->InspectPopup(GetExtensionAction(index)); |
| 44 } |
| 45 |
44 bool BrowserActionTestUtil::HasIcon(int index) { | 46 bool BrowserActionTestUtil::HasIcon(int index) { |
45 return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> | 47 return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> |
46 HasIcon(); | 48 HasIcon(); |
47 } | 49 } |
48 | 50 |
49 gfx::Image BrowserActionTestUtil::GetIcon(int index) { | 51 gfx::Image BrowserActionTestUtil::GetIcon(int index) { |
50 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 52 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
51 button()->GetIconForTest(); | 53 button()->GetIconForTest(); |
52 return gfx::Image(icon); | 54 return gfx::Image(icon); |
53 } | 55 } |
(...skipping 17 matching lines...) Expand all Loading... |
71 | 73 |
72 bool BrowserActionTestUtil::HasPopup() { | 74 bool BrowserActionTestUtil::HasPopup() { |
73 return GetContainer(browser_)->TestGetPopup() != NULL; | 75 return GetContainer(browser_)->TestGetPopup() != NULL; |
74 } | 76 } |
75 | 77 |
76 gfx::Rect BrowserActionTestUtil::GetPopupBounds() { | 78 gfx::Rect BrowserActionTestUtil::GetPopupBounds() { |
77 return GetContainer(browser_)->TestGetPopup()->bounds(); | 79 return GetContainer(browser_)->TestGetPopup()->bounds(); |
78 } | 80 } |
79 | 81 |
80 bool BrowserActionTestUtil::HidePopup() { | 82 bool BrowserActionTestUtil::HidePopup() { |
81 BrowserActionsContainer* container = GetContainer(browser_); | 83 GetContainer(browser_)->HidePopup(); |
82 container->HidePopup(); | |
83 return !HasPopup(); | 84 return !HasPopup(); |
84 } | 85 } |
85 | 86 |
86 void BrowserActionTestUtil::SetIconVisibilityCount(size_t icons) { | 87 void BrowserActionTestUtil::SetIconVisibilityCount(size_t icons) { |
87 GetContainer(browser_)->TestSetIconVisibilityCount(icons); | 88 GetContainer(browser_)->TestSetIconVisibilityCount(icons); |
88 } | 89 } |
89 | 90 |
90 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { | 91 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { |
91 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); | 92 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); |
92 } | 93 } |
93 | 94 |
94 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { | 95 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { |
95 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); | 96 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); |
96 } | 97 } |
OLD | NEW |