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

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: Sky's I 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"
17 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
19 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
20 21
21 namespace { 22 namespace {
22 23
23 BrowserActionsContainer* GetContainer(Browser* browser) { 24 BrowserActionsContainer* GetContainer(Browser* browser) {
24 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> 25 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()->
25 browser_actions(); 26 browser_actions();
26 } 27 }
27 28
28 } // namespace 29 } // namespace
29 30
30 int BrowserActionTestUtil::NumberOfBrowserActions() { 31 int BrowserActionTestUtil::NumberOfBrowserActions() {
31 return GetContainer(browser_)->num_browser_actions(); 32 return GetContainer(browser_)->num_browser_actions();
32 } 33 }
33 34
34 int BrowserActionTestUtil::VisibleBrowserActions() { 35 int BrowserActionTestUtil::VisibleBrowserActions() {
35 return GetContainer(browser_)->VisibleBrowserActions(); 36 return GetContainer(browser_)->VisibleBrowserActions();
36 } 37 }
37 38
38 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { 39 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) {
39 return extensions::ExtensionActionManager::Get(browser_->profile())-> 40 return extensions::ExtensionActionManager::Get(browser_->profile())->
40 GetBrowserAction(*GetContainer(browser_)->GetBrowserActionViewAt(index)-> 41 GetBrowserAction(*GetContainer(browser_)->GetExtensionAt(index));
41 extension());
42 } 42 }
43 43
44 void BrowserActionTestUtil::InspectPopup(int index) { 44 void BrowserActionTestUtil::InspectPopup(int index) {
45 GetContainer(browser_)->GetBrowserActionViewAt(index)-> 45 GetContainer(browser_)->GetBrowserActionViewAt(index)->
46 view_controller()->InspectPopup(); 46 GetExtensionActionViewController()->InspectPopup();
47 } 47 }
48 48
49 bool BrowserActionTestUtil::HasIcon(int index) { 49 bool BrowserActionTestUtil::HasIcon(int index) {
50 return !GetContainer(browser_)->GetBrowserActionViewAt(index)-> 50 return !GetContainer(browser_)->GetBrowserActionViewAt(index)->
51 GetImage(views::Button::STATE_NORMAL).isNull(); 51 GetImage(views::Button::STATE_NORMAL).isNull();
52 } 52 }
53 53
54 gfx::Image BrowserActionTestUtil::GetIcon(int index) { 54 gfx::Image BrowserActionTestUtil::GetIcon(int index) {
55 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> 55 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)->
56 GetIconForTest(); 56 GetIconForTest();
57 return gfx::Image(icon); 57 return gfx::Image(icon);
58 } 58 }
59 59
60 void BrowserActionTestUtil::Press(int index) { 60 void BrowserActionTestUtil::Press(int index) {
61 GetContainer(browser_)->GetBrowserActionViewAt(index)-> 61 GetContainer(browser_)->GetBrowserActionViewAt(index)->
62 view_controller()->ExecuteActionByUser(); 62 view_controller()->ExecuteActionByUser();
63 } 63 }
64 64
65 std::string BrowserActionTestUtil::GetExtensionId(int index) { 65 std::string BrowserActionTestUtil::GetExtensionId(int index) {
66 return GetContainer(browser_)->GetBrowserActionViewAt(index)-> 66 return GetContainer(browser_)->GetExtensionAt(index)->id();
67 extension()->id();
68 } 67 }
69 68
70 std::string BrowserActionTestUtil::GetTooltip(int index) { 69 std::string BrowserActionTestUtil::GetTooltip(int index) {
71 base::string16 text; 70 base::string16 text;
72 GetContainer(browser_)->GetBrowserActionViewAt(index)-> 71 GetContainer(browser_)->GetBrowserActionViewAt(index)->
73 GetTooltipText(gfx::Point(), &text); 72 GetTooltipText(gfx::Point(), &text);
74 return base::UTF16ToUTF8(text); 73 return base::UTF16ToUTF8(text);
75 } 74 }
76 75
77 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() { 76 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() {
(...skipping 30 matching lines...) Expand all
108 107
109 // static 108 // static
110 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { 109 gfx::Size BrowserActionTestUtil::GetMinPopupSize() {
111 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); 110 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight);
112 } 111 }
113 112
114 // static 113 // static
115 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { 114 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() {
116 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); 115 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight);
117 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698