| OLD | NEW |
| 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "chrome/browser/download/download_request_infobar_delegate.h" | 7 #include "chrome/browser/download/download_request_infobar_delegate.h" |
| 8 #include "chrome/browser/download/download_request_limiter.h" | 8 #include "chrome/browser/download/download_request_limiter.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 // MockTabDownloadState ------------------------------------------------------- | 11 // MockTabDownloadState ------------------------------------------------------- |
| 12 | 12 |
| 13 class MockTabDownloadState : public DownloadRequestLimiter::TabDownloadState { | 13 class MockTabDownloadState : public DownloadRequestLimiter::TabDownloadState { |
| 14 public: | 14 public: |
| 15 MockTabDownloadState(); | 15 MockTabDownloadState(); |
| 16 virtual ~MockTabDownloadState(); | 16 virtual ~MockTabDownloadState(); |
| 17 | 17 |
| 18 // DownloadRequestLimiter::TabDownloadState: | 18 // DownloadRequestLimiter::TabDownloadState: |
| 19 virtual void Cancel() OVERRIDE; | 19 virtual void Cancel() override; |
| 20 virtual void Accept() OVERRIDE; | 20 virtual void Accept() override; |
| 21 virtual void CancelOnce() OVERRIDE; | 21 virtual void CancelOnce() override; |
| 22 | 22 |
| 23 ConfirmInfoBarDelegate* infobar_delegate() { return infobar_delegate_.get(); } | 23 ConfirmInfoBarDelegate* infobar_delegate() { return infobar_delegate_.get(); } |
| 24 void delete_infobar_delegate() { infobar_delegate_.reset(); } | 24 void delete_infobar_delegate() { infobar_delegate_.reset(); } |
| 25 bool responded() const { return responded_; } | 25 bool responded() const { return responded_; } |
| 26 bool accepted() const { return accepted_; } | 26 bool accepted() const { return accepted_; } |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // The actual infobar delegate we're listening to. | 29 // The actual infobar delegate we're listening to. |
| 30 scoped_ptr<DownloadRequestInfoBarDelegate> infobar_delegate_; | 30 scoped_ptr<DownloadRequestInfoBarDelegate> infobar_delegate_; |
| 31 | 31 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (state.infobar_delegate()->Cancel()) | 86 if (state.infobar_delegate()->Cancel()) |
| 87 state.delete_infobar_delegate(); | 87 state.delete_infobar_delegate(); |
| 88 EXPECT_FALSE(state.accepted()); | 88 EXPECT_FALSE(state.accepted()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST(DownloadRequestInfoBarDelegate, CloseTest) { | 91 TEST(DownloadRequestInfoBarDelegate, CloseTest) { |
| 92 MockTabDownloadState state; | 92 MockTabDownloadState state; |
| 93 state.delete_infobar_delegate(); | 93 state.delete_infobar_delegate(); |
| 94 EXPECT_FALSE(state.accepted()); | 94 EXPECT_FALSE(state.accepted()); |
| 95 } | 95 } |
| OLD | NEW |