OLD | NEW |
---|---|
1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 #include <sstream> | 6 #include <sstream> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
24 #include "webkit/quota/quota_manager.h" | 24 #include "webkit/quota/quota_manager.h" |
25 | 25 |
26 using base::MessageLoopProxy; | 26 using base::MessageLoopProxy; |
27 | 27 |
28 namespace quota { | 28 namespace quota { |
29 | 29 |
30 // For shorter names. | 30 // For shorter names. |
31 const StorageType kTemp = kStorageTypeTemporary; | 31 const StorageType kTemp = kStorageTypeTemporary; |
32 const StorageType kPerm = kStorageTypePersistent; | 32 const StorageType kPerm = kStorageTypePersistent; |
33 | 33 |
34 const int kAllClients = QuotaClient::kAllClientsMask; | |
35 | |
34 class QuotaManagerTest : public testing::Test { | 36 class QuotaManagerTest : public testing::Test { |
35 protected: | 37 protected: |
36 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; | 38 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; |
37 typedef QuotaManager::QuotaTableEntries QuotaTableEntries; | 39 typedef QuotaManager::QuotaTableEntries QuotaTableEntries; |
38 typedef QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; | 40 typedef QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; |
39 | 41 |
40 public: | 42 public: |
41 QuotaManagerTest() | 43 QuotaManagerTest() |
42 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 44 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
43 mock_time_counter_(0) { | 45 mock_time_counter_(0) { |
(...skipping 18 matching lines...) Expand all Loading... | |
62 quota_manager_ = NULL; | 64 quota_manager_ = NULL; |
63 MessageLoop::current()->RunAllPending(); | 65 MessageLoop::current()->RunAllPending(); |
64 } | 66 } |
65 | 67 |
66 protected: | 68 protected: |
67 MockStorageClient* CreateClient( | 69 MockStorageClient* CreateClient( |
68 const MockOriginData* mock_data, size_t mock_data_size) { | 70 const MockOriginData* mock_data, size_t mock_data_size) { |
69 return new MockStorageClient(quota_manager_->proxy(), | 71 return new MockStorageClient(quota_manager_->proxy(), |
70 mock_data, mock_data_size); | 72 mock_data, mock_data_size); |
71 } | 73 } |
74 MockStorageClient* CreateClient( | |
75 const MockOriginData* mock_data, size_t mock_data_size, | |
kinuko
2012/02/09 14:43:33
style-nit: break the line after 'mock_data,' if al
| |
76 QuotaClient::ID id) { | |
77 return new MockStorageClient(quota_manager_->proxy(), | |
78 mock_data, id, mock_data_size); | |
79 } | |
72 | 80 |
73 void RegisterClient(MockStorageClient* client) { | 81 void RegisterClient(MockStorageClient* client) { |
74 quota_manager_->proxy()->RegisterClient(client); | 82 quota_manager_->proxy()->RegisterClient(client); |
75 } | 83 } |
76 | 84 |
77 void GetUsageInfo() { | 85 void GetUsageInfo() { |
78 usage_info_.clear(); | 86 usage_info_.clear(); |
79 quota_manager_->GetUsageInfo( | 87 quota_manager_->GetUsageInfo( |
80 base::Bind(&QuotaManagerTest::DidGetUsageInfo, | 88 base::Bind(&QuotaManagerTest::DidGetUsageInfo, |
81 weak_factory_.GetWeakPtr())); | 89 weak_factory_.GetWeakPtr())); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 void EvictOriginData(const GURL& origin, | 179 void EvictOriginData(const GURL& origin, |
172 StorageType type) { | 180 StorageType type) { |
173 quota_status_ = kQuotaStatusUnknown; | 181 quota_status_ = kQuotaStatusUnknown; |
174 quota_manager_->EvictOriginData( | 182 quota_manager_->EvictOriginData( |
175 origin, type, | 183 origin, type, |
176 base::Bind(&QuotaManagerTest::StatusCallback, | 184 base::Bind(&QuotaManagerTest::StatusCallback, |
177 weak_factory_.GetWeakPtr())); | 185 weak_factory_.GetWeakPtr())); |
178 } | 186 } |
179 | 187 |
180 void DeleteOriginData(const GURL& origin, | 188 void DeleteOriginData(const GURL& origin, |
181 StorageType type) { | 189 StorageType type, |
190 int quota_client_mask) { | |
182 quota_status_ = kQuotaStatusUnknown; | 191 quota_status_ = kQuotaStatusUnknown; |
183 quota_manager_->DeleteOriginData( | 192 quota_manager_->DeleteOriginData( |
184 origin, type, | 193 origin, type, quota_client_mask, |
185 base::Bind(&QuotaManagerTest::StatusCallback, | 194 base::Bind(&QuotaManagerTest::StatusCallback, |
186 weak_factory_.GetWeakPtr())); | 195 weak_factory_.GetWeakPtr())); |
187 } | 196 } |
188 | 197 |
189 void DeleteHostData(const std::string& host, | 198 void DeleteHostData(const std::string& host, |
190 StorageType type) { | 199 StorageType type, |
200 int quota_client_mask) { | |
191 quota_status_ = kQuotaStatusUnknown; | 201 quota_status_ = kQuotaStatusUnknown; |
192 quota_manager_->DeleteHostData( | 202 quota_manager_->DeleteHostData( |
193 host, type, | 203 host, type, quota_client_mask, |
194 base::Bind(&QuotaManagerTest::StatusCallback, | 204 base::Bind(&QuotaManagerTest::StatusCallback, |
195 weak_factory_.GetWeakPtr())); | 205 weak_factory_.GetWeakPtr())); |
196 } | 206 } |
197 | 207 |
198 void GetAvailableSpace() { | 208 void GetAvailableSpace() { |
199 quota_status_ = kQuotaStatusUnknown; | 209 quota_status_ = kQuotaStatusUnknown; |
200 available_space_ = -1; | 210 available_space_ = -1; |
201 quota_manager_->GetAvailableSpace( | 211 quota_manager_->GetAvailableSpace( |
202 base::Bind(&QuotaManagerTest::DidGetAvailableSpace, | 212 base::Bind(&QuotaManagerTest::DidGetAvailableSpace, |
203 weak_factory_.GetWeakPtr())); | 213 weak_factory_.GetWeakPtr())); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 SetTemporaryGlobalQuota(100); | 727 SetTemporaryGlobalQuota(100); |
718 MessageLoop::current()->RunAllPending(); | 728 MessageLoop::current()->RunAllPending(); |
719 | 729 |
720 set_additional_callback_count(0); | 730 set_additional_callback_count(0); |
721 GetUsageAndQuota(GURL("http://foo.com/"), kTemp); | 731 GetUsageAndQuota(GURL("http://foo.com/"), kTemp); |
722 RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"), | 732 RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"), |
723 kTemp); | 733 kTemp); |
724 RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), | 734 RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), |
725 kTemp); | 735 kTemp); |
726 | 736 |
727 DeleteOriginData(GURL("http://foo.com/"), kTemp); | 737 DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients); |
728 DeleteOriginData(GURL("http://bar.com/"), kTemp); | 738 DeleteOriginData(GURL("http://bar.com/"), kTemp, kAllClients); |
729 | 739 |
730 // Nuke before waiting for callbacks. | 740 // Nuke before waiting for callbacks. |
731 set_quota_manager(NULL); | 741 set_quota_manager(NULL); |
732 MessageLoop::current()->RunAllPending(); | 742 MessageLoop::current()->RunAllPending(); |
733 EXPECT_EQ(kQuotaErrorAbort, status()); | 743 EXPECT_EQ(kQuotaErrorAbort, status()); |
734 } | 744 } |
735 | 745 |
736 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Overbudget) { | 746 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Overbudget) { |
737 static const MockOriginData kData[] = { | 747 static const MockOriginData kData[] = { |
738 { "http://usage1/", kTemp, 1 }, | 748 { "http://usage1/", kTemp, 1 }, |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1312 const int64 predelete_global_tmp = usage(); | 1322 const int64 predelete_global_tmp = usage(); |
1313 | 1323 |
1314 GetHostUsage("foo.com", kTemp); | 1324 GetHostUsage("foo.com", kTemp); |
1315 MessageLoop::current()->RunAllPending(); | 1325 MessageLoop::current()->RunAllPending(); |
1316 int64 predelete_host_tmp = usage(); | 1326 int64 predelete_host_tmp = usage(); |
1317 | 1327 |
1318 GetHostUsage("foo.com", kPerm); | 1328 GetHostUsage("foo.com", kPerm); |
1319 MessageLoop::current()->RunAllPending(); | 1329 MessageLoop::current()->RunAllPending(); |
1320 int64 predelete_host_pers = usage(); | 1330 int64 predelete_host_pers = usage(); |
1321 | 1331 |
1322 DeleteHostData("", kTemp); | 1332 DeleteHostData("", kTemp, kAllClients); |
1323 MessageLoop::current()->RunAllPending(); | 1333 MessageLoop::current()->RunAllPending(); |
1324 EXPECT_EQ(kQuotaStatusOk, status()); | 1334 EXPECT_EQ(kQuotaStatusOk, status()); |
1325 | 1335 |
1326 GetGlobalUsage(kTemp); | 1336 GetGlobalUsage(kTemp); |
1327 MessageLoop::current()->RunAllPending(); | 1337 MessageLoop::current()->RunAllPending(); |
1328 EXPECT_EQ(predelete_global_tmp, usage()); | 1338 EXPECT_EQ(predelete_global_tmp, usage()); |
1329 | 1339 |
1330 GetHostUsage("foo.com", kTemp); | 1340 GetHostUsage("foo.com", kTemp); |
1331 MessageLoop::current()->RunAllPending(); | 1341 MessageLoop::current()->RunAllPending(); |
1332 EXPECT_EQ(predelete_host_tmp, usage()); | 1342 EXPECT_EQ(predelete_host_tmp, usage()); |
1333 | 1343 |
1334 GetHostUsage("foo.com", kPerm); | 1344 GetHostUsage("foo.com", kPerm); |
1335 MessageLoop::current()->RunAllPending(); | 1345 MessageLoop::current()->RunAllPending(); |
1336 EXPECT_EQ(predelete_host_pers, usage()); | 1346 EXPECT_EQ(predelete_host_pers, usage()); |
1337 | 1347 |
1338 DeleteHostData("foo.com", kTemp); | 1348 DeleteHostData("foo.com", kTemp, kAllClients); |
1339 MessageLoop::current()->RunAllPending(); | 1349 MessageLoop::current()->RunAllPending(); |
1340 EXPECT_EQ(kQuotaStatusOk, status()); | 1350 EXPECT_EQ(kQuotaStatusOk, status()); |
1341 | 1351 |
1342 GetGlobalUsage(kTemp); | 1352 GetGlobalUsage(kTemp); |
1343 MessageLoop::current()->RunAllPending(); | 1353 MessageLoop::current()->RunAllPending(); |
1344 EXPECT_EQ(predelete_global_tmp - 1, usage()); | 1354 EXPECT_EQ(predelete_global_tmp - 1, usage()); |
1345 | 1355 |
1346 GetHostUsage("foo.com", kTemp); | 1356 GetHostUsage("foo.com", kTemp); |
1347 MessageLoop::current()->RunAllPending(); | 1357 MessageLoop::current()->RunAllPending(); |
1348 EXPECT_EQ(predelete_host_tmp - 1, usage()); | 1358 EXPECT_EQ(predelete_host_tmp - 1, usage()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 | 1395 |
1386 GetHostUsage("foo.com", kPerm); | 1396 GetHostUsage("foo.com", kPerm); |
1387 MessageLoop::current()->RunAllPending(); | 1397 MessageLoop::current()->RunAllPending(); |
1388 const int64 predelete_foo_pers = usage(); | 1398 const int64 predelete_foo_pers = usage(); |
1389 | 1399 |
1390 GetHostUsage("bar.com", kPerm); | 1400 GetHostUsage("bar.com", kPerm); |
1391 MessageLoop::current()->RunAllPending(); | 1401 MessageLoop::current()->RunAllPending(); |
1392 const int64 predelete_bar_pers = usage(); | 1402 const int64 predelete_bar_pers = usage(); |
1393 | 1403 |
1394 reset_status_callback_count(); | 1404 reset_status_callback_count(); |
1395 DeleteHostData("foo.com", kTemp); | 1405 DeleteHostData("foo.com", kTemp, kAllClients); |
1396 DeleteHostData("bar.com", kTemp); | 1406 DeleteHostData("bar.com", kTemp, kAllClients); |
1397 DeleteHostData("foo.com", kTemp); | 1407 DeleteHostData("foo.com", kTemp, kAllClients); |
1398 MessageLoop::current()->RunAllPending(); | 1408 MessageLoop::current()->RunAllPending(); |
1399 | 1409 |
1400 EXPECT_EQ(3, status_callback_count()); | 1410 EXPECT_EQ(3, status_callback_count()); |
1401 | 1411 |
1402 DumpOriginInfoTable(); | 1412 DumpOriginInfoTable(); |
1403 MessageLoop::current()->RunAllPending(); | 1413 MessageLoop::current()->RunAllPending(); |
1404 | 1414 |
1405 typedef OriginInfoTableEntries::const_iterator iterator; | 1415 typedef OriginInfoTableEntries::const_iterator iterator; |
1406 for (iterator itr(origin_info_entries().begin()), | 1416 for (iterator itr(origin_info_entries().begin()), |
1407 end(origin_info_entries().end()); | 1417 end(origin_info_entries().end()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 | 1489 |
1480 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData1); ++i) | 1490 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData1); ++i) |
1481 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, | 1491 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, |
1482 GURL(kData1[i].origin), kData1[i].type); | 1492 GURL(kData1[i].origin), kData1[i].type); |
1483 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i) | 1493 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i) |
1484 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, | 1494 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, |
1485 GURL(kData2[i].origin), kData2[i].type); | 1495 GURL(kData2[i].origin), kData2[i].type); |
1486 MessageLoop::current()->RunAllPending(); | 1496 MessageLoop::current()->RunAllPending(); |
1487 | 1497 |
1488 reset_status_callback_count(); | 1498 reset_status_callback_count(); |
1489 DeleteOriginData(GURL("http://foo.com/"), kTemp); | 1499 DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients); |
1490 DeleteOriginData(GURL("http://bar.com/"), kTemp); | 1500 DeleteOriginData(GURL("http://bar.com/"), kTemp, kAllClients); |
1491 DeleteOriginData(GURL("http://foo.com/"), kTemp); | 1501 DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients); |
1492 MessageLoop::current()->RunAllPending(); | 1502 MessageLoop::current()->RunAllPending(); |
1493 | 1503 |
1494 EXPECT_EQ(3, status_callback_count()); | 1504 EXPECT_EQ(3, status_callback_count()); |
1495 | 1505 |
1496 DumpOriginInfoTable(); | 1506 DumpOriginInfoTable(); |
1497 MessageLoop::current()->RunAllPending(); | 1507 MessageLoop::current()->RunAllPending(); |
1498 | 1508 |
1499 typedef OriginInfoTableEntries::const_iterator iterator; | 1509 typedef OriginInfoTableEntries::const_iterator iterator; |
1500 for (iterator itr(origin_info_entries().begin()), | 1510 for (iterator itr(origin_info_entries().begin()), |
1501 end(origin_info_entries().end()); | 1511 end(origin_info_entries().end()); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1789 TEST_F(QuotaManagerTest, QuotaForEmptyHost) { | 1799 TEST_F(QuotaManagerTest, QuotaForEmptyHost) { |
1790 GetPersistentHostQuota(std::string()); | 1800 GetPersistentHostQuota(std::string()); |
1791 MessageLoop::current()->RunAllPending(); | 1801 MessageLoop::current()->RunAllPending(); |
1792 EXPECT_EQ(kQuotaStatusOk, status()); | 1802 EXPECT_EQ(kQuotaStatusOk, status()); |
1793 EXPECT_EQ(0, quota()); | 1803 EXPECT_EQ(0, quota()); |
1794 | 1804 |
1795 SetPersistentHostQuota(std::string(), 10); | 1805 SetPersistentHostQuota(std::string(), 10); |
1796 MessageLoop::current()->RunAllPending(); | 1806 MessageLoop::current()->RunAllPending(); |
1797 EXPECT_EQ(kQuotaErrorNotSupported, status()); | 1807 EXPECT_EQ(kQuotaErrorNotSupported, status()); |
1798 } | 1808 } |
1809 | |
1810 TEST_F(QuotaManagerTest, DeleteSpecificClientTypeSingleOrigin) { | |
1811 static const MockOriginData kData1[] = { | |
1812 { "http://foo.com/", kTemp, 1 }, | |
1813 }; | |
1814 static const MockOriginData kData2[] = { | |
1815 { "http://foo.com/", kTemp, 2 }, | |
1816 }; | |
1817 static const MockOriginData kData3[] = { | |
1818 { "http://foo.com/", kTemp, 4 }, | |
1819 }; | |
1820 static const MockOriginData kData4[] = { | |
1821 { "http://foo.com/", kTemp, 8 }, | |
1822 }; | |
1823 MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1), | |
1824 QuotaClient::kFileSystem); | |
1825 MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2), | |
1826 QuotaClient::kAppcache); | |
1827 MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3), | |
1828 QuotaClient::kDatabase); | |
1829 MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4), | |
1830 QuotaClient::kIndexedDatabase); | |
1831 RegisterClient(client1); | |
1832 RegisterClient(client2); | |
1833 RegisterClient(client3); | |
1834 RegisterClient(client4); | |
1835 | |
1836 GetHostUsage("foo.com", kTemp); | |
1837 MessageLoop::current()->RunAllPending(); | |
1838 const int64 predelete_foo_tmp = usage(); | |
1839 | |
1840 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kFileSystem); | |
1841 MessageLoop::current()->RunAllPending(); | |
1842 GetHostUsage("foo.com", kTemp); | |
1843 MessageLoop::current()->RunAllPending(); | |
1844 EXPECT_EQ(predelete_foo_tmp - 1, usage()); | |
1845 | |
1846 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kAppcache); | |
1847 MessageLoop::current()->RunAllPending(); | |
1848 GetHostUsage("foo.com", kTemp); | |
1849 MessageLoop::current()->RunAllPending(); | |
1850 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); | |
1851 | |
1852 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kDatabase); | |
1853 MessageLoop::current()->RunAllPending(); | |
1854 GetHostUsage("foo.com", kTemp); | |
1855 MessageLoop::current()->RunAllPending(); | |
1856 EXPECT_EQ(predelete_foo_tmp - 4 - 2 - 1, usage()); | |
1857 | |
1858 DeleteOriginData(GURL("http://foo.com/"), kTemp, | |
1859 QuotaClient::kIndexedDatabase); | |
1860 MessageLoop::current()->RunAllPending(); | |
1861 GetHostUsage("foo.com", kTemp); | |
1862 MessageLoop::current()->RunAllPending(); | |
1863 EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage()); | |
1864 } | |
1865 | |
1866 TEST_F(QuotaManagerTest, DeleteSpecificClientTypeSingleHost) { | |
1867 static const MockOriginData kData1[] = { | |
1868 { "http://foo.com:1111/", kTemp, 1 }, | |
1869 }; | |
1870 static const MockOriginData kData2[] = { | |
1871 { "http://foo.com:2222/", kTemp, 2 }, | |
1872 }; | |
1873 static const MockOriginData kData3[] = { | |
1874 { "http://foo.com:3333/", kTemp, 4 }, | |
1875 }; | |
1876 static const MockOriginData kData4[] = { | |
1877 { "http://foo.com:4444/", kTemp, 8 }, | |
1878 }; | |
1879 MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1), | |
1880 QuotaClient::kFileSystem); | |
1881 MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2), | |
1882 QuotaClient::kAppcache); | |
1883 MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3), | |
1884 QuotaClient::kDatabase); | |
1885 MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4), | |
1886 QuotaClient::kIndexedDatabase); | |
1887 RegisterClient(client1); | |
1888 RegisterClient(client2); | |
1889 RegisterClient(client3); | |
1890 RegisterClient(client4); | |
1891 | |
1892 GetHostUsage("foo.com", kTemp); | |
1893 MessageLoop::current()->RunAllPending(); | |
1894 const int64 predelete_foo_tmp = usage(); | |
1895 | |
1896 DeleteHostData("foo.com", kTemp, QuotaClient::kFileSystem); | |
1897 MessageLoop::current()->RunAllPending(); | |
1898 GetHostUsage("foo.com", kTemp); | |
1899 MessageLoop::current()->RunAllPending(); | |
1900 EXPECT_EQ(predelete_foo_tmp - 1, usage()); | |
1901 | |
1902 DeleteHostData("foo.com", kTemp, QuotaClient::kAppcache); | |
1903 MessageLoop::current()->RunAllPending(); | |
1904 GetHostUsage("foo.com", kTemp); | |
1905 MessageLoop::current()->RunAllPending(); | |
1906 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); | |
1907 | |
1908 DeleteHostData("foo.com", kTemp, QuotaClient::kDatabase); | |
1909 MessageLoop::current()->RunAllPending(); | |
1910 GetHostUsage("foo.com", kTemp); | |
1911 MessageLoop::current()->RunAllPending(); | |
1912 EXPECT_EQ(predelete_foo_tmp - 4 - 2 - 1, usage()); | |
1913 | |
1914 DeleteHostData("foo.com", kTemp, QuotaClient::kIndexedDatabase); | |
1915 MessageLoop::current()->RunAllPending(); | |
1916 GetHostUsage("foo.com", kTemp); | |
1917 MessageLoop::current()->RunAllPending(); | |
1918 EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage()); | |
1919 } | |
1920 | |
1921 TEST_F(QuotaManagerTest, DeleteMultipleClientTypesSingleOrigin) { | |
1922 static const MockOriginData kData1[] = { | |
1923 { "http://foo.com/", kTemp, 1 }, | |
1924 }; | |
1925 static const MockOriginData kData2[] = { | |
1926 { "http://foo.com/", kTemp, 2 }, | |
1927 }; | |
1928 static const MockOriginData kData3[] = { | |
1929 { "http://foo.com/", kTemp, 4 }, | |
1930 }; | |
1931 static const MockOriginData kData4[] = { | |
1932 { "http://foo.com/", kTemp, 8 }, | |
1933 }; | |
1934 MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1), | |
1935 QuotaClient::kFileSystem); | |
1936 MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2), | |
1937 QuotaClient::kAppcache); | |
1938 MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3), | |
1939 QuotaClient::kDatabase); | |
1940 MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4), | |
1941 QuotaClient::kIndexedDatabase); | |
1942 RegisterClient(client1); | |
1943 RegisterClient(client2); | |
1944 RegisterClient(client3); | |
1945 RegisterClient(client4); | |
1946 | |
1947 GetHostUsage("foo.com", kTemp); | |
1948 MessageLoop::current()->RunAllPending(); | |
1949 const int64 predelete_foo_tmp = usage(); | |
1950 | |
1951 DeleteOriginData(GURL("http://foo.com/"), kTemp, | |
1952 QuotaClient::kFileSystem | QuotaClient::kDatabase); | |
1953 MessageLoop::current()->RunAllPending(); | |
1954 GetHostUsage("foo.com", kTemp); | |
1955 MessageLoop::current()->RunAllPending(); | |
1956 EXPECT_EQ(predelete_foo_tmp - 4 - 1, usage()); | |
1957 | |
1958 DeleteOriginData(GURL("http://foo.com/"), kTemp, | |
1959 QuotaClient::kAppcache | QuotaClient::kIndexedDatabase); | |
1960 MessageLoop::current()->RunAllPending(); | |
1961 GetHostUsage("foo.com", kTemp); | |
1962 MessageLoop::current()->RunAllPending(); | |
1963 EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage()); | |
1964 } | |
1965 | |
1966 TEST_F(QuotaManagerTest, DeleteMultipleClientTypesSingleHost) { | |
1967 static const MockOriginData kData1[] = { | |
1968 { "http://foo.com:1111/", kTemp, 1 }, | |
1969 }; | |
1970 static const MockOriginData kData2[] = { | |
1971 { "http://foo.com:2222/", kTemp, 2 }, | |
1972 }; | |
1973 static const MockOriginData kData3[] = { | |
1974 { "http://foo.com:3333/", kTemp, 4 }, | |
1975 }; | |
1976 static const MockOriginData kData4[] = { | |
1977 { "http://foo.com:4444/", kTemp, 8 }, | |
1978 }; | |
1979 MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1), | |
1980 QuotaClient::kFileSystem); | |
1981 MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2), | |
1982 QuotaClient::kAppcache); | |
1983 MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3), | |
1984 QuotaClient::kDatabase); | |
1985 MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4), | |
1986 QuotaClient::kIndexedDatabase); | |
1987 RegisterClient(client1); | |
1988 RegisterClient(client2); | |
1989 RegisterClient(client3); | |
1990 RegisterClient(client4); | |
1991 | |
1992 GetHostUsage("foo.com", kTemp); | |
1993 MessageLoop::current()->RunAllPending(); | |
1994 const int64 predelete_foo_tmp = usage(); | |
1995 | |
1996 DeleteHostData("foo.com", kTemp, | |
1997 QuotaClient::kFileSystem | QuotaClient::kAppcache); | |
1998 MessageLoop::current()->RunAllPending(); | |
1999 GetHostUsage("foo.com", kTemp); | |
2000 MessageLoop::current()->RunAllPending(); | |
2001 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); | |
2002 | |
2003 DeleteHostData("foo.com", kTemp, | |
2004 QuotaClient::kDatabase | QuotaClient::kIndexedDatabase); | |
2005 MessageLoop::current()->RunAllPending(); | |
2006 GetHostUsage("foo.com", kTemp); | |
2007 MessageLoop::current()->RunAllPending(); | |
2008 EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage()); | |
2009 } | |
1799 } // namespace quota | 2010 } // namespace quota |
OLD | NEW |