| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/download/download_request_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
| 6 #include "chrome/test/testing_profile.h" | 6 #include "chrome/test/testing_profile.h" |
| 7 #include "content/browser/browser_thread.h" | 7 #include "content/browser/browser_thread.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "content/browser/tab_contents/navigation_controller.h" | 9 #include "content/browser/tab_contents/navigation_controller.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 RenderViewHostTestHarness::TearDown(); | 33 RenderViewHostTestHarness::TearDown(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual void ContinueDownload() { | 36 virtual void ContinueDownload() { |
| 37 continue_count_++; | 37 continue_count_++; |
| 38 } | 38 } |
| 39 virtual void CancelDownload() { | 39 virtual void CancelDownload() { |
| 40 cancel_count_++; | 40 cancel_count_++; |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual int GetRequestId() { | |
| 44 return -1; | |
| 45 } | |
| 46 | |
| 47 void CanDownload() { | 43 void CanDownload() { |
| 48 download_request_limiter_->CanDownloadImpl( | 44 download_request_limiter_->CanDownloadImpl( |
| 49 controller().tab_contents(), this); | 45 controller().tab_contents(), -1, this); |
| 50 message_loop_.RunAllPending(); | 46 message_loop_.RunAllPending(); |
| 51 } | 47 } |
| 52 | 48 |
| 53 bool ShouldAllowDownload() { | 49 bool ShouldAllowDownload() { |
| 54 ask_allow_count_++; | 50 ask_allow_count_++; |
| 55 return allow_download_; | 51 return allow_download_; |
| 56 } | 52 } |
| 57 | 53 |
| 58 protected: | 54 protected: |
| 59 class DownloadRequestLimiterTestDelegate | 55 class DownloadRequestLimiterTestDelegate |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 ask_allow_count_ = continue_count_ = cancel_count_ = 0; | 201 ask_allow_count_ = continue_count_ = cancel_count_ = 0; |
| 206 CanDownload(); | 202 CanDownload(); |
| 207 ASSERT_EQ(0, ask_allow_count_); | 203 ASSERT_EQ(0, ask_allow_count_); |
| 208 ASSERT_EQ(0, continue_count_); | 204 ASSERT_EQ(0, continue_count_); |
| 209 ASSERT_EQ(1, cancel_count_); | 205 ASSERT_EQ(1, cancel_count_); |
| 210 // And the state shouldn't have changed. | 206 // And the state shouldn't have changed. |
| 211 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, | 207 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
| 212 download_request_limiter_->GetDownloadStatus( | 208 download_request_limiter_->GetDownloadStatus( |
| 213 controller().tab_contents())); | 209 controller().tab_contents())); |
| 214 } | 210 } |
| OLD | NEW |