Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / quota / quota_database_unittest.cc
blob8241c188d0b9ecbe23818cb4d617722c33b240d6
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.
5 #include <algorithm>
6 #include <iterator>
7 #include <set>
9 #include "base/bind.h"
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"
20 #include "url/gurl.h"
22 using storage::kStorageTypePersistent;
23 using storage::kStorageTypeTemporary;
24 using storage::QuotaDatabase;
26 namespace content {
27 namespace {
29 const base::Time kZeroTime;
31 const char kDBFileName[] = "quota_manager.db";
33 } // namespace
35 class QuotaDatabaseTest : public testing::Test {
36 protected:
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;
78 int64 quota = -1;
79 EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
80 EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypePersistent, &quota));
82 // Insert quota for temporary.
83 EXPECT_TRUE(db.SetHostQuota(kHost, kStorageTypeTemporary, kQuota1));
84 EXPECT_TRUE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
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, &quota));
90 EXPECT_EQ(kQuota2, quota);
92 // Quota for persistent must not be updated.
93 EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypePersistent, &quota));
95 // Delete temporary storage quota.
96 EXPECT_TRUE(db.DeleteHostQuota(kHost, kStorageTypeTemporary));
97 EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
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;
107 int64 value = 0;
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;
135 GURL origin;
136 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
137 NULL, &origin));
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)));
153 // one persistent.
154 EXPECT_TRUE(db.SetOriginLastAccessTime(
155 kOrigin4, kStorageTypePersistent, base::Time::FromInternalValue(40)));
157 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
158 NULL, &origin));
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 exceptions.insert(kOrigin1);
172 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
173 NULL, &origin));
174 EXPECT_EQ(kOrigin2.spec(), origin.spec());
176 exceptions.insert(kOrigin2);
177 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
178 NULL, &origin));
179 EXPECT_EQ(kOrigin3.spec(), origin.spec());
181 exceptions.insert(kOrigin3);
182 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
183 NULL, &origin));
184 EXPECT_TRUE(origin.is_empty());
186 EXPECT_TRUE(db.SetOriginLastAccessTime(
187 kOrigin1, kStorageTypeTemporary, base::Time::Now()));
189 // Delete origin/type last access time information.
190 EXPECT_TRUE(db.DeleteOriginInfo(kOrigin3, kStorageTypeTemporary));
192 // Querying again to see if the deletion has worked.
193 exceptions.clear();
194 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
195 NULL, &origin));
196 EXPECT_EQ(kOrigin2.spec(), origin.spec());
198 exceptions.insert(kOrigin1);
199 exceptions.insert(kOrigin2);
200 EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
201 NULL, &origin));
202 EXPECT_TRUE(origin.is_empty());
205 void OriginLastModifiedSince(const base::FilePath& kDbFile) {
206 QuotaDatabase db(kDbFile);
207 ASSERT_TRUE(db.LazyOpen(true));
209 std::set<GURL> origins;
210 EXPECT_TRUE(db.GetOriginsModifiedSince(
211 kStorageTypeTemporary, &origins, base::Time()));
212 EXPECT_TRUE(origins.empty());
214 const GURL kOrigin1("http://a/");
215 const GURL kOrigin2("http://b/");
216 const GURL kOrigin3("http://c/");
218 // Report last mod time for the test origins.
219 EXPECT_TRUE(db.SetOriginLastModifiedTime(
220 kOrigin1, kStorageTypeTemporary, base::Time::FromInternalValue(0)));
221 EXPECT_TRUE(db.SetOriginLastModifiedTime(
222 kOrigin2, kStorageTypeTemporary, base::Time::FromInternalValue(10)));
223 EXPECT_TRUE(db.SetOriginLastModifiedTime(
224 kOrigin3, kStorageTypeTemporary, base::Time::FromInternalValue(20)));
226 EXPECT_TRUE(db.GetOriginsModifiedSince(
227 kStorageTypeTemporary, &origins, base::Time()));
228 EXPECT_EQ(3U, origins.size());
229 EXPECT_EQ(1U, origins.count(kOrigin1));
230 EXPECT_EQ(1U, origins.count(kOrigin2));
231 EXPECT_EQ(1U, origins.count(kOrigin3));
233 EXPECT_TRUE(db.GetOriginsModifiedSince(
234 kStorageTypeTemporary, &origins, base::Time::FromInternalValue(5)));
235 EXPECT_EQ(2U, origins.size());
236 EXPECT_EQ(0U, origins.count(kOrigin1));
237 EXPECT_EQ(1U, origins.count(kOrigin2));
238 EXPECT_EQ(1U, origins.count(kOrigin3));
240 EXPECT_TRUE(db.GetOriginsModifiedSince(
241 kStorageTypeTemporary, &origins, base::Time::FromInternalValue(15)));
242 EXPECT_EQ(1U, origins.size());
243 EXPECT_EQ(0U, origins.count(kOrigin1));
244 EXPECT_EQ(0U, origins.count(kOrigin2));
245 EXPECT_EQ(1U, origins.count(kOrigin3));
247 EXPECT_TRUE(db.GetOriginsModifiedSince(
248 kStorageTypeTemporary, &origins, base::Time::FromInternalValue(25)));
249 EXPECT_TRUE(origins.empty());
251 // Update origin1's mod time but for persistent storage.
252 EXPECT_TRUE(db.SetOriginLastModifiedTime(
253 kOrigin1, kStorageTypePersistent, base::Time::FromInternalValue(30)));
255 // Must have no effects on temporary origins info.
256 EXPECT_TRUE(db.GetOriginsModifiedSince(
257 kStorageTypeTemporary, &origins, base::Time::FromInternalValue(5)));
258 EXPECT_EQ(2U, origins.size());
259 EXPECT_EQ(0U, origins.count(kOrigin1));
260 EXPECT_EQ(1U, origins.count(kOrigin2));
261 EXPECT_EQ(1U, origins.count(kOrigin3));
263 // One more update for persistent origin2.
264 EXPECT_TRUE(db.SetOriginLastModifiedTime(
265 kOrigin2, kStorageTypePersistent, base::Time::FromInternalValue(40)));
267 EXPECT_TRUE(db.GetOriginsModifiedSince(
268 kStorageTypePersistent, &origins, base::Time::FromInternalValue(25)));
269 EXPECT_EQ(2U, origins.size());
270 EXPECT_EQ(1U, origins.count(kOrigin1));
271 EXPECT_EQ(1U, origins.count(kOrigin2));
272 EXPECT_EQ(0U, origins.count(kOrigin3));
274 EXPECT_TRUE(db.GetOriginsModifiedSince(
275 kStorageTypePersistent, &origins, base::Time::FromInternalValue(35)));
276 EXPECT_EQ(1U, origins.size());
277 EXPECT_EQ(0U, origins.count(kOrigin1));
278 EXPECT_EQ(1U, origins.count(kOrigin2));
279 EXPECT_EQ(0U, origins.count(kOrigin3));
282 void RegisterInitialOriginInfo(const base::FilePath& kDbFile) {
283 QuotaDatabase db(kDbFile);
285 const GURL kOrigins[] = {
286 GURL("http://a/"),
287 GURL("http://b/"),
288 GURL("http://c/") };
289 std::set<GURL> origins(kOrigins, kOrigins + arraysize(kOrigins));
291 EXPECT_TRUE(db.RegisterInitialOriginInfo(origins, kStorageTypeTemporary));
293 int used_count = -1;
294 EXPECT_TRUE(db.FindOriginUsedCount(GURL("http://a/"),
295 kStorageTypeTemporary,
296 &used_count));
297 EXPECT_EQ(0, used_count);
299 EXPECT_TRUE(db.SetOriginLastAccessTime(
300 GURL("http://a/"), kStorageTypeTemporary,
301 base::Time::FromDoubleT(1.0)));
302 used_count = -1;
303 EXPECT_TRUE(db.FindOriginUsedCount(GURL("http://a/"),
304 kStorageTypeTemporary,
305 &used_count));
306 EXPECT_EQ(1, used_count);
308 EXPECT_TRUE(db.RegisterInitialOriginInfo(origins, kStorageTypeTemporary));
310 used_count = -1;
311 EXPECT_TRUE(db.FindOriginUsedCount(GURL("http://a/"),
312 kStorageTypeTemporary,
313 &used_count));
314 EXPECT_EQ(1, used_count);
317 template <typename EntryType>
318 struct EntryVerifier {
319 std::set<EntryType> table;
321 template <typename Iterator>
322 EntryVerifier(Iterator itr, Iterator end)
323 : table(itr, end) {}
325 bool Run(const EntryType& entry) {
326 EXPECT_EQ(1u, table.erase(entry));
327 return true;
331 void DumpQuotaTable(const base::FilePath& kDbFile) {
332 QuotaTableEntry kTableEntries[] = {
333 QuotaTableEntry("http://go/", kStorageTypeTemporary, 1),
334 QuotaTableEntry("http://oo/", kStorageTypeTemporary, 2),
335 QuotaTableEntry("http://gle/", kStorageTypePersistent, 3)
337 QuotaTableEntry* begin = kTableEntries;
338 QuotaTableEntry* end = kTableEntries + arraysize(kTableEntries);
340 QuotaDatabase db(kDbFile);
341 EXPECT_TRUE(db.LazyOpen(true));
342 AssignQuotaTable(db.db_.get(), begin, end);
343 db.Commit();
345 typedef EntryVerifier<QuotaTableEntry> Verifier;
346 Verifier verifier(begin, end);
347 EXPECT_TRUE(db.DumpQuotaTable(
348 base::Bind(&Verifier::Run, base::Unretained(&verifier))));
349 EXPECT_TRUE(verifier.table.empty());
352 void DumpOriginInfoTable(const base::FilePath& kDbFile) {
353 base::Time now(base::Time::Now());
354 typedef QuotaDatabase::OriginInfoTableEntry Entry;
355 Entry kTableEntries[] = {
356 Entry(GURL("http://go/"), kStorageTypeTemporary, 2147483647, now, now),
357 Entry(GURL("http://oo/"), kStorageTypeTemporary, 0, now, now),
358 Entry(GURL("http://gle/"), kStorageTypeTemporary, 1, now, now),
360 Entry* begin = kTableEntries;
361 Entry* end = kTableEntries + arraysize(kTableEntries);
363 QuotaDatabase db(kDbFile);
364 EXPECT_TRUE(db.LazyOpen(true));
365 AssignOriginInfoTable(db.db_.get(), begin, end);
366 db.Commit();
368 typedef EntryVerifier<Entry> Verifier;
369 Verifier verifier(begin, end);
370 EXPECT_TRUE(db.DumpOriginInfoTable(
371 base::Bind(&Verifier::Run, base::Unretained(&verifier))));
372 EXPECT_TRUE(verifier.table.empty());
375 private:
376 template <typename Iterator>
377 void AssignQuotaTable(sql::Connection* db, Iterator itr, Iterator end) {
378 ASSERT_NE(db, (sql::Connection*)NULL);
379 for (; itr != end; ++itr) {
380 const char* kSql =
381 "INSERT INTO HostQuotaTable"
382 " (host, type, quota)"
383 " VALUES (?, ?, ?)";
384 sql::Statement statement;
385 statement.Assign(db->GetCachedStatement(SQL_FROM_HERE, kSql));
386 ASSERT_TRUE(statement.is_valid());
388 statement.BindString(0, itr->host);
389 statement.BindInt(1, static_cast<int>(itr->type));
390 statement.BindInt64(2, itr->quota);
391 EXPECT_TRUE(statement.Run());
395 template <typename Iterator>
396 void AssignOriginInfoTable(sql::Connection* db, Iterator itr, Iterator end) {
397 ASSERT_NE(db, (sql::Connection*)NULL);
398 for (; itr != end; ++itr) {
399 const char* kSql =
400 "INSERT INTO OriginInfoTable"
401 " (origin, type, used_count, last_access_time, last_modified_time)"
402 " VALUES (?, ?, ?, ?, ?)";
403 sql::Statement statement;
404 statement.Assign(db->GetCachedStatement(SQL_FROM_HERE, kSql));
405 ASSERT_TRUE(statement.is_valid());
407 statement.BindString(0, itr->origin.spec());
408 statement.BindInt(1, static_cast<int>(itr->type));
409 statement.BindInt(2, itr->used_count);
410 statement.BindInt64(3, itr->last_access_time.ToInternalValue());
411 statement.BindInt64(4, itr->last_modified_time.ToInternalValue());
412 EXPECT_TRUE(statement.Run());
416 bool OpenDatabase(sql::Connection* db, const base::FilePath& kDbFile) {
417 if (kDbFile.empty()) {
418 return db->OpenInMemory();
420 if (!base::CreateDirectory(kDbFile.DirName()))
421 return false;
422 if (!db->Open(kDbFile))
423 return false;
424 db->Preload();
425 return true;
428 // Create V2 database and populate some data.
429 void CreateV2Database(
430 const base::FilePath& kDbFile,
431 const QuotaTableEntry* entries,
432 size_t entries_size) {
433 scoped_ptr<sql::Connection> db(new sql::Connection);
434 scoped_ptr<sql::MetaTable> meta_table(new sql::MetaTable);
436 // V2 schema definitions.
437 static const int kCurrentVersion = 2;
438 static const int kCompatibleVersion = 2;
439 static const char kHostQuotaTable[] = "HostQuotaTable";
440 static const char kOriginLastAccessTable[] = "OriginLastAccessTable";
441 static const QuotaDatabase::TableSchema kTables[] = {
442 { kHostQuotaTable,
443 "(host TEXT NOT NULL,"
444 " type INTEGER NOT NULL,"
445 " quota INTEGER,"
446 " UNIQUE(host, type))" },
447 { kOriginLastAccessTable,
448 "(origin TEXT NOT NULL,"
449 " type INTEGER NOT NULL,"
450 " used_count INTEGER,"
451 " last_access_time INTEGER,"
452 " UNIQUE(origin, type))" },
454 static const QuotaDatabase::IndexSchema kIndexes[] = {
455 { "HostIndex",
456 kHostQuotaTable,
457 "(host)",
458 false },
459 { "OriginLastAccessIndex",
460 kOriginLastAccessTable,
461 "(origin, last_access_time)",
462 false },
465 ASSERT_TRUE(OpenDatabase(db.get(), kDbFile));
466 EXPECT_TRUE(QuotaDatabase::CreateSchema(
467 db.get(), meta_table.get(),
468 kCurrentVersion, kCompatibleVersion,
469 kTables, arraysize(kTables),
470 kIndexes, arraysize(kIndexes)));
472 // V2 and V3 QuotaTable are compatible, so we can simply use
473 // AssignQuotaTable to poplulate v2 database here.
474 db->BeginTransaction();
475 AssignQuotaTable(db.get(), entries, entries + entries_size);
476 db->CommitTransaction();
479 base::MessageLoop message_loop_;
482 TEST_F(QuotaDatabaseTest, LazyOpen) {
483 base::ScopedTempDir data_dir;
484 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
485 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
486 LazyOpen(kDbFile);
487 LazyOpen(base::FilePath());
490 TEST_F(QuotaDatabaseTest, UpgradeSchema) {
491 base::ScopedTempDir data_dir;
492 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
493 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
494 UpgradeSchemaV2toV3(kDbFile);
497 TEST_F(QuotaDatabaseTest, HostQuota) {
498 base::ScopedTempDir data_dir;
499 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
500 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
501 HostQuota(kDbFile);
502 HostQuota(base::FilePath());
505 TEST_F(QuotaDatabaseTest, GlobalQuota) {
506 base::ScopedTempDir data_dir;
507 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
508 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
509 GlobalQuota(kDbFile);
510 GlobalQuota(base::FilePath());
513 TEST_F(QuotaDatabaseTest, OriginLastAccessTimeLRU) {
514 base::ScopedTempDir data_dir;
515 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
516 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
517 OriginLastAccessTimeLRU(kDbFile);
518 OriginLastAccessTimeLRU(base::FilePath());
521 TEST_F(QuotaDatabaseTest, OriginLastModifiedSince) {
522 base::ScopedTempDir data_dir;
523 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
524 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
525 OriginLastModifiedSince(kDbFile);
526 OriginLastModifiedSince(base::FilePath());
529 TEST_F(QuotaDatabaseTest, BootstrapFlag) {
530 base::ScopedTempDir data_dir;
531 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
533 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
534 QuotaDatabase db(kDbFile);
536 EXPECT_FALSE(db.IsOriginDatabaseBootstrapped());
537 EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(true));
538 EXPECT_TRUE(db.IsOriginDatabaseBootstrapped());
539 EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(false));
540 EXPECT_FALSE(db.IsOriginDatabaseBootstrapped());
543 TEST_F(QuotaDatabaseTest, RegisterInitialOriginInfo) {
544 base::ScopedTempDir data_dir;
545 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
546 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
547 RegisterInitialOriginInfo(kDbFile);
548 RegisterInitialOriginInfo(base::FilePath());
551 TEST_F(QuotaDatabaseTest, DumpQuotaTable) {
552 base::ScopedTempDir data_dir;
553 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
554 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
555 DumpQuotaTable(kDbFile);
556 DumpQuotaTable(base::FilePath());
559 TEST_F(QuotaDatabaseTest, DumpOriginInfoTable) {
560 base::ScopedTempDir data_dir;
561 ASSERT_TRUE(data_dir.CreateUniqueTempDir());
562 const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
563 DumpOriginInfoTable(kDbFile);
564 DumpOriginInfoTable(base::FilePath());
566 } // namespace content