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

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

Issue 2619603002: Remove android_java_ui as it is not used (Closed)
Patch Set: Rebase to master Created 3 years, 11 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
OLDNEW
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"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/resource_throttle.h" 13 #include "content/public/browser/resource_throttle.h"
15 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_delegate.h" 15 #include "content/public/browser/web_contents_delegate.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 16 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
20 19
21 #if BUILDFLAG(ANDROID_JAVA_UI) 20 #if defined(OS_ANDROID)
22 #include "chrome/browser/android/download/mock_download_controller.h" 21 #include "chrome/browser/android/download/mock_download_controller.h"
23 #endif 22 #endif
24 23
25 namespace { 24 namespace {
26 25
27 const char kTestUrl[] = "http://www.example.com/"; 26 const char kTestUrl[] = "http://www.example.com/";
28 27
29 } // namespace 28 } // namespace
30 29
31 class MockWebContentsDelegate : public content::WebContentsDelegate { 30 class MockWebContentsDelegate : public content::WebContentsDelegate {
(...skipping 24 matching lines...) Expand all
56 // Cannot use IO_MAIN_LOOP with RenderViewHostTestHarness. 55 // Cannot use IO_MAIN_LOOP with RenderViewHostTestHarness.
57 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); 56 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
58 } 57 }
59 58
60 ~DownloadResourceThrottleTest() override {} 59 ~DownloadResourceThrottleTest() override {}
61 60
62 void SetUp() override { 61 void SetUp() override {
63 ChromeRenderViewHostTestHarness::SetUp(); 62 ChromeRenderViewHostTestHarness::SetUp();
64 web_contents()->SetDelegate(&delegate_); 63 web_contents()->SetDelegate(&delegate_);
65 run_loop_.reset(new base::RunLoop()); 64 run_loop_.reset(new base::RunLoop());
66 #if BUILDFLAG(ANDROID_JAVA_UI) 65 #if defined(OS_ANDROID)
67 DownloadControllerBase::SetDownloadControllerBase(&download_controller_); 66 DownloadControllerBase::SetDownloadControllerBase(&download_controller_);
68 #endif 67 #endif
69 } 68 }
70 69
71 void TearDown() override { 70 void TearDown() override {
72 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, 71 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
73 throttle_); 72 throttle_);
74 #if BUILDFLAG(ANDROID_JAVA_UI) 73 #if defined(OS_ANDROID)
75 DownloadControllerBase::SetDownloadControllerBase(nullptr); 74 DownloadControllerBase::SetDownloadControllerBase(nullptr);
76 #endif 75 #endif
77 ChromeRenderViewHostTestHarness::TearDown(); 76 ChromeRenderViewHostTestHarness::TearDown();
78 } 77 }
79 78
80 void StartThrottleOnIOThread(int process_id, int render_view_id) { 79 void StartThrottleOnIOThread(int process_id, int render_view_id) {
81 throttle_ = new DownloadResourceThrottle( 80 throttle_ = new DownloadResourceThrottle(
82 limiter_, 81 limiter_,
83 base::Bind(&tab_util::GetWebContentsByID, process_id, render_view_id), 82 base::Bind(&tab_util::GetWebContentsByID, process_id, render_view_id),
84 GURL(kTestUrl), "GET"); 83 GURL(kTestUrl), "GET");
(...skipping 12 matching lines...) Expand all
97 web_contents()->GetRenderViewHost()->GetRoutingID())); 96 web_contents()->GetRenderViewHost()->GetRoutingID()));
98 run_loop_->Run(); 97 run_loop_->Run();
99 } 98 }
100 99
101 protected: 100 protected:
102 content::ResourceThrottle* throttle_; 101 content::ResourceThrottle* throttle_;
103 MockWebContentsDelegate delegate_; 102 MockWebContentsDelegate delegate_;
104 scoped_refptr<DownloadRequestLimiter> limiter_; 103 scoped_refptr<DownloadRequestLimiter> limiter_;
105 ::testing::NiceMock<MockResourceThrottleDelegate> resource_throttle_delegate_; 104 ::testing::NiceMock<MockResourceThrottleDelegate> resource_throttle_delegate_;
106 std::unique_ptr<base::RunLoop> run_loop_; 105 std::unique_ptr<base::RunLoop> run_loop_;
107 #if BUILDFLAG(ANDROID_JAVA_UI) 106 #if defined(OS_ANDROID)
108 chrome::android::MockDownloadController download_controller_; 107 chrome::android::MockDownloadController download_controller_;
109 #endif 108 #endif
110 }; 109 };
111 110
112 TEST_F(DownloadResourceThrottleTest, StartDownloadThrottle_Basic) { 111 TEST_F(DownloadResourceThrottleTest, StartDownloadThrottle_Basic) {
113 EXPECT_CALL(resource_throttle_delegate_, Resume()) 112 EXPECT_CALL(resource_throttle_delegate_, Resume())
114 .WillOnce(QuitLoop(run_loop_->QuitClosure())); 113 .WillOnce(QuitLoop(run_loop_->QuitClosure()));
115 StartThrottle(); 114 StartThrottle();
116 } 115 }
117 116
118 #if BUILDFLAG(ANDROID_JAVA_UI) 117 #if defined(OS_ANDROID)
119 TEST_F(DownloadResourceThrottleTest, DownloadWithFailedFileAcecssRequest) { 118 TEST_F(DownloadResourceThrottleTest, DownloadWithFailedFileAcecssRequest) {
120 DownloadControllerBase::Get() 119 DownloadControllerBase::Get()
121 ->SetApproveFileAccessRequestForTesting(false); 120 ->SetApproveFileAccessRequestForTesting(false);
122 EXPECT_CALL(resource_throttle_delegate_, Cancel()) 121 EXPECT_CALL(resource_throttle_delegate_, Cancel())
123 .WillOnce(QuitLoop(run_loop_->QuitClosure())); 122 .WillOnce(QuitLoop(run_loop_->QuitClosure()));
124 StartThrottle(); 123 StartThrottle();
125 } 124 }
126 #endif 125 #endif
OLDNEW
« no previous file with comments | « chrome/browser/download/download_request_limiter.cc ('k') | chrome/browser/download/download_target_determiner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698