| 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/download/download_history.h" | 10 #include "chrome/browser/download/download_history.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 void ExpectNoDownloadsRemoved() { | 157 void ExpectNoDownloadsRemoved() { |
| 158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 159 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 159 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); |
| 160 EXPECT_EQ(0, static_cast<int>(remove_downloads_.size())); | 160 EXPECT_EQ(0, static_cast<int>(remove_downloads_.size())); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ExpectDownloadsRemoved(const IdSet& ids) { | 163 void ExpectDownloadsRemoved(const IdSet& ids) { |
| 164 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 164 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 165 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 165 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); |
| 166 IdSet differences; | 166 IdSet differences = base::STLSetDifference<IdSet>(ids, remove_downloads_); |
| 167 std::insert_iterator<IdSet> differences_iter( | |
| 168 differences, differences.begin()); | |
| 169 std::set_difference(ids.begin(), ids.end(), | |
| 170 remove_downloads_.begin(), | |
| 171 remove_downloads_.end(), | |
| 172 differences_iter); | |
| 173 for (IdSet::const_iterator different = differences.begin(); | 167 for (IdSet::const_iterator different = differences.begin(); |
| 174 different != differences.end(); ++different) { | 168 different != differences.end(); ++different) { |
| 175 EXPECT_TRUE(false) << *different; | 169 EXPECT_TRUE(false) << *different; |
| 176 } | 170 } |
| 177 remove_downloads_.clear(); | 171 remove_downloads_.clear(); |
| 178 } | 172 } |
| 179 | 173 |
| 180 private: | 174 private: |
| 181 bool slow_create_download_; | 175 bool slow_create_download_; |
| 182 bool fail_create_download_; | 176 bool fail_create_download_; |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 item_observer()->OnDownloadUpdated(&item(0)); | 764 item_observer()->OnDownloadUpdated(&item(0)); |
| 771 | 765 |
| 772 FinishCreateDownload(); | 766 FinishCreateDownload(); |
| 773 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); | 767 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); |
| 774 | 768 |
| 775 // ItemAdded should call OnDownloadUpdated, which should detect that the item | 769 // ItemAdded should call OnDownloadUpdated, which should detect that the item |
| 776 // changed while it was being added and call UpdateDownload immediately. | 770 // changed while it was being added and call UpdateDownload immediately. |
| 777 info.opened = true; | 771 info.opened = true; |
| 778 ExpectDownloadUpdated(info); | 772 ExpectDownloadUpdated(info); |
| 779 } | 773 } |
| OLD | NEW |