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

Side by Side Diff: content/browser/download/download_manager_impl_unittest.cc

Issue 10805020: Kill DownloadItem::IsOtr() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); 132 MOCK_METHOD1(SetOpenWhenComplete, void(bool));
133 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool()); 133 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool());
134 MOCK_CONST_METHOD0(GetSafetyState, SafetyState()); 134 MOCK_CONST_METHOD0(GetSafetyState, SafetyState());
135 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType()); 135 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType());
136 MOCK_CONST_METHOD0(IsDangerous, bool()); 136 MOCK_CONST_METHOD0(IsDangerous, bool());
137 MOCK_METHOD0(GetAutoOpened, bool()); 137 MOCK_METHOD0(GetAutoOpened, bool());
138 MOCK_CONST_METHOD0(GetTargetName, FilePath()); 138 MOCK_CONST_METHOD0(GetTargetName, FilePath());
139 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&()); 139 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&());
140 MOCK_CONST_METHOD0(HasUserGesture, bool()); 140 MOCK_CONST_METHOD0(HasUserGesture, bool());
141 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition()); 141 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition());
142 MOCK_CONST_METHOD0(IsOtr, bool());
143 MOCK_CONST_METHOD0(IsTemporary, bool()); 142 MOCK_CONST_METHOD0(IsTemporary, bool());
144 MOCK_METHOD1(SetIsTemporary, void(bool)); 143 MOCK_METHOD1(SetIsTemporary, void(bool));
145 MOCK_METHOD1(SetOpened, void(bool)); 144 MOCK_METHOD1(SetOpened, void(bool));
146 MOCK_CONST_METHOD0(GetOpened, bool()); 145 MOCK_CONST_METHOD0(GetOpened, bool());
147 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); 146 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&());
148 MOCK_CONST_METHOD0(GetETag, const std::string&()); 147 MOCK_CONST_METHOD0(GetETag, const std::string&());
149 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); 148 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason());
150 MOCK_CONST_METHOD0(GetPersistentStoreInfo, 149 MOCK_CONST_METHOD0(GetPersistentStoreInfo,
151 content::DownloadPersistentStoreInfo()); 150 content::DownloadPersistentStoreInfo());
152 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); 151 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // Overridden methods from DownloadItemFactory. 265 // Overridden methods from DownloadItemFactory.
267 virtual DownloadItemImpl* CreatePersistedItem( 266 virtual DownloadItemImpl* CreatePersistedItem(
268 DownloadItemImplDelegate* delegate, 267 DownloadItemImplDelegate* delegate,
269 content::DownloadId download_id, 268 content::DownloadId download_id,
270 const content::DownloadPersistentStoreInfo& info, 269 const content::DownloadPersistentStoreInfo& info,
271 const net::BoundNetLog& bound_net_log) OVERRIDE; 270 const net::BoundNetLog& bound_net_log) OVERRIDE;
272 virtual DownloadItemImpl* CreateActiveItem( 271 virtual DownloadItemImpl* CreateActiveItem(
273 DownloadItemImplDelegate* delegate, 272 DownloadItemImplDelegate* delegate,
274 const DownloadCreateInfo& info, 273 const DownloadCreateInfo& info,
275 scoped_ptr<DownloadRequestHandleInterface> request_handle, 274 scoped_ptr<DownloadRequestHandleInterface> request_handle,
276 bool is_otr,
277 const net::BoundNetLog& bound_net_log) OVERRIDE; 275 const net::BoundNetLog& bound_net_log) OVERRIDE;
278 virtual DownloadItemImpl* CreateSavePageItem( 276 virtual DownloadItemImpl* CreateSavePageItem(
279 DownloadItemImplDelegate* delegate, 277 DownloadItemImplDelegate* delegate,
280 const FilePath& path, 278 const FilePath& path,
281 const GURL& url, 279 const GURL& url,
282 bool is_otr,
283 content::DownloadId download_id, 280 content::DownloadId download_id,
284 const std::string& mime_type, 281 const std::string& mime_type,
285 const net::BoundNetLog& bound_net_log) OVERRIDE; 282 const net::BoundNetLog& bound_net_log) OVERRIDE;
286 283
287 private: 284 private:
288 std::map<int32, MockDownloadItemImpl*> items_; 285 std::map<int32, MockDownloadItemImpl*> items_;
289 DownloadItemImplDelegate item_delegate_; 286 DownloadItemImplDelegate item_delegate_;
290 287
291 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); 288 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory);
292 }; 289 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 .WillRepeatedly(Return(local_id)); 328 .WillRepeatedly(Return(local_id));
332 items_[local_id] = result; 329 items_[local_id] = result;
333 330
334 return result; 331 return result;
335 } 332 }
336 333
337 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( 334 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
338 DownloadItemImplDelegate* delegate, 335 DownloadItemImplDelegate* delegate,
339 const DownloadCreateInfo& info, 336 const DownloadCreateInfo& info,
340 scoped_ptr<DownloadRequestHandleInterface> request_handle, 337 scoped_ptr<DownloadRequestHandleInterface> request_handle,
341 bool is_otr,
342 const net::BoundNetLog& bound_net_log) { 338 const net::BoundNetLog& bound_net_log) {
343 int local_id = info.download_id.local(); 339 int local_id = info.download_id.local();
344 DCHECK(items_.find(local_id) == items_.end()); 340 DCHECK(items_.find(local_id) == items_.end());
345 341
346 MockDownloadItemImpl* result = 342 MockDownloadItemImpl* result =
347 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 343 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
348 EXPECT_CALL(*result, GetId()) 344 EXPECT_CALL(*result, GetId())
349 .WillRepeatedly(Return(local_id)); 345 .WillRepeatedly(Return(local_id));
350 items_[local_id] = result; 346 items_[local_id] = result;
351 347
352 return result; 348 return result;
353 } 349 }
354 350
355 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem( 351 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem(
356 DownloadItemImplDelegate* delegate, 352 DownloadItemImplDelegate* delegate,
357 const FilePath& path, 353 const FilePath& path,
358 const GURL& url, 354 const GURL& url,
359 bool is_otr,
360 content::DownloadId download_id, 355 content::DownloadId download_id,
361 const std::string& mime_type, 356 const std::string& mime_type,
362 const net::BoundNetLog& bound_net_log) { 357 const net::BoundNetLog& bound_net_log) {
363 int local_id = download_id.local(); 358 int local_id = download_id.local();
364 DCHECK(items_.find(local_id) == items_.end()); 359 DCHECK(items_.find(local_id) == items_.end());
365 360
366 MockDownloadItemImpl* result = 361 MockDownloadItemImpl* result =
367 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 362 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
368 EXPECT_CALL(*result, GetId()) 363 EXPECT_CALL(*result, GetId())
369 .WillRepeatedly(Return(local_id)); 364 .WillRepeatedly(Return(local_id));
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 UpdateItemInPersistentStore(&item)); 648 UpdateItemInPersistentStore(&item));
654 EXPECT_CALL(item, GetState()) 649 EXPECT_CALL(item, GetState())
655 .WillRepeatedly(Return(DownloadItem::CANCELLED)); 650 .WillRepeatedly(Return(DownloadItem::CANCELLED));
656 EXPECT_CALL(item, GetDbHandle()) 651 EXPECT_CALL(item, GetDbHandle())
657 .WillRepeatedly(Return(db_handle)); 652 .WillRepeatedly(Return(db_handle));
658 653
659 EXPECT_CALL(item, OffThreadCancel()); 654 EXPECT_CALL(item, OffThreadCancel());
660 DownloadStopped(&item); 655 DownloadStopped(&item);
661 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); 656 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id));
662 } 657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698