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

Side by Side Diff: components/offline_pages/core/downloads/download_ui_adapter_unittest.cc

Issue 2700773003: [Offline Pages] Download UI: Remove all observers when clearing cache. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « components/offline_pages/core/downloads/download_ui_adapter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « components/offline_pages/core/downloads/download_ui_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698