| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 AssignQuotaTable(db.get(), entries, entries + entries_size); | 580 AssignQuotaTable(db.get(), entries, entries + entries_size); |
| 581 db->CommitTransaction(); | 581 db->CommitTransaction(); |
| 582 } | 582 } |
| 583 | 583 |
| 584 base::MessageLoop message_loop_; | 584 base::MessageLoop message_loop_; |
| 585 }; | 585 }; |
| 586 | 586 |
| 587 TEST_F(QuotaDatabaseTest, LazyOpen) { | 587 TEST_F(QuotaDatabaseTest, LazyOpen) { |
| 588 base::ScopedTempDir data_dir; | 588 base::ScopedTempDir data_dir; |
| 589 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 589 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 590 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 590 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 591 LazyOpen(kDbFile); | 591 LazyOpen(kDbFile); |
| 592 LazyOpen(base::FilePath()); | 592 LazyOpen(base::FilePath()); |
| 593 } | 593 } |
| 594 | 594 |
| 595 TEST_F(QuotaDatabaseTest, UpgradeSchema) { | 595 TEST_F(QuotaDatabaseTest, UpgradeSchema) { |
| 596 base::ScopedTempDir data_dir; | 596 base::ScopedTempDir data_dir; |
| 597 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 597 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 598 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 598 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 599 UpgradeSchemaV2toV5(kDbFile); | 599 UpgradeSchemaV2toV5(kDbFile); |
| 600 } | 600 } |
| 601 | 601 |
| 602 TEST_F(QuotaDatabaseTest, HostQuota) { | 602 TEST_F(QuotaDatabaseTest, HostQuota) { |
| 603 base::ScopedTempDir data_dir; | 603 base::ScopedTempDir data_dir; |
| 604 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 604 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 605 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 605 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 606 HostQuota(kDbFile); | 606 HostQuota(kDbFile); |
| 607 HostQuota(base::FilePath()); | 607 HostQuota(base::FilePath()); |
| 608 } | 608 } |
| 609 | 609 |
| 610 TEST_F(QuotaDatabaseTest, GlobalQuota) { | 610 TEST_F(QuotaDatabaseTest, GlobalQuota) { |
| 611 base::ScopedTempDir data_dir; | 611 base::ScopedTempDir data_dir; |
| 612 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 612 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 613 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 613 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 614 GlobalQuota(kDbFile); | 614 GlobalQuota(kDbFile); |
| 615 GlobalQuota(base::FilePath()); | 615 GlobalQuota(base::FilePath()); |
| 616 } | 616 } |
| 617 | 617 |
| 618 TEST_F(QuotaDatabaseTest, OriginLastAccessTimeLRU) { | 618 TEST_F(QuotaDatabaseTest, OriginLastAccessTimeLRU) { |
| 619 base::ScopedTempDir data_dir; | 619 base::ScopedTempDir data_dir; |
| 620 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 620 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 621 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 621 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 622 OriginLastAccessTimeLRU(kDbFile); | 622 OriginLastAccessTimeLRU(kDbFile); |
| 623 OriginLastAccessTimeLRU(base::FilePath()); | 623 OriginLastAccessTimeLRU(base::FilePath()); |
| 624 } | 624 } |
| 625 | 625 |
| 626 TEST_F(QuotaDatabaseTest, OriginLastModifiedSince) { | 626 TEST_F(QuotaDatabaseTest, OriginLastModifiedSince) { |
| 627 base::ScopedTempDir data_dir; | 627 base::ScopedTempDir data_dir; |
| 628 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 628 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 629 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 629 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 630 OriginLastModifiedSince(kDbFile); | 630 OriginLastModifiedSince(kDbFile); |
| 631 OriginLastModifiedSince(base::FilePath()); | 631 OriginLastModifiedSince(base::FilePath()); |
| 632 } | 632 } |
| 633 | 633 |
| 634 TEST_F(QuotaDatabaseTest, OriginLastEvicted) { | 634 TEST_F(QuotaDatabaseTest, OriginLastEvicted) { |
| 635 base::ScopedTempDir data_dir; | 635 base::ScopedTempDir data_dir; |
| 636 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 636 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 637 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 637 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 638 OriginLastEvicted(kDbFile); | 638 OriginLastEvicted(kDbFile); |
| 639 OriginLastEvicted(base::FilePath()); | 639 OriginLastEvicted(base::FilePath()); |
| 640 } | 640 } |
| 641 | 641 |
| 642 TEST_F(QuotaDatabaseTest, BootstrapFlag) { | 642 TEST_F(QuotaDatabaseTest, BootstrapFlag) { |
| 643 base::ScopedTempDir data_dir; | 643 base::ScopedTempDir data_dir; |
| 644 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 644 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 645 | 645 |
| 646 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 646 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 647 QuotaDatabase db(kDbFile); | 647 QuotaDatabase db(kDbFile); |
| 648 | 648 |
| 649 EXPECT_FALSE(db.IsOriginDatabaseBootstrapped()); | 649 EXPECT_FALSE(db.IsOriginDatabaseBootstrapped()); |
| 650 EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(true)); | 650 EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(true)); |
| 651 EXPECT_TRUE(db.IsOriginDatabaseBootstrapped()); | 651 EXPECT_TRUE(db.IsOriginDatabaseBootstrapped()); |
| 652 EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(false)); | 652 EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(false)); |
| 653 EXPECT_FALSE(db.IsOriginDatabaseBootstrapped()); | 653 EXPECT_FALSE(db.IsOriginDatabaseBootstrapped()); |
| 654 } | 654 } |
| 655 | 655 |
| 656 TEST_F(QuotaDatabaseTest, RegisterInitialOriginInfo) { | 656 TEST_F(QuotaDatabaseTest, RegisterInitialOriginInfo) { |
| 657 base::ScopedTempDir data_dir; | 657 base::ScopedTempDir data_dir; |
| 658 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 658 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 659 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 659 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 660 RegisterInitialOriginInfo(kDbFile); | 660 RegisterInitialOriginInfo(kDbFile); |
| 661 RegisterInitialOriginInfo(base::FilePath()); | 661 RegisterInitialOriginInfo(base::FilePath()); |
| 662 } | 662 } |
| 663 | 663 |
| 664 TEST_F(QuotaDatabaseTest, DumpQuotaTable) { | 664 TEST_F(QuotaDatabaseTest, DumpQuotaTable) { |
| 665 base::ScopedTempDir data_dir; | 665 base::ScopedTempDir data_dir; |
| 666 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 666 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 667 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 667 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 668 DumpQuotaTable(kDbFile); | 668 DumpQuotaTable(kDbFile); |
| 669 DumpQuotaTable(base::FilePath()); | 669 DumpQuotaTable(base::FilePath()); |
| 670 } | 670 } |
| 671 | 671 |
| 672 TEST_F(QuotaDatabaseTest, DumpOriginInfoTable) { | 672 TEST_F(QuotaDatabaseTest, DumpOriginInfoTable) { |
| 673 base::ScopedTempDir data_dir; | 673 base::ScopedTempDir data_dir; |
| 674 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 674 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 675 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 675 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 676 DumpOriginInfoTable(kDbFile); | 676 DumpOriginInfoTable(kDbFile); |
| 677 DumpOriginInfoTable(base::FilePath()); | 677 DumpOriginInfoTable(base::FilePath()); |
| 678 } | 678 } |
| 679 | 679 |
| 680 TEST_F(QuotaDatabaseTest, GetOriginInfo) { | 680 TEST_F(QuotaDatabaseTest, GetOriginInfo) { |
| 681 GetOriginInfo(base::FilePath()); | 681 GetOriginInfo(base::FilePath()); |
| 682 } | 682 } |
| 683 | 683 |
| 684 TEST_F(QuotaDatabaseTest, OpenCorruptedDatabase) { | 684 TEST_F(QuotaDatabaseTest, OpenCorruptedDatabase) { |
| 685 base::ScopedTempDir data_dir; | 685 base::ScopedTempDir data_dir; |
| 686 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); | 686 ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
| 687 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); | 687 const base::FilePath kDbFile = data_dir.GetPath().AppendASCII(kDBFileName); |
| 688 LazyOpen(kDbFile); | 688 LazyOpen(kDbFile); |
| 689 ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); | 689 ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); |
| 690 { | 690 { |
| 691 sql::test::ScopedErrorExpecter expecter; | 691 sql::test::ScopedErrorExpecter expecter; |
| 692 expecter.ExpectError(SQLITE_CORRUPT); | 692 expecter.ExpectError(SQLITE_CORRUPT); |
| 693 Reopen(kDbFile); | 693 Reopen(kDbFile); |
| 694 EXPECT_TRUE(expecter.SawExpectedErrors()); | 694 EXPECT_TRUE(expecter.SawExpectedErrors()); |
| 695 } | 695 } |
| 696 } | 696 } |
| 697 | 697 |
| 698 } // namespace content | 698 } // namespace content |
| OLD | NEW |