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

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

Issue 6377001: [Mac] Organize all infobar files into chrome/browser/ui/cocoa/infobars/.... (Closed) Base URL: svn://svn.chromium.org/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
(Empty)
1 // Copyright (c) 2009 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/tab_contents/infobar_delegate.h"
6
7 #include "base/utf_string_conversions.h"
8
9 namespace {
10 const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage";
11 const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage";
12 const char kMockLinkInfoBarLink[] = "http://dev.chromium.org";
13 const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage";
14 }
15
16 //////////////////////////////////////////////////////////////////////////
17 // Mock InfoBarDelgates
18
19 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate {
20 public:
21 explicit MockAlertInfoBarDelegate()
22 : AlertInfoBarDelegate(NULL),
23 message_text_accessed(false),
24 icon_accessed(false),
25 closed(false) {
26 }
27
28 virtual string16 GetMessageText() const {
29 message_text_accessed = true;
30 return ASCIIToUTF16(kMockAlertInfoBarMessage);
31 }
32
33 virtual SkBitmap* GetIcon() const {
34 icon_accessed = true;
35 return NULL;
36 }
37
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;
44 mutable bool icon_accessed;
45 bool closed;
46 };
47
48 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate {
49 public:
50 explicit 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
60 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const {
61 message_text_accessed = true;
62 return ASCIIToUTF16(kMockLinkInfoBarMessage);
63 }
64
65 virtual string16 GetLinkText() const {
66 link_text_accessed = true;
67 return ASCIIToUTF16(kMockLinkInfoBarLink);
68 }
69
70 virtual SkBitmap* GetIcon() const {
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;
86 mutable bool link_text_accessed;
87 mutable bool icon_accessed;
88 bool link_clicked;
89 bool closed;
90
91 // Determines whether the infobar closes when an action is taken or not.
92 bool closes_on_action;
93 };
94
95 class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
96 public:
97 explicit 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
109 virtual int GetButtons() const {
110 return (BUTTON_OK | BUTTON_CANCEL);
111 }
112
113 virtual string16 GetButtonLabel(InfoBarButton button) const {
114 if (button == BUTTON_OK)
115 return ASCIIToUTF16("OK");
116 else
117 return ASCIIToUTF16("Cancel");
118 }
119
120 virtual bool Accept() {
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;
156 mutable bool link_text_accessed;
157 mutable bool icon_accessed;
158 bool ok_clicked;
159 bool cancel_clicked;
160 bool link_clicked;
161 bool closed;
162
163 // Determines whether the infobar closes when an action is taken or not.
164 bool closes_on_action;
165 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698