| 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());
|
| }
|
|
|