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

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

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/ui/cocoa/infobars/infobar_test_helper.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 8
9 namespace { 9
10 const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage"; 10 // MockAlertInfoBarDelegate ---------------------------------------------------
11 const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage"; 11
12 const char kMockLinkInfoBarLink[] = "http://dev.chromium.org"; 12 const char MockAlertInfoBarDelegate::kMessage[] = "MockAlertInfoBarMessage";
13 const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage"; 13
14 MockAlertInfoBarDelegate::MockAlertInfoBarDelegate()
15 : AlertInfoBarDelegate(NULL),
16 icon_accessed_(false),
17 message_text_accessed_(false),
18 closed_(false) {
14 } 19 }
15 20
16 ////////////////////////////////////////////////////////////////////////// 21 MockAlertInfoBarDelegate::~MockAlertInfoBarDelegate() {
17 // Mock InfoBarDelgates 22 }
18 23
19 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate { 24 void MockAlertInfoBarDelegate::InfoBarClosed() {
20 public: 25 closed_ = true;
21 explicit MockAlertInfoBarDelegate() 26 }
22 : AlertInfoBarDelegate(NULL),
23 message_text_accessed(false),
24 icon_accessed(false),
25 closed(false) {
26 }
27 27
28 virtual string16 GetMessageText() const { 28 SkBitmap* MockAlertInfoBarDelegate::GetIcon() const {
29 message_text_accessed = true; 29 icon_accessed_ = true;
30 return ASCIIToUTF16(kMockAlertInfoBarMessage); 30 return NULL;
31 } 31 }
32 32
33 virtual SkBitmap* GetIcon() const { 33 string16 MockAlertInfoBarDelegate::GetMessageText() const {
34 icon_accessed = true; 34 message_text_accessed_ = true;
35 return NULL; 35 return ASCIIToUTF16(kMessage);
36 } 36 }
37 37
38 virtual void InfoBarClosed() {
39 closed = true;
40 }
41 38
42 // These are declared mutable to get around const-ness issues. 39 // MockLinkInfoBarDelegate ----------------------------------------------------
43 mutable bool message_text_accessed;
44 mutable bool icon_accessed;
45 bool closed;
46 };
47 40
48 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate { 41 const char MockLinkInfoBarDelegate::kMessage[] = "MockLinkInfoBarMessage";
49 public: 42 const char MockLinkInfoBarDelegate::kLink[] = "http://dev.chromium.org";
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 43
60 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { 44 MockLinkInfoBarDelegate::MockLinkInfoBarDelegate()
61 message_text_accessed = true; 45 : LinkInfoBarDelegate(NULL),
62 return ASCIIToUTF16(kMockLinkInfoBarMessage); 46 closes_on_action_(true),
63 } 47 icon_accessed_(false),
48 message_text_accessed_(false),
49 link_text_accessed_(false),
50 link_clicked_(false),
51 closed_(false) {
52 }
64 53
65 virtual string16 GetLinkText() const { 54 MockLinkInfoBarDelegate::~MockLinkInfoBarDelegate() {
66 link_text_accessed = true; 55 }
67 return ASCIIToUTF16(kMockLinkInfoBarLink);
68 }
69 56
70 virtual SkBitmap* GetIcon() const { 57 void MockLinkInfoBarDelegate::InfoBarClosed() {
71 icon_accessed = true; 58 closed_ = true;
72 return NULL; 59 }
73 }
74 60
75 virtual bool LinkClicked(WindowOpenDisposition disposition) { 61 SkBitmap* MockLinkInfoBarDelegate::GetIcon() const {
76 link_clicked = true; 62 icon_accessed_ = true;
77 return closes_on_action; 63 return NULL;
78 } 64 }
79 65
80 virtual void InfoBarClosed() { 66 string16 MockLinkInfoBarDelegate::GetMessageTextWithOffset(
81 closed = true; 67 size_t* link_offset) const {
82 } 68 message_text_accessed_ = true;
69 return ASCIIToUTF16(kMessage);
70 }
83 71
84 // These are declared mutable to get around const-ness issues. 72 string16 MockLinkInfoBarDelegate::GetLinkText() const {
85 mutable bool message_text_accessed; 73 link_text_accessed_ = true;
86 mutable bool link_text_accessed; 74 return ASCIIToUTF16(kLink);
87 mutable bool icon_accessed; 75 }
88 bool link_clicked;
89 bool closed;
90 76
91 // Determines whether the infobar closes when an action is taken or not. 77 bool MockLinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
92 bool closes_on_action; 78 link_clicked_ = true;
93 }; 79 return closes_on_action_;
80 }
94 81
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 82
109 virtual int GetButtons() const { 83 // MockConfirmInfoBarDelegate -------------------------------------------------
110 return (BUTTON_OK | BUTTON_CANCEL);
111 }
112 84
113 virtual string16 GetButtonLabel(InfoBarButton button) const { 85 const char MockConfirmInfoBarDelegate::kMessage[] = "MockConfirmInfoBarMessage";
114 if (button == BUTTON_OK)
115 return ASCIIToUTF16("OK");
116 else
117 return ASCIIToUTF16("Cancel");
118 }
119 86
120 virtual bool Accept() { 87 MockConfirmInfoBarDelegate::MockConfirmInfoBarDelegate()
121 ok_clicked = true; 88 : ConfirmInfoBarDelegate(NULL),
122 return closes_on_action; 89 closes_on_action_(true),
123 } 90 icon_accessed_(false),
91 message_text_accessed_(false),
92 link_text_accessed_(false),
93 ok_clicked_(false),
94 cancel_clicked_(false),
95 link_clicked_(false),
96 closed_(false) {
97 }
124 98
125 virtual bool Cancel() { 99 MockConfirmInfoBarDelegate::~MockConfirmInfoBarDelegate() {
126 cancel_clicked = true; 100 }
127 return closes_on_action;
128 }
129 101
130 virtual string16 GetMessageText() const { 102 void MockConfirmInfoBarDelegate::InfoBarClosed() {
131 message_text_accessed = true; 103 closed_ = true;
132 return ASCIIToUTF16(kMockConfirmInfoBarMessage); 104 }
133 }
134 105
135 virtual SkBitmap* GetIcon() const { 106 SkBitmap* MockConfirmInfoBarDelegate::GetIcon() const {
136 icon_accessed = true; 107 icon_accessed_ = true;
137 return NULL; 108 return NULL;
138 } 109 }
139 110
140 virtual void InfoBarClosed() { 111 string16 MockConfirmInfoBarDelegate::GetMessageText() const {
141 closed = true; 112 message_text_accessed_ = true;
142 } 113 return ASCIIToUTF16(kMessage);
114 }
143 115
144 virtual string16 GetLinkText() { 116 int MockConfirmInfoBarDelegate::GetButtons() const {
145 link_text_accessed = true; 117 return BUTTON_OK | BUTTON_CANCEL;
146 return string16(); 118 }
147 }
148 119
149 virtual bool LinkClicked(WindowOpenDisposition disposition) { 120 string16 MockConfirmInfoBarDelegate::GetButtonLabel(
150 link_clicked = true; 121 InfoBarButton button) const {
151 return closes_on_action; 122 return ASCIIToUTF16((button == BUTTON_OK) ? "OK" : "Cancel");
152 } 123 }
153 124
154 // These are declared mutable to get around const-ness issues. 125 bool MockConfirmInfoBarDelegate::Accept() {
155 mutable bool message_text_accessed; 126 ok_clicked_ = true;
156 mutable bool link_text_accessed; 127 return closes_on_action_;
157 mutable bool icon_accessed; 128 }
158 bool ok_clicked;
159 bool cancel_clicked;
160 bool link_clicked;
161 bool closed;
162 129
163 // Determines whether the infobar closes when an action is taken or not. 130 bool MockConfirmInfoBarDelegate::Cancel() {
164 bool closes_on_action; 131 cancel_clicked_ = true;
165 }; 132 return closes_on_action_;
133 }
134
135 string16 MockConfirmInfoBarDelegate::GetLinkText() {
136 link_text_accessed_ = true;
137 return string16();
138 }
139
140 bool MockConfirmInfoBarDelegate::LinkClicked(
141 WindowOpenDisposition disposition) {
142 link_clicked_ = true;
143 return closes_on_action_;
144 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/infobars/infobar_test_helper.h ('k') | chrome/browser/ui/cocoa/keystone_infobar.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698