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
3 // found in the LICENSE file.
10 #include "base/callback.h"
11 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h"
13 #include "base/message_loop/message_loop.h"
14 #include "content/public/test/mock_special_storage_policy.h"
15 #include "sql/connection.h"
16 #include "sql/meta_table.h"
17 #include "sql/statement.h"
18 #include "storage/browser/quota/quota_database.h"
19 #include "testing/gtest/include/gtest/gtest.h"
22 using storage::kStorageTypePersistent
;
23 using storage::kStorageTypeTemporary
;
24 using storage::QuotaDatabase
;
29 const base::Time kZeroTime
;
31 const char kDBFileName
[] = "quota_manager.db";
35 class QuotaDatabaseTest
: public testing::Test
{
37 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry
;
38 typedef QuotaDatabase::QuotaTableCallback QuotaTableCallback
;
39 typedef QuotaDatabase::OriginInfoTableCallback
40 OriginInfoTableCallback
;
42 void LazyOpen(const base::FilePath
& kDbFile
) {
43 QuotaDatabase
db(kDbFile
);
44 EXPECT_FALSE(db
.LazyOpen(false));
45 ASSERT_TRUE(db
.LazyOpen(true));
46 EXPECT_TRUE(db
.db_
.get());
47 EXPECT_TRUE(kDbFile
.empty() || base::PathExists(kDbFile
));
50 void UpgradeSchemaV2toV3(const base::FilePath
& kDbFile
) {
51 const QuotaTableEntry entries
[] = {
52 QuotaTableEntry("a", kStorageTypeTemporary
, 1),
53 QuotaTableEntry("b", kStorageTypeTemporary
, 2),
54 QuotaTableEntry("c", kStorageTypePersistent
, 3),
57 CreateV2Database(kDbFile
, entries
, arraysize(entries
));
59 QuotaDatabase
db(kDbFile
);
60 EXPECT_TRUE(db
.LazyOpen(true));
61 EXPECT_TRUE(db
.db_
.get());
63 typedef EntryVerifier
<QuotaTableEntry
> Verifier
;
64 Verifier
verifier(entries
, entries
+ arraysize(entries
));
65 EXPECT_TRUE(db
.DumpQuotaTable(
66 base::Bind(&Verifier::Run
, base::Unretained(&verifier
))));
67 EXPECT_TRUE(verifier
.table
.empty());
70 void HostQuota(const base::FilePath
& kDbFile
) {
71 QuotaDatabase
db(kDbFile
);
72 ASSERT_TRUE(db
.LazyOpen(true));
74 const char* kHost
= "foo.com";
75 const int kQuota1
= 13579;
76 const int kQuota2
= kQuota1
+ 1024;
79 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
80 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypePersistent
, "a
));
82 // Insert quota for temporary.
83 EXPECT_TRUE(db
.SetHostQuota(kHost
, kStorageTypeTemporary
, kQuota1
));
84 EXPECT_TRUE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
85 EXPECT_EQ(kQuota1
, quota
);
87 // Update quota for temporary.
88 EXPECT_TRUE(db
.SetHostQuota(kHost
, kStorageTypeTemporary
, kQuota2
));
89 EXPECT_TRUE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
90 EXPECT_EQ(kQuota2
, quota
);
92 // Quota for persistent must not be updated.
93 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypePersistent
, "a
));
95 // Delete temporary storage quota.
96 EXPECT_TRUE(db
.DeleteHostQuota(kHost
, kStorageTypeTemporary
));
97 EXPECT_FALSE(db
.GetHostQuota(kHost
, kStorageTypeTemporary
, "a
));
100 void GlobalQuota(const base::FilePath
& kDbFile
) {
101 QuotaDatabase
db(kDbFile
);
102 ASSERT_TRUE(db
.LazyOpen(true));
104 const char* kTempQuotaKey
= QuotaDatabase::kTemporaryQuotaOverrideKey
;
105 const char* kAvailSpaceKey
= QuotaDatabase::kDesiredAvailableSpaceKey
;
108 const int64 kValue1
= 456;
109 const int64 kValue2
= 123000;
110 EXPECT_FALSE(db
.GetQuotaConfigValue(kTempQuotaKey
, &value
));
111 EXPECT_FALSE(db
.GetQuotaConfigValue(kAvailSpaceKey
, &value
));
113 EXPECT_TRUE(db
.SetQuotaConfigValue(kTempQuotaKey
, kValue1
));
114 EXPECT_TRUE(db
.GetQuotaConfigValue(kTempQuotaKey
, &value
));
115 EXPECT_EQ(kValue1
, value
);
117 EXPECT_TRUE(db
.SetQuotaConfigValue(kTempQuotaKey
, kValue2
));
118 EXPECT_TRUE(db
.GetQuotaConfigValue(kTempQuotaKey
, &value
));
119 EXPECT_EQ(kValue2
, value
);
121 EXPECT_TRUE(db
.SetQuotaConfigValue(kAvailSpaceKey
, kValue1
));
122 EXPECT_TRUE(db
.GetQuotaConfigValue(kAvailSpaceKey
, &value
));
123 EXPECT_EQ(kValue1
, value
);
125 EXPECT_TRUE(db
.SetQuotaConfigValue(kAvailSpaceKey
, kValue2
));
126 EXPECT_TRUE(db
.GetQuotaConfigValue(kAvailSpaceKey
, &value
));
127 EXPECT_EQ(kValue2
, value
);
130 void OriginLastAccessTimeLRU(const base::FilePath
& kDbFile
) {
131 QuotaDatabase
db(kDbFile
);
132 ASSERT_TRUE(db
.LazyOpen(true));
134 std::set
<GURL
> exceptions
;
136 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
138 EXPECT_TRUE(origin
.is_empty());
140 const GURL
kOrigin1("http://a/");
141 const GURL
kOrigin2("http://b/");
142 const GURL
kOrigin3("http://c/");
143 const GURL
kOrigin4("http://p/");
145 // Adding three temporary storages, and
146 EXPECT_TRUE(db
.SetOriginLastAccessTime(
147 kOrigin1
, kStorageTypeTemporary
, base::Time::FromInternalValue(10)));
148 EXPECT_TRUE(db
.SetOriginLastAccessTime(
149 kOrigin2
, kStorageTypeTemporary
, base::Time::FromInternalValue(20)));
150 EXPECT_TRUE(db
.SetOriginLastAccessTime(
151 kOrigin3
, kStorageTypeTemporary
, base::Time::FromInternalValue(30)));
154 EXPECT_TRUE(db
.SetOriginLastAccessTime(
155 kOrigin4
, kStorageTypePersistent
, base::Time::FromInternalValue(40)));
157 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
159 EXPECT_EQ(kOrigin1
.spec(), origin
.spec());
161 // Test that unlimited origins are exluded from eviction, but
162 // protected origins are not excluded.
163 scoped_refptr
<MockSpecialStoragePolicy
> policy(
164 new MockSpecialStoragePolicy
);
165 policy
->AddUnlimited(kOrigin1
);
166 policy
->AddProtected(kOrigin2
);
167 EXPECT_TRUE(db
.GetLRUOrigin(
168 kStorageTypeTemporary
, exceptions
, policy
.get(), &origin
));
169 EXPECT_EQ(kOrigin2
.spec(), origin
.spec());
171 // Test that durable origins are excluded from eviction.
172 policy
->AddDurable(kOrigin2
);
173 EXPECT_TRUE(db
.GetLRUOrigin(
174 kStorageTypeTemporary
, exceptions
, policy
.get(), &origin
));
175 EXPECT_EQ(kOrigin3
.spec(), origin
.spec());
177 exceptions
.insert(kOrigin1
);
178 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
180 EXPECT_EQ(kOrigin2
.spec(), origin
.spec());
182 exceptions
.insert(kOrigin2
);
183 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
185 EXPECT_EQ(kOrigin3
.spec(), origin
.spec());
187 exceptions
.insert(kOrigin3
);
188 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
190 EXPECT_TRUE(origin
.is_empty());
192 EXPECT_TRUE(db
.SetOriginLastAccessTime(
193 kOrigin1
, kStorageTypeTemporary
, base::Time::Now()));
195 // Delete origin/type last access time information.
196 EXPECT_TRUE(db
.DeleteOriginInfo(kOrigin3
, kStorageTypeTemporary
));
198 // Querying again to see if the deletion has worked.
200 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
202 EXPECT_EQ(kOrigin2
.spec(), origin
.spec());
204 exceptions
.insert(kOrigin1
);
205 exceptions
.insert(kOrigin2
);
206 EXPECT_TRUE(db
.GetLRUOrigin(kStorageTypeTemporary
, exceptions
,
208 EXPECT_TRUE(origin
.is_empty());
211 void OriginLastModifiedSince(const base::FilePath
& kDbFile
) {
212 QuotaDatabase
db(kDbFile
);
213 ASSERT_TRUE(db
.LazyOpen(true));
215 std::set
<GURL
> origins
;
216 EXPECT_TRUE(db
.GetOriginsModifiedSince(
217 kStorageTypeTemporary
, &origins
, base::Time()));
218 EXPECT_TRUE(origins
.empty());
220 const GURL
kOrigin1("http://a/");
221 const GURL
kOrigin2("http://b/");
222 const GURL
kOrigin3("http://c/");
224 // Report last mod time for the test origins.
225 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
226 kOrigin1
, kStorageTypeTemporary
, base::Time::FromInternalValue(0)));
227 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
228 kOrigin2
, kStorageTypeTemporary
, base::Time::FromInternalValue(10)));
229 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
230 kOrigin3
, kStorageTypeTemporary
, base::Time::FromInternalValue(20)));
232 EXPECT_TRUE(db
.GetOriginsModifiedSince(
233 kStorageTypeTemporary
, &origins
, base::Time()));
234 EXPECT_EQ(3U, origins
.size());
235 EXPECT_EQ(1U, origins
.count(kOrigin1
));
236 EXPECT_EQ(1U, origins
.count(kOrigin2
));
237 EXPECT_EQ(1U, origins
.count(kOrigin3
));
239 EXPECT_TRUE(db
.GetOriginsModifiedSince(
240 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(5)));
241 EXPECT_EQ(2U, origins
.size());
242 EXPECT_EQ(0U, origins
.count(kOrigin1
));
243 EXPECT_EQ(1U, origins
.count(kOrigin2
));
244 EXPECT_EQ(1U, origins
.count(kOrigin3
));
246 EXPECT_TRUE(db
.GetOriginsModifiedSince(
247 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(15)));
248 EXPECT_EQ(1U, origins
.size());
249 EXPECT_EQ(0U, origins
.count(kOrigin1
));
250 EXPECT_EQ(0U, origins
.count(kOrigin2
));
251 EXPECT_EQ(1U, origins
.count(kOrigin3
));
253 EXPECT_TRUE(db
.GetOriginsModifiedSince(
254 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(25)));
255 EXPECT_TRUE(origins
.empty());
257 // Update origin1's mod time but for persistent storage.
258 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
259 kOrigin1
, kStorageTypePersistent
, base::Time::FromInternalValue(30)));
261 // Must have no effects on temporary origins info.
262 EXPECT_TRUE(db
.GetOriginsModifiedSince(
263 kStorageTypeTemporary
, &origins
, base::Time::FromInternalValue(5)));
264 EXPECT_EQ(2U, origins
.size());
265 EXPECT_EQ(0U, origins
.count(kOrigin1
));
266 EXPECT_EQ(1U, origins
.count(kOrigin2
));
267 EXPECT_EQ(1U, origins
.count(kOrigin3
));
269 // One more update for persistent origin2.
270 EXPECT_TRUE(db
.SetOriginLastModifiedTime(
271 kOrigin2
, kStorageTypePersistent
, base::Time::FromInternalValue(40)));
273 EXPECT_TRUE(db
.GetOriginsModifiedSince(
274 kStorageTypePersistent
, &origins
, base::Time::FromInternalValue(25)));
275 EXPECT_EQ(2U, origins
.size());
276 EXPECT_EQ(1U, origins
.count(kOrigin1
));
277 EXPECT_EQ(1U, origins
.count(kOrigin2
));
278 EXPECT_EQ(0U, origins
.count(kOrigin3
));
280 EXPECT_TRUE(db
.GetOriginsModifiedSince(
281 kStorageTypePersistent
, &origins
, base::Time::FromInternalValue(35)));
282 EXPECT_EQ(1U, origins
.size());
283 EXPECT_EQ(0U, origins
.count(kOrigin1
));
284 EXPECT_EQ(1U, origins
.count(kOrigin2
));
285 EXPECT_EQ(0U, origins
.count(kOrigin3
));
288 void RegisterInitialOriginInfo(const base::FilePath
& kDbFile
) {
289 QuotaDatabase
db(kDbFile
);
291 const GURL kOrigins
[] = {
295 std::set
<GURL
> origins(kOrigins
, kOrigins
+ arraysize(kOrigins
));
297 EXPECT_TRUE(db
.RegisterInitialOriginInfo(origins
, kStorageTypeTemporary
));
300 EXPECT_TRUE(db
.FindOriginUsedCount(GURL("http://a/"),
301 kStorageTypeTemporary
,
303 EXPECT_EQ(0, used_count
);
305 EXPECT_TRUE(db
.SetOriginLastAccessTime(
306 GURL("http://a/"), kStorageTypeTemporary
,
307 base::Time::FromDoubleT(1.0)));
309 EXPECT_TRUE(db
.FindOriginUsedCount(GURL("http://a/"),
310 kStorageTypeTemporary
,
312 EXPECT_EQ(1, used_count
);
314 EXPECT_TRUE(db
.RegisterInitialOriginInfo(origins
, kStorageTypeTemporary
));
317 EXPECT_TRUE(db
.FindOriginUsedCount(GURL("http://a/"),
318 kStorageTypeTemporary
,
320 EXPECT_EQ(1, used_count
);
323 template <typename EntryType
>
324 struct EntryVerifier
{
325 std::set
<EntryType
> table
;
327 template <typename Iterator
>
328 EntryVerifier(Iterator itr
, Iterator end
)
331 bool Run(const EntryType
& entry
) {
332 EXPECT_EQ(1u, table
.erase(entry
));
337 void DumpQuotaTable(const base::FilePath
& kDbFile
) {
338 QuotaTableEntry kTableEntries
[] = {
339 QuotaTableEntry("http://go/", kStorageTypeTemporary
, 1),
340 QuotaTableEntry("http://oo/", kStorageTypeTemporary
, 2),
341 QuotaTableEntry("http://gle/", kStorageTypePersistent
, 3)
343 QuotaTableEntry
* begin
= kTableEntries
;
344 QuotaTableEntry
* end
= kTableEntries
+ arraysize(kTableEntries
);
346 QuotaDatabase
db(kDbFile
);
347 EXPECT_TRUE(db
.LazyOpen(true));
348 AssignQuotaTable(db
.db_
.get(), begin
, end
);
351 typedef EntryVerifier
<QuotaTableEntry
> Verifier
;
352 Verifier
verifier(begin
, end
);
353 EXPECT_TRUE(db
.DumpQuotaTable(
354 base::Bind(&Verifier::Run
, base::Unretained(&verifier
))));
355 EXPECT_TRUE(verifier
.table
.empty());
358 void DumpOriginInfoTable(const base::FilePath
& kDbFile
) {
359 base::Time
now(base::Time::Now());
360 typedef QuotaDatabase::OriginInfoTableEntry Entry
;
361 Entry kTableEntries
[] = {
362 Entry(GURL("http://go/"), kStorageTypeTemporary
, 2147483647, now
, now
),
363 Entry(GURL("http://oo/"), kStorageTypeTemporary
, 0, now
, now
),
364 Entry(GURL("http://gle/"), kStorageTypeTemporary
, 1, now
, now
),
366 Entry
* begin
= kTableEntries
;
367 Entry
* end
= kTableEntries
+ arraysize(kTableEntries
);
369 QuotaDatabase
db(kDbFile
);
370 EXPECT_TRUE(db
.LazyOpen(true));
371 AssignOriginInfoTable(db
.db_
.get(), begin
, end
);
374 typedef EntryVerifier
<Entry
> Verifier
;
375 Verifier
verifier(begin
, end
);
376 EXPECT_TRUE(db
.DumpOriginInfoTable(
377 base::Bind(&Verifier::Run
, base::Unretained(&verifier
))));
378 EXPECT_TRUE(verifier
.table
.empty());
382 template <typename Iterator
>
383 void AssignQuotaTable(sql::Connection
* db
, Iterator itr
, Iterator end
) {
384 ASSERT_NE(db
, (sql::Connection
*)NULL
);
385 for (; itr
!= end
; ++itr
) {
387 "INSERT INTO HostQuotaTable"
388 " (host, type, quota)"
390 sql::Statement statement
;
391 statement
.Assign(db
->GetCachedStatement(SQL_FROM_HERE
, kSql
));
392 ASSERT_TRUE(statement
.is_valid());
394 statement
.BindString(0, itr
->host
);
395 statement
.BindInt(1, static_cast<int>(itr
->type
));
396 statement
.BindInt64(2, itr
->quota
);
397 EXPECT_TRUE(statement
.Run());
401 template <typename Iterator
>
402 void AssignOriginInfoTable(sql::Connection
* db
, Iterator itr
, Iterator end
) {
403 ASSERT_NE(db
, (sql::Connection
*)NULL
);
404 for (; itr
!= end
; ++itr
) {
406 "INSERT INTO OriginInfoTable"
407 " (origin, type, used_count, last_access_time, last_modified_time)"
408 " VALUES (?, ?, ?, ?, ?)";
409 sql::Statement statement
;
410 statement
.Assign(db
->GetCachedStatement(SQL_FROM_HERE
, kSql
));
411 ASSERT_TRUE(statement
.is_valid());
413 statement
.BindString(0, itr
->origin
.spec());
414 statement
.BindInt(1, static_cast<int>(itr
->type
));
415 statement
.BindInt(2, itr
->used_count
);
416 statement
.BindInt64(3, itr
->last_access_time
.ToInternalValue());
417 statement
.BindInt64(4, itr
->last_modified_time
.ToInternalValue());
418 EXPECT_TRUE(statement
.Run());
422 bool OpenDatabase(sql::Connection
* db
, const base::FilePath
& kDbFile
) {
423 if (kDbFile
.empty()) {
424 return db
->OpenInMemory();
426 if (!base::CreateDirectory(kDbFile
.DirName()))
428 if (!db
->Open(kDbFile
))
434 // Create V2 database and populate some data.
435 void CreateV2Database(
436 const base::FilePath
& kDbFile
,
437 const QuotaTableEntry
* entries
,
438 size_t entries_size
) {
439 scoped_ptr
<sql::Connection
> db(new sql::Connection
);
440 scoped_ptr
<sql::MetaTable
> meta_table(new sql::MetaTable
);
442 // V2 schema definitions.
443 static const int kCurrentVersion
= 2;
444 static const int kCompatibleVersion
= 2;
445 static const char kHostQuotaTable
[] = "HostQuotaTable";
446 static const char kOriginLastAccessTable
[] = "OriginLastAccessTable";
447 static const QuotaDatabase::TableSchema kTables
[] = {
449 "(host TEXT NOT NULL,"
450 " type INTEGER NOT NULL,"
452 " UNIQUE(host, type))" },
453 { kOriginLastAccessTable
,
454 "(origin TEXT NOT NULL,"
455 " type INTEGER NOT NULL,"
456 " used_count INTEGER,"
457 " last_access_time INTEGER,"
458 " UNIQUE(origin, type))" },
460 static const QuotaDatabase::IndexSchema kIndexes
[] = {
465 { "OriginLastAccessIndex",
466 kOriginLastAccessTable
,
467 "(origin, last_access_time)",
471 ASSERT_TRUE(OpenDatabase(db
.get(), kDbFile
));
472 EXPECT_TRUE(QuotaDatabase::CreateSchema(
473 db
.get(), meta_table
.get(),
474 kCurrentVersion
, kCompatibleVersion
,
475 kTables
, arraysize(kTables
),
476 kIndexes
, arraysize(kIndexes
)));
478 // V2 and V3 QuotaTable are compatible, so we can simply use
479 // AssignQuotaTable to poplulate v2 database here.
480 db
->BeginTransaction();
481 AssignQuotaTable(db
.get(), entries
, entries
+ entries_size
);
482 db
->CommitTransaction();
485 base::MessageLoop message_loop_
;
488 TEST_F(QuotaDatabaseTest
, LazyOpen
) {
489 base::ScopedTempDir data_dir
;
490 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
491 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
493 LazyOpen(base::FilePath());
496 TEST_F(QuotaDatabaseTest
, UpgradeSchema
) {
497 base::ScopedTempDir data_dir
;
498 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
499 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
500 UpgradeSchemaV2toV3(kDbFile
);
503 TEST_F(QuotaDatabaseTest
, HostQuota
) {
504 base::ScopedTempDir data_dir
;
505 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
506 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
508 HostQuota(base::FilePath());
511 TEST_F(QuotaDatabaseTest
, GlobalQuota
) {
512 base::ScopedTempDir data_dir
;
513 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
514 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
515 GlobalQuota(kDbFile
);
516 GlobalQuota(base::FilePath());
519 TEST_F(QuotaDatabaseTest
, OriginLastAccessTimeLRU
) {
520 base::ScopedTempDir data_dir
;
521 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
522 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
523 OriginLastAccessTimeLRU(kDbFile
);
524 OriginLastAccessTimeLRU(base::FilePath());
527 TEST_F(QuotaDatabaseTest
, OriginLastModifiedSince
) {
528 base::ScopedTempDir data_dir
;
529 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
530 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
531 OriginLastModifiedSince(kDbFile
);
532 OriginLastModifiedSince(base::FilePath());
535 TEST_F(QuotaDatabaseTest
, BootstrapFlag
) {
536 base::ScopedTempDir data_dir
;
537 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
539 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
540 QuotaDatabase
db(kDbFile
);
542 EXPECT_FALSE(db
.IsOriginDatabaseBootstrapped());
543 EXPECT_TRUE(db
.SetOriginDatabaseBootstrapped(true));
544 EXPECT_TRUE(db
.IsOriginDatabaseBootstrapped());
545 EXPECT_TRUE(db
.SetOriginDatabaseBootstrapped(false));
546 EXPECT_FALSE(db
.IsOriginDatabaseBootstrapped());
549 TEST_F(QuotaDatabaseTest
, RegisterInitialOriginInfo
) {
550 base::ScopedTempDir data_dir
;
551 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
552 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
553 RegisterInitialOriginInfo(kDbFile
);
554 RegisterInitialOriginInfo(base::FilePath());
557 TEST_F(QuotaDatabaseTest
, DumpQuotaTable
) {
558 base::ScopedTempDir data_dir
;
559 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
560 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
561 DumpQuotaTable(kDbFile
);
562 DumpQuotaTable(base::FilePath());
565 TEST_F(QuotaDatabaseTest
, DumpOriginInfoTable
) {
566 base::ScopedTempDir data_dir
;
567 ASSERT_TRUE(data_dir
.CreateUniqueTempDir());
568 const base::FilePath kDbFile
= data_dir
.path().AppendASCII(kDBFileName
);
569 DumpOriginInfoTable(kDbFile
);
570 DumpOriginInfoTable(base::FilePath());
572 } // namespace content