Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: chrome/browser/download/download_request_limiter_unittest.cc

Issue 7374008: Move download stuff from download helper back to TabContents. This is basically a revert of r8576... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/download/download_request_limiter.h" 5 #include "chrome/browser/download/download_request_limiter.h"
6 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
7 #include "chrome/test/testing_profile.h" 6 #include "chrome/test/testing_profile.h"
8 #include "content/browser/browser_thread.h" 7 #include "content/browser/browser_thread.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 "content/browser/tab_contents/test_tab_contents.h" 10 #include "content/browser/tab_contents/test_tab_contents.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 class DownloadRequestLimiterTest 13 class DownloadRequestLimiterTest
14 : public TabContentsWrapperTestHarness, 14 : public RenderViewHostTestHarness,
15 public DownloadRequestLimiter::Callback { 15 public DownloadRequestLimiter::Callback {
16 public: 16 public:
17 DownloadRequestLimiterTest() 17 DownloadRequestLimiterTest()
18 : ui_thread_(BrowserThread::UI, &message_loop_), 18 : ui_thread_(BrowserThread::UI, &message_loop_),
19 io_thread_(BrowserThread::IO, &message_loop_) { 19 io_thread_(BrowserThread::IO, &message_loop_) {
20 } 20 }
21 21
22 virtual void SetUp() { 22 virtual void SetUp() {
23 TabContentsWrapperTestHarness::SetUp(); 23 RenderViewHostTestHarness::SetUp();
24 24
25 allow_download_ = true; 25 allow_download_ = true;
26 ask_allow_count_ = cancel_count_ = continue_count_ = 0; 26 ask_allow_count_ = cancel_count_ = continue_count_ = 0;
27 27
28 download_request_limiter_ = new DownloadRequestLimiter(); 28 download_request_limiter_ = new DownloadRequestLimiter();
29 test_delegate_.reset(new DownloadRequestLimiterTestDelegate(this)); 29 test_delegate_.reset(new DownloadRequestLimiterTestDelegate(this));
30 DownloadRequestLimiter::SetTestingDelegate(test_delegate_.get()); 30 DownloadRequestLimiter::SetTestingDelegate(test_delegate_.get());
31 } 31 }
32 32
33 virtual void TearDown() { 33 virtual void TearDown() {
34 DownloadRequestLimiter::SetTestingDelegate(NULL); 34 DownloadRequestLimiter::SetTestingDelegate(NULL);
35 35
36 TabContentsWrapperTestHarness::TearDown(); 36 RenderViewHostTestHarness::TearDown();
37 } 37 }
38 38
39 virtual void ContinueDownload() { 39 virtual void ContinueDownload() {
40 continue_count_++; 40 continue_count_++;
41 } 41 }
42 virtual void CancelDownload() { 42 virtual void CancelDownload() {
43 cancel_count_++; 43 cancel_count_++;
44 } 44 }
45 45
46 void CanDownload() { 46 void CanDownload() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // And make sure we really can't download. 191 // And make sure we really can't download.
192 ask_allow_count_ = continue_count_ = cancel_count_ = 0; 192 ask_allow_count_ = continue_count_ = cancel_count_ = 0;
193 CanDownload(); 193 CanDownload();
194 ASSERT_EQ(0, ask_allow_count_); 194 ASSERT_EQ(0, ask_allow_count_);
195 ASSERT_EQ(0, continue_count_); 195 ASSERT_EQ(0, continue_count_);
196 ASSERT_EQ(1, cancel_count_); 196 ASSERT_EQ(1, cancel_count_);
197 // And the state shouldn't have changed. 197 // And the state shouldn't have changed.
198 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, 198 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED,
199 download_request_limiter_->GetDownloadStatus(contents())); 199 download_request_limiter_->GetDownloadStatus(contents()));
200 } 200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698