OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stack> | 5 #include <stack> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 // Change the cache. | 703 // Change the cache. |
704 base::Time now = base::Time::Now(); | 704 base::Time now = base::Time::Now(); |
705 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1, 100)); | 705 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1, 100)); |
706 cache_->set_update_time(now); | 706 cache_->set_update_time(now); |
707 | 707 |
708 PushNextTask(base::Bind( | 708 PushNextTask(base::Bind( |
709 &AppCacheStorageImplTest::Verify_StoreExistingGroupExistingCache, | 709 &AppCacheStorageImplTest::Verify_StoreExistingGroupExistingCache, |
710 base::Unretained(this), now)); | 710 base::Unretained(this), now)); |
711 | 711 |
712 // Conduct the test. | 712 // Conduct the test. |
713 EXPECT_EQ(cache_, group_->newest_complete_cache()); | 713 EXPECT_EQ(cache_.get(), group_->newest_complete_cache()); |
714 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate()); | 714 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate()); |
715 EXPECT_FALSE(delegate()->stored_group_success_); | 715 EXPECT_FALSE(delegate()->stored_group_success_); |
716 } | 716 } |
717 | 717 |
718 void Verify_StoreExistingGroupExistingCache( | 718 void Verify_StoreExistingGroupExistingCache( |
719 base::Time expected_update_time) { | 719 base::Time expected_update_time) { |
720 EXPECT_TRUE(delegate()->stored_group_success_); | 720 EXPECT_TRUE(delegate()->stored_group_success_); |
721 EXPECT_EQ(cache_, group_->newest_complete_cache()); | 721 EXPECT_EQ(cache_.get(), group_->newest_complete_cache()); |
722 | 722 |
723 AppCacheDatabase::CacheRecord cache_record; | 723 AppCacheDatabase::CacheRecord cache_record; |
724 EXPECT_TRUE(database()->FindCache(1, &cache_record)); | 724 EXPECT_TRUE(database()->FindCache(1, &cache_record)); |
725 EXPECT_EQ(1, cache_record.cache_id); | 725 EXPECT_EQ(1, cache_record.cache_id); |
726 EXPECT_EQ(1, cache_record.group_id); | 726 EXPECT_EQ(1, cache_record.group_id); |
727 EXPECT_FALSE(cache_record.online_wildcard); | 727 EXPECT_FALSE(cache_record.online_wildcard); |
728 EXPECT_TRUE(expected_update_time == cache_record.update_time); | 728 EXPECT_TRUE(expected_update_time == cache_record.update_time); |
729 EXPECT_EQ(100 + kDefaultEntrySize, cache_record.cache_size); | 729 EXPECT_EQ(100 + kDefaultEntrySize, cache_record.cache_size); |
730 | 730 |
731 std::vector<AppCacheDatabase::EntryRecord> entry_records; | 731 std::vector<AppCacheDatabase::EntryRecord> entry_records; |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 observer_->observed_old_storage_->storage()); | 1791 observer_->observed_old_storage_->storage()); |
1792 EXPECT_TRUE(storage->database_->was_corruption_detected()); | 1792 EXPECT_TRUE(storage->database_->was_corruption_detected()); |
1793 } | 1793 } |
1794 | 1794 |
1795 // Verify that the hosts saw appropriate events. | 1795 // Verify that the hosts saw appropriate events. |
1796 if (test_case == CORRUPT_CACHE_ON_INSTALL || | 1796 if (test_case == CORRUPT_CACHE_ON_INSTALL || |
1797 test_case == CORRUPT_SQL_ON_INSTALL) { | 1797 test_case == CORRUPT_SQL_ON_INSTALL) { |
1798 EXPECT_TRUE(frontend_.error_event_was_raised_); | 1798 EXPECT_TRUE(frontend_.error_event_was_raised_); |
1799 AppCacheHost* host1 = backend_->GetHost(1); | 1799 AppCacheHost* host1 = backend_->GetHost(1); |
1800 EXPECT_FALSE(host1->associated_cache()); | 1800 EXPECT_FALSE(host1->associated_cache()); |
1801 EXPECT_FALSE(host1->group_being_updated_); | 1801 EXPECT_FALSE(host1->group_being_updated_.get()); |
1802 EXPECT_TRUE(host1->disabled_storage_reference_.get()); | 1802 EXPECT_TRUE(host1->disabled_storage_reference_.get()); |
1803 } else { | 1803 } else { |
1804 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); | 1804 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); |
1805 AppCacheHost* host2 = backend_->GetHost(2); | 1805 AppCacheHost* host2 = backend_->GetHost(2); |
1806 EXPECT_EQ(1, host2->main_resource_cache_->cache_id()); | 1806 EXPECT_EQ(1, host2->main_resource_cache_->cache_id()); |
1807 EXPECT_TRUE(host2->disabled_storage_reference_.get()); | 1807 EXPECT_TRUE(host2->disabled_storage_reference_.get()); |
1808 } | 1808 } |
1809 | 1809 |
1810 // Cleanup and claim victory. | 1810 // Cleanup and claim victory. |
1811 service_->RemoveObserver(observer_.get()); | 1811 service_->RemoveObserver(observer_.get()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2016 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
2017 } | 2017 } |
2018 | 2018 |
2019 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2019 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
2020 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2020 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
2021 } | 2021 } |
2022 | 2022 |
2023 // That's all folks! | 2023 // That's all folks! |
2024 | 2024 |
2025 } // namespace content | 2025 } // namespace content |
OLD | NEW |