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/tab_contents.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
8 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | 8 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 | 234 |
235 TEST_F(DownloadRequestLimiterTest, | 235 TEST_F(DownloadRequestLimiterTest, |
236 DownloadRequestLimiter_RawWebContents) { | 236 DownloadRequestLimiter_RawWebContents) { |
237 // By-pass TabContentsTestHarness and use | 237 // By-pass TabContentsTestHarness and use |
238 // RenderViewHostTestHarness::CreateTestWebContents() directly so that there | 238 // RenderViewHostTestHarness::CreateTestWebContents() directly so that there |
239 // will be no TabContents for web_contents. | 239 // will be no TabContents for web_contents. |
240 scoped_ptr<WebContents> web_contents(CreateTestWebContents()); | 240 scoped_ptr<WebContents> web_contents(CreateTestWebContents()); |
241 TabContents* tab_contents = TabContents::FromWebContents(web_contents.get()); | 241 TabContents* tab_contents = TabContents::FromWebContents(web_contents.get()); |
242 ASSERT_TRUE(tab_contents == NULL); | 242 ASSERT_TRUE(tab_contents == NULL); |
243 // DRL won't try to make an infobar if it doesn't have a TCW, and we want to | 243 // DownloadRequestLimiter won't try to make an infobar if it doesn't have a |
244 // test that it will Cancel() instead of prompting when it doesn't have a TCW, | 244 // TabContents, and we want to test that it will Cancel() instead of prompting |
245 // so unset the delegate. | 245 // when it doesn't have a TabContents, so unset the delegate. |
246 UnsetDelegate(); | 246 UnsetDelegate(); |
247 EXPECT_EQ(0, continue_count_); | 247 EXPECT_EQ(0, continue_count_); |
248 EXPECT_EQ(0, cancel_count_); | 248 EXPECT_EQ(0, cancel_count_); |
249 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 249 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
250 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 250 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
251 // You get one freebie. | 251 // You get one freebie. |
252 CanDownloadFor(web_contents.get()); | 252 CanDownloadFor(web_contents.get()); |
253 EXPECT_EQ(1, continue_count_); | 253 EXPECT_EQ(1, continue_count_); |
254 EXPECT_EQ(0, cancel_count_); | 254 EXPECT_EQ(0, cancel_count_); |
255 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 255 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
(...skipping 13 matching lines...) Expand all Loading... |
269 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 269 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
270 OnUserGestureFor(web_contents.get()); | 270 OnUserGestureFor(web_contents.get()); |
271 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 271 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
272 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 272 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
273 CanDownloadFor(web_contents.get()); | 273 CanDownloadFor(web_contents.get()); |
274 EXPECT_EQ(3, continue_count_); | 274 EXPECT_EQ(3, continue_count_); |
275 EXPECT_EQ(1, cancel_count_); | 275 EXPECT_EQ(1, cancel_count_); |
276 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 276 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
277 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 277 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
278 } | 278 } |
OLD | NEW |