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

Unified Diff: chrome/browser/download/download_request_infobar_delegate_unittest.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_request_infobar_delegate_unittest.cc
===================================================================
--- chrome/browser/download/download_request_infobar_delegate_unittest.cc (revision 175396)
+++ chrome/browser/download/download_request_infobar_delegate_unittest.cc (working copy)
@@ -18,23 +18,14 @@
virtual void Cancel();
virtual void Accept();
- ConfirmInfoBarDelegate* infobar() {
- return infobar_->AsConfirmInfoBarDelegate();
- }
- void close_infobar() {
- // TODO(pkasting): Right now InfoBarDelegates delete themselves via
- // InfoBarClosed(); once InfoBars own their delegates, this can become a
- // simple reset() call and ~MockTabDownloadState() will no longer need to
- // call it.
- if (infobar_ != NULL)
- infobar_.release()->InfoBarClosed();
- }
+ ConfirmInfoBarDelegate* infobar() { return infobar_.get(); }
+ void delete_infobar_delegate() { infobar_.reset(); }
bool responded() const { return responded_; }
bool accepted() const { return accepted_; }
private:
// The actual infobar delegate we're listening to.
- scoped_ptr<InfoBarDelegate> infobar_;
+ scoped_ptr<DownloadRequestInfoBarDelegate> infobar_;
// True if we have gotten some sort of response.
bool responded_;
@@ -45,12 +36,12 @@
};
MockTabDownloadState::MockTabDownloadState()
- : responded_(false), accepted_(false) {
- infobar_.reset(new DownloadRequestInfoBarDelegate(NULL, this));
+ : infobar_(DownloadRequestInfoBarDelegate::Create(this)),
+ responded_(false),
+ accepted_(false) {
}
MockTabDownloadState::~MockTabDownloadState() {
- close_infobar();
EXPECT_TRUE(responded_);
}
@@ -64,7 +55,7 @@
EXPECT_FALSE(responded_);
responded_ = true;
accepted_ = true;
- static_cast<DownloadRequestInfoBarDelegate*>(infobar_.get())->set_host(NULL);
+ infobar_->set_host(NULL);
}
@@ -73,19 +64,19 @@
TEST(DownloadRequestInfobarDelegate, AcceptTest) {
MockTabDownloadState state;
if (state.infobar()->Accept())
- state.close_infobar();
+ state.delete_infobar_delegate();
EXPECT_TRUE(state.accepted());
}
TEST(DownloadRequestInfobarDelegate, CancelTest) {
MockTabDownloadState state;
if (state.infobar()->Cancel())
- state.close_infobar();
+ state.delete_infobar_delegate();
EXPECT_FALSE(state.accepted());
}
TEST(DownloadRequestInfobarDelegate, CloseTest) {
MockTabDownloadState state;
- state.close_infobar();
+ state.delete_infobar_delegate();
EXPECT_FALSE(state.accepted());
}
« no previous file with comments | « chrome/browser/download/download_request_infobar_delegate.cc ('k') | chrome/browser/download/download_request_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698