diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 21:15:55 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 21:15:55 +0000 |
commit | 3ccfe535658c8852c1cc1df01372ecc602f376cd (patch) | |
tree | 47582af5ba2a4f0658126d564d618c18a93173cf /webkit/database/databases_table_unittest.cc | |
parent | 6d8e2a64b6961331816689850192a8ee864f9a97 (diff) | |
download | chromium_src-3ccfe535658c8852c1cc1df01372ecc602f376cd.zip chromium_src-3ccfe535658c8852c1cc1df01372ecc602f376cd.tar.gz chromium_src-3ccfe535658c8852c1cc1df01372ecc602f376cd.tar.bz2 |
Adding methods that will be used by the quota management UI.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/507014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/database/databases_table_unittest.cc')
-rw-r--r-- | webkit/database/databases_table_unittest.cc | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/webkit/database/databases_table_unittest.cc b/webkit/database/databases_table_unittest.cc index fb46d08..2d72d60 100644 --- a/webkit/database/databases_table_unittest.cc +++ b/webkit/database/databases_table_unittest.cc @@ -4,12 +4,11 @@ #include "app/sql/connection.h" #include "app/sql/statement.h" -#include "base/scoped_temp_dir.h" #include "base/string_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/database/databases_table.h" -namespace webkit_database { +namespace { class TestErrorDelegate : public sql::ErrorDelegate { public: @@ -20,6 +19,10 @@ class TestErrorDelegate : public sql::ErrorDelegate { } }; +} // namespace + +namespace webkit_database { + static void CheckDetailsAreEqual(const DatabaseDetails& d1, const DatabaseDetails& d2) { EXPECT_EQ(d1.origin_identifier, d2.origin_identifier); @@ -36,7 +39,6 @@ static bool DatabasesTableIsEmpty(sql::Connection* db) { TEST(DatabasesTableTest, TestIt) { // Initialize the 'Databases' table. - ScopedTempDir temp_dir; sql::Connection db; // Set an error delegate that will make all operations return false on error. @@ -44,8 +46,7 @@ TEST(DatabasesTableTest, TestIt) { db.set_error_delegate(error_delegate); // Initialize the temp dir and the 'Databases' table. - EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); - EXPECT_TRUE(db.Open(temp_dir.path().Append(FILE_PATH_LITERAL("tracker.db")))); + EXPECT_TRUE(db.OpenInMemory()); DatabasesTable databases_table(&db); EXPECT_TRUE(databases_table.Init()); @@ -116,6 +117,23 @@ TEST(DatabasesTableTest, TestIt) { CheckDetailsAreEqual(details_in1, details_out_origin1[0]); CheckDetailsAreEqual(details_in2, details_out_origin1[1]); + // Get the list of all origins: should be "origin1" and "origin2". + std::vector<string16> origins_out; + EXPECT_TRUE(databases_table.GetAllOrigins(&origins_out)); + EXPECT_EQ(size_t(2), origins_out.size()); + EXPECT_EQ(details_in1.origin_identifier, origins_out[0]); + EXPECT_EQ(details_in3.origin_identifier, origins_out[1]); + + // Delete an origin and check that it's no longer in the table. + origins_out.clear(); + EXPECT_TRUE(databases_table.DeleteOrigin(details_in3.origin_identifier)); + EXPECT_TRUE(databases_table.GetAllOrigins(&origins_out)); + EXPECT_EQ(size_t(1), origins_out.size()); + EXPECT_EQ(details_in1.origin_identifier, origins_out[0]); + + // Deleting an origin that doesn't have any record in this table should fail. + EXPECT_FALSE(databases_table.DeleteOrigin(ASCIIToUTF16("unknown_origin"))); + // Delete the details for 'db1' and check that they're no longer there. EXPECT_TRUE(databases_table.DeleteDatabaseDetails( details_in1.origin_identifier, details_in1.database_name)); |