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

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: 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" 10 #include "chrome/common/features.h"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/resource_throttle.h" 14 #include "content/public/browser/resource_throttle.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_delegate.h" 16 #include "content/public/browser/web_contents_delegate.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 17 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 #if BUILDFLAG(ANDROID_JAVA_UI) 21 #if defined(OS_ANDROID)
22 #include "chrome/browser/android/download/mock_download_controller.h" 22 #include "chrome/browser/android/download/mock_download_controller.h"
23 #endif 23 #endif
24 24
25 namespace { 25 namespace {
26 26
27 const char kTestUrl[] = "http://www.example.com/"; 27 const char kTestUrl[] = "http://www.example.com/";
28 28
29 } // namespace 29 } // namespace
30 30
31 class MockWebContentsDelegate : public content::WebContentsDelegate { 31 class MockWebContentsDelegate : public content::WebContentsDelegate {
(...skipping 24 matching lines...) Expand all
56 // Cannot use IO_MAIN_LOOP with RenderViewHostTestHarness. 56 // Cannot use IO_MAIN_LOOP with RenderViewHostTestHarness.
57 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); 57 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
58 } 58 }
59 59
60 ~DownloadResourceThrottleTest() override {} 60 ~DownloadResourceThrottleTest() override {}
61 61
62 void SetUp() override { 62 void SetUp() override {
63 ChromeRenderViewHostTestHarness::SetUp(); 63 ChromeRenderViewHostTestHarness::SetUp();
64 web_contents()->SetDelegate(&delegate_); 64 web_contents()->SetDelegate(&delegate_);
65 run_loop_.reset(new base::RunLoop()); 65 run_loop_.reset(new base::RunLoop());
66 #if BUILDFLAG(ANDROID_JAVA_UI) 66 #if defined(OS_ANDROID)
67 DownloadControllerBase::SetDownloadControllerBase(&download_controller_); 67 DownloadControllerBase::SetDownloadControllerBase(&download_controller_);
68 #endif 68 #endif
69 } 69 }
70 70
71 void TearDown() override { 71 void TearDown() override {
72 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, 72 content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
73 throttle_); 73 throttle_);
74 #if BUILDFLAG(ANDROID_JAVA_UI) 74 #if defined(OS_ANDROID)
75 DownloadControllerBase::SetDownloadControllerBase(nullptr); 75 DownloadControllerBase::SetDownloadControllerBase(nullptr);
76 #endif 76 #endif
77 ChromeRenderViewHostTestHarness::TearDown(); 77 ChromeRenderViewHostTestHarness::TearDown();
78 } 78 }
79 79
80 void StartThrottleOnIOThread(int process_id, int render_view_id) { 80 void StartThrottleOnIOThread(int process_id, int render_view_id) {
81 throttle_ = new DownloadResourceThrottle( 81 throttle_ = new DownloadResourceThrottle(
82 limiter_, 82 limiter_,
83 base::Bind(&tab_util::GetWebContentsByID, process_id, render_view_id), 83 base::Bind(&tab_util::GetWebContentsByID, process_id, render_view_id),
84 GURL(kTestUrl), "GET"); 84 GURL(kTestUrl), "GET");
(...skipping 12 matching lines...) Expand all
97 web_contents()->GetRenderViewHost()->GetRoutingID())); 97 web_contents()->GetRenderViewHost()->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<MockResourceThrottleDelegate> resource_throttle_delegate_; 105 ::testing::NiceMock<MockResourceThrottleDelegate> resource_throttle_delegate_;
106 std::unique_ptr<base::RunLoop> run_loop_; 106 std::unique_ptr<base::RunLoop> run_loop_;
107 #if BUILDFLAG(ANDROID_JAVA_UI) 107 #if defined(OS_ANDROID)
108 chrome::android::MockDownloadController download_controller_; 108 chrome::android::MockDownloadController download_controller_;
109 #endif 109 #endif
110 }; 110 };
111 111
112 TEST_F(DownloadResourceThrottleTest, StartDownloadThrottle_Basic) { 112 TEST_F(DownloadResourceThrottleTest, StartDownloadThrottle_Basic) {
113 EXPECT_CALL(resource_throttle_delegate_, Resume()) 113 EXPECT_CALL(resource_throttle_delegate_, Resume())
114 .WillOnce(QuitLoop(run_loop_->QuitClosure())); 114 .WillOnce(QuitLoop(run_loop_->QuitClosure()));
115 StartThrottle(); 115 StartThrottle();
116 } 116 }
117 117
118 #if BUILDFLAG(ANDROID_JAVA_UI) 118 #if defined(OS_ANDROID)
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_throttle_delegate_, Cancel()) 122 EXPECT_CALL(resource_throttle_delegate_, Cancel())
123 .WillOnce(QuitLoop(run_loop_->QuitClosure())); 123 .WillOnce(QuitLoop(run_loop_->QuitClosure()));
124 StartThrottle(); 124 StartThrottle();
125 } 125 }
126 #endif 126 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698