Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc

Issue 661493004: Add infrastructure for Chrome Actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/extension_toolbar_model.h" 9 #include "chrome/browser/extensions/extension_toolbar_model.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/browser_window_testing_views.h" 12 #include "chrome/browser/ui/browser_window_testing_views.h"
13 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h"
13 #include "chrome/browser/ui/views/extensions/extension_popup.h" 14 #include "chrome/browser/ui/views/extensions/extension_popup.h"
14 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" 15 #include "chrome/browser/ui/views/toolbar/browser_action_view.h"
15 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 16 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
18 #include "ui/aura/window.h"
17 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
19 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
20 22
21 namespace { 23 namespace {
22 24
23 BrowserActionsContainer* GetContainer(Browser* browser) { 25 BrowserActionsContainer* GetContainer(Browser* browser) {
24 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> 26 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()->
25 browser_actions(); 27 browser_actions();
26 } 28 }
27 29
28 } // namespace 30 } // namespace
29 31
30 int BrowserActionTestUtil::NumberOfBrowserActions() { 32 int BrowserActionTestUtil::NumberOfBrowserActions() {
31 return GetContainer(browser_)->num_browser_actions(); 33 return GetContainer(browser_)->num_browser_actions();
32 } 34 }
33 35
34 int BrowserActionTestUtil::VisibleBrowserActions() { 36 int BrowserActionTestUtil::VisibleBrowserActions() {
35 return GetContainer(browser_)->VisibleBrowserActions(); 37 return GetContainer(browser_)->VisibleBrowserActions();
36 } 38 }
37 39
38 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) {
39 return extensions::ExtensionActionManager::Get(browser_->profile())->
40 GetBrowserAction(*GetContainer(browser_)->GetBrowserActionViewAt(index)->
41 extension());
42 }
43
44 void BrowserActionTestUtil::InspectPopup(int index) { 40 void BrowserActionTestUtil::InspectPopup(int index) {
45 GetContainer(browser_)->GetBrowserActionViewAt(index)-> 41 BrowserActionView* view =
46 view_controller()->InspectPopup(); 42 GetContainer(browser_)->GetBrowserActionViewAt(index);
43 static_cast<ExtensionActionViewController*>(view->view_controller())->
44 InspectPopup();
47 } 45 }
48 46
49 bool BrowserActionTestUtil::HasIcon(int index) { 47 bool BrowserActionTestUtil::HasIcon(int index) {
50 return !GetContainer(browser_)->GetBrowserActionViewAt(index)-> 48 return !GetContainer(browser_)->GetBrowserActionViewAt(index)->
51 GetImage(views::Button::STATE_NORMAL).isNull(); 49 GetImage(views::Button::STATE_NORMAL).isNull();
52 } 50 }
53 51
54 gfx::Image BrowserActionTestUtil::GetIcon(int index) { 52 gfx::Image BrowserActionTestUtil::GetIcon(int index) {
55 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> 53 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)->
56 GetIconForTest(); 54 GetIconForTest();
57 return gfx::Image(icon); 55 return gfx::Image(icon);
58 } 56 }
59 57
60 void BrowserActionTestUtil::Press(int index) { 58 void BrowserActionTestUtil::Press(int index) {
61 GetContainer(browser_)->GetBrowserActionViewAt(index)-> 59 GetContainer(browser_)->GetBrowserActionViewAt(index)->
62 view_controller()->ExecuteActionByUser(); 60 view_controller()->ExecuteAction(true);
63 } 61 }
64 62
65 std::string BrowserActionTestUtil::GetExtensionId(int index) { 63 std::string BrowserActionTestUtil::GetExtensionId(int index) {
66 return GetContainer(browser_)->GetBrowserActionViewAt(index)-> 64 return GetContainer(browser_)->GetBrowserActionViewAt(index)->
67 extension()->id(); 65 view_controller()->GetId();
68 } 66 }
69 67
70 std::string BrowserActionTestUtil::GetTooltip(int index) { 68 std::string BrowserActionTestUtil::GetTooltip(int index) {
71 base::string16 text; 69 base::string16 text;
72 GetContainer(browser_)->GetBrowserActionViewAt(index)-> 70 GetContainer(browser_)->GetBrowserActionViewAt(index)->
73 GetTooltipText(gfx::Point(), &text); 71 GetTooltipText(gfx::Point(), &text);
74 return base::UTF16ToUTF8(text); 72 return base::UTF16ToUTF8(text);
75 } 73 }
76 74
77 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() { 75 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() {
78 return GetContainer(browser_)->TestGetPopup()->GetWidget()->GetNativeView(); 76 return GetContainer(browser_)->TestGetPopup();
79 } 77 }
80 78
81 bool BrowserActionTestUtil::HasPopup() { 79 bool BrowserActionTestUtil::HasPopup() {
82 return GetContainer(browser_)->TestGetPopup() != NULL; 80 return GetContainer(browser_)->TestGetPopup() != NULL;
83 } 81 }
84 82
85 gfx::Rect BrowserActionTestUtil::GetPopupBounds() { 83 gfx::Rect BrowserActionTestUtil::GetPopupBounds() {
86 return GetContainer(browser_)->TestGetPopup()->bounds(); 84 return GetContainer(browser_)->TestGetPopup()->bounds();
87 } 85 }
88 86
(...skipping 19 matching lines...) Expand all
108 106
109 // static 107 // static
110 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { 108 gfx::Size BrowserActionTestUtil::GetMinPopupSize() {
111 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); 109 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight);
112 } 110 }
113 111
114 // static 112 // static
115 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { 113 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() {
116 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); 114 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight);
117 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.cc ('k') | chrome/browser/ui/views/toolbar/browser_action_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698