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

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

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add proper method mock for BrowserContext::CreateZoomLevelDelegate() override. Created 6 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
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/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/browser/download/download_item_factory.h" 21 #include "content/browser/download/download_item_factory.h"
22 #include "content/browser/download/download_item_impl.h" 22 #include "content/browser/download/download_item_impl.h"
23 #include "content/browser/download/download_item_impl_delegate.h" 23 #include "content/browser/download/download_item_impl_delegate.h"
24 #include "content/browser/download/download_manager_impl.h" 24 #include "content/browser/download/download_manager_impl.h"
25 #include "content/browser/download/download_request_handle.h" 25 #include "content/browser/download/download_request_handle.h"
26 #include "content/browser/download/mock_download_file.h" 26 #include "content/browser/download/mock_download_file.h"
27 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/download_interrupt_reasons.h" 28 #include "content/public/browser/download_interrupt_reasons.h"
29 #include "content/public/browser/download_item.h" 29 #include "content/public/browser/download_item.h"
30 #include "content/public/browser/download_manager_delegate.h" 30 #include "content/public/browser/download_manager_delegate.h"
31 #include "content/public/browser/zoom_level_delegate.h"
31 #include "content/public/test/mock_download_item.h" 32 #include "content/public/test/mock_download_item.h"
32 #include "content/public/test/test_browser_context.h" 33 #include "content/public/test/test_browser_context.h"
33 #include "content/public/test/test_browser_thread.h" 34 #include "content/public/test/test_browser_thread.h"
34 #include "net/base/net_log.h" 35 #include "net/base/net_log.h"
35 #include "net/base/net_util.h" 36 #include "net/base/net_util.h"
36 #include "testing/gmock/include/gmock/gmock.h" 37 #include "testing/gmock/include/gmock/gmock.h"
37 #include "testing/gmock_mutant.h" 38 #include "testing/gmock_mutant.h"
38 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
39 40
40 using ::testing::AllOf; 41 using ::testing::AllOf;
41 using ::testing::DoAll; 42 using ::testing::DoAll;
42 using ::testing::Eq; 43 using ::testing::Eq;
43 using ::testing::Ref; 44 using ::testing::Ref;
44 using ::testing::Return; 45 using ::testing::Return;
45 using ::testing::ReturnRef; 46 using ::testing::ReturnRef;
46 using ::testing::SetArgPointee; 47 using ::testing::SetArgPointee;
47 using ::testing::StrictMock; 48 using ::testing::StrictMock;
48 using ::testing::_; 49 using ::testing::_;
49 50
50 ACTION_TEMPLATE(RunCallback, 51 ACTION_TEMPLATE(RunCallback,
51 HAS_1_TEMPLATE_PARAMS(int, k), 52 HAS_1_TEMPLATE_PARAMS(int, k),
52 AND_1_VALUE_PARAMS(p0)) { 53 AND_1_VALUE_PARAMS(p0)) {
53 return ::std::tr1::get<k>(args).Run(p0); 54 return ::std::tr1::get<k>(args).Run(p0);
54 } 55 }
55 56
57 // Create a specialization so we can mock an override for
Charlie Reis 2014/11/11 05:29:22 This looks questionable to me, but it's well beyon
wjmaclean 2014/11/11 19:20:52 It seems to be necessary. I think the main issue
58 // scoped_ptr<content::ZoomLevelDelegate>
59 // BrowserContext::CreateZoomLevelDelegate(const base::FilePath&).
60 template<>
61 class scoped_ptr<content::ZoomLevelDelegate> {
62 public:
63 scoped_ptr() {}
64 ~scoped_ptr() {}
65 };
66
56 namespace content { 67 namespace content {
57 class ByteStreamReader; 68 class ByteStreamReader;
58 69
59 namespace { 70 namespace {
60 71
61 // Matches a DownloadCreateInfo* that points to the same object as |info| and 72 // Matches a DownloadCreateInfo* that points to the same object as |info| and
62 // has a |default_download_directory| that matches |download_directory|. 73 // has a |default_download_directory| that matches |download_directory|.
63 MATCHER_P2(DownloadCreateInfoWithDefaultPath, info, download_directory, "") { 74 MATCHER_P2(DownloadCreateInfoWithDefaultPath, info, download_directory, "") {
64 return arg == info && 75 return arg == info &&
65 arg->default_download_directory == download_directory; 76 arg->default_download_directory == download_directory;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 stream.get(), bound_net_log, observer); 405 stream.get(), bound_net_log, observer);
395 } 406 }
396 }; 407 };
397 408
398 class MockBrowserContext : public BrowserContext { 409 class MockBrowserContext : public BrowserContext {
399 public: 410 public:
400 MockBrowserContext() {} 411 MockBrowserContext() {}
401 ~MockBrowserContext() {} 412 ~MockBrowserContext() {}
402 413
403 MOCK_CONST_METHOD0(GetPath, base::FilePath()); 414 MOCK_CONST_METHOD0(GetPath, base::FilePath());
415 MOCK_METHOD1(CreateZoomLevelDelegate,
416 scoped_ptr<ZoomLevelDelegate>(const base::FilePath&));
404 MOCK_CONST_METHOD0(IsOffTheRecord, bool()); 417 MOCK_CONST_METHOD0(IsOffTheRecord, bool());
405 MOCK_METHOD0(GetRequestContext, net::URLRequestContextGetter*()); 418 MOCK_METHOD0(GetRequestContext, net::URLRequestContextGetter*());
406 MOCK_METHOD1(GetRequestContextForRenderProcess, 419 MOCK_METHOD1(GetRequestContextForRenderProcess,
407 net::URLRequestContextGetter*(int renderer_child_id)); 420 net::URLRequestContextGetter*(int renderer_child_id));
408 MOCK_METHOD0(GetMediaRequestContext, 421 MOCK_METHOD0(GetMediaRequestContext,
409 net::URLRequestContextGetter*()); 422 net::URLRequestContextGetter*());
410 MOCK_METHOD1(GetMediaRequestContextForRenderProcess, 423 MOCK_METHOD1(GetMediaRequestContextForRenderProcess,
411 net::URLRequestContextGetter*(int renderer_child_id)); 424 net::URLRequestContextGetter*(int renderer_child_id));
412 MOCK_METHOD2(GetMediaRequestContextForStoragePartition, 425 MOCK_METHOD2(GetMediaRequestContextForStoragePartition,
413 net::URLRequestContextGetter*( 426 net::URLRequestContextGetter*(
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 .WillOnce(Return()); 693 .WillOnce(Return());
681 EXPECT_CALL(GetMockDownloadItem(3), Remove()) 694 EXPECT_CALL(GetMockDownloadItem(3), Remove())
682 .Times(0); 695 .Times(0);
683 696
684 download_manager_->RemoveAllDownloads(); 697 download_manager_->RemoveAllDownloads();
685 // Because we're mocking the download item, the Remove call doesn't 698 // Because we're mocking the download item, the Remove call doesn't
686 // result in them being removed from the DownloadManager list. 699 // result in them being removed from the DownloadManager list.
687 } 700 }
688 701
689 } // namespace content 702 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698