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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/infobar_test_helper.h
===================================================================
--- chrome/browser/cocoa/infobar_test_helper.h (revision 0)
+++ chrome/browser/cocoa/infobar_test_helper.h (revision 0)
@@ -0,0 +1,152 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/tab_contents/infobar_delegate.h"
+
+namespace {
+const wchar_t* kMockAlertInfoBarMessage = L"MockAlertInfoBarMessage";
+const wchar_t* kMockLinkInfoBarMessage = L"MockLinkInfoBarMessage";
+const wchar_t* kMockLinkInfoBarLink = L"http://dev.chromium.org";
+const wchar_t* kMockConfirmInfoBarMessage = L"MockConfirmInfoBarMessage";
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Mock InfoBarDelgates
+
+class MockAlertInfoBarDelegate : public AlertInfoBarDelegate {
+ public:
+ explicit MockAlertInfoBarDelegate()
+ : AlertInfoBarDelegate(NULL),
+ message_text_accessed(false),
+ icon_accessed(false),
+ closed(false) {
+ }
+
+ virtual std::wstring GetMessageText() const {
+ message_text_accessed = true;
+ return kMockAlertInfoBarMessage;
+ }
+
+ virtual SkBitmap* GetIcon() const {
+ icon_accessed = true;
+ return NULL;
+ }
+
+ virtual void InfoBarClosed() {
+ closed = true;
+ }
+
+ // These are declared mutable to get around const-ness issues.
+ mutable bool message_text_accessed;
+ mutable bool icon_accessed;
+ bool closed;
+};
+
+class MockLinkInfoBarDelegate : public LinkInfoBarDelegate {
+ public:
+ explicit MockLinkInfoBarDelegate()
+ : LinkInfoBarDelegate(NULL),
+ message_text_accessed(false),
+ link_text_accessed(false),
+ icon_accessed(false),
+ link_clicked(false),
+ closed(false),
+ closes_on_action(true) {
+ }
+
+ virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const {
+ message_text_accessed = true;
+ *link_offset = 1;
+ return kMockLinkInfoBarMessage;
+ }
+
+ virtual std::wstring GetLinkText() const {
+ link_text_accessed = true;
+ return kMockLinkInfoBarLink;
+ }
+
+ virtual SkBitmap* GetIcon() const {
+ icon_accessed = true;
+ return NULL;
+ }
+
+ virtual bool LinkClicked(WindowOpenDisposition disposition) {
+ link_clicked = true;
+ return closes_on_action;
+ }
+
+ virtual void InfoBarClosed() {
+ closed = true;
+ }
+
+ // These are declared mutable to get around const-ness issues.
+ mutable bool message_text_accessed;
+ mutable bool link_text_accessed;
+ mutable bool icon_accessed;
+ bool link_clicked;
+ bool closed;
+
+ // Determines whether the infobar closes when an action is taken or not.
+ bool closes_on_action;
+};
+
+class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ explicit MockConfirmInfoBarDelegate()
+ : ConfirmInfoBarDelegate(NULL),
+ message_text_accessed(false),
+ link_text_accessed(false),
+ icon_accessed(false),
+ ok_clicked(false),
+ cancel_clicked(false),
+ closed(false),
+ closes_on_action(true) {
+ }
+
+ virtual int GetButtons() const {
+ return (BUTTON_OK | BUTTON_CANCEL);
+ }
+
+ virtual std::wstring GetButtonLabel(InfoBarButton button) const {
+ if (button == BUTTON_OK)
+ return L"OK";
+ else
+ return L"Cancel";
+ }
+
+ virtual bool Accept() {
+ ok_clicked = true;
+ return closes_on_action;
+ }
+
+ virtual bool Cancel() {
+ cancel_clicked = true;
+ return closes_on_action;
+ }
+
+ virtual std::wstring GetMessageText() const {
+ message_text_accessed = true;
+ return kMockConfirmInfoBarMessage;
+ }
+
+ virtual SkBitmap* GetIcon() const {
+ icon_accessed = true;
+ return NULL;
+ }
+
+ virtual void InfoBarClosed() {
+ closed = true;
+ }
+
+ // These are declared mutable to get around const-ness issues.
+ mutable bool message_text_accessed;
+ mutable bool link_text_accessed;
+ mutable bool icon_accessed;
+ bool ok_clicked;
+ bool cancel_clicked;
+ bool closed;
+
+ // Determines whether the infobar closes when an action is taken or not.
+ bool closes_on_action;
+};
Property changes on: chrome/browser/cocoa/infobar_test_helper.h
___________________________________________________________________
Name: svn:eol-style
+ LF
« 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