Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: webkit/dom_storage/dom_storage_area_unittest.cc

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/dom_storage/dom_storage_area.cc ('k') | webkit/dom_storage/dom_storage_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 EXPECT_TRUE(area->GetItem(kKey).is_null()); 119 EXPECT_TRUE(area->GetItem(kKey).is_null());
120 EXPECT_FALSE(area->SetItem(kKey, kValue, &old_nullable_value)); 120 EXPECT_FALSE(area->SetItem(kKey, kValue, &old_nullable_value));
121 EXPECT_FALSE(area->RemoveItem(kKey, &old_value)); 121 EXPECT_FALSE(area->RemoveItem(kKey, &old_value));
122 EXPECT_FALSE(area->Clear()); 122 EXPECT_FALSE(area->Clear());
123 } 123 }
124 124
125 TEST_F(DomStorageAreaTest, BackingDatabaseOpened) { 125 TEST_F(DomStorageAreaTest, BackingDatabaseOpened) {
126 const int64 kSessionStorageNamespaceId = kLocalStorageNamespaceId + 1; 126 const int64 kSessionStorageNamespaceId = kLocalStorageNamespaceId + 1;
127 base::ScopedTempDir temp_dir; 127 base::ScopedTempDir temp_dir;
128 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 128 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
129 const FilePath kExpectedOriginFilePath = temp_dir.path().Append( 129 const base::FilePath kExpectedOriginFilePath = temp_dir.path().Append(
130 DomStorageArea::DatabaseFileNameFromOrigin(kOrigin)); 130 DomStorageArea::DatabaseFileNameFromOrigin(kOrigin));
131 131
132 // No directory, backing should be null. 132 // No directory, backing should be null.
133 { 133 {
134 scoped_refptr<DomStorageArea> area( 134 scoped_refptr<DomStorageArea> area(
135 new DomStorageArea(kOrigin, FilePath(), NULL)); 135 new DomStorageArea(kOrigin, base::FilePath(), NULL));
136 EXPECT_EQ(NULL, area->backing_.get()); 136 EXPECT_EQ(NULL, area->backing_.get());
137 EXPECT_TRUE(area->is_initial_import_done_); 137 EXPECT_TRUE(area->is_initial_import_done_);
138 EXPECT_FALSE(file_util::PathExists(kExpectedOriginFilePath)); 138 EXPECT_FALSE(file_util::PathExists(kExpectedOriginFilePath));
139 } 139 }
140 140
141 // Valid directory and origin but no session storage backing. Backing should 141 // Valid directory and origin but no session storage backing. Backing should
142 // be null. 142 // be null.
143 { 143 {
144 scoped_refptr<DomStorageArea> area( 144 scoped_refptr<DomStorageArea> area(
145 new DomStorageArea(kSessionStorageNamespaceId, std::string(), kOrigin, 145 new DomStorageArea(kSessionStorageNamespaceId, std::string(), kOrigin,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 TEST_F(DomStorageAreaTest, DeleteOrigin) { 309 TEST_F(DomStorageAreaTest, DeleteOrigin) {
310 base::ScopedTempDir temp_dir; 310 base::ScopedTempDir temp_dir;
311 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 311 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
312 scoped_refptr<DomStorageArea> area( 312 scoped_refptr<DomStorageArea> area(
313 new DomStorageArea(kOrigin, 313 new DomStorageArea(kOrigin,
314 temp_dir.path(), 314 temp_dir.path(),
315 new MockDomStorageTaskRunner(base::MessageLoopProxy::current()))); 315 new MockDomStorageTaskRunner(base::MessageLoopProxy::current())));
316 316
317 // This test puts files on disk. 317 // This test puts files on disk.
318 FilePath db_file_path = static_cast<LocalStorageDatabaseAdapter*>( 318 base::FilePath db_file_path = static_cast<LocalStorageDatabaseAdapter*>(
319 area->backing_.get())->db_->file_path(); 319 area->backing_.get())->db_->file_path();
320 FilePath db_journal_file_path = 320 base::FilePath db_journal_file_path =
321 DomStorageDatabase::GetJournalFilePath(db_file_path); 321 DomStorageDatabase::GetJournalFilePath(db_file_path);
322 322
323 // Nothing bad should happen when invoked w/o any files on disk. 323 // Nothing bad should happen when invoked w/o any files on disk.
324 area->DeleteOrigin(); 324 area->DeleteOrigin();
325 EXPECT_FALSE(file_util::PathExists(db_file_path)); 325 EXPECT_FALSE(file_util::PathExists(db_file_path));
326 326
327 // Commit something in the database and then delete. 327 // Commit something in the database and then delete.
328 NullableString16 old_value; 328 NullableString16 old_value;
329 area->SetItem(kKey, kValue, &old_value); 329 area->SetItem(kKey, kValue, &old_value);
330 MessageLoop::current()->RunUntilIdle(); 330 MessageLoop::current()->RunUntilIdle();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 { "http://www.google.com:8080/", 436 { "http://www.google.com:8080/",
437 "http_www.google.com_8080.localstorage", 437 "http_www.google.com_8080.localstorage",
438 "http_www.google.com_8080.localstorage-journal" }, 438 "http_www.google.com_8080.localstorage-journal" },
439 { "file:///", 439 { "file:///",
440 "file__0.localstorage", 440 "file__0.localstorage",
441 "file__0.localstorage-journal" }, 441 "file__0.localstorage-journal" },
442 }; 442 };
443 443
444 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kCases); ++i) { 444 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kCases); ++i) {
445 GURL origin = GURL(kCases[i].origin).GetOrigin(); 445 GURL origin = GURL(kCases[i].origin).GetOrigin();
446 FilePath file_name = FilePath().AppendASCII(kCases[i].file_name); 446 base::FilePath file_name = base::FilePath().AppendASCII(kCases[i].file_name) ;
447 FilePath journal_file_name = 447 base::FilePath journal_file_name =
448 FilePath().AppendASCII(kCases[i].journal_file_name); 448 base::FilePath().AppendASCII(kCases[i].journal_file_name);
449 449
450 EXPECT_EQ(file_name, 450 EXPECT_EQ(file_name,
451 DomStorageArea::DatabaseFileNameFromOrigin(origin)); 451 DomStorageArea::DatabaseFileNameFromOrigin(origin));
452 EXPECT_EQ(origin, 452 EXPECT_EQ(origin,
453 DomStorageArea::OriginFromDatabaseFileName(file_name)); 453 DomStorageArea::OriginFromDatabaseFileName(file_name));
454 EXPECT_EQ(journal_file_name, 454 EXPECT_EQ(journal_file_name,
455 DomStorageDatabase::GetJournalFilePath(file_name)); 455 DomStorageDatabase::GetJournalFilePath(file_name));
456 } 456 }
457 457
458 // Also test some DomStorageDatabase::GetJournalFilePath cases here. 458 // Also test some DomStorageDatabase::GetJournalFilePath cases here.
459 FilePath parent = FilePath().AppendASCII("a").AppendASCII("b"); 459 base::FilePath parent = base::FilePath().AppendASCII("a").AppendASCII("b");
460 EXPECT_EQ( 460 EXPECT_EQ(
461 parent.AppendASCII("file-journal"), 461 parent.AppendASCII("file-journal"),
462 DomStorageDatabase::GetJournalFilePath(parent.AppendASCII("file"))); 462 DomStorageDatabase::GetJournalFilePath(parent.AppendASCII("file")));
463 EXPECT_EQ( 463 EXPECT_EQ(
464 FilePath().AppendASCII("-journal"), 464 base::FilePath().AppendASCII("-journal"),
465 DomStorageDatabase::GetJournalFilePath(FilePath())); 465 DomStorageDatabase::GetJournalFilePath(base::FilePath()));
466 EXPECT_EQ( 466 EXPECT_EQ(
467 FilePath().AppendASCII(".extensiononly-journal"), 467 base::FilePath().AppendASCII(".extensiononly-journal"),
468 DomStorageDatabase::GetJournalFilePath( 468 DomStorageDatabase::GetJournalFilePath(
469 FilePath().AppendASCII(".extensiononly"))); 469 base::FilePath().AppendASCII(".extensiononly")));
470 } 470 }
471 471
472 } // namespace dom_storage 472 } // namespace dom_storage
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_area.cc ('k') | webkit/dom_storage/dom_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698