1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
10 #include "base/callback.h"
11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h"
13 #include "base/message_loop.h"
14 #include "googleurl/src/gurl.h"
15 #include "sql/connection.h"
16 #include "sql/meta_table.h"
17 #include "sql/statement.h"
18 #include "sql/transaction.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "webkit/quota/mock_special_storage_policy.h"
21 #include "webkit/quota/quota_database.h"
26 const base::Time kZeroTime
;
28 class TestErrorDelegate
: public sql::ErrorDelegate
{
30 virtual int OnError(int error
,
31 sql::Connection
* connection
,
32 sql::Statement
* stmt
) OVERRIDE
{
37 virtual ~TestErrorDelegate() {}
42 class QuotaDatabaseTest
: public testing::Test
{
44 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry
;
45 typedef QuotaDatabase::QuotaTableCallback QuotaTableCallback
;
46 typedef QuotaDatabase::OriginInfoTableCallback
47 OriginInfoTableCallback
;
49 void LazyOpen(const base::FilePath
& kDbFile
) {
50 QuotaDatabase
db(kDbFile
);
51 EXPECT_FALSE(db
.LazyOpen(false));
52 ASSERT_TRUE(db
.LazyOpen(true));
53 EXPECT_TRUE(db
.db_
.get());
54 EXPECT_TRUE(kDbFile
.empty() || file_util::PathExists(kDbFile
));
57 void UpgradeSchemaV2toV3(const base::FilePath
& kDbFile
) {
58 const QuotaTableEntry entries
[] = {
59 QuotaTableEntry("a", kStorageTypeTemporary
, 1),
60 QuotaTableEntry("b", kStorageTypeTemporary
, 2),
61 QuotaTableEntry("c", kStorageTypePersistent
, 3),
64 CreateV2Database(kDbFile
, entries
, ARRAYSIZE_UNSAFE(entries
));
66 QuotaDatabase
db(kDbFile
);
67 EXPECT_TRUE(db
.LazyOpen(true));
68 EXPECT_TRUE(db
.db_
.get());
70 typedef EntryVerifier
<QuotaTableEntry
> Verifier
;
71 Verifier
verifier(entries
, entries
+ ARRAYSIZE_UNSAFE(entries
));
72 EXPECT_TRUE(db
.DumpQuotaTable(
73 new QuotaTableCallback(
74 base::Bind(&Verifier::Run
,
75 base::Unretained(&verifier
)))));
76 EXPECT_TRUE(verifier
.table
.empty());
79 void HostQuota(const base::FilePath
& kDbFile
) {
80 QuotaDatabase
db(kDbFile
);
81 ASSERT_TRUE(db
.LazyOpen(true));
83 const char* kHost
= "foo.com";
84 const int kQuota1
= 13579;
85 const int kQuota2
= kQuota1
+ 1024;
88 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
89 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypePersistent
, "a
));
91 // Insert quota for temporary.
92 EXPECT_TRUE(db
.SetHostQuota(kHost
, kStorageTypeTemporary
, kQuota1
));
93 EXPECT_TRUE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
94 EXPECT_EQ(kQuota1
, quota
);
96 // Update quota for temporary.
97 EXPECT_TRUE(db
.SetHostQuota(kHost
, kStorageTypeTemporary
, kQuota2
));
98 EXPECT_TRUE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
99 EXPECT_EQ(kQuota2
, quota
);
101 // Quota for persistent must not be updated.
102 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypePersistent
, "a
));
104 // Delete temporary storage quota.
105 EXPECT_TRUE(db
.DeleteHostQuota(kHost
, kStorageTypeTemporary
));
106 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
109 void GlobalQuota(const base::FilePath
& kDbFile
) {
110 QuotaDatabase
db(kDbFile
);
111 ASSERT_TRUE(db
.LazyOpen(true));
113 const char* kTempQuotaKey
= QuotaDatabase::kTemporaryQuotaOverrideKey
;
114 const char* kAvailSpaceKey
= QuotaDatabase::kDesiredAvailableSpaceKey
;
117 const int64 kValue1
= 456;
118 const int64 kValue2
= 123000;
119 EXPECT_FALSE(db
.GetQuotaConfigValue(kTempQuotaKey
, &value
));
120 EXPECT_FALSE(db
.GetQuotaConfigValue(kAvailSpaceKey
, &value
));
122 EXPECT_TRUE(db
.SetQuotaConfigValue(kTempQuotaKey
, kValue1
));
123 EXPECT_TRUE(db
.GetQuotaConfigValue(kTempQuotaKey
, &value
));
124 EXPECT_EQ(kValue1
, value
);
126 EXPECT_TRUE(db
.SetQuotaConfigValue(kTempQuotaKey
, kValue2
));
127 EXPECT_TRUE(db
.GetQuotaConfigValue(kTempQuotaKey
, &value
));
128 EXPECT_EQ(kValue2
, value
);
130 EXPECT_TRUE(db
.SetQuotaConfigValue(kAvailSpaceKey
, kValue1
));
131 EXPECT_TRUE(db
.GetQuotaConfigValue(kAvailSpaceKey
, &value
));
132 EXPECT_EQ(kValue1
, value
);
134 EXPECT_TRUE(db
.SetQuotaConfigValue(kAvailSpaceKey
, kValue2
));
135 EXPECT_TRUE(db
.GetQuotaConfigValue(kAvailSpaceKey
, &value
));
136 EXPECT_EQ(kValue2
, value
);
139 void OriginLastAccessTimeLRU(const base::FilePath
& kDbFile
) {
140 QuotaDatabase
db(kDbFile
);
141 ASSERT_TRUE(db
.LazyOpen(true));
143 std::set
<GURL
> exceptions
;
145 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
147 EXPECT_TRUE(origin
.is_empty());
149 const GURL
kOrigin1("http://a/");
150 const GURL
kOrigin2("http://b/");
151 const GURL
kOrigin3("http://c/");
152 const GURL
kOrigin4("http://p/");
154 // Adding three temporary storages, and
155 EXPECT_TRUE(db
.SetOriginLastAccessTime(
156 kOrigin1
, kStorageTypeTemporary
, base::Time::FromInternalValue(10)));
157 EXPECT_TRUE(db
.SetOriginLastAccessTime(
158 kOrigin2
, kStorageTypeTemporary
, base::Time::FromInternalValue(20)));
159 EXPECT_TRUE(db
.SetOriginLastAccessTime(
160 kOrigin3
, kStorageTypeTemporary
, base::Time::FromInternalValue(30)));
163 EXPECT_TRUE(db
.SetOriginLastAccessTime(
164 kOrigin4
, kStorageTypePersistent
, base::Time::FromInternalValue(40)));
166 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
168 EXPECT_EQ(kOrigin1
.spec(), origin
.spec());
170 // Test that unlimited origins are exluded from eviction, but
171 // protected origins are not excluded.
172 scoped_refptr
<MockSpecialStoragePolicy
> policy(
173 new MockSpecialStoragePolicy
);
174 policy
->AddUnlimited(kOrigin1
);
175 policy
->AddProtected(kOrigin2
);
176 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
178 EXPECT_EQ(kOrigin2
.spec(), origin
.spec());
180 exceptions
.insert(kOrigin1
);
181 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
183 EXPECT_EQ(kOrigin2
.spec(), origin
.spec());
185 exceptions
.insert(kOrigin2
);
186 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
188 EXPECT_EQ(kOrigin3
.spec(), origin
.spec());
190 exceptions
.insert(kOrigin3
);
191 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
193 EXPECT_TRUE(origin
.is_empty());
195 EXPECT_TRUE(db
.SetOriginLastAccessTime(
196 kOrigin1
, kStorageTypeTemporary
, base::Time::Now()));
198 // Delete origin/type last access time information.
199 EXPECT_TRUE(db
.DeleteOriginInfo(kOrigin3
, kStorageTypeTemporary
));
201 // Querying again to see if the deletion has worked.
203 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
205 EXPECT_EQ(kOrigin2
.spec(), origin
.spec());
207 exceptions
.insert(kOrigin1
);
208 exceptions
.insert(kOrigin2
);
209 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
211 EXPECT_TRUE(origin
.is_empty());
214 void OriginLastModifiedSince(const base::FilePath
& kDbFile
) {
215 QuotaDatabase
db(kDbFile
);
216 ASSERT_TRUE(db
.LazyOpen(true));
218 std::set
<GURL
> origins
;
219 EXPECT_TRUE(db
.GetOriginsModifiedSince(
220 kStorageTypeTemporary
, &origins
, base::Time()));
221 EXPECT_TRUE(origins
.empty());
223 const GURL
kOrigin1("http://a/");
224 const GURL
kOrigin2("http://b/");
225 const GURL
kOrigin3("http://c/");
227 // Report last mod time for the test origins.
228 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
229 kOrigin1
, kStorageTypeTemporary
, base::Time::FromInternalValue(0)));
230 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
231 kOrigin2
, kStorageTypeTemporary
, base::Time::FromInternalValue(10)));
232 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
233 kOrigin3
, kStorageTypeTemporary
, base::Time::FromInternalValue(20)));
235 EXPECT_TRUE(db
.GetOriginsModifiedSince(
236 kStorageTypeTemporary
, &origins
, base::Time()));
237 EXPECT_EQ(3U, origins
.size());
238 EXPECT_EQ(1U, origins
.count(kOrigin1
));
239 EXPECT_EQ(1U, origins
.count(kOrigin2
));
240 EXPECT_EQ(1U, origins
.count(kOrigin3
));
242 EXPECT_TRUE(db
.GetOriginsModifiedSince(
243 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(5)));
244 EXPECT_EQ(2U, origins
.size());
245 EXPECT_EQ(0U, origins
.count(kOrigin1
));
246 EXPECT_EQ(1U, origins
.count(kOrigin2
));
247 EXPECT_EQ(1U, origins
.count(kOrigin3
));
249 EXPECT_TRUE(db
.GetOriginsModifiedSince(
250 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(15)));
251 EXPECT_EQ(1U, origins
.size());
252 EXPECT_EQ(0U, origins
.count(kOrigin1
));
253 EXPECT_EQ(0U, origins
.count(kOrigin2
));
254 EXPECT_EQ(1U, origins
.count(kOrigin3
));
256 EXPECT_TRUE(db
.GetOriginsModifiedSince(
257 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(25)));
258 EXPECT_TRUE(origins
.empty());
260 // Update origin1's mod time but for persistent storage.
261 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
262 kOrigin1
, kStorageTypePersistent
, base::Time::FromInternalValue(30)));
264 // Must have no effects on temporary origins info.
265 EXPECT_TRUE(db
.GetOriginsModifiedSince(
266 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(5)));
267 EXPECT_EQ(2U, origins
.size());
268 EXPECT_EQ(0U, origins
.count(kOrigin1
));
269 EXPECT_EQ(1U, origins
.count(kOrigin2
));
270 EXPECT_EQ(1U, origins
.count(kOrigin3
));
272 // One more update for persistent origin2.
273 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
274 kOrigin2
, kStorageTypePersistent
, base::Time::FromInternalValue(40)));
276 EXPECT_TRUE(db
.GetOriginsModifiedSince(
277 kStorageTypePersistent
, &origins
, base::Time::FromInternalValue(25)));
278 EXPECT_EQ(2U, origins
.size());
279 EXPECT_EQ(1U, origins
.count(kOrigin1
));
280 EXPECT_EQ(1U, origins
.count(kOrigin2
));
281 EXPECT_EQ(0U, origins
.count(kOrigin3
));
283 EXPECT_TRUE(db
.GetOriginsModifiedSince(
284 kStorageTypePersistent
, &origins
, base::Time::FromInternalValue(35)));
285 EXPECT_EQ(1U, origins
.size());
286 EXPECT_EQ(0U, origins
.count(kOrigin1
));
287 EXPECT_EQ(1U, origins
.count(kOrigin2
));
288 EXPECT_EQ(0U, origins
.count(kOrigin3
));
291 void RegisterInitialOriginInfo(const base::FilePath
& kDbFile
) {
292 QuotaDatabase
db(kDbFile
);
294 const GURL kOrigins
[] = {
298 std::set
<GURL
> origins(kOrigins
, kOrigins
+ ARRAYSIZE_UNSAFE(kOrigins
));
300 EXPECT_TRUE(db
.RegisterInitialOriginInfo(origins
, kStorageTypeTemporary
));
303 EXPECT_TRUE(db
.FindOriginUsedCount(GURL("http://a/"),
304 kStorageTypeTemporary
,
306 EXPECT_EQ(0, used_count
);
308 EXPECT_TRUE(db
.SetOriginLastAccessTime(
309 GURL("http://a/"), kStorageTypeTemporary
,
310 base::Time::FromDoubleT(1.0)));
312 EXPECT_TRUE(db
.FindOriginUsedCount(GURL("http://a/"),
313 kStorageTypeTemporary
,
315 EXPECT_EQ(1, used_count
);
317 EXPECT_TRUE(db
.RegisterInitialOriginInfo(origins
, kStorageTypeTemporary
));
320 EXPECT_TRUE(db
.FindOriginUsedCount(GURL("http://a/"),
321 kStorageTypeTemporary
,
323 EXPECT_EQ(1, used_count
);
326 template <typename EntryType
>
327 struct EntryVerifier
{
328 std::set
<EntryType
> table
;
330 template <typename Iterator
>
331 EntryVerifier(Iterator itr
, Iterator end
)
334 bool Run(const EntryType
& entry
) {
335 EXPECT_EQ(1u, table
.erase(entry
));
340 void DumpQuotaTable(const base::FilePath
& kDbFile
) {
341 QuotaTableEntry kTableEntries
[] = {
342 QuotaTableEntry("http://go/", kStorageTypeTemporary
, 1),
343 QuotaTableEntry("http://oo/", kStorageTypeTemporary
, 2),
344 QuotaTableEntry("http://gle/", kStorageTypePersistent
, 3)
346 QuotaTableEntry
* begin
= kTableEntries
;
347 QuotaTableEntry
* end
= kTableEntries
+ ARRAYSIZE_UNSAFE(kTableEntries
);
349 QuotaDatabase
db(kDbFile
);
350 EXPECT_TRUE(db
.LazyOpen(true));
351 AssignQuotaTable(db
.db_
.get(), begin
, end
);
354 typedef EntryVerifier
<QuotaTableEntry
> Verifier
;
355 Verifier
verifier(begin
, end
);
356 EXPECT_TRUE(db
.DumpQuotaTable(
357 new QuotaTableCallback(
358 base::Bind(&Verifier::Run
,
359 base::Unretained(&verifier
)))));
360 EXPECT_TRUE(verifier
.table
.empty());
363 void DumpOriginInfoTable(const base::FilePath
& kDbFile
) {
364 base::Time
now(base::Time::Now());
365 typedef QuotaDatabase::OriginInfoTableEntry Entry
;
366 Entry kTableEntries
[] = {
367 Entry(GURL("http://go/"), kStorageTypeTemporary
, 2147483647, now
, now
),
368 Entry(GURL("http://oo/"), kStorageTypeTemporary
, 0, now
, now
),
369 Entry(GURL("http://gle/"), kStorageTypeTemporary
, 1, now
, now
),
371 Entry
* begin
= kTableEntries
;
372 Entry
* end
= kTableEntries
+ ARRAYSIZE_UNSAFE(kTableEntries
);
374 QuotaDatabase
db(kDbFile
);
375 EXPECT_TRUE(db
.LazyOpen(true));
376 AssignOriginInfoTable(db
.db_
.get(), begin
, end
);
379 typedef EntryVerifier
<Entry
> Verifier
;
380 Verifier
verifier(begin
, end
);
381 EXPECT_TRUE(db
.DumpOriginInfoTable(
382 new OriginInfoTableCallback(
383 base::Bind(&Verifier::Run
,
384 base::Unretained(&verifier
)))));
385 EXPECT_TRUE(verifier
.table
.empty());
389 template <typename Iterator
>
390 void AssignQuotaTable(sql::Connection
* db
, Iterator itr
, Iterator end
) {
391 ASSERT_NE(db
, (sql::Connection
*)NULL
);
392 for (; itr
!= end
; ++itr
) {
394 "INSERT INTO HostQuotaTable"
395 " (host, type, quota)"
397 sql::Statement statement
;
398 statement
.Assign(db
->GetCachedStatement(SQL_FROM_HERE
, kSql
));
399 ASSERT_TRUE(statement
.is_valid());
401 statement
.BindString(0, itr
->host
);
402 statement
.BindInt(1, static_cast<int>(itr
->type
));
403 statement
.BindInt64(2, itr
->quota
);
404 EXPECT_TRUE(statement
.Run());
408 template <typename Iterator
>
409 void AssignOriginInfoTable(sql::Connection
* db
, Iterator itr
, Iterator end
) {
410 ASSERT_NE(db
, (sql::Connection
*)NULL
);
411 for (; itr
!= end
; ++itr
) {
413 "INSERT INTO OriginInfoTable"
414 " (origin, type, used_count, last_access_time, last_modified_time)"
415 " VALUES (?, ?, ?, ?, ?)";
416 sql::Statement statement
;
417 statement
.Assign(db
->GetCachedStatement(SQL_FROM_HERE
, kSql
));
418 ASSERT_TRUE(statement
.is_valid());
420 statement
.BindString(0, itr
->origin
.spec());
421 statement
.BindInt(1, static_cast<int>(itr
->type
));
422 statement
.BindInt(2, itr
->used_count
);
423 statement
.BindInt64(3, itr
->last_access_time
.ToInternalValue());
424 statement
.BindInt64(4, itr
->last_modified_time
.ToInternalValue());
425 EXPECT_TRUE(statement
.Run());
429 bool OpenDatabase(sql::Connection
* db
, const base::FilePath
& kDbFile
) {
430 if (kDbFile
.empty()) {
431 return db
->OpenInMemory();
433 if (!file_util::CreateDirectory(kDbFile
.DirName()))
435 if (!db
->Open(kDbFile
))
441 // Create V2 database and populate some data.
442 void CreateV2Database(
443 const base::FilePath
& kDbFile
,
444 const QuotaTableEntry
* entries
,
445 size_t entries_size
) {
446 scoped_ptr
<sql::Connection
> db(new sql::Connection
);
447 scoped_ptr
<sql::MetaTable
> meta_table(new sql::MetaTable
);
449 // V2 schema definitions.
450 static const int kCurrentVersion
= 2;
451 static const int kCompatibleVersion
= 2;
452 static const char kHostQuotaTable
[] = "HostQuotaTable";
453 static const char kOriginLastAccessTable
[] = "OriginLastAccessTable";
454 static const QuotaDatabase::TableSchema kTables
[] = {
456 "(host TEXT NOT NULL,"
457 " type INTEGER NOT NULL,"
459 " UNIQUE(host, type))" },
460 { kOriginLastAccessTable
,
461 "(origin TEXT NOT NULL,"
462 " type INTEGER NOT NULL,"
463 " used_count INTEGER,"
464 " last_access_time INTEGER,"
465 " UNIQUE(origin, type))" },
467 static const QuotaDatabase::IndexSchema kIndexes
[] = {
472 { "OriginLastAccessIndex",
473 kOriginLastAccessTable
,
474 "(origin, last_access_time)",
478 ASSERT_TRUE(OpenDatabase(db
.get(), kDbFile
));
479 EXPECT_TRUE(QuotaDatabase::CreateSchema(
480 db
.get(), meta_table
.get(),
481 kCurrentVersion
, kCompatibleVersion
,
482 kTables
, ARRAYSIZE_UNSAFE(kTables
),
483 kIndexes
, ARRAYSIZE_UNSAFE(kIndexes
)));
485 // V2 and V3 QuotaTable are compatible, so we can simply use
486 // AssignQuotaTable to poplulate v2 database here.
487 db
->BeginTransaction();
488 AssignQuotaTable(db
.get(), entries
, entries
+ entries_size
);
489 db
->CommitTransaction();
492 MessageLoop message_loop_
;
495 TEST_F(QuotaDatabaseTest
, LazyOpen
) {
496 base::ScopedTempDir data_dir
;
497 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
498 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
500 LazyOpen(base::FilePath());
503 TEST_F(QuotaDatabaseTest
, UpgradeSchema
) {
504 base::ScopedTempDir data_dir
;
505 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
506 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
507 UpgradeSchemaV2toV3(kDbFile
);
510 TEST_F(QuotaDatabaseTest
, HostQuota
) {
511 base::ScopedTempDir data_dir
;
512 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
513 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
515 HostQuota(base::FilePath());
518 TEST_F(QuotaDatabaseTest
, GlobalQuota
) {
519 base::ScopedTempDir data_dir
;
520 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
521 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
522 GlobalQuota(kDbFile
);
523 GlobalQuota(base::FilePath());
526 TEST_F(QuotaDatabaseTest
, OriginLastAccessTimeLRU
) {
527 base::ScopedTempDir data_dir
;
528 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
529 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
530 OriginLastAccessTimeLRU(kDbFile
);
531 OriginLastAccessTimeLRU(base::FilePath());
534 TEST_F(QuotaDatabaseTest
, OriginLastModifiedSince
) {
535 base::ScopedTempDir data_dir
;
536 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
537 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
538 OriginLastModifiedSince(kDbFile
);
539 OriginLastModifiedSince(base::FilePath());
542 TEST_F(QuotaDatabaseTest
, BootstrapFlag
) {
543 base::ScopedTempDir data_dir
;
544 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
546 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
547 QuotaDatabase
db(kDbFile
);
549 EXPECT_FALSE(db
.IsOriginDatabaseBootstrapped());
550 EXPECT_TRUE(db
.SetOriginDatabaseBootstrapped(true));
551 EXPECT_TRUE(db
.IsOriginDatabaseBootstrapped());
552 EXPECT_TRUE(db
.SetOriginDatabaseBootstrapped(false));
553 EXPECT_FALSE(db
.IsOriginDatabaseBootstrapped());
556 TEST_F(QuotaDatabaseTest
, RegisterInitialOriginInfo
) {
557 base::ScopedTempDir data_dir
;
558 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
559 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
560 RegisterInitialOriginInfo(kDbFile
);
561 RegisterInitialOriginInfo(base::FilePath());
564 TEST_F(QuotaDatabaseTest
, DumpQuotaTable
) {
565 base::ScopedTempDir data_dir
;
566 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
567 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
568 DumpQuotaTable(kDbFile
);
569 DumpQuotaTable(base::FilePath());
572 TEST_F(QuotaDatabaseTest
, DumpOriginInfoTable
) {
573 base::ScopedTempDir data_dir
;
574 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
575 const base::FilePath kDbFile
= data_dir
.path().AppendASCII("quota_manager.db");
576 DumpOriginInfoTable(kDbFile
);
577 DumpOriginInfoTable(base::FilePath());