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

Side by Side Diff: webkit/appcache/appcache_database_unittest.cc

Issue 7031065: AppCache + Quota integration (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache_database.cc ('k') | webkit/appcache/appcache_quota_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "app/sql/connection.h" 7 #include "app/sql/connection.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "webkit/appcache/appcache_database.h" 10 #include "webkit/appcache/appcache_database.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 // Ensure that we can delete from the table. 534 // Ensure that we can delete from the table.
535 EXPECT_TRUE(db.DeleteDeletableResponseIds(ids)); 535 EXPECT_TRUE(db.DeleteDeletableResponseIds(ids));
536 ids.clear(); 536 ids.clear();
537 EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 100)); 537 EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 100));
538 EXPECT_EQ(5U, ids.size()); 538 EXPECT_EQ(5U, ids.size());
539 for (int i = 0; i < static_cast<int>(ids.size()); ++i) 539 for (int i = 0; i < static_cast<int>(ids.size()); ++i)
540 EXPECT_EQ(i + 5, ids[i]); 540 EXPECT_EQ(i + 5, ids[i]);
541 } 541 }
542 542
543 TEST(AppCacheDatabaseTest, Quotas) { 543 TEST(AppCacheDatabaseTest, OriginUsage) {
544 const GURL kManifestUrl("http://blah/manifest"); 544 const GURL kManifestUrl("http://blah/manifest");
545 const GURL kManifestUrl2("http://blah/manifest2"); 545 const GURL kManifestUrl2("http://blah/manifest2");
546 const GURL kOrigin(kManifestUrl.GetOrigin()); 546 const GURL kOrigin(kManifestUrl.GetOrigin());
547 const GURL kOtherOriginManifestUrl("http://other/manifest"); 547 const GURL kOtherOriginManifestUrl("http://other/manifest");
548 const GURL kOtherOrigin(kOtherOriginManifestUrl.GetOrigin()); 548 const GURL kOtherOrigin(kOtherOriginManifestUrl.GetOrigin());
549 549
550 const FilePath kEmptyPath; 550 const FilePath kEmptyPath;
551 AppCacheDatabase db(kEmptyPath); 551 AppCacheDatabase db(kEmptyPath);
552 EXPECT_TRUE(db.LazyOpen(true)); 552 EXPECT_TRUE(db.LazyOpen(true));
553 553
554 scoped_refptr<TestErrorDelegate> error_delegate(new TestErrorDelegate); 554 scoped_refptr<TestErrorDelegate> error_delegate(new TestErrorDelegate);
555 db.db_->set_error_delegate(error_delegate); 555 db.db_->set_error_delegate(error_delegate);
556 556
557 std::vector<AppCacheDatabase::CacheRecord> cache_records; 557 std::vector<AppCacheDatabase::CacheRecord> cache_records;
558 EXPECT_EQ(db.GetDefaultOriginQuota(), db.GetOriginQuota(kOrigin));
559 EXPECT_EQ(0, db.GetOriginUsage(kOrigin)); 558 EXPECT_EQ(0, db.GetOriginUsage(kOrigin));
560 EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records)); 559 EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records));
561 EXPECT_TRUE(cache_records.empty()); 560 EXPECT_TRUE(cache_records.empty());
562 561
563 AppCacheDatabase::GroupRecord group_record; 562 AppCacheDatabase::GroupRecord group_record;
564 group_record.group_id = 1; 563 group_record.group_id = 1;
565 group_record.manifest_url = kManifestUrl; 564 group_record.manifest_url = kManifestUrl;
566 group_record.origin = kOrigin; 565 group_record.origin = kOrigin;
567 EXPECT_TRUE(db.InsertGroup(&group_record)); 566 EXPECT_TRUE(db.InsertGroup(&group_record));
568 AppCacheDatabase::CacheRecord cache_record; 567 AppCacheDatabase::CacheRecord cache_record;
(...skipping 30 matching lines...) Expand all
599 cache_record.cache_size = 5000; 598 cache_record.cache_size = 5000;
600 EXPECT_TRUE(db.InsertCache(&cache_record)); 599 EXPECT_TRUE(db.InsertCache(&cache_record));
601 600
602 EXPECT_EQ(5000, db.GetOriginUsage(kOtherOrigin)); 601 EXPECT_EQ(5000, db.GetOriginUsage(kOtherOrigin));
603 602
604 EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records)); 603 EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records));
605 EXPECT_EQ(2U, cache_records.size()); 604 EXPECT_EQ(2U, cache_records.size());
606 cache_records.clear(); 605 cache_records.clear();
607 EXPECT_TRUE(db.FindCachesForOrigin(kOtherOrigin, &cache_records)); 606 EXPECT_TRUE(db.FindCachesForOrigin(kOtherOrigin, &cache_records));
608 EXPECT_EQ(1U, cache_records.size()); 607 EXPECT_EQ(1U, cache_records.size());
608
609 std::map<GURL, int64> usage_map;
610 EXPECT_TRUE(db.GetAllOriginUsage(&usage_map));
611 EXPECT_EQ(2U, usage_map.size());
612 EXPECT_EQ(1100, usage_map[kOrigin]);
613 EXPECT_EQ(5000, usage_map[kOtherOrigin]);
609 } 614 }
610 615
611 } // namespace appcache 616 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_database.cc ('k') | webkit/appcache/appcache_quota_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698