Index: chrome/browser/ui/cocoa/infobars/infobar_test_helper.h |
=================================================================== |
--- chrome/browser/ui/cocoa/infobars/infobar_test_helper.h (revision 71863) |
+++ chrome/browser/ui/cocoa/infobars/infobar_test_helper.h (working copy) |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 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. |
@@ -13,148 +13,141 @@ |
const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage"; |
} |
-////////////////////////////////////////////////////////////////////////// |
-// Mock InfoBarDelgates |
+// MockAlertInfoBarDelegate --------------------------------------------------- |
+ |
class MockAlertInfoBarDelegate : public AlertInfoBarDelegate { |
public: |
- explicit MockAlertInfoBarDelegate() |
- : AlertInfoBarDelegate(NULL), |
- message_text_accessed(false), |
- icon_accessed(false), |
- closed(false) { |
- } |
+ MockAlertInfoBarDelegate(); |
- virtual string16 GetMessageText() const { |
- message_text_accessed = true; |
- return ASCIIToUTF16(kMockAlertInfoBarMessage); |
- } |
+ private: |
+ virtual ~MockAlertInfoBarDelegate(); |
- virtual SkBitmap* GetIcon() const { |
- icon_accessed = true; |
- return NULL; |
- } |
+ // AlertInfoBarDelegate |
+ virtual void InfoBarClosed(); |
+ virtual SkBitmap* GetIcon() const; |
+ virtual string16 GetMessageText() const; |
- 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; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MockAlertInfoBarDelegate); |
}; |
-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) { |
- } |
+MockAlertInfoBarDelegate::MockAlertInfoBarDelegate() |
+ : AlertInfoBarDelegate(NULL), |
+ message_text_accessed(false), |
+ icon_accessed(false), |
+ closed(false) { |
+} |
- virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { |
- message_text_accessed = true; |
- return ASCIIToUTF16(kMockLinkInfoBarMessage); |
- } |
+void MockAlertInfoBarDelegate::InfoBarClosed() { |
+ closed = true; |
+} |
- virtual string16 GetLinkText() const { |
- link_text_accessed = true; |
- return ASCIIToUTF16(kMockLinkInfoBarLink); |
- } |
+SkBitmap* MockAlertInfoBarDelegate::GetIcon() const { |
+ icon_accessed = true; |
+ return NULL; |
+} |
- virtual SkBitmap* GetIcon() const { |
- icon_accessed = true; |
- return NULL; |
- } |
+string16 MockAlertInfoBarDelegate::GetMessageText() const { |
+ message_text_accessed = true; |
+ return ASCIIToUTF16(kMockAlertInfoBarMessage); |
+} |
- virtual bool LinkClicked(WindowOpenDisposition disposition) { |
- link_clicked = true; |
- return closes_on_action; |
- } |
- virtual void InfoBarClosed() { |
- closed = true; |
- } |
+// MockLinkInfoBarDelegate ---------------------------------------------------- |
- // These are declared mutable to get around const-ness issues. |
+class MockLinkInfoBarDelegate : public LinkInfoBarDelegate { |
+ public: |
+ MockLinkInfoBarDelegate(); |
+ |
+ private: |
+ virtual ~MockLinkInfoBarDelegate(); |
+ |
+ // LinkInfoBarDelegate |
+ virtual void InfoBarClosed(); |
+ virtual SkBitmap* GetIcon() const; |
+ virtual string16 GetMessageTextWithOffset(size_t* link_offset) const; |
+ virtual string16 GetLinkText() const; |
+ virtual bool LinkClicked(WindowOpenDisposition disposition); |
+ |
+ mutable bool icon_accessed; |
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; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MockLinkInfoBarDelegate); |
}; |
-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), |
- link_clicked(false), |
- closed(false), |
- closes_on_action(true) { |
- } |
- virtual int GetButtons() const { |
- return (BUTTON_OK | BUTTON_CANCEL); |
- } |
+MockLinkInfoBarDelegate::MockLinkInfoBarDelegate() |
+ : LinkInfoBarDelegate(NULL), |
+ icon_accessed(false), |
+ message_text_accessed(false), |
+ link_text_accessed(false), |
+ link_clicked(false), |
+ closed(false), |
+ closes_on_action(true) { |
+} |
- virtual string16 GetButtonLabel(InfoBarButton button) const { |
- if (button == BUTTON_OK) |
- return ASCIIToUTF16("OK"); |
- else |
- return ASCIIToUTF16("Cancel"); |
- } |
+MockLinkInfoBarDelegate::~MockLinkInfoBarDelegate() { |
+} |
- virtual bool Accept() { |
- ok_clicked = true; |
- return closes_on_action; |
- } |
+void MockLinkInfoBarDelegate::InfoBarClosed() { |
+ closed = true; |
+} |
- virtual bool Cancel() { |
- cancel_clicked = true; |
- return closes_on_action; |
- } |
+SkBitmap* MockLinkInfoBarDelegate::GetIcon() const { |
+ icon_accessed = true; |
+ return NULL; |
+} |
- virtual string16 GetMessageText() const { |
- message_text_accessed = true; |
- return ASCIIToUTF16(kMockConfirmInfoBarMessage); |
- } |
+string16 MockLinkInfoBarDelegate::GetMessageTextWithOffset( |
+ size_t* link_offset) const { |
+ message_text_accessed = true; |
+ return ASCIIToUTF16(kMockLinkInfoBarMessage); |
+} |
- virtual SkBitmap* GetIcon() const { |
- icon_accessed = true; |
- return NULL; |
- } |
+string16 MockLinkInfoBarDelegate::GetLinkText() const { |
+ link_text_accessed = true; |
+ return ASCIIToUTF16(kMockLinkInfoBarLink); |
+} |
- virtual void InfoBarClosed() { |
- closed = true; |
- } |
+bool MockLinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
+ link_clicked = true; |
+ return closes_on_action; |
+} |
- virtual string16 GetLinkText() { |
- link_text_accessed = true; |
- return string16(); |
- } |
- virtual bool LinkClicked(WindowOpenDisposition disposition) { |
- link_clicked = true; |
- return closes_on_action; |
- } |
+// MockConfirmInfoBarDelegate ------------------------------------------------- |
- // These are declared mutable to get around const-ness issues. |
+class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { |
+ public: |
+ MockConfirmInfoBarDelegate(); |
+ |
+ private: |
+ virtual ~MockConfirmInfoBarDelegate(); |
+ |
+ // ConfirmInfoBarDelegate |
+ virtual void InfoBarClosed(); |
+ virtual SkBitmap* GetIcon() const; |
+ virtual string16 GetMessageText() const; |
+ virtual int GetButtons() const; |
+ virtual string16 GetButtonLabel(InfoBarButton button) const; |
+ virtual bool Accept(); |
+ virtual bool Cancel(); |
+ virtual string16 GetLinkText(); |
+ virtual bool LinkClicked(WindowOpenDisposition disposition); |
+ |
+ mutable bool icon_accessed; |
mutable bool message_text_accessed; |
mutable bool link_text_accessed; |
- mutable bool icon_accessed; |
bool ok_clicked; |
bool cancel_clicked; |
bool link_clicked; |
@@ -162,4 +155,65 @@ |
// Determines whether the infobar closes when an action is taken or not. |
bool closes_on_action; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MockConfirmInfoBarDelegate); |
}; |
+ |
+MockConfirmInfoBarDelegate::MockConfirmInfoBarDelegate() |
+ : ConfirmInfoBarDelegate(NULL), |
+ icon_accessed(false), |
+ message_text_accessed(false), |
+ link_text_accessed(false), |
+ ok_clicked(false), |
+ cancel_clicked(false), |
+ link_clicked(false), |
+ closed(false), |
+ closes_on_action(true) { |
+} |
+ |
+MockConfirmInfoBarDelegate::~MockConfirmInfoBarDelegate() { |
+} |
+ |
+void MockConfirmInfoBarDelegate::InfoBarClosed() { |
+ closed = true; |
+} |
+ |
+SkBitmap* MockConfirmInfoBarDelegate::GetIcon() const { |
+ icon_accessed = true; |
+ return NULL; |
+} |
+ |
+string16 MockConfirmInfoBarDelegate::GetMessageText() const { |
+ message_text_accessed = true; |
+ return ASCIIToUTF16(kMockConfirmInfoBarMessage); |
+} |
+ |
+int MockConfirmInfoBarDelegate::GetButtons() const { |
+ return (BUTTON_OK | BUTTON_CANCEL); |
+} |
+ |
+string16 MockConfirmInfoBarDelegate::GetButtonLabel( |
+ InfoBarButton button) const { |
+ return ASCIIToUTF16((button == BUTTON_OK) ? "OK" : "Cancel"); |
+} |
+ |
+bool MockConfirmInfoBarDelegate::Accept() { |
+ ok_clicked = true; |
+ return closes_on_action; |
+} |
+ |
+bool MockConfirmInfoBarDelegate::Cancel() { |
+ cancel_clicked = true; |
+ return closes_on_action; |
+} |
+ |
+string16 MockConfirmInfoBarDelegate::GetLinkText() { |
+ link_text_accessed = true; |
+ return string16(); |
+} |
+ |
+bool MockConfirmInfoBarDelegate::LinkClicked( |
+ WindowOpenDisposition disposition) { |
+ link_clicked = true; |
+ return closes_on_action; |
+} |