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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_test_helper.h

Issue 6249010: Cleanup: de-inline a bunch of classes, rename and move "PluginInstaller" to "... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/infobar_delegate.h" 5 #include "chrome/browser/tab_contents/infobar_delegate.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 8
9 namespace { 9 namespace {
10 const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage"; 10 const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage";
11 const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage"; 11 const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage";
12 const char kMockLinkInfoBarLink[] = "http://dev.chromium.org"; 12 const char kMockLinkInfoBarLink[] = "http://dev.chromium.org";
13 const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage"; 13 const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage";
14 } 14 }
15 15
16 ////////////////////////////////////////////////////////////////////////// 16
17 // Mock InfoBarDelgates 17 // MockAlertInfoBarDelegate ---------------------------------------------------
18 18
19 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate { 19 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate {
20 public: 20 public:
21 explicit MockAlertInfoBarDelegate() 21 MockAlertInfoBarDelegate();
22 : AlertInfoBarDelegate(NULL),
23 message_text_accessed(false),
24 icon_accessed(false),
25 closed(false) {
26 }
27 22
28 virtual string16 GetMessageText() const { 23 private:
29 message_text_accessed = true; 24 virtual ~MockAlertInfoBarDelegate();
30 return ASCIIToUTF16(kMockAlertInfoBarMessage);
31 }
32 25
33 virtual SkBitmap* GetIcon() const { 26 // AlertInfoBarDelegate
34 icon_accessed = true; 27 virtual void InfoBarClosed();
35 return NULL; 28 virtual SkBitmap* GetIcon() const;
36 } 29 virtual string16 GetMessageText() const;
37 30
38 virtual void InfoBarClosed() {
39 closed = true;
40 }
41
42 // These are declared mutable to get around const-ness issues.
43 mutable bool message_text_accessed; 31 mutable bool message_text_accessed;
44 mutable bool icon_accessed; 32 mutable bool icon_accessed;
45 bool closed; 33 bool closed;
34
35 DISALLOW_COPY_AND_ASSIGN(MockAlertInfoBarDelegate);
46 }; 36 };
47 37
38 MockAlertInfoBarDelegate::MockAlertInfoBarDelegate()
39 : AlertInfoBarDelegate(NULL),
40 message_text_accessed(false),
41 icon_accessed(false),
42 closed(false) {
43 }
44
45 void MockAlertInfoBarDelegate::InfoBarClosed() {
46 closed = true;
47 }
48
49 SkBitmap* MockAlertInfoBarDelegate::GetIcon() const {
50 icon_accessed = true;
51 return NULL;
52 }
53
54 string16 MockAlertInfoBarDelegate::GetMessageText() const {
55 message_text_accessed = true;
56 return ASCIIToUTF16(kMockAlertInfoBarMessage);
57 }
58
59
60 // MockLinkInfoBarDelegate ----------------------------------------------------
61
48 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate { 62 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate {
49 public: 63 public:
50 explicit MockLinkInfoBarDelegate() 64 MockLinkInfoBarDelegate();
51 : LinkInfoBarDelegate(NULL),
52 message_text_accessed(false),
53 link_text_accessed(false),
54 icon_accessed(false),
55 link_clicked(false),
56 closed(false),
57 closes_on_action(true) {
58 }
59 65
60 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { 66 private:
61 message_text_accessed = true; 67 virtual ~MockLinkInfoBarDelegate();
62 return ASCIIToUTF16(kMockLinkInfoBarMessage);
63 }
64 68
65 virtual string16 GetLinkText() const { 69 // LinkInfoBarDelegate
66 link_text_accessed = true; 70 virtual void InfoBarClosed();
67 return ASCIIToUTF16(kMockLinkInfoBarLink); 71 virtual SkBitmap* GetIcon() const;
68 } 72 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const;
73 virtual string16 GetLinkText() const;
74 virtual bool LinkClicked(WindowOpenDisposition disposition);
69 75
70 virtual SkBitmap* GetIcon() const { 76 mutable bool icon_accessed;
71 icon_accessed = true;
72 return NULL;
73 }
74
75 virtual bool LinkClicked(WindowOpenDisposition disposition) {
76 link_clicked = true;
77 return closes_on_action;
78 }
79
80 virtual void InfoBarClosed() {
81 closed = true;
82 }
83
84 // These are declared mutable to get around const-ness issues.
85 mutable bool message_text_accessed; 77 mutable bool message_text_accessed;
86 mutable bool link_text_accessed; 78 mutable bool link_text_accessed;
87 mutable bool icon_accessed;
88 bool link_clicked; 79 bool link_clicked;
89 bool closed; 80 bool closed;
90 81
91 // Determines whether the infobar closes when an action is taken or not. 82 // Determines whether the infobar closes when an action is taken or not.
92 bool closes_on_action; 83 bool closes_on_action;
84
85 DISALLOW_COPY_AND_ASSIGN(MockLinkInfoBarDelegate);
93 }; 86 };
94 87
88
89 MockLinkInfoBarDelegate::MockLinkInfoBarDelegate()
90 : LinkInfoBarDelegate(NULL),
91 icon_accessed(false),
92 message_text_accessed(false),
93 link_text_accessed(false),
94 link_clicked(false),
95 closed(false),
96 closes_on_action(true) {
97 }
98
99 MockLinkInfoBarDelegate::~MockLinkInfoBarDelegate() {
100 }
101
102 void MockLinkInfoBarDelegate::InfoBarClosed() {
103 closed = true;
104 }
105
106 SkBitmap* MockLinkInfoBarDelegate::GetIcon() const {
107 icon_accessed = true;
108 return NULL;
109 }
110
111 string16 MockLinkInfoBarDelegate::GetMessageTextWithOffset(
112 size_t* link_offset) const {
113 message_text_accessed = true;
114 return ASCIIToUTF16(kMockLinkInfoBarMessage);
115 }
116
117 string16 MockLinkInfoBarDelegate::GetLinkText() const {
118 link_text_accessed = true;
119 return ASCIIToUTF16(kMockLinkInfoBarLink);
120 }
121
122 bool MockLinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
123 link_clicked = true;
124 return closes_on_action;
125 }
126
127
128 // MockConfirmInfoBarDelegate -------------------------------------------------
129
95 class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { 130 class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
96 public: 131 public:
97 explicit MockConfirmInfoBarDelegate() 132 MockConfirmInfoBarDelegate();
98 : ConfirmInfoBarDelegate(NULL),
99 message_text_accessed(false),
100 link_text_accessed(false),
101 icon_accessed(false),
102 ok_clicked(false),
103 cancel_clicked(false),
104 link_clicked(false),
105 closed(false),
106 closes_on_action(true) {
107 }
108 133
109 virtual int GetButtons() const { 134 private:
110 return (BUTTON_OK | BUTTON_CANCEL); 135 virtual ~MockConfirmInfoBarDelegate();
111 }
112 136
113 virtual string16 GetButtonLabel(InfoBarButton button) const { 137 // ConfirmInfoBarDelegate
114 if (button == BUTTON_OK) 138 virtual void InfoBarClosed();
115 return ASCIIToUTF16("OK"); 139 virtual SkBitmap* GetIcon() const;
116 else 140 virtual string16 GetMessageText() const;
117 return ASCIIToUTF16("Cancel"); 141 virtual int GetButtons() const;
118 } 142 virtual string16 GetButtonLabel(InfoBarButton button) const;
143 virtual bool Accept();
144 virtual bool Cancel();
145 virtual string16 GetLinkText();
146 virtual bool LinkClicked(WindowOpenDisposition disposition);
119 147
120 virtual bool Accept() { 148 mutable bool icon_accessed;
121 ok_clicked = true;
122 return closes_on_action;
123 }
124
125 virtual bool Cancel() {
126 cancel_clicked = true;
127 return closes_on_action;
128 }
129
130 virtual string16 GetMessageText() const {
131 message_text_accessed = true;
132 return ASCIIToUTF16(kMockConfirmInfoBarMessage);
133 }
134
135 virtual SkBitmap* GetIcon() const {
136 icon_accessed = true;
137 return NULL;
138 }
139
140 virtual void InfoBarClosed() {
141 closed = true;
142 }
143
144 virtual string16 GetLinkText() {
145 link_text_accessed = true;
146 return string16();
147 }
148
149 virtual bool LinkClicked(WindowOpenDisposition disposition) {
150 link_clicked = true;
151 return closes_on_action;
152 }
153
154 // These are declared mutable to get around const-ness issues.
155 mutable bool message_text_accessed; 149 mutable bool message_text_accessed;
156 mutable bool link_text_accessed; 150 mutable bool link_text_accessed;
157 mutable bool icon_accessed;
158 bool ok_clicked; 151 bool ok_clicked;
159 bool cancel_clicked; 152 bool cancel_clicked;
160 bool link_clicked; 153 bool link_clicked;
161 bool closed; 154 bool closed;
162 155
163 // Determines whether the infobar closes when an action is taken or not. 156 // Determines whether the infobar closes when an action is taken or not.
164 bool closes_on_action; 157 bool closes_on_action;
158
159 DISALLOW_COPY_AND_ASSIGN(MockConfirmInfoBarDelegate);
165 }; 160 };
161
162 MockConfirmInfoBarDelegate::MockConfirmInfoBarDelegate()
163 : ConfirmInfoBarDelegate(NULL),
164 icon_accessed(false),
165 message_text_accessed(false),
166 link_text_accessed(false),
167 ok_clicked(false),
168 cancel_clicked(false),
169 link_clicked(false),
170 closed(false),
171 closes_on_action(true) {
172 }
173
174 MockConfirmInfoBarDelegate::~MockConfirmInfoBarDelegate() {
175 }
176
177 void MockConfirmInfoBarDelegate::InfoBarClosed() {
178 closed = true;
179 }
180
181 SkBitmap* MockConfirmInfoBarDelegate::GetIcon() const {
182 icon_accessed = true;
183 return NULL;
184 }
185
186 string16 MockConfirmInfoBarDelegate::GetMessageText() const {
187 message_text_accessed = true;
188 return ASCIIToUTF16(kMockConfirmInfoBarMessage);
189 }
190
191 int MockConfirmInfoBarDelegate::GetButtons() const {
192 return (BUTTON_OK | BUTTON_CANCEL);
193 }
194
195 string16 MockConfirmInfoBarDelegate::GetButtonLabel(
196 InfoBarButton button) const {
197 return ASCIIToUTF16((button == BUTTON_OK) ? "OK" : "Cancel");
198 }
199
200 bool MockConfirmInfoBarDelegate::Accept() {
201 ok_clicked = true;
202 return closes_on_action;
203 }
204
205 bool MockConfirmInfoBarDelegate::Cancel() {
206 cancel_clicked = true;
207 return closes_on_action;
208 }
209
210 string16 MockConfirmInfoBarDelegate::GetLinkText() {
211 link_text_accessed = true;
212 return string16();
213 }
214
215 bool MockConfirmInfoBarDelegate::LinkClicked(
216 WindowOpenDisposition disposition) {
217 link_clicked = true;
218 return closes_on_action;
219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698