OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "chrome/browser/download/download_request_limiter.h" | 7 #include "chrome/browser/download/download_request_limiter.h" |
8 #include "chrome/browser/download/download_resource_throttle.h" | 8 #include "chrome/browser/download/download_resource_throttle.h" |
9 #include "chrome/browser/tab_contents/tab_util.h" | 9 #include "chrome/browser/tab_contents/tab_util.h" |
10 #include "chrome/common/features.h" | 10 #include "chrome/common/features.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 bool defer; | 86 bool defer; |
87 throttle_->WillStartRequest(&defer); | 87 throttle_->WillStartRequest(&defer); |
88 EXPECT_EQ(true, defer); | 88 EXPECT_EQ(true, defer); |
89 } | 89 } |
90 | 90 |
91 void StartThrottle() { | 91 void StartThrottle() { |
92 content::BrowserThread::PostTask( | 92 content::BrowserThread::PostTask( |
93 content::BrowserThread::IO, FROM_HERE, | 93 content::BrowserThread::IO, FROM_HERE, |
94 base::Bind(&DownloadResourceThrottleTest::StartThrottleOnIOThread, | 94 base::Bind(&DownloadResourceThrottleTest::StartThrottleOnIOThread, |
95 base::Unretained(this), | 95 base::Unretained(this), |
96 web_contents()->GetRenderViewHost()->GetProcess()->GetID(), | 96 web_contents()->GetMainFrame()->GetProcess()->GetID(), |
97 web_contents()->GetRoutingID())); | 97 web_contents()->GetRoutingID())); |
98 run_loop_->Run(); | 98 run_loop_->Run(); |
99 } | 99 } |
100 | 100 |
101 protected: | 101 protected: |
102 content::ResourceThrottle* throttle_; | 102 content::ResourceThrottle* throttle_; |
103 MockWebContentsDelegate delegate_; | 103 MockWebContentsDelegate delegate_; |
104 scoped_refptr<DownloadRequestLimiter> limiter_; | 104 scoped_refptr<DownloadRequestLimiter> limiter_; |
105 ::testing::NiceMock<MockResourceController> resource_controller_; | 105 ::testing::NiceMock<MockResourceController> resource_controller_; |
106 std::unique_ptr<base::RunLoop> run_loop_; | 106 std::unique_ptr<base::RunLoop> run_loop_; |
(...skipping 10 matching lines...) Expand all Loading... |
117 | 117 |
118 #if BUILDFLAG(ANDROID_JAVA_UI) | 118 #if BUILDFLAG(ANDROID_JAVA_UI) |
119 TEST_F(DownloadResourceThrottleTest, DownloadWithFailedFileAcecssRequest) { | 119 TEST_F(DownloadResourceThrottleTest, DownloadWithFailedFileAcecssRequest) { |
120 DownloadControllerBase::Get() | 120 DownloadControllerBase::Get() |
121 ->SetApproveFileAccessRequestForTesting(false); | 121 ->SetApproveFileAccessRequestForTesting(false); |
122 EXPECT_CALL(resource_controller_, Cancel()) | 122 EXPECT_CALL(resource_controller_, Cancel()) |
123 .WillOnce(QuitLoop(run_loop_->QuitClosure())); | 123 .WillOnce(QuitLoop(run_loop_->QuitClosure())); |
124 StartThrottle(); | 124 StartThrottle(); |
125 } | 125 } |
126 #endif | 126 #endif |
OLD | NEW |