| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "chrome/browser/download/download_request_limiter.h" | 6 #include "chrome/browser/download/download_request_limiter.h" |
| 7 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
| 10 #include "content/test/test_browser_thread.h" | 10 #include "content/test/test_browser_thread.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void TearDown() { | 35 virtual void TearDown() { |
| 36 DownloadRequestLimiter::SetTestingDelegate(NULL); | 36 DownloadRequestLimiter::SetTestingDelegate(NULL); |
| 37 | 37 |
| 38 TabContentsWrapperTestHarness::TearDown(); | 38 TabContentsWrapperTestHarness::TearDown(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void CanDownload() { | 41 void CanDownload() { |
| 42 download_request_limiter_->CanDownloadImpl( | 42 download_request_limiter_->CanDownloadImpl( |
| 43 contents_wrapper(), | 43 web_contents(), |
| 44 -1, // request id | 44 -1, // request id |
| 45 "GET", // request method | 45 "GET", // request method |
| 46 base::Bind(&DownloadRequestLimiterTest::ContinueDownload, | 46 base::Bind(&DownloadRequestLimiterTest::ContinueDownload, |
| 47 base::Unretained(this))); | 47 base::Unretained(this))); |
| 48 message_loop_.RunAllPending(); | 48 message_loop_.RunAllPending(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool ShouldAllowDownload() { | 51 bool ShouldAllowDownload() { |
| 52 ask_allow_count_++; | 52 ask_allow_count_++; |
| 53 return allow_download_; | 53 return allow_download_; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // And make sure we really can't download. | 200 // And make sure we really can't download. |
| 201 ask_allow_count_ = continue_count_ = cancel_count_ = 0; | 201 ask_allow_count_ = continue_count_ = cancel_count_ = 0; |
| 202 CanDownload(); | 202 CanDownload(); |
| 203 ASSERT_EQ(0, ask_allow_count_); | 203 ASSERT_EQ(0, ask_allow_count_); |
| 204 ASSERT_EQ(0, continue_count_); | 204 ASSERT_EQ(0, continue_count_); |
| 205 ASSERT_EQ(1, cancel_count_); | 205 ASSERT_EQ(1, cancel_count_); |
| 206 // And the state shouldn't have changed. | 206 // And the state shouldn't have changed. |
| 207 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, | 207 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
| 208 download_request_limiter_->GetDownloadStatus(contents())); | 208 download_request_limiter_->GetDownloadStatus(contents())); |
| 209 } | 209 } |
| OLD | NEW |