| 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 #include "chrome/browser/download/all_download_item_notifier.h" | 5 #include "chrome/browser/download/all_download_item_notifier.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "content/public/test/mock_download_item.h" | 8 #include "content/public/test/mock_download_item.h" |
| 9 #include "content/public/test/mock_download_manager.h" | 9 #include "content/public/test/mock_download_manager.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 MockNotifierObserver() { | 21 MockNotifierObserver() { |
| 22 } | 22 } |
| 23 virtual ~MockNotifierObserver() {} | 23 virtual ~MockNotifierObserver() {} |
| 24 | 24 |
| 25 MOCK_METHOD2(OnDownloadCreated, void( | 25 MOCK_METHOD2(OnDownloadCreated, void( |
| 26 content::DownloadManager* manager, content::DownloadItem* item)); | 26 content::DownloadManager* manager, content::DownloadItem* item)); |
| 27 MOCK_METHOD2(OnDownloadUpdated, void( | 27 MOCK_METHOD2(OnDownloadUpdated, void( |
| 28 content::DownloadManager* manager, content::DownloadItem* item)); | 28 content::DownloadManager* manager, content::DownloadItem* item)); |
| 29 MOCK_METHOD2(OnDownloadOpened, void( | 29 MOCK_METHOD2(OnDownloadOpened, void( |
| 30 content::DownloadManager* manager, content::DownloadItem* item)); | 30 content::DownloadManager* manager, content::DownloadItem* item)); |
| 31 MOCK_METHOD2(OnDownloadShown, void( |
| 32 content::DownloadManager* manager, content::DownloadItem* item)); |
| 31 MOCK_METHOD2(OnDownloadRemoved, void( | 33 MOCK_METHOD2(OnDownloadRemoved, void( |
| 32 content::DownloadManager* manager, content::DownloadItem* item)); | 34 content::DownloadManager* manager, content::DownloadItem* item)); |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(MockNotifierObserver); | 37 DISALLOW_COPY_AND_ASSIGN(MockNotifierObserver); |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 class AllDownloadItemNotifierTest : public testing::Test { | 40 class AllDownloadItemNotifierTest : public testing::Test { |
| 39 public: | 41 public: |
| 40 AllDownloadItemNotifierTest() | 42 AllDownloadItemNotifierTest() |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 EXPECT_CALL(manager(), GetAllDownloads(_)) | 89 EXPECT_CALL(manager(), GetAllDownloads(_)) |
| 88 .WillOnce(SetArgPointee<0>(items)); | 90 .WillOnce(SetArgPointee<0>(items)); |
| 89 SetNotifier(); | 91 SetNotifier(); |
| 90 | 92 |
| 91 EXPECT_CALL(observer(), OnDownloadUpdated(&manager(), &item())); | 93 EXPECT_CALL(observer(), OnDownloadUpdated(&manager(), &item())); |
| 92 NotifierAsItemObserver()->OnDownloadUpdated(&item()); | 94 NotifierAsItemObserver()->OnDownloadUpdated(&item()); |
| 93 | 95 |
| 94 EXPECT_CALL(observer(), OnDownloadOpened(&manager(), &item())); | 96 EXPECT_CALL(observer(), OnDownloadOpened(&manager(), &item())); |
| 95 NotifierAsItemObserver()->OnDownloadOpened(&item()); | 97 NotifierAsItemObserver()->OnDownloadOpened(&item()); |
| 96 | 98 |
| 99 EXPECT_CALL(observer(), OnDownloadShown(&manager(), &item())); |
| 100 NotifierAsItemObserver()->OnDownloadShown(&item()); |
| 101 |
| 97 EXPECT_CALL(observer(), OnDownloadRemoved(&manager(), &item())); | 102 EXPECT_CALL(observer(), OnDownloadRemoved(&manager(), &item())); |
| 98 NotifierAsItemObserver()->OnDownloadRemoved(&item()); | 103 NotifierAsItemObserver()->OnDownloadRemoved(&item()); |
| 99 | 104 |
| 100 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver())); | 105 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver())); |
| 101 ClearNotifier(); | 106 ClearNotifier(); |
| 102 } | 107 } |
| 103 | 108 |
| 104 TEST_F(AllDownloadItemNotifierTest, | 109 TEST_F(AllDownloadItemNotifierTest, |
| 105 AllDownloadItemNotifierTest_1) { | 110 AllDownloadItemNotifierTest_1) { |
| 106 EXPECT_CALL(manager(), GetAllDownloads(_)); | 111 EXPECT_CALL(manager(), GetAllDownloads(_)); |
| 107 SetNotifier(); | 112 SetNotifier(); |
| 108 | 113 |
| 109 EXPECT_CALL(observer(), OnDownloadCreated(&manager(), &item())); | 114 EXPECT_CALL(observer(), OnDownloadCreated(&manager(), &item())); |
| 110 NotifierAsManagerObserver()->OnDownloadCreated( | 115 NotifierAsManagerObserver()->OnDownloadCreated( |
| 111 &manager(), &item()); | 116 &manager(), &item()); |
| 112 | 117 |
| 113 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver())); | 118 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver())); |
| 114 NotifierAsManagerObserver()->ManagerGoingDown(&manager()); | 119 NotifierAsManagerObserver()->ManagerGoingDown(&manager()); |
| 115 | 120 |
| 116 ClearNotifier(); | 121 ClearNotifier(); |
| 117 } | 122 } |
| OLD | NEW |