Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_ |
| 6 #define CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/observer_list.h" | |
| 9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 10 #include "content/public/browser/download_interrupt_reasons.h" | 11 #include "content/public/browser/download_interrupt_reasons.h" |
| 11 #include "content/public/browser/download_item.h" | 12 #include "content/public/browser/download_item.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 class MockDownloadItem : public DownloadItem { | 19 class MockDownloadItem : public DownloadItem { |
| 19 public: | 20 public: |
| 20 MockDownloadItem(); | 21 MockDownloadItem(); |
| 21 virtual ~MockDownloadItem(); | 22 virtual ~MockDownloadItem(); |
| 22 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); | 23 |
| 23 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); | 24 // Management of observer lists is common in tests. So Add/RemoveObserver |
| 24 MOCK_METHOD0(UpdateObservers, void()); | 25 // methods are not mocks. In addition, any registered observers will receive a |
| 26 // OnDownloadDestroyed() notification when the mock is destroyed. | |
| 27 virtual void AddObserver(Observer* observer) OVERRIDE; | |
| 28 virtual void RemoveObserver(Observer* observer) OVERRIDE; | |
| 29 virtual void UpdateObservers() OVERRIDE; | |
|
Randy Smith (Not in Mondays)
2014/04/23 19:28:35
I'd cluster this with the below and name it somewh
asanka
2014/04/25 21:31:27
Done.
| |
| 30 | |
| 31 // Dispatches an OnDownloadOpened() notification to observers. | |
| 32 void UpdateObserversOnOpened(); | |
| 33 // Dispatches an OnDownloadRemoved() notification to observers. | |
| 34 void UpdateObserversOnRemoved(); | |
| 35 | |
| 25 MOCK_METHOD0(ValidateDangerousDownload, void()); | 36 MOCK_METHOD0(ValidateDangerousDownload, void()); |
| 26 MOCK_METHOD1(StealDangerousDownload, void(const AcquireFileCallback&)); | 37 MOCK_METHOD1(StealDangerousDownload, void(const AcquireFileCallback&)); |
| 27 MOCK_METHOD0(Pause, void()); | 38 MOCK_METHOD0(Pause, void()); |
| 28 MOCK_METHOD0(Resume, void()); | 39 MOCK_METHOD0(Resume, void()); |
| 29 MOCK_METHOD1(Cancel, void(bool)); | 40 MOCK_METHOD1(Cancel, void(bool)); |
| 30 MOCK_METHOD0(Remove, void()); | 41 MOCK_METHOD0(Remove, void()); |
| 31 MOCK_METHOD0(OpenDownload, void()); | 42 MOCK_METHOD0(OpenDownload, void()); |
| 32 MOCK_METHOD0(ShowDownloadInShell, void()); | 43 MOCK_METHOD0(ShowDownloadInShell, void()); |
| 33 MOCK_CONST_METHOD0(GetId, uint32()); | 44 MOCK_CONST_METHOD0(GetId, uint32()); |
| 34 MOCK_CONST_METHOD0(GetState, DownloadState()); | 45 MOCK_CONST_METHOD0(GetState, DownloadState()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 MOCK_METHOD0(GetAutoOpened, bool()); | 91 MOCK_METHOD0(GetAutoOpened, bool()); |
| 81 MOCK_CONST_METHOD0(GetOpened, bool()); | 92 MOCK_CONST_METHOD0(GetOpened, bool()); |
| 82 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); | 93 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
| 83 MOCK_CONST_METHOD0(GetWebContents, WebContents*()); | 94 MOCK_CONST_METHOD0(GetWebContents, WebContents*()); |
| 84 MOCK_METHOD1(OnContentCheckCompleted, void(DownloadDangerType)); | 95 MOCK_METHOD1(OnContentCheckCompleted, void(DownloadDangerType)); |
| 85 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); | 96 MOCK_METHOD1(SetOpenWhenComplete, void(bool)); |
| 86 MOCK_METHOD1(SetIsTemporary, void(bool)); | 97 MOCK_METHOD1(SetIsTemporary, void(bool)); |
| 87 MOCK_METHOD1(SetOpened, void(bool)); | 98 MOCK_METHOD1(SetOpened, void(bool)); |
| 88 MOCK_METHOD1(SetDisplayName, void(const base::FilePath&)); | 99 MOCK_METHOD1(SetDisplayName, void(const base::FilePath&)); |
| 89 MOCK_CONST_METHOD1(DebugString, std::string(bool)); | 100 MOCK_CONST_METHOD1(DebugString, std::string(bool)); |
| 101 | |
| 102 private: | |
| 103 ObserverList<Observer> observers_; | |
| 90 }; | 104 }; |
| 91 | 105 |
| 92 } // namespace content | 106 } // namespace content |
| 93 | 107 |
| 94 #endif // CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_ | 108 #endif // CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_ITEM_H_ |
| OLD | NEW |