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

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, 5 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); 135 MOCK_METHOD1(SetOpenWhenComplete, void(bool));
136 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool()); 136 MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool());
137 MOCK_CONST_METHOD0(GetSafetyState, SafetyState()); 137 MOCK_CONST_METHOD0(GetSafetyState, SafetyState());
138 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType()); 138 MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType());
139 MOCK_CONST_METHOD0(IsDangerous, bool()); 139 MOCK_CONST_METHOD0(IsDangerous, bool());
140 MOCK_METHOD0(GetAutoOpened, bool()); 140 MOCK_METHOD0(GetAutoOpened, bool());
141 MOCK_CONST_METHOD0(GetTargetName, FilePath()); 141 MOCK_CONST_METHOD0(GetTargetName, FilePath());
142 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&()); 142 MOCK_CONST_METHOD0(GetForcedFilePath, const FilePath&());
143 MOCK_CONST_METHOD0(HasUserGesture, bool()); 143 MOCK_CONST_METHOD0(HasUserGesture, bool());
144 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition()); 144 MOCK_CONST_METHOD0(GetTransitionType, content::PageTransition());
145 MOCK_CONST_METHOD0(IsOtr, bool());
146 MOCK_CONST_METHOD0(IsTemporary, bool()); 145 MOCK_CONST_METHOD0(IsTemporary, bool());
147 MOCK_METHOD1(SetIsTemporary, void(bool)); 146 MOCK_METHOD1(SetIsTemporary, void(bool));
148 MOCK_METHOD1(SetOpened, void(bool)); 147 MOCK_METHOD1(SetOpened, void(bool));
149 MOCK_CONST_METHOD0(GetOpened, bool()); 148 MOCK_CONST_METHOD0(GetOpened, bool());
150 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); 149 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&());
151 MOCK_CONST_METHOD0(GetETag, const std::string&()); 150 MOCK_CONST_METHOD0(GetETag, const std::string&());
152 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); 151 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason());
153 MOCK_CONST_METHOD0(GetPersistentStoreInfo, 152 MOCK_CONST_METHOD0(GetPersistentStoreInfo,
154 content::DownloadPersistentStoreInfo()); 153 content::DownloadPersistentStoreInfo());
155 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); 154 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // Overridden methods from DownloadItemFactory. 268 // Overridden methods from DownloadItemFactory.
270 virtual DownloadItemImpl* CreatePersistedItem( 269 virtual DownloadItemImpl* CreatePersistedItem(
271 DownloadItemImplDelegate* delegate, 270 DownloadItemImplDelegate* delegate,
272 content::DownloadId download_id, 271 content::DownloadId download_id,
273 const content::DownloadPersistentStoreInfo& info, 272 const content::DownloadPersistentStoreInfo& info,
274 const net::BoundNetLog& bound_net_log) OVERRIDE; 273 const net::BoundNetLog& bound_net_log) OVERRIDE;
275 virtual DownloadItemImpl* CreateActiveItem( 274 virtual DownloadItemImpl* CreateActiveItem(
276 DownloadItemImplDelegate* delegate, 275 DownloadItemImplDelegate* delegate,
277 const DownloadCreateInfo& info, 276 const DownloadCreateInfo& info,
278 scoped_ptr<DownloadRequestHandleInterface> request_handle, 277 scoped_ptr<DownloadRequestHandleInterface> request_handle,
279 bool is_otr,
280 const net::BoundNetLog& bound_net_log) OVERRIDE; 278 const net::BoundNetLog& bound_net_log) OVERRIDE;
281 virtual DownloadItemImpl* CreateSavePageItem( 279 virtual DownloadItemImpl* CreateSavePageItem(
282 DownloadItemImplDelegate* delegate, 280 DownloadItemImplDelegate* delegate,
283 const FilePath& path, 281 const FilePath& path,
284 const GURL& url, 282 const GURL& url,
285 bool is_otr,
286 content::DownloadId download_id, 283 content::DownloadId download_id,
287 const std::string& mime_type, 284 const std::string& mime_type,
288 const net::BoundNetLog& bound_net_log) OVERRIDE; 285 const net::BoundNetLog& bound_net_log) OVERRIDE;
289 286
290 private: 287 private:
291 std::map<int32, MockDownloadItemImpl*> items_; 288 std::map<int32, MockDownloadItemImpl*> items_;
292 DownloadItemImplDelegate item_delegate_; 289 DownloadItemImplDelegate item_delegate_;
293 290
294 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); 291 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory);
295 }; 292 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 .WillRepeatedly(Return(local_id)); 331 .WillRepeatedly(Return(local_id));
335 items_[local_id] = result; 332 items_[local_id] = result;
336 333
337 return result; 334 return result;
338 } 335 }
339 336
340 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( 337 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
341 DownloadItemImplDelegate* delegate, 338 DownloadItemImplDelegate* delegate,
342 const DownloadCreateInfo& info, 339 const DownloadCreateInfo& info,
343 scoped_ptr<DownloadRequestHandleInterface> request_handle, 340 scoped_ptr<DownloadRequestHandleInterface> request_handle,
344 bool is_otr,
345 const net::BoundNetLog& bound_net_log) { 341 const net::BoundNetLog& bound_net_log) {
346 int local_id = info.download_id.local(); 342 int local_id = info.download_id.local();
347 DCHECK(items_.find(local_id) == items_.end()); 343 DCHECK(items_.find(local_id) == items_.end());
348 344
349 MockDownloadItemImpl* result = 345 MockDownloadItemImpl* result =
350 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 346 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
351 EXPECT_CALL(*result, GetId()) 347 EXPECT_CALL(*result, GetId())
352 .WillRepeatedly(Return(local_id)); 348 .WillRepeatedly(Return(local_id));
353 items_[local_id] = result; 349 items_[local_id] = result;
354 350
355 return result; 351 return result;
356 } 352 }
357 353
358 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem( 354 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem(
359 DownloadItemImplDelegate* delegate, 355 DownloadItemImplDelegate* delegate,
360 const FilePath& path, 356 const FilePath& path,
361 const GURL& url, 357 const GURL& url,
362 bool is_otr,
363 content::DownloadId download_id, 358 content::DownloadId download_id,
364 const std::string& mime_type, 359 const std::string& mime_type,
365 const net::BoundNetLog& bound_net_log) { 360 const net::BoundNetLog& bound_net_log) {
366 int local_id = download_id.local(); 361 int local_id = download_id.local();
367 DCHECK(items_.find(local_id) == items_.end()); 362 DCHECK(items_.find(local_id) == items_.end());
368 363
369 MockDownloadItemImpl* result = 364 MockDownloadItemImpl* result =
370 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 365 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
371 EXPECT_CALL(*result, GetId()) 366 EXPECT_CALL(*result, GetId())
372 .WillRepeatedly(Return(local_id)); 367 .WillRepeatedly(Return(local_id));
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 UpdateItemInPersistentStore(&item)); 668 UpdateItemInPersistentStore(&item));
674 EXPECT_CALL(item, GetState()) 669 EXPECT_CALL(item, GetState())
675 .WillRepeatedly(Return(DownloadItem::CANCELLED)); 670 .WillRepeatedly(Return(DownloadItem::CANCELLED));
676 EXPECT_CALL(item, GetDbHandle()) 671 EXPECT_CALL(item, GetDbHandle())
677 .WillRepeatedly(Return(db_handle)); 672 .WillRepeatedly(Return(db_handle));
678 673
679 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager())); 674 EXPECT_CALL(item, OffThreadCancel(&GetMockDownloadFileManager()));
680 DownloadStopped(&item); 675 DownloadStopped(&item);
681 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id)); 676 EXPECT_EQ(NULL, download_manager_->GetActiveDownloadItem(download_id));
682 } 677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698