OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/offline_pages/core/downloads/download_ui_adapter.h" | 5 #include "components/offline_pages/core/downloads/download_ui_adapter.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 EXPECT_EQ(0UL, added_guids.size()); | 432 EXPECT_EQ(0UL, added_guids.size()); |
433 EXPECT_EQ(0UL, deleted_guids.size()); | 433 EXPECT_EQ(0UL, deleted_guids.size()); |
434 | 434 |
435 EXPECT_GE(updated_guids.size(), 1UL); | 435 EXPECT_GE(updated_guids.size(), 1UL); |
436 std::string last_updated_guid = updated_guids[updated_guids.size() - 1]; | 436 std::string last_updated_guid = updated_guids[updated_guids.size() - 1]; |
437 item = adapter->GetItem(last_updated_guid); | 437 item = adapter->GetItem(last_updated_guid); |
438 EXPECT_NE(nullptr, item); | 438 EXPECT_NE(nullptr, item); |
439 EXPECT_EQ(DownloadUIItem::DownloadState::COMPLETE, item->download_state); | 439 EXPECT_EQ(DownloadUIItem::DownloadState::COMPLETE, item->download_state); |
440 } | 440 } |
441 | 441 |
| 442 TEST_F(DownloadUIAdapterTest, RemoveObserversWhenClearingCache) { |
| 443 PumpLoop(); |
| 444 EXPECT_TRUE(items_loaded); |
| 445 |
| 446 // Remove this from the adapter's observer list. This should cause the cache |
| 447 // to be cleared. |
| 448 adapter->RemoveObserver(this); |
| 449 items_loaded = false; |
| 450 |
| 451 PumpLoop(); |
| 452 |
| 453 adapter->AddObserver(this); |
| 454 PumpLoop(); |
| 455 EXPECT_TRUE(items_loaded); |
| 456 } |
| 457 |
442 } // namespace offline_pages | 458 } // namespace offline_pages |
OLD | NEW |