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

Side by Side Diff: chrome/browser/download/all_download_item_notifier_unittest.cc

Issue 248713004: [Downloads] Add real observers to MockDownloadItem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 "chrome/browser/download/all_download_item_notifier.h" 5 #include "chrome/browser/download/all_download_item_notifier.h"
6 6
7 #include "content/public/test/mock_download_item.h" 7 #include "content/public/test/mock_download_item.h"
8 #include "content/public/test/mock_download_manager.h" 8 #include "content/public/test/mock_download_manager.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }; 78 };
79 79
80 } // namespace 80 } // namespace
81 81
82 TEST_F(AllDownloadItemNotifierTest, 82 TEST_F(AllDownloadItemNotifierTest,
83 AllDownloadItemNotifierTest_0) { 83 AllDownloadItemNotifierTest_0) {
84 content::DownloadManager::DownloadVector items; 84 content::DownloadManager::DownloadVector items;
85 items.push_back(&item()); 85 items.push_back(&item());
86 EXPECT_CALL(manager(), GetAllDownloads(_)) 86 EXPECT_CALL(manager(), GetAllDownloads(_))
87 .WillOnce(SetArgPointee<0>(items)); 87 .WillOnce(SetArgPointee<0>(items));
88 EXPECT_CALL(item(), AddObserver(_));
89 SetNotifier(); 88 SetNotifier();
90 89
91 EXPECT_CALL(observer(), OnDownloadUpdated(&manager(), &item())); 90 EXPECT_CALL(observer(), OnDownloadUpdated(&manager(), &item()));
92 NotifierAsItemObserver()->OnDownloadUpdated(&item()); 91 NotifierAsItemObserver()->OnDownloadUpdated(&item());
93 92
94 EXPECT_CALL(observer(), OnDownloadOpened(&manager(), &item())); 93 EXPECT_CALL(observer(), OnDownloadOpened(&manager(), &item()));
95 NotifierAsItemObserver()->OnDownloadOpened(&item()); 94 NotifierAsItemObserver()->OnDownloadOpened(&item());
96 95
97 EXPECT_CALL(observer(), OnDownloadRemoved(&manager(), &item())); 96 EXPECT_CALL(observer(), OnDownloadRemoved(&manager(), &item()));
98 NotifierAsItemObserver()->OnDownloadRemoved(&item()); 97 NotifierAsItemObserver()->OnDownloadRemoved(&item());
99 98
100 EXPECT_CALL(item(), RemoveObserver(NotifierAsItemObserver()));
101 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver())); 99 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver()));
102 ClearNotifier(); 100 ClearNotifier();
103 } 101 }
104 102
105 TEST_F(AllDownloadItemNotifierTest, 103 TEST_F(AllDownloadItemNotifierTest,
106 AllDownloadItemNotifierTest_1) { 104 AllDownloadItemNotifierTest_1) {
107 EXPECT_CALL(manager(), GetAllDownloads(_)); 105 EXPECT_CALL(manager(), GetAllDownloads(_));
108 SetNotifier(); 106 SetNotifier();
109 107
110 EXPECT_CALL(item(), AddObserver(NotifierAsItemObserver()));
111 EXPECT_CALL(observer(), OnDownloadCreated(&manager(), &item())); 108 EXPECT_CALL(observer(), OnDownloadCreated(&manager(), &item()));
112 NotifierAsManagerObserver()->OnDownloadCreated( 109 NotifierAsManagerObserver()->OnDownloadCreated(
113 &manager(), &item()); 110 &manager(), &item());
114 111
115 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver())); 112 EXPECT_CALL(manager(), RemoveObserver(NotifierAsManagerObserver()));
116 NotifierAsManagerObserver()->ManagerGoingDown(&manager()); 113 NotifierAsManagerObserver()->ManagerGoingDown(&manager());
117 114
118 EXPECT_CALL(item(), RemoveObserver(NotifierAsItemObserver()));
119 NotifierAsItemObserver()->OnDownloadDestroyed(&item());
120
121 ClearNotifier(); 115 ClearNotifier();
122 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698