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_wrapper.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" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using content::BrowserThread; | 15 using content::BrowserThread; |
16 using content::WebContents; | 16 using content::WebContents; |
17 | 17 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 ASSERT_EQ(1, cancel_count_); | 229 ASSERT_EQ(1, cancel_count_); |
230 // And the state shouldn't have changed. | 230 // And the state shouldn't have changed. |
231 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, | 231 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
232 download_request_limiter_->GetDownloadStatus(contents())); | 232 download_request_limiter_->GetDownloadStatus(contents())); |
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 TabContentsWrapper 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 TabContentsWrapper* tab_wrapper = | 241 TabContents* tab_contents = |
242 TabContentsWrapper::GetCurrentWrapperForContents(web_contents.get()); | 242 TabContents::GetOwningTabContentsForWebContents(web_contents.get()); |
243 ASSERT_TRUE(tab_wrapper == NULL); | 243 ASSERT_TRUE(tab_contents == NULL); |
244 // DRL won't try to make an infobar if it doesn't have a TCW, and we want to | 244 // DRL won't try to make an infobar if it doesn't have a TCW, and we want to |
245 // test that it will Cancel() instead of prompting when it doesn't have a TCW, | 245 // test that it will Cancel() instead of prompting when it doesn't have a TCW, |
246 // so unset the delegate. | 246 // so unset the delegate. |
247 UnsetDelegate(); | 247 UnsetDelegate(); |
248 EXPECT_EQ(0, continue_count_); | 248 EXPECT_EQ(0, continue_count_); |
249 EXPECT_EQ(0, cancel_count_); | 249 EXPECT_EQ(0, cancel_count_); |
250 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 250 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
251 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 251 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
252 // You get one freebie. | 252 // You get one freebie. |
253 CanDownloadFor(web_contents.get()); | 253 CanDownloadFor(web_contents.get()); |
(...skipping 16 matching lines...) Expand all Loading... |
270 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 270 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
271 OnUserGestureFor(web_contents.get()); | 271 OnUserGestureFor(web_contents.get()); |
272 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 272 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
273 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 273 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
274 CanDownloadFor(web_contents.get()); | 274 CanDownloadFor(web_contents.get()); |
275 EXPECT_EQ(3, continue_count_); | 275 EXPECT_EQ(3, continue_count_); |
276 EXPECT_EQ(1, cancel_count_); | 276 EXPECT_EQ(1, cancel_count_); |
277 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 277 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
278 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 278 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
279 } | 279 } |
OLD | NEW |