diff options
author | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-22 16:45:42 +0000 |
---|---|---|
committer | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-22 16:45:42 +0000 |
commit | 0e623c188f818c9bf61356a1043b2b709669ccde (patch) | |
tree | abdb5fbfd80491c4a8da60620ca939f447a01429 /chrome/browser/in_process_webkit | |
parent | 53dc42935d330bd09b86bd9d5cb9e20d776d6b15 (diff) | |
download | chromium_src-0e623c188f818c9bf61356a1043b2b709669ccde.zip chromium_src-0e623c188f818c9bf61356a1043b2b709669ccde.tar.gz chromium_src-0e623c188f818c9bf61356a1043b2b709669ccde.tar.bz2 |
UI test for removal of empty DOM Storage database files.
Implement tests to make sure that database files are only created when needed,
and deleted when they are empty.
BUG=39067
TEST=ui_tests --gtest_filter=DomStorageEmptyDatabaseTest.*
Review URL: http://codereview.chromium.org/2867019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50467 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/in_process_webkit')
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_uitest.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/chrome/browser/in_process_webkit/dom_storage_uitest.cc b/chrome/browser/in_process_webkit/dom_storage_uitest.cc index 709c75a..bd8e18d 100644 --- a/chrome/browser/in_process_webkit/dom_storage_uitest.cc +++ b/chrome/browser/in_process_webkit/dom_storage_uitest.cc @@ -3,10 +3,12 @@ // found in the LICENSE file. #include "base/file_path.h" +#include "base/file_util.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_layout_test.h" #include "chrome/test/ui_test_utils.h" +#include "net/base/net_util.h" static const char* kRootFiles[] = { "clear.html", @@ -127,3 +129,63 @@ TEST_F(DOMStorageTest, SessionStorageLayoutTests) { AppendASCII("resources")); RunTests(kStorageFiles); } + +class DomStorageEmptyDatabaseTest : public UITest { + protected: + FilePath storageDir() const { + FilePath storage_dir = user_data_dir(); + storage_dir = storage_dir.AppendASCII("Default"); + storage_dir = storage_dir.AppendASCII("Local Storage"); + return storage_dir; + } + + GURL testUrl() const { + FilePath test_dir = test_data_directory_; + FilePath test_file = test_dir.AppendASCII("dom_storage_empty_db.html"); + return net::FilePathToFileURL(test_file); + } +}; + +namespace { + +bool dirIsEmpty(const FilePath& path) { + if (!file_util::DirectoryExists(path)) + return true; + return file_util::CountFilesCreatedAfter(path, base::Time()) == 0; +} + +} // namespace + +TEST_F(DomStorageEmptyDatabaseTest, EmptyDirAfterClear) { + NavigateToURL(testUrl()); + ASSERT_TRUE(dirIsEmpty(storageDir())); + + NavigateToURL(GURL("javascript:set()")); + NavigateToURL(GURL("javascript:clear()")); + QuitBrowser(); + EXPECT_TRUE(dirIsEmpty(storageDir())); +} + +TEST_F(DomStorageEmptyDatabaseTest, EmptyDirAfterGet) { + NavigateToURL(testUrl()); + ASSERT_TRUE(dirIsEmpty(storageDir())); + + NavigateToURL(GURL("javascript:get()")); + QuitBrowser(); + EXPECT_TRUE(dirIsEmpty(storageDir())); +} + +TEST_F(DomStorageEmptyDatabaseTest, NonEmptyDirAfterSet) { + NavigateToURL(testUrl()); + ASSERT_TRUE(dirIsEmpty(storageDir())); + + NavigateToURL(GURL("javascript:set()")); + QuitBrowser(); + EXPECT_FALSE(dirIsEmpty(storageDir())); + + LaunchBrowserAndServer(); + NavigateToURL(testUrl()); + NavigateToURL(GURL("javascript:clear()")); + QuitBrowser(); + EXPECT_TRUE(dirIsEmpty(storageDir())); +} |