OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "sql/connection.h" | 7 #include "sql/connection.h" |
8 #include "sql/statement.h" | 8 #include "sql/statement.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/database/quota_table.h" | 10 #include "webkit/database/quota_table.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 class TestErrorDelegate : public sql::ErrorDelegate { | 14 class TestErrorDelegate : public sql::ErrorDelegate { |
15 public: | 15 public: |
16 virtual ~TestErrorDelegate() { } | 16 virtual int OnError(int error, |
17 virtual int OnError( | 17 sql::Connection* connection, |
18 int error, sql::Connection* connection, sql::Statement* stmt) { | 18 sql::Statement* stmt) OVERRIDE { |
19 return error; | 19 return error; |
20 } | 20 } |
| 21 |
| 22 protected: |
| 23 virtual ~TestErrorDelegate() {} |
21 }; | 24 }; |
22 | 25 |
23 } // namespace | 26 } // namespace |
24 | 27 |
25 namespace webkit_database { | 28 namespace webkit_database { |
26 | 29 |
27 static bool QuotaTableIsEmpty(sql::Connection* db) { | 30 static bool QuotaTableIsEmpty(sql::Connection* db) { |
28 sql::Statement statement(db->GetCachedStatement( | 31 sql::Statement statement(db->GetCachedStatement( |
29 SQL_FROM_HERE, "SELECT COUNT(*) FROM Quota")); | 32 SQL_FROM_HERE, "SELECT COUNT(*) FROM Quota")); |
30 return (statement.is_valid() && statement.Step() && !statement.ColumnInt(0)); | 33 return (statement.is_valid() && statement.Step() && !statement.ColumnInt(0)); |
(...skipping 26 matching lines...) Expand all Loading... |
57 | 60 |
58 // Clear the quota for an origin | 61 // Clear the quota for an origin |
59 EXPECT_TRUE(quota_table.ClearOriginQuota(origin)); | 62 EXPECT_TRUE(quota_table.ClearOriginQuota(origin)); |
60 EXPECT_TRUE(quota_table.GetOriginQuota(origin) < 0); | 63 EXPECT_TRUE(quota_table.GetOriginQuota(origin) < 0); |
61 | 64 |
62 // Check that there's no quota set for unknown origins. | 65 // Check that there's no quota set for unknown origins. |
63 EXPECT_TRUE(quota_table.GetOriginQuota(ASCIIToUTF16("unknown_origin")) < 0); | 66 EXPECT_TRUE(quota_table.GetOriginQuota(ASCIIToUTF16("unknown_origin")) < 0); |
64 } | 67 } |
65 | 68 |
66 } // namespace webkit_database | 69 } // namespace webkit_database |
OLD | NEW |