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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "content/browser/appcache/appcache_database.h" | 14 #include "content/browser/appcache/appcache_database.h" |
15 #include "content/browser/appcache/appcache_entry.h" | 15 #include "content/browser/appcache/appcache_entry.h" |
16 #include "sql/connection.h" | 16 #include "sql/connection.h" |
17 #include "sql/meta_table.h" | 17 #include "sql/meta_table.h" |
18 #include "sql/statement.h" | 18 #include "sql/statement.h" |
19 #include "sql/test/scoped_error_ignorer.h" | 19 #include "sql/test/scoped_error_expecter.h" |
20 #include "sql/test/test_helpers.h" | 20 #include "sql/test/test_helpers.h" |
21 #include "sql/transaction.h" | 21 #include "sql/transaction.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/sqlite/sqlite3.h" | 23 #include "third_party/sqlite/sqlite3.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const base::Time kZeroTime; | 27 const base::Time kZeroTime; |
28 | 28 |
29 } // namespace | 29 } // namespace |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 EXPECT_TRUE(db.LazyOpen(true)); | 103 EXPECT_TRUE(db.LazyOpen(true)); |
104 EXPECT_TRUE(base::PathExists(kOtherFile)); | 104 EXPECT_TRUE(base::PathExists(kOtherFile)); |
105 EXPECT_TRUE(base::PathExists(kDbFile)); | 105 EXPECT_TRUE(base::PathExists(kDbFile)); |
106 } | 106 } |
107 | 107 |
108 // Break it. | 108 // Break it. |
109 ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); | 109 ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); |
110 | 110 |
111 // Reopening will notice the corruption and delete/recreate the directory. | 111 // Reopening will notice the corruption and delete/recreate the directory. |
112 { | 112 { |
113 sql::ScopedErrorIgnorer ignore_errors; | 113 sql::test::ScopedErrorExpecter expecter; |
114 ignore_errors.IgnoreError(SQLITE_CORRUPT); | 114 expecter.ExpectError(SQLITE_CORRUPT); |
115 AppCacheDatabase db(kDbFile); | 115 AppCacheDatabase db(kDbFile); |
116 EXPECT_TRUE(db.LazyOpen(true)); | 116 EXPECT_TRUE(db.LazyOpen(true)); |
117 EXPECT_FALSE(base::PathExists(kOtherFile)); | 117 EXPECT_FALSE(base::PathExists(kOtherFile)); |
118 EXPECT_TRUE(base::PathExists(kDbFile)); | 118 EXPECT_TRUE(base::PathExists(kDbFile)); |
119 EXPECT_TRUE(ignore_errors.CheckIgnoredErrors()); | 119 EXPECT_TRUE(expecter.SawExpectedErrors()); |
120 } | 120 } |
121 } | 121 } |
122 #endif // NDEBUG | 122 #endif // NDEBUG |
123 | 123 |
124 TEST(AppCacheDatabaseTest, WasCorrutionDetected) { | 124 TEST(AppCacheDatabaseTest, WasCorrutionDetected) { |
125 // Real files on disk for this test too, a corrupt database file. | 125 // Real files on disk for this test too, a corrupt database file. |
126 base::ScopedTempDir temp_dir; | 126 base::ScopedTempDir temp_dir; |
127 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 127 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
128 const base::FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db"); | 128 const base::FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db"); |
129 | 129 |
130 // First create a valid db file. | 130 // First create a valid db file. |
131 AppCacheDatabase db(kDbFile); | 131 AppCacheDatabase db(kDbFile); |
132 EXPECT_TRUE(db.LazyOpen(true)); | 132 EXPECT_TRUE(db.LazyOpen(true)); |
133 EXPECT_TRUE(base::PathExists(kDbFile)); | 133 EXPECT_TRUE(base::PathExists(kDbFile)); |
134 EXPECT_FALSE(db.was_corruption_detected()); | 134 EXPECT_FALSE(db.was_corruption_detected()); |
135 | 135 |
136 // Break it. | 136 // Break it. |
137 ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); | 137 ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); |
138 | 138 |
139 // See the the corruption is detected and reported. | 139 // See the the corruption is detected and reported. |
140 { | 140 { |
141 sql::ScopedErrorIgnorer ignore_errors; | 141 sql::test::ScopedErrorExpecter expecter; |
142 ignore_errors.IgnoreError(SQLITE_CORRUPT); | 142 expecter.ExpectError(SQLITE_CORRUPT); |
143 std::map<GURL, int64_t> usage_map; | 143 std::map<GURL, int64_t> usage_map; |
144 EXPECT_FALSE(db.GetAllOriginUsage(&usage_map)); | 144 EXPECT_FALSE(db.GetAllOriginUsage(&usage_map)); |
145 EXPECT_TRUE(db.was_corruption_detected()); | 145 EXPECT_TRUE(db.was_corruption_detected()); |
146 EXPECT_TRUE(base::PathExists(kDbFile)); | 146 EXPECT_TRUE(base::PathExists(kDbFile)); |
147 EXPECT_TRUE(ignore_errors.CheckIgnoredErrors()); | 147 EXPECT_TRUE(expecter.SawExpectedErrors()); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 TEST(AppCacheDatabaseTest, ExperimentalFlags) { | 151 TEST(AppCacheDatabaseTest, ExperimentalFlags) { |
152 const char kExperimentFlagsKey[] = "ExperimentFlags"; | 152 const char kExperimentFlagsKey[] = "ExperimentFlags"; |
153 std::string kInjectedFlags("exp1,exp2"); | 153 std::string kInjectedFlags("exp1,exp2"); |
154 | 154 |
155 // Real files on disk for this test. | 155 // Real files on disk for this test. |
156 base::ScopedTempDir temp_dir; | 156 base::ScopedTempDir temp_dir; |
157 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 157 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
(...skipping 22 matching lines...) Expand all Loading... |
180 EXPECT_TRUE(flags.empty()); | 180 EXPECT_TRUE(flags.empty()); |
181 EXPECT_FALSE(base::PathExists(kOtherFile)); | 181 EXPECT_FALSE(base::PathExists(kOtherFile)); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 TEST(AppCacheDatabaseTest, EntryRecords) { | 185 TEST(AppCacheDatabaseTest, EntryRecords) { |
186 const base::FilePath kEmptyPath; | 186 const base::FilePath kEmptyPath; |
187 AppCacheDatabase db(kEmptyPath); | 187 AppCacheDatabase db(kEmptyPath); |
188 EXPECT_TRUE(db.LazyOpen(true)); | 188 EXPECT_TRUE(db.LazyOpen(true)); |
189 | 189 |
190 sql::ScopedErrorIgnorer ignore_errors; | 190 sql::test::ScopedErrorExpecter expecter; |
191 // TODO(shess): Suppressing SQLITE_CONSTRAINT because the code | 191 // TODO(shess): Suppressing SQLITE_CONSTRAINT because the code |
192 // expects that and handles the resulting error. Consider revising | 192 // expects that and handles the resulting error. Consider revising |
193 // the code to use INSERT OR IGNORE (which would not throw | 193 // the code to use INSERT OR IGNORE (which would not throw |
194 // SQLITE_CONSTRAINT) and then check ChangeCount() to see if any | 194 // SQLITE_CONSTRAINT) and then check ChangeCount() to see if any |
195 // changes were made. | 195 // changes were made. |
196 ignore_errors.IgnoreError(SQLITE_CONSTRAINT); | 196 expecter.ExpectError(SQLITE_CONSTRAINT); |
197 | 197 |
198 AppCacheDatabase::EntryRecord entry; | 198 AppCacheDatabase::EntryRecord entry; |
199 | 199 |
200 entry.cache_id = 1; | 200 entry.cache_id = 1; |
201 entry.url = GURL("http://blah/1"); | 201 entry.url = GURL("http://blah/1"); |
202 entry.flags = AppCacheEntry::MASTER; | 202 entry.flags = AppCacheEntry::MASTER; |
203 entry.response_id = 1; | 203 entry.response_id = 1; |
204 entry.response_size = 100; | 204 entry.response_size = 100; |
205 EXPECT_TRUE(db.InsertEntry(&entry)); | 205 EXPECT_TRUE(db.InsertEntry(&entry)); |
206 EXPECT_FALSE(db.InsertEntry(&entry)); | 206 EXPECT_FALSE(db.InsertEntry(&entry)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 EXPECT_TRUE(db.DeleteEntriesForCache(2)); | 254 EXPECT_TRUE(db.DeleteEntriesForCache(2)); |
255 EXPECT_TRUE(db.FindEntriesForCache(2, &found)); | 255 EXPECT_TRUE(db.FindEntriesForCache(2, &found)); |
256 EXPECT_TRUE(found.empty()); | 256 EXPECT_TRUE(found.empty()); |
257 found.clear(); | 257 found.clear(); |
258 | 258 |
259 EXPECT_TRUE(db.DeleteEntriesForCache(1)); | 259 EXPECT_TRUE(db.DeleteEntriesForCache(1)); |
260 EXPECT_FALSE(db.AddEntryFlags(GURL("http://blah/1"), 1, | 260 EXPECT_FALSE(db.AddEntryFlags(GURL("http://blah/1"), 1, |
261 AppCacheEntry::FOREIGN)); | 261 AppCacheEntry::FOREIGN)); |
262 | 262 |
263 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 263 ASSERT_TRUE(expecter.SawExpectedErrors()); |
264 } | 264 } |
265 | 265 |
266 TEST(AppCacheDatabaseTest, CacheRecords) { | 266 TEST(AppCacheDatabaseTest, CacheRecords) { |
267 const base::FilePath kEmptyPath; | 267 const base::FilePath kEmptyPath; |
268 AppCacheDatabase db(kEmptyPath); | 268 AppCacheDatabase db(kEmptyPath); |
269 EXPECT_TRUE(db.LazyOpen(true)); | 269 EXPECT_TRUE(db.LazyOpen(true)); |
270 | 270 |
271 sql::ScopedErrorIgnorer ignore_errors; | 271 sql::test::ScopedErrorExpecter expecter; |
272 // TODO(shess): See EntryRecords test. | 272 // TODO(shess): See EntryRecords test. |
273 ignore_errors.IgnoreError(SQLITE_CONSTRAINT); | 273 expecter.ExpectError(SQLITE_CONSTRAINT); |
274 | 274 |
275 const AppCacheDatabase::CacheRecord kZeroRecord; | 275 const AppCacheDatabase::CacheRecord kZeroRecord; |
276 AppCacheDatabase::CacheRecord record; | 276 AppCacheDatabase::CacheRecord record; |
277 EXPECT_FALSE(db.FindCache(1, &record)); | 277 EXPECT_FALSE(db.FindCache(1, &record)); |
278 | 278 |
279 record.cache_id = 1; | 279 record.cache_id = 1; |
280 record.group_id = 1; | 280 record.group_id = 1; |
281 record.online_wildcard = true; | 281 record.online_wildcard = true; |
282 record.update_time = kZeroTime; | 282 record.update_time = kZeroTime; |
283 record.cache_size = 100; | 283 record.cache_size = 100; |
(...skipping 15 matching lines...) Expand all Loading... |
299 EXPECT_TRUE(record.online_wildcard); | 299 EXPECT_TRUE(record.online_wildcard); |
300 EXPECT_TRUE(kZeroTime == record.update_time); | 300 EXPECT_TRUE(kZeroTime == record.update_time); |
301 EXPECT_EQ(100, record.cache_size); | 301 EXPECT_EQ(100, record.cache_size); |
302 | 302 |
303 EXPECT_TRUE(db.DeleteCache(1)); | 303 EXPECT_TRUE(db.DeleteCache(1)); |
304 EXPECT_FALSE(db.FindCache(1, &record)); | 304 EXPECT_FALSE(db.FindCache(1, &record)); |
305 EXPECT_FALSE(db.FindCacheForGroup(1, &record)); | 305 EXPECT_FALSE(db.FindCacheForGroup(1, &record)); |
306 | 306 |
307 EXPECT_TRUE(db.DeleteCache(1)); | 307 EXPECT_TRUE(db.DeleteCache(1)); |
308 | 308 |
309 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 309 ASSERT_TRUE(expecter.SawExpectedErrors()); |
310 } | 310 } |
311 | 311 |
312 TEST(AppCacheDatabaseTest, GroupRecords) { | 312 TEST(AppCacheDatabaseTest, GroupRecords) { |
313 const base::FilePath kEmptyPath; | 313 const base::FilePath kEmptyPath; |
314 AppCacheDatabase db(kEmptyPath); | 314 AppCacheDatabase db(kEmptyPath); |
315 EXPECT_TRUE(db.LazyOpen(true)); | 315 EXPECT_TRUE(db.LazyOpen(true)); |
316 | 316 |
317 sql::ScopedErrorIgnorer ignore_errors; | 317 sql::test::ScopedErrorExpecter expecter; |
318 // TODO(shess): See EntryRecords test. | 318 // TODO(shess): See EntryRecords test. |
319 ignore_errors.IgnoreError(SQLITE_CONSTRAINT); | 319 expecter.ExpectError(SQLITE_CONSTRAINT); |
320 | 320 |
321 const GURL kManifestUrl("http://blah/manifest"); | 321 const GURL kManifestUrl("http://blah/manifest"); |
322 const GURL kOrigin(kManifestUrl.GetOrigin()); | 322 const GURL kOrigin(kManifestUrl.GetOrigin()); |
323 const base::Time kLastAccessTime = base::Time::Now(); | 323 const base::Time kLastAccessTime = base::Time::Now(); |
324 const base::Time kCreationTime = | 324 const base::Time kCreationTime = |
325 kLastAccessTime - base::TimeDelta::FromDays(7); | 325 kLastAccessTime - base::TimeDelta::FromDays(7); |
326 | 326 |
327 const AppCacheDatabase::GroupRecord kZeroRecord; | 327 const AppCacheDatabase::GroupRecord kZeroRecord; |
328 AppCacheDatabase::GroupRecord record; | 328 AppCacheDatabase::GroupRecord record; |
329 std::vector<AppCacheDatabase::GroupRecord> records; | 329 std::vector<AppCacheDatabase::GroupRecord> records; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 cache_record.online_wildcard = true; | 430 cache_record.online_wildcard = true; |
431 cache_record.update_time = kZeroTime; | 431 cache_record.update_time = kZeroTime; |
432 EXPECT_TRUE(db.InsertCache(&cache_record)); | 432 EXPECT_TRUE(db.InsertCache(&cache_record)); |
433 | 433 |
434 record = kZeroRecord; | 434 record = kZeroRecord; |
435 EXPECT_TRUE(db.FindGroupForCache(1, &record)); | 435 EXPECT_TRUE(db.FindGroupForCache(1, &record)); |
436 EXPECT_EQ(1, record.group_id); | 436 EXPECT_EQ(1, record.group_id); |
437 EXPECT_EQ(kManifest2, record.manifest_url); | 437 EXPECT_EQ(kManifest2, record.manifest_url); |
438 EXPECT_EQ(kOrigin2, record.origin); | 438 EXPECT_EQ(kOrigin2, record.origin); |
439 | 439 |
440 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 440 ASSERT_TRUE(expecter.SawExpectedErrors()); |
441 } | 441 } |
442 | 442 |
443 TEST(AppCacheDatabaseTest, GroupAccessAndEvictionTimes) { | 443 TEST(AppCacheDatabaseTest, GroupAccessAndEvictionTimes) { |
444 const base::FilePath kEmptyPath; | 444 const base::FilePath kEmptyPath; |
445 AppCacheDatabase db(kEmptyPath); | 445 AppCacheDatabase db(kEmptyPath); |
446 EXPECT_TRUE(db.LazyOpen(true)); | 446 EXPECT_TRUE(db.LazyOpen(true)); |
447 | 447 |
448 const GURL kManifestUrl("http://blah/manifest"); | 448 const GURL kManifestUrl("http://blah/manifest"); |
449 const GURL kOrigin(kManifestUrl.GetOrigin()); | 449 const GURL kOrigin(kManifestUrl.GetOrigin()); |
450 const base::Time kDayOne = | 450 const base::Time kDayOne = |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 record = AppCacheDatabase::GroupRecord(); | 511 record = AppCacheDatabase::GroupRecord(); |
512 EXPECT_TRUE(db.FindGroup(1, &record)); | 512 EXPECT_TRUE(db.FindGroup(1, &record)); |
513 EXPECT_EQ(kDayTwo, record.last_access_time); | 513 EXPECT_EQ(kDayTwo, record.last_access_time); |
514 } | 514 } |
515 | 515 |
516 TEST(AppCacheDatabaseTest, NamespaceRecords) { | 516 TEST(AppCacheDatabaseTest, NamespaceRecords) { |
517 const base::FilePath kEmptyPath; | 517 const base::FilePath kEmptyPath; |
518 AppCacheDatabase db(kEmptyPath); | 518 AppCacheDatabase db(kEmptyPath); |
519 EXPECT_TRUE(db.LazyOpen(true)); | 519 EXPECT_TRUE(db.LazyOpen(true)); |
520 | 520 |
521 sql::ScopedErrorIgnorer ignore_errors; | 521 sql::test::ScopedErrorExpecter expecter; |
522 // TODO(shess): See EntryRecords test. | 522 // TODO(shess): See EntryRecords test. |
523 ignore_errors.IgnoreError(SQLITE_CONSTRAINT); | 523 expecter.ExpectError(SQLITE_CONSTRAINT); |
524 | 524 |
525 const GURL kFooNameSpace1("http://foo/namespace1"); | 525 const GURL kFooNameSpace1("http://foo/namespace1"); |
526 const GURL kFooNameSpace2("http://foo/namespace2"); | 526 const GURL kFooNameSpace2("http://foo/namespace2"); |
527 const GURL kFooFallbackEntry("http://foo/entry"); | 527 const GURL kFooFallbackEntry("http://foo/entry"); |
528 const GURL kFooOrigin(kFooNameSpace1.GetOrigin()); | 528 const GURL kFooOrigin(kFooNameSpace1.GetOrigin()); |
529 const GURL kBarNameSpace1("http://bar/namespace1"); | 529 const GURL kBarNameSpace1("http://bar/namespace1"); |
530 const GURL kBarNameSpace2("http://bar/namespace2"); | 530 const GURL kBarNameSpace2("http://bar/namespace2"); |
531 const GURL kBarFallbackEntry("http://bar/entry"); | 531 const GURL kBarFallbackEntry("http://bar/entry"); |
532 const GURL kBarOrigin(kBarNameSpace1.GetOrigin()); | 532 const GURL kBarOrigin(kBarNameSpace1.GetOrigin()); |
533 | 533 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 EXPECT_EQ(2U, fallbacks.size()); | 619 EXPECT_EQ(2U, fallbacks.size()); |
620 EXPECT_TRUE(fallbacks[0].namespace_.is_pattern); | 620 EXPECT_TRUE(fallbacks[0].namespace_.is_pattern); |
621 EXPECT_TRUE(fallbacks[1].namespace_.is_pattern); | 621 EXPECT_TRUE(fallbacks[1].namespace_.is_pattern); |
622 | 622 |
623 fallbacks.clear(); | 623 fallbacks.clear(); |
624 EXPECT_TRUE(db.FindNamespacesForOrigin(kBarOrigin, &intercepts, &fallbacks)); | 624 EXPECT_TRUE(db.FindNamespacesForOrigin(kBarOrigin, &intercepts, &fallbacks)); |
625 EXPECT_EQ(2U, fallbacks.size()); | 625 EXPECT_EQ(2U, fallbacks.size()); |
626 EXPECT_TRUE(fallbacks[0].namespace_.is_pattern); | 626 EXPECT_TRUE(fallbacks[0].namespace_.is_pattern); |
627 EXPECT_TRUE(fallbacks[1].namespace_.is_pattern); | 627 EXPECT_TRUE(fallbacks[1].namespace_.is_pattern); |
628 | 628 |
629 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 629 ASSERT_TRUE(expecter.SawExpectedErrors()); |
630 } | 630 } |
631 | 631 |
632 TEST(AppCacheDatabaseTest, OnlineWhiteListRecords) { | 632 TEST(AppCacheDatabaseTest, OnlineWhiteListRecords) { |
633 const base::FilePath kEmptyPath; | 633 const base::FilePath kEmptyPath; |
634 AppCacheDatabase db(kEmptyPath); | 634 AppCacheDatabase db(kEmptyPath); |
635 EXPECT_TRUE(db.LazyOpen(true)); | 635 EXPECT_TRUE(db.LazyOpen(true)); |
636 | 636 |
637 const GURL kFooNameSpace1("http://foo/namespace1"); | 637 const GURL kFooNameSpace1("http://foo/namespace1"); |
638 const GURL kFooNameSpace2("http://foo/namespace2"); | 638 const GURL kFooNameSpace2("http://foo/namespace2"); |
639 const GURL kBarNameSpace1("http://bar/namespace1"); | 639 const GURL kBarNameSpace1("http://bar/namespace1"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 records.clear(); | 674 records.clear(); |
675 EXPECT_TRUE(db.FindOnlineWhiteListForCache(1, &records)); | 675 EXPECT_TRUE(db.FindOnlineWhiteListForCache(1, &records)); |
676 EXPECT_TRUE(records.empty()); | 676 EXPECT_TRUE(records.empty()); |
677 } | 677 } |
678 | 678 |
679 TEST(AppCacheDatabaseTest, DeletableResponseIds) { | 679 TEST(AppCacheDatabaseTest, DeletableResponseIds) { |
680 const base::FilePath kEmptyPath; | 680 const base::FilePath kEmptyPath; |
681 AppCacheDatabase db(kEmptyPath); | 681 AppCacheDatabase db(kEmptyPath); |
682 EXPECT_TRUE(db.LazyOpen(true)); | 682 EXPECT_TRUE(db.LazyOpen(true)); |
683 | 683 |
684 sql::ScopedErrorIgnorer ignore_errors; | 684 sql::test::ScopedErrorExpecter expecter; |
685 // TODO(shess): See EntryRecords test. | 685 // TODO(shess): See EntryRecords test. |
686 ignore_errors.IgnoreError(SQLITE_CONSTRAINT); | 686 expecter.ExpectError(SQLITE_CONSTRAINT); |
687 | 687 |
688 std::vector<int64_t> ids; | 688 std::vector<int64_t> ids; |
689 | 689 |
690 EXPECT_TRUE(db.GetDeletableResponseIds( | 690 EXPECT_TRUE(db.GetDeletableResponseIds( |
691 &ids, std::numeric_limits<int64_t>::max(), 100)); | 691 &ids, std::numeric_limits<int64_t>::max(), 100)); |
692 EXPECT_TRUE(ids.empty()); | 692 EXPECT_TRUE(ids.empty()); |
693 ids.push_back(0); | 693 ids.push_back(0); |
694 EXPECT_TRUE(db.DeleteDeletableResponseIds(ids)); | 694 EXPECT_TRUE(db.DeleteDeletableResponseIds(ids)); |
695 EXPECT_TRUE(db.InsertDeletableResponseIds(ids)); | 695 EXPECT_TRUE(db.InsertDeletableResponseIds(ids)); |
696 | 696 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 745 |
746 // Ensure that we can delete from the table. | 746 // Ensure that we can delete from the table. |
747 EXPECT_TRUE(db.DeleteDeletableResponseIds(ids)); | 747 EXPECT_TRUE(db.DeleteDeletableResponseIds(ids)); |
748 ids.clear(); | 748 ids.clear(); |
749 EXPECT_TRUE(db.GetDeletableResponseIds( | 749 EXPECT_TRUE(db.GetDeletableResponseIds( |
750 &ids, std::numeric_limits<int64_t>::max(), 100)); | 750 &ids, std::numeric_limits<int64_t>::max(), 100)); |
751 EXPECT_EQ(5U, ids.size()); | 751 EXPECT_EQ(5U, ids.size()); |
752 for (int i = 0; i < static_cast<int>(ids.size()); ++i) | 752 for (int i = 0; i < static_cast<int>(ids.size()); ++i) |
753 EXPECT_EQ(i + 5, ids[i]); | 753 EXPECT_EQ(i + 5, ids[i]); |
754 | 754 |
755 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 755 ASSERT_TRUE(expecter.SawExpectedErrors()); |
756 } | 756 } |
757 | 757 |
758 TEST(AppCacheDatabaseTest, OriginUsage) { | 758 TEST(AppCacheDatabaseTest, OriginUsage) { |
759 const GURL kManifestUrl("http://blah/manifest"); | 759 const GURL kManifestUrl("http://blah/manifest"); |
760 const GURL kManifestUrl2("http://blah/manifest2"); | 760 const GURL kManifestUrl2("http://blah/manifest2"); |
761 const GURL kOrigin(kManifestUrl.GetOrigin()); | 761 const GURL kOrigin(kManifestUrl.GetOrigin()); |
762 const GURL kOtherOriginManifestUrl("http://other/manifest"); | 762 const GURL kOtherOriginManifestUrl("http://other/manifest"); |
763 const GURL kOtherOrigin(kOtherOriginManifestUrl.GetOrigin()); | 763 const GURL kOtherOrigin(kOtherOriginManifestUrl.GetOrigin()); |
764 | 764 |
765 const base::FilePath kEmptyPath; | 765 const base::FilePath kEmptyPath; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 AppCacheDatabase::GroupRecord group; | 1296 AppCacheDatabase::GroupRecord group; |
1297 EXPECT_TRUE(db.FindGroup(1, &group)); | 1297 EXPECT_TRUE(db.FindGroup(1, &group)); |
1298 EXPECT_EQ(kMockTime, group.last_full_update_check_time); | 1298 EXPECT_EQ(kMockTime, group.last_full_update_check_time); |
1299 EXPECT_EQ(kZeroTime, group.first_evictable_error_time); | 1299 EXPECT_EQ(kZeroTime, group.first_evictable_error_time); |
1300 EXPECT_TRUE(db.FindGroup(2, &group)); | 1300 EXPECT_TRUE(db.FindGroup(2, &group)); |
1301 EXPECT_EQ(kZeroTime, group.last_full_update_check_time); | 1301 EXPECT_EQ(kZeroTime, group.last_full_update_check_time); |
1302 EXPECT_EQ(kZeroTime, group.first_evictable_error_time); | 1302 EXPECT_EQ(kZeroTime, group.first_evictable_error_time); |
1303 } | 1303 } |
1304 | 1304 |
1305 } // namespace content | 1305 } // namespace content |
OLD | NEW |