| OLD | NEW |
| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webkit/database/database_quota_client.h" | 15 #include "webkit/database/database_quota_client.h" |
| 16 #include "webkit/database/database_tracker.h" | 16 #include "webkit/database/database_tracker.h" |
| 17 #include "webkit/database/database_util.h" | 17 #include "webkit/database/database_util.h" |
| 18 | 18 |
| 19 namespace webkit_database { | 19 namespace webkit_database { |
| 20 | 20 |
| 21 // Declared to shorten the line lengths. | 21 // Declared to shorten the line lengths. |
| 22 static const quota::StorageType kTemp = quota::kStorageTypeTemporary; | 22 static const quota::StorageType kTemp = quota::kStorageTypeTemporary; |
| 23 static const quota::StorageType kPerm = quota::kStorageTypePersistent; | 23 static const quota::StorageType kPerm = quota::kStorageTypePersistent; |
| 24 | 24 |
| 25 // Mock tracker class the mocks up those methods of the tracker | 25 // Mock tracker class the mocks up those methods of the tracker |
| 26 // that are used by the QuotaClient. | 26 // that are used by the QuotaClient. |
| 27 class MockDatabaseTracker : public DatabaseTracker { | 27 class MockDatabaseTracker : public DatabaseTracker { |
| 28 public: | 28 public: |
| 29 MockDatabaseTracker() | 29 MockDatabaseTracker() |
| 30 : DatabaseTracker(FilePath(), false, NULL, NULL, NULL), | 30 : DatabaseTracker(base::FilePath(), false, NULL, NULL, NULL), |
| 31 delete_called_count_(0), | 31 delete_called_count_(0), |
| 32 async_delete_(false) {} | 32 async_delete_(false) {} |
| 33 | 33 |
| 34 virtual bool GetOriginInfo( | 34 virtual bool GetOriginInfo( |
| 35 const string16& origin_identifier, | 35 const string16& origin_identifier, |
| 36 OriginInfo* info) OVERRIDE { | 36 OriginInfo* info) OVERRIDE { |
| 37 std::map<GURL, MockOriginInfo>::const_iterator found = | 37 std::map<GURL, MockOriginInfo>::const_iterator found = |
| 38 mock_origin_infos_.find( | 38 mock_origin_infos_.find( |
| 39 DatabaseUtil::GetOriginFromIdentifier(origin_identifier)); | 39 DatabaseUtil::GetOriginFromIdentifier(origin_identifier)); |
| 40 if (found == mock_origin_infos_.end()) | 40 if (found == mock_origin_infos_.end()) |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 mock_tracker()->set_async_delete(false); | 282 mock_tracker()->set_async_delete(false); |
| 283 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA)); | 283 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA)); |
| 284 EXPECT_EQ(1, mock_tracker()->delete_called_count()); | 284 EXPECT_EQ(1, mock_tracker()->delete_called_count()); |
| 285 | 285 |
| 286 mock_tracker()->set_async_delete(true); | 286 mock_tracker()->set_async_delete(true); |
| 287 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA)); | 287 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA)); |
| 288 EXPECT_EQ(2, mock_tracker()->delete_called_count()); | 288 EXPECT_EQ(2, mock_tracker()->delete_called_count()); |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace webkit_database | 291 } // namespace webkit_database |
| OLD | NEW |