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

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

Issue 155494: First cut at infobars on Mac. These are not expected to be... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 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
Property Changes:
Name: svn:eol-style
+ LF
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 namespace {
8 const wchar_t* kMockAlertInfoBarMessage = L"MockAlertInfoBarMessage";
9 const wchar_t* kMockLinkInfoBarMessage = L"MockLinkInfoBarMessage";
10 const wchar_t* kMockLinkInfoBarLink = L"http://dev.chromium.org";
11 const wchar_t* kMockConfirmInfoBarMessage = L"MockConfirmInfoBarMessage";
12 }
13
14 //////////////////////////////////////////////////////////////////////////
15 // Mock InfoBarDelgates
16
17 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate {
18 public:
19 explicit MockAlertInfoBarDelegate()
20 : AlertInfoBarDelegate(NULL),
21 message_text_accessed(false),
22 icon_accessed(false),
23 closed(false) {
24 }
25
26 virtual std::wstring GetMessageText() const {
27 message_text_accessed = true;
28 return kMockAlertInfoBarMessage;
29 }
30
31 virtual SkBitmap* GetIcon() const {
32 icon_accessed = true;
33 return NULL;
34 }
35
36 virtual void InfoBarClosed() {
37 closed = true;
38 }
39
40 // These are declared mutable to get around const-ness issues.
41 mutable bool message_text_accessed;
42 mutable bool icon_accessed;
43 bool closed;
44 };
45
46 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate {
47 public:
48 explicit MockLinkInfoBarDelegate()
49 : LinkInfoBarDelegate(NULL),
50 message_text_accessed(false),
51 link_text_accessed(false),
52 icon_accessed(false),
53 link_clicked(false),
54 closed(false),
55 closes_on_action(true) {
56 }
57
58 virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const {
59 message_text_accessed = true;
60 *link_offset = 1;
61 return kMockLinkInfoBarMessage;
62 }
63
64 virtual std::wstring GetLinkText() const {
65 link_text_accessed = true;
66 return kMockLinkInfoBarLink;
67 }
68
69 virtual SkBitmap* GetIcon() const {
70 icon_accessed = true;
71 return NULL;
72 }
73
74 virtual bool LinkClicked(WindowOpenDisposition disposition) {
75 link_clicked = true;
76 return closes_on_action;
77 }
78
79 virtual void InfoBarClosed() {
80 closed = true;
81 }
82
83 // These are declared mutable to get around const-ness issues.
84 mutable bool message_text_accessed;
85 mutable bool link_text_accessed;
86 mutable bool icon_accessed;
87 bool link_clicked;
88 bool closed;
89
90 // Determines whether the infobar closes when an action is taken or not.
91 bool closes_on_action;
92 };
93
94 class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
95 public:
96 explicit MockConfirmInfoBarDelegate()
97 : ConfirmInfoBarDelegate(NULL),
98 message_text_accessed(false),
99 link_text_accessed(false),
100 icon_accessed(false),
101 ok_clicked(false),
102 cancel_clicked(false),
103 closed(false),
104 closes_on_action(true) {
105 }
106
107 virtual int GetButtons() const {
108 return (BUTTON_OK | BUTTON_CANCEL);
109 }
110
111 virtual std::wstring GetButtonLabel(InfoBarButton button) const {
112 if (button == BUTTON_OK)
113 return L"OK";
114 else
115 return L"Cancel";
116 }
117
118 virtual bool Accept() {
119 ok_clicked = true;
120 return closes_on_action;
121 }
122
123 virtual bool Cancel() {
124 cancel_clicked = true;
125 return closes_on_action;
126 }
127
128 virtual std::wstring GetMessageText() const {
129 message_text_accessed = true;
130 return kMockConfirmInfoBarMessage;
131 }
132
133 virtual SkBitmap* GetIcon() const {
134 icon_accessed = true;
135 return NULL;
136 }
137
138 virtual void InfoBarClosed() {
139 closed = true;
140 }
141
142 // These are declared mutable to get around const-ness issues.
143 mutable bool message_text_accessed;
144 mutable bool link_text_accessed;
145 mutable bool icon_accessed;
146 bool ok_clicked;
147 bool cancel_clicked;
148 bool closed;
149
150 // Determines whether the infobar closes when an action is taken or not.
151 bool closes_on_action;
152 };
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/infobar_controller_unittest.mm ('k') | chrome/browser/cocoa/infobar_text_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698