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

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

Issue 8186: Plumb the referrer throughout the OpenURL APIs.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.cc ('k') | chrome/browser/external_tab_container.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_manager.h" 5 #include "chrome/browser/download/download_request_manager.h"
6 #include "chrome/browser/navigation_controller.h" 6 #include "chrome/browser/navigation_controller.h"
7 #include "chrome/test/test_tab_contents.h" 7 #include "chrome/test/test_tab_contents.h"
8 #include "chrome/test/testing_profile.h" 8 #include "chrome/test/testing_profile.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS, 102 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS,
103 download_request_manager_->GetDownloadStatus( 103 download_request_manager_->GetDownloadStatus(
104 controller_->active_contents())); 104 controller_->active_contents()));
105 // We should have been told we can download. 105 // We should have been told we can download.
106 ASSERT_EQ(1, continue_count_); 106 ASSERT_EQ(1, continue_count_);
107 ASSERT_EQ(0, cancel_count_); 107 ASSERT_EQ(0, cancel_count_);
108 continue_count_ = 0; 108 continue_count_ = 0;
109 } 109 }
110 110
111 TEST_F(DownloadRequestManagerTest, ResetOnNavigation) { 111 TEST_F(DownloadRequestManagerTest, ResetOnNavigation) {
112 controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), 0); 112 controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), GURL(), 0);
113 113
114 // Do two downloads, allowing the second so that we end up with allow all. 114 // Do two downloads, allowing the second so that we end up with allow all.
115 CanDownload(); 115 CanDownload();
116 allow_download_ = true; 116 allow_download_ = true;
117 CanDownload(); 117 CanDownload();
118 ask_allow_count_ = continue_count_ = cancel_count_ = 0; 118 ask_allow_count_ = continue_count_ = cancel_count_ = 0;
119 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS, 119 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS,
120 download_request_manager_->GetDownloadStatus( 120 download_request_manager_->GetDownloadStatus(
121 controller_->active_contents())); 121 controller_->active_contents()));
122 122
123 // Navigate to a new URL with the same host, which shouldn't reset the allow 123 // Navigate to a new URL with the same host, which shouldn't reset the allow
124 // all state. 124 // all state.
125 controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar2"), 0); 125 controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar2"),
126 GURL(), 0);
126 CanDownload(); 127 CanDownload();
127 ASSERT_EQ(1, continue_count_); 128 ASSERT_EQ(1, continue_count_);
128 ASSERT_EQ(0, cancel_count_); 129 ASSERT_EQ(0, cancel_count_);
129 ASSERT_EQ(0, ask_allow_count_); 130 ASSERT_EQ(0, ask_allow_count_);
130 ask_allow_count_ = continue_count_ = cancel_count_ = 0; 131 ask_allow_count_ = continue_count_ = cancel_count_ = 0;
131 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS, 132 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS,
132 download_request_manager_->GetDownloadStatus( 133 download_request_manager_->GetDownloadStatus(
133 controller_->active_contents())); 134 controller_->active_contents()));
134 135
135 // Do a user gesture, because we're at allow all, this shouldn't change the 136 // Do a user gesture, because we're at allow all, this shouldn't change the
136 // state. 137 // state.
137 download_request_manager_->OnUserGesture(controller_->active_contents()); 138 download_request_manager_->OnUserGesture(controller_->active_contents());
138 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS, 139 ASSERT_EQ(DownloadRequestManager::ALLOW_ALL_DOWNLOADS,
139 download_request_manager_->GetDownloadStatus( 140 download_request_manager_->GetDownloadStatus(
140 controller_->active_contents())); 141 controller_->active_contents()));
141 142
142 // Navigate to a completely different host, which should reset the state. 143 // Navigate to a completely different host, which should reset the state.
143 controller_->LoadURL(GURL(factory_->scheme() + "://fooey.com"), 0); 144 controller_->LoadURL(GURL(factory_->scheme() + "://fooey.com"), GURL(), 0);
144 ASSERT_EQ(DownloadRequestManager::ALLOW_ONE_DOWNLOAD, 145 ASSERT_EQ(DownloadRequestManager::ALLOW_ONE_DOWNLOAD,
145 download_request_manager_->GetDownloadStatus( 146 download_request_manager_->GetDownloadStatus(
146 controller_->active_contents())); 147 controller_->active_contents()));
147 } 148 }
148 149
149 TEST_F(DownloadRequestManagerTest, ResetOnUserGesture) { 150 TEST_F(DownloadRequestManagerTest, ResetOnUserGesture) {
150 controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), 0); 151 controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), GURL(), 0);
151 152
152 // Do one download, which should change to prompt before download. 153 // Do one download, which should change to prompt before download.
153 CanDownload(); 154 CanDownload();
154 ask_allow_count_ = continue_count_ = cancel_count_ = 0; 155 ask_allow_count_ = continue_count_ = cancel_count_ = 0;
155 ASSERT_EQ(DownloadRequestManager::PROMPT_BEFORE_DOWNLOAD, 156 ASSERT_EQ(DownloadRequestManager::PROMPT_BEFORE_DOWNLOAD,
156 download_request_manager_->GetDownloadStatus( 157 download_request_manager_->GetDownloadStatus(
157 controller_->active_contents())); 158 controller_->active_contents()));
158 159
159 // Do a user gesture, which should reset back to allow one. 160 // Do a user gesture, which should reset back to allow one.
160 download_request_manager_->OnUserGesture(controller_->active_contents()); 161 download_request_manager_->OnUserGesture(controller_->active_contents());
(...skipping 19 matching lines...) Expand all
180 ask_allow_count_ = continue_count_ = cancel_count_ = 0; 181 ask_allow_count_ = continue_count_ = cancel_count_ = 0;
181 CanDownload(); 182 CanDownload();
182 ASSERT_EQ(0, ask_allow_count_); 183 ASSERT_EQ(0, ask_allow_count_);
183 ASSERT_EQ(0, continue_count_); 184 ASSERT_EQ(0, continue_count_);
184 ASSERT_EQ(1, cancel_count_); 185 ASSERT_EQ(1, cancel_count_);
185 // And the state shouldn't have changed. 186 // And the state shouldn't have changed.
186 ASSERT_EQ(DownloadRequestManager::DOWNLOADS_NOT_ALLOWED, 187 ASSERT_EQ(DownloadRequestManager::DOWNLOADS_NOT_ALLOWED,
187 download_request_manager_->GetDownloadStatus( 188 download_request_manager_->GetDownloadStatus(
188 controller_->active_contents())); 189 controller_->active_contents()));
189 } 190 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.cc ('k') | chrome/browser/external_tab_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698