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(); | 19 virtual void Cancel() OVERRIDE; |
20 virtual void Accept(); | 20 virtual void Accept() OVERRIDE; |
21 | 21 |
22 ConfirmInfoBarDelegate* infobar() { return infobar_.get(); } | 22 ConfirmInfoBarDelegate* infobar() { return infobar_.get(); } |
23 void delete_infobar_delegate() { infobar_.reset(); } | 23 void delete_infobar_delegate() { infobar_.reset(); } |
24 bool responded() const { return responded_; } | 24 bool responded() const { return responded_; } |
25 bool accepted() const { return accepted_; } | 25 bool accepted() const { return accepted_; } |
26 | 26 |
27 private: | 27 private: |
28 // To produce weak pointers for infobar_ construction. | 28 // To produce weak pointers for infobar_ construction. |
29 base::WeakPtrFactory<DownloadRequestLimiter::TabDownloadState> factory_; | 29 base::WeakPtrFactory<DownloadRequestLimiter::TabDownloadState> factory_; |
30 | 30 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if (state.infobar()->Cancel()) | 78 if (state.infobar()->Cancel()) |
79 state.delete_infobar_delegate(); | 79 state.delete_infobar_delegate(); |
80 EXPECT_FALSE(state.accepted()); | 80 EXPECT_FALSE(state.accepted()); |
81 } | 81 } |
82 | 82 |
83 TEST(DownloadRequestInfobarDelegate, CloseTest) { | 83 TEST(DownloadRequestInfobarDelegate, CloseTest) { |
84 MockTabDownloadState state; | 84 MockTabDownloadState state; |
85 state.delete_infobar_delegate(); | 85 state.delete_infobar_delegate(); |
86 EXPECT_FALSE(state.accepted()); | 86 EXPECT_FALSE(state.accepted()); |
87 } | 87 } |
OLD | NEW |