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

Side by Side Diff: chrome/browser/ui/toolbar/test_toolbar_action_view_controller.cc

Issue 888043003: [Extensions Toolbar Views] Add a ToolbarActionView unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 10 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
(Empty)
1 // Copyright 2015 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 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
6
7 #include "base/strings/string16.h"
8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h"
9 #include "ui/gfx/image/image.h"
10 #include "ui/gfx/image/image_skia.h"
11
12 TestToolbarActionViewController::TestToolbarActionViewController(
13 const std::string& id)
14 : id_(id),
15 delegate_(nullptr),
16 is_enabled_(true),
17 wants_to_run_(false),
18 execute_action_count_(0) {
19 }
20
21 TestToolbarActionViewController::~TestToolbarActionViewController() {
22 }
23
24 const std::string& TestToolbarActionViewController::GetId() const {
25 return id_;
26 }
27
28 void TestToolbarActionViewController::SetDelegate(
29 ToolbarActionViewDelegate* delegate) {
30 delegate_ = delegate;
31 }
32
33 gfx::Image TestToolbarActionViewController::GetIcon(
34 content::WebContents* web_contents) {
35 return gfx::Image();
36 }
37
38 gfx::ImageSkia TestToolbarActionViewController::GetIconWithBadge() {
39 return gfx::ImageSkia();
40 }
41
42 base::string16 TestToolbarActionViewController::GetActionName() const {
43 return base::string16();
44 }
45
46 base::string16 TestToolbarActionViewController::GetAccessibleName(
47 content::WebContents* web_contents) const {
48 return accessible_name_;
49 }
50
51 base::string16 TestToolbarActionViewController::GetTooltip(
52 content::WebContents* web_contents) const {
53 return tooltip_;
54 }
55
56 bool TestToolbarActionViewController::IsEnabled(
57 content::WebContents* web_contents) const {
58 return is_enabled_;
59 }
60
61 bool TestToolbarActionViewController::WantsToRun(
62 content::WebContents* web_contents) const {
63 return wants_to_run_;
64 }
65
66 bool TestToolbarActionViewController::HasPopup(
67 content::WebContents* web_contents) const {
68 return true;
69 }
70
71 void TestToolbarActionViewController::HidePopup() {
72 delegate_->OnPopupClosed();
73 }
74
75 gfx::NativeView TestToolbarActionViewController::GetPopupNativeView() {
76 return nullptr;
77 }
78
79 ui::MenuModel* TestToolbarActionViewController::GetContextMenu() {
80 return nullptr;
81 }
82
83 bool TestToolbarActionViewController::IsMenuRunning() const {
84 return false;
85 }
86
87 bool TestToolbarActionViewController::CanDrag() const {
88 return false;
89 }
90
91 bool TestToolbarActionViewController::ExecuteAction(bool by_user) {
92 ++execute_action_count_;
93 return false;
94 }
95
96 void TestToolbarActionViewController::UpdateState() {
97 UpdateDelegate();
98 }
99
100 void TestToolbarActionViewController::ShowPopup(bool by_user) {
101 delegate_->OnPopupShown(by_user);
102 }
103
104 void TestToolbarActionViewController::SetAccessibleName(
105 const base::string16& name) {
106 accessible_name_ = name;
107 UpdateDelegate();
108 }
109
110 void TestToolbarActionViewController::SetTooltip(
111 const base::string16& tooltip) {
112 tooltip_ = tooltip;
113 UpdateDelegate();
114 }
115
116 void TestToolbarActionViewController::SetEnabled(bool is_enabled) {
117 is_enabled_ = is_enabled;
118 UpdateDelegate();
119 }
120
121 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run) {
122 wants_to_run_ = wants_to_run;
123 UpdateDelegate();
124 }
125
126 void TestToolbarActionViewController::UpdateDelegate() {
127 if (delegate_)
128 delegate_->UpdateState();
129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698