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 "base/files/file.h" | 5 #include "base/files/file.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/message_loop/message_loop_proxy.h" | |
12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/thread_task_runner_handle.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "content/public/test/mock_special_storage_policy.h" | 14 #include "content/public/test/mock_special_storage_policy.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
17 #include "storage/browser/database/database_tracker.h" | 17 #include "storage/browser/database/database_tracker.h" |
18 #include "storage/browser/quota/quota_manager_proxy.h" | 18 #include "storage/browser/quota/quota_manager_proxy.h" |
19 #include "storage/common/database/database_identifier.h" | 19 #include "storage/common/database/database_identifier.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/sqlite/sqlite3.h" | 21 #include "third_party/sqlite/sqlite3.h" |
22 | 22 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // Initialize the tracker database. | 557 // Initialize the tracker database. |
558 base::MessageLoop message_loop; | 558 base::MessageLoop message_loop; |
559 base::ScopedTempDir temp_dir; | 559 base::ScopedTempDir temp_dir; |
560 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 560 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
561 base::FilePath origin1_db_dir; | 561 base::FilePath origin1_db_dir; |
562 base::FilePath origin2_db_dir; | 562 base::FilePath origin2_db_dir; |
563 { | 563 { |
564 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy = | 564 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy = |
565 new MockSpecialStoragePolicy; | 565 new MockSpecialStoragePolicy; |
566 special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); | 566 special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); |
567 scoped_refptr<DatabaseTracker> tracker( | 567 scoped_refptr<DatabaseTracker> tracker(new DatabaseTracker( |
568 new DatabaseTracker(temp_dir.path(), | 568 temp_dir.path(), false, special_storage_policy.get(), NULL, |
569 false, | 569 base::ThreadTaskRunnerHandle::Get().get())); |
570 special_storage_policy.get(), | |
571 NULL, | |
572 base::MessageLoopProxy::current().get())); | |
573 | 570 |
574 // Open two new databases. | 571 // Open two new databases. |
575 tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, | 572 tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, |
576 &database_size); | 573 &database_size); |
577 EXPECT_EQ(0, database_size); | 574 EXPECT_EQ(0, database_size); |
578 tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0, | 575 tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0, |
579 &database_size); | 576 &database_size); |
580 EXPECT_EQ(0, database_size); | 577 EXPECT_EQ(0, database_size); |
581 | 578 |
582 // Write some data to each file. | 579 // Write some data to each file. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 // Initialize the tracker database. | 634 // Initialize the tracker database. |
638 base::MessageLoop message_loop; | 635 base::MessageLoop message_loop; |
639 base::ScopedTempDir temp_dir; | 636 base::ScopedTempDir temp_dir; |
640 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 637 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
641 base::FilePath origin1_db_dir; | 638 base::FilePath origin1_db_dir; |
642 base::FilePath origin2_db_dir; | 639 base::FilePath origin2_db_dir; |
643 { | 640 { |
644 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy = | 641 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy = |
645 new MockSpecialStoragePolicy; | 642 new MockSpecialStoragePolicy; |
646 special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); | 643 special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); |
647 scoped_refptr<DatabaseTracker> tracker( | 644 scoped_refptr<DatabaseTracker> tracker(new DatabaseTracker( |
648 new DatabaseTracker(temp_dir.path(), | 645 temp_dir.path(), false, special_storage_policy.get(), NULL, |
649 false, | 646 base::ThreadTaskRunnerHandle::Get().get())); |
650 special_storage_policy.get(), | |
651 NULL, | |
652 base::MessageLoopProxy::current().get())); | |
653 tracker->SetForceKeepSessionState(); | 647 tracker->SetForceKeepSessionState(); |
654 | 648 |
655 // Open two new databases. | 649 // Open two new databases. |
656 tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, | 650 tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, |
657 &database_size); | 651 &database_size); |
658 EXPECT_EQ(0, database_size); | 652 EXPECT_EQ(0, database_size); |
659 tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0, | 653 tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0, |
660 &database_size); | 654 &database_size); |
661 EXPECT_EQ(0, database_size); | 655 EXPECT_EQ(0, database_size); |
662 | 656 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 | 854 |
861 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { | 855 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { |
862 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); | 856 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); |
863 } | 857 } |
864 | 858 |
865 TEST(DatabaseTrackerTest, HandleSqliteError) { | 859 TEST(DatabaseTrackerTest, HandleSqliteError) { |
866 DatabaseTracker_TestHelper_Test::HandleSqliteError(); | 860 DatabaseTracker_TestHelper_Test::HandleSqliteError(); |
867 } | 861 } |
868 | 862 |
869 } // namespace content | 863 } // namespace content |
OLD | NEW |