OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 26 matching lines...) Expand all Loading... | |
37 using storage::kQuotaStatusOk; | 37 using storage::kQuotaStatusOk; |
38 using storage::kQuotaStatusUnknown; | 38 using storage::kQuotaStatusUnknown; |
39 using storage::kStorageTypePersistent; | 39 using storage::kStorageTypePersistent; |
40 using storage::kStorageTypeSyncable; | 40 using storage::kStorageTypeSyncable; |
41 using storage::kStorageTypeTemporary; | 41 using storage::kStorageTypeTemporary; |
42 using storage::kStorageTypeUnknown; | 42 using storage::kStorageTypeUnknown; |
43 using storage::QuotaClient; | 43 using storage::QuotaClient; |
44 using storage::QuotaManager; | 44 using storage::QuotaManager; |
45 using storage::QuotaStatusCode; | 45 using storage::QuotaStatusCode; |
46 using storage::StorageType; | 46 using storage::StorageType; |
47 using storage::UsageAndQuota; | |
48 using storage::UsageInfo; | 47 using storage::UsageInfo; |
49 using storage::UsageInfoEntries; | 48 using storage::UsageInfoEntries; |
50 | 49 |
51 namespace content { | 50 namespace content { |
52 | 51 |
53 namespace { | 52 namespace { |
54 | 53 |
55 // For shorter names. | 54 // For shorter names. |
56 const StorageType kTemp = kStorageTypeTemporary; | 55 const StorageType kTemp = kStorageTypeTemporary; |
57 const StorageType kPerm = kStorageTypePersistent; | 56 const StorageType kPerm = kStorageTypePersistent; |
58 const StorageType kSync = kStorageTypeSyncable; | 57 const StorageType kSync = kStorageTypeSyncable; |
59 | 58 |
60 const int kAllClients = QuotaClient::kAllClientsMask; | 59 const int kAllClients = QuotaClient::kAllClientsMask; |
61 | 60 |
61 // Values in bytes. | |
62 const int64_t kAvailableSpaceForApp = 13377331U; | 62 const int64_t kAvailableSpaceForApp = 13377331U; |
63 | 63 const int64_t kMustRemainAvailableForSystem = kAvailableSpaceForApp / 2; |
64 const int64_t kMinimumPreserveForSystem = | 64 const int64_t kDefaultPoolSize = 1000; |
65 QuotaManager::kMinimumPreserveForSystem; | 65 const int64_t kDefaultPerHostQuota = 200; |
66 const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion; | |
67 | 66 |
68 const GURL kTestEvictionOrigin = GURL("http://test.eviction.policy/result"); | 67 const GURL kTestEvictionOrigin = GURL("http://test.eviction.policy/result"); |
69 | 68 |
70 // Returns a deterministic value for the amount of available disk space. | 69 // Returns a deterministic value for the amount of available disk space. |
71 int64_t GetAvailableDiskSpaceForTest() { | 70 int64_t GetAvailableDiskSpaceForTest() { |
72 return kAvailableSpaceForApp + kMinimumPreserveForSystem; | 71 return kAvailableSpaceForApp + kMustRemainAvailableForSystem; |
73 } | 72 } |
74 | 73 |
75 bool GetVolumeInfoForTests(const base::FilePath&, | 74 std::pair<int64_t, int64_t> GetVolumeInfoForTests( |
76 uint64_t* available, uint64_t* total) { | 75 const base::FilePath& unused) { |
77 *available = static_cast<uint64_t>(GetAvailableDiskSpaceForTest()); | 76 int64_t available = static_cast<uint64_t>(GetAvailableDiskSpaceForTest()); |
78 *total = *available * 2; | 77 int64_t total = available * 2; |
79 return true; | 78 return std::make_pair(total, available); |
80 } | 79 } |
81 | 80 |
82 class TestEvictionPolicy : public storage::QuotaEvictionPolicy { | 81 class TestEvictionPolicy : public storage::QuotaEvictionPolicy { |
83 public: | 82 public: |
84 TestEvictionPolicy() {} | 83 TestEvictionPolicy() {} |
85 ~TestEvictionPolicy() override {} | 84 ~TestEvictionPolicy() override {} |
86 | 85 |
87 // Overridden from storage::QuotaEvictionPolicy: | 86 // Overridden from storage::QuotaEvictionPolicy: |
88 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>& | 87 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>& |
89 special_storage_policy, | 88 special_storage_policy, |
(...skipping 29 matching lines...) Expand all Loading... | |
119 // Make sure the quota manager cleans up correctly. | 118 // Make sure the quota manager cleans up correctly. |
120 quota_manager_ = NULL; | 119 quota_manager_ = NULL; |
121 base::RunLoop().RunUntilIdle(); | 120 base::RunLoop().RunUntilIdle(); |
122 } | 121 } |
123 | 122 |
124 protected: | 123 protected: |
125 void ResetQuotaManager(bool is_incognito) { | 124 void ResetQuotaManager(bool is_incognito) { |
126 quota_manager_ = new QuotaManager(is_incognito, data_dir_.GetPath(), | 125 quota_manager_ = new QuotaManager(is_incognito, data_dir_.GetPath(), |
127 base::ThreadTaskRunnerHandle::Get().get(), | 126 base::ThreadTaskRunnerHandle::Get().get(), |
128 base::ThreadTaskRunnerHandle::Get().get(), | 127 base::ThreadTaskRunnerHandle::Get().get(), |
129 mock_special_storage_policy_.get()); | 128 mock_special_storage_policy_.get(), |
129 storage::GetQuotaSettingsFunc()); | |
130 SetQuotaSettings(kDefaultPoolSize, kDefaultPerHostQuota, | |
131 is_incognito ? INT64_C(0) : kMustRemainAvailableForSystem); | |
132 | |
130 // Don't (automatically) start the eviction for testing. | 133 // Don't (automatically) start the eviction for testing. |
131 quota_manager_->eviction_disabled_ = true; | 134 quota_manager_->eviction_disabled_ = true; |
132 // Don't query the hard disk for remaining capacity. | 135 // Don't query the hard disk for remaining capacity. |
133 quota_manager_->get_volume_info_fn_= &GetVolumeInfoForTests; | 136 quota_manager_->get_volume_info_fn_= &GetVolumeInfoForTests; |
134 additional_callback_count_ = 0; | 137 additional_callback_count_ = 0; |
135 } | 138 } |
136 | 139 |
137 MockStorageClient* CreateClient( | 140 MockStorageClient* CreateClient( |
138 const MockOriginData* mock_data, | 141 const MockOriginData* mock_data, |
139 size_t mock_data_size, | 142 size_t mock_data_size, |
(...skipping 26 matching lines...) Expand all Loading... | |
166 void GetUsageAndQuotaForStorageClient(const GURL& origin, | 169 void GetUsageAndQuotaForStorageClient(const GURL& origin, |
167 StorageType type) { | 170 StorageType type) { |
168 quota_status_ = kQuotaStatusUnknown; | 171 quota_status_ = kQuotaStatusUnknown; |
169 usage_ = -1; | 172 usage_ = -1; |
170 quota_ = -1; | 173 quota_ = -1; |
171 quota_manager_->GetUsageAndQuota( | 174 quota_manager_->GetUsageAndQuota( |
172 origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota, | 175 origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota, |
173 weak_factory_.GetWeakPtr())); | 176 weak_factory_.GetWeakPtr())); |
174 } | 177 } |
175 | 178 |
176 void GetTemporaryGlobalQuota() { | 179 void SetQuotaSettings(int64_t pool_size, |
177 quota_status_ = kQuotaStatusUnknown; | 180 int64_t per_host_quota, |
178 quota_ = -1; | 181 int64_t must_remain_available) { |
179 quota_manager_->GetTemporaryGlobalQuota( | 182 storage::QuotaSettings settings; |
180 base::Bind(&QuotaManagerTest::DidGetQuota, | 183 settings.pool_size = pool_size; |
181 weak_factory_.GetWeakPtr())); | 184 settings.per_host_quota = per_host_quota; |
182 } | 185 settings.must_remain_available = must_remain_available; |
183 | 186 settings.refresh_interval = base::TimeDelta::Max(); |
184 void SetTemporaryGlobalQuota(int64_t new_quota) { | 187 quota_manager_->SetQuotaSettings(settings); |
185 quota_status_ = kQuotaStatusUnknown; | |
186 quota_ = -1; | |
187 quota_manager_->SetTemporaryGlobalOverrideQuota( | |
188 new_quota, | |
189 base::Bind(&QuotaManagerTest::DidGetQuota, | |
190 weak_factory_.GetWeakPtr())); | |
191 } | 188 } |
192 | 189 |
193 void GetPersistentHostQuota(const std::string& host) { | 190 void GetPersistentHostQuota(const std::string& host) { |
194 quota_status_ = kQuotaStatusUnknown; | 191 quota_status_ = kQuotaStatusUnknown; |
195 quota_ = -1; | 192 quota_ = -1; |
196 quota_manager_->GetPersistentHostQuota( | 193 quota_manager_->GetPersistentHostQuota( |
197 host, | 194 host, |
198 base::Bind(&QuotaManagerTest::DidGetHostQuota, | 195 base::Bind(&QuotaManagerTest::DidGetHostQuota, |
199 weak_factory_.GetWeakPtr())); | 196 weak_factory_.GetWeakPtr())); |
200 } | 197 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 void DeleteHostData(const std::string& host, | 262 void DeleteHostData(const std::string& host, |
266 StorageType type, | 263 StorageType type, |
267 int quota_client_mask) { | 264 int quota_client_mask) { |
268 quota_status_ = kQuotaStatusUnknown; | 265 quota_status_ = kQuotaStatusUnknown; |
269 quota_manager_->DeleteHostData( | 266 quota_manager_->DeleteHostData( |
270 host, type, quota_client_mask, | 267 host, type, quota_client_mask, |
271 base::Bind(&QuotaManagerTest::StatusCallback, | 268 base::Bind(&QuotaManagerTest::StatusCallback, |
272 weak_factory_.GetWeakPtr())); | 269 weak_factory_.GetWeakPtr())); |
273 } | 270 } |
274 | 271 |
275 void GetAvailableSpace() { | 272 void GetStorageCapacity() { |
273 available_space_ = -1; | |
274 total_space_ = -1; | |
275 quota_manager_->GetStorageCapacity(base::Bind( | |
276 &QuotaManagerTest::DidGetStorageCapacity, weak_factory_.GetWeakPtr())); | |
277 } | |
278 | |
279 void GetEvictionRoundInfo() { | |
276 quota_status_ = kQuotaStatusUnknown; | 280 quota_status_ = kQuotaStatusUnknown; |
281 settings_ = storage::QuotaSettings(); | |
277 available_space_ = -1; | 282 available_space_ = -1; |
278 quota_manager_->GetAvailableSpace( | 283 total_space_ = -1; |
279 base::Bind(&QuotaManagerTest::DidGetAvailableSpace, | 284 usage_ = -1; |
285 quota_manager_->GetEvictionRoundInfo( | |
286 base::Bind(&QuotaManagerTest::DidGetEvictionRoundInfo, | |
280 weak_factory_.GetWeakPtr())); | 287 weak_factory_.GetWeakPtr())); |
281 } | 288 } |
282 | 289 |
283 void GetUsageAndQuotaForEviction() { | |
284 quota_status_ = kQuotaStatusUnknown; | |
285 usage_ = -1; | |
286 unlimited_usage_ = -1; | |
287 quota_ = -1; | |
288 available_space_ = -1; | |
289 quota_manager_->GetUsageAndQuotaForEviction( | |
290 base::Bind(&QuotaManagerTest::DidGetUsageAndQuotaForEviction, | |
291 weak_factory_.GetWeakPtr())); | |
292 } | |
293 | |
294 void GetCachedOrigins(StorageType type, std::set<GURL>* origins) { | 290 void GetCachedOrigins(StorageType type, std::set<GURL>* origins) { |
295 ASSERT_TRUE(origins != NULL); | 291 ASSERT_TRUE(origins != NULL); |
296 origins->clear(); | 292 origins->clear(); |
297 quota_manager_->GetCachedOrigins(type, origins); | 293 quota_manager_->GetCachedOrigins(type, origins); |
298 } | 294 } |
299 | 295 |
300 bool GetVolumeInfo(const base::FilePath& path, | |
301 uint64_t* available_space, | |
302 uint64_t* total_size) { | |
303 return QuotaManager::GetVolumeInfo(path, available_space, total_size); | |
304 } | |
305 | |
306 void NotifyStorageAccessed(QuotaClient* client, | 296 void NotifyStorageAccessed(QuotaClient* client, |
307 const GURL& origin, | 297 const GURL& origin, |
308 StorageType type) { | 298 StorageType type) { |
309 DCHECK(client); | 299 DCHECK(client); |
310 quota_manager_->NotifyStorageAccessedInternal( | 300 quota_manager_->NotifyStorageAccessedInternal( |
311 client->id(), origin, type, IncrementMockTime()); | 301 client->id(), origin, type, IncrementMockTime()); |
312 } | 302 } |
313 | 303 |
314 void DeleteOriginFromDatabase(const GURL& origin, StorageType type) { | 304 void DeleteOriginFromDatabase(const GURL& origin, StorageType type) { |
315 quota_manager_->DeleteOriginFromDatabase(origin, type, false); | 305 quota_manager_->DeleteOriginFromDatabase(origin, type, false); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 quota_status_ = status; | 356 quota_status_ = status; |
367 usage_ = usage; | 357 usage_ = usage; |
368 quota_ = quota; | 358 quota_ = quota; |
369 } | 359 } |
370 | 360 |
371 void DidGetQuota(QuotaStatusCode status, int64_t quota) { | 361 void DidGetQuota(QuotaStatusCode status, int64_t quota) { |
372 quota_status_ = status; | 362 quota_status_ = status; |
373 quota_ = quota; | 363 quota_ = quota; |
374 } | 364 } |
375 | 365 |
376 void DidGetAvailableSpace(QuotaStatusCode status, int64_t available_space) { | 366 void DidGetStorageCapacity(int64_t total_space, int64_t available_space) { |
377 quota_status_ = status; | 367 total_space_ = total_space; |
378 available_space_ = available_space; | 368 available_space_ = available_space; |
379 } | 369 } |
380 | 370 |
381 void DidGetHostQuota(QuotaStatusCode status, int64_t quota) { | 371 void DidGetHostQuota(QuotaStatusCode status, int64_t quota) { |
382 quota_status_ = status; | 372 quota_status_ = status; |
383 quota_ = quota; | 373 quota_ = quota; |
384 } | 374 } |
385 | 375 |
386 void DidGetGlobalUsage(int64_t usage, int64_t unlimited_usage) { | 376 void DidGetGlobalUsage(int64_t usage, int64_t unlimited_usage) { |
387 usage_ = usage; | 377 usage_ = usage; |
388 unlimited_usage_ = unlimited_usage; | 378 unlimited_usage_ = unlimited_usage; |
389 } | 379 } |
390 | 380 |
391 void DidGetHostUsage(int64_t usage) { usage_ = usage; } | 381 void DidGetHostUsage(int64_t usage) { usage_ = usage; } |
392 | 382 |
393 void StatusCallback(QuotaStatusCode status) { | 383 void StatusCallback(QuotaStatusCode status) { |
394 ++status_callback_count_; | 384 ++status_callback_count_; |
395 quota_status_ = status; | 385 quota_status_ = status; |
396 } | 386 } |
397 | 387 |
398 void DidGetUsageAndQuotaForEviction(QuotaStatusCode status, | 388 void DidGetEvictionRoundInfo(QuotaStatusCode status, |
399 const UsageAndQuota& usage_and_quota) { | 389 const storage::QuotaSettings& settings, |
390 int64_t available_space, | |
391 int64_t total_space, | |
392 int64_t global_usage, | |
393 bool global_usage_is_complete) { | |
400 quota_status_ = status; | 394 quota_status_ = status; |
401 limited_usage_ = usage_and_quota.global_limited_usage; | 395 settings_ = settings; |
402 quota_ = usage_and_quota.quota; | 396 available_space_ = available_space; |
403 available_space_ = usage_and_quota.available_disk_space; | 397 total_space_ = total_space; |
398 usage_ = global_usage; | |
404 } | 399 } |
405 | 400 |
406 void DidGetEvictionOrigin(const GURL& origin) { | 401 void DidGetEvictionOrigin(const GURL& origin) { |
407 eviction_origin_ = origin; | 402 eviction_origin_ = origin; |
408 } | 403 } |
409 | 404 |
410 void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) { | 405 void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) { |
411 modified_origins_ = origins; | 406 modified_origins_ = origins; |
412 modified_origins_type_ = type; | 407 modified_origins_type_ = type; |
413 } | 408 } |
(...skipping 24 matching lines...) Expand all Loading... | |
438 MockSpecialStoragePolicy* mock_special_storage_policy() const { | 433 MockSpecialStoragePolicy* mock_special_storage_policy() const { |
439 return mock_special_storage_policy_.get(); | 434 return mock_special_storage_policy_.get(); |
440 } | 435 } |
441 | 436 |
442 QuotaStatusCode status() const { return quota_status_; } | 437 QuotaStatusCode status() const { return quota_status_; } |
443 const UsageInfoEntries& usage_info() const { return usage_info_; } | 438 const UsageInfoEntries& usage_info() const { return usage_info_; } |
444 int64_t usage() const { return usage_; } | 439 int64_t usage() const { return usage_; } |
445 int64_t limited_usage() const { return limited_usage_; } | 440 int64_t limited_usage() const { return limited_usage_; } |
446 int64_t unlimited_usage() const { return unlimited_usage_; } | 441 int64_t unlimited_usage() const { return unlimited_usage_; } |
447 int64_t quota() const { return quota_; } | 442 int64_t quota() const { return quota_; } |
443 int64_t total_space() const { return total_space_; } | |
448 int64_t available_space() const { return available_space_; } | 444 int64_t available_space() const { return available_space_; } |
449 const GURL& eviction_origin() const { return eviction_origin_; } | 445 const GURL& eviction_origin() const { return eviction_origin_; } |
450 const std::set<GURL>& modified_origins() const { return modified_origins_; } | 446 const std::set<GURL>& modified_origins() const { return modified_origins_; } |
451 StorageType modified_origins_type() const { return modified_origins_type_; } | 447 StorageType modified_origins_type() const { return modified_origins_type_; } |
452 const QuotaTableEntries& quota_entries() const { return quota_entries_; } | 448 const QuotaTableEntries& quota_entries() const { return quota_entries_; } |
453 const OriginInfoTableEntries& origin_info_entries() const { | 449 const OriginInfoTableEntries& origin_info_entries() const { |
454 return origin_info_entries_; | 450 return origin_info_entries_; |
455 } | 451 } |
452 const storage::QuotaSettings& settings() const { return settings_; } | |
456 base::FilePath profile_path() const { return data_dir_.GetPath(); } | 453 base::FilePath profile_path() const { return data_dir_.GetPath(); } |
457 int status_callback_count() const { return status_callback_count_; } | 454 int status_callback_count() const { return status_callback_count_; } |
458 void reset_status_callback_count() { status_callback_count_ = 0; } | 455 void reset_status_callback_count() { status_callback_count_ = 0; } |
459 | 456 |
460 private: | 457 private: |
461 base::Time IncrementMockTime() { | 458 base::Time IncrementMockTime() { |
462 ++mock_time_counter_; | 459 ++mock_time_counter_; |
463 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); | 460 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); |
464 } | 461 } |
465 | 462 |
466 base::MessageLoop message_loop_; | 463 base::MessageLoop message_loop_; |
467 base::ScopedTempDir data_dir_; | 464 base::ScopedTempDir data_dir_; |
468 | 465 |
469 scoped_refptr<QuotaManager> quota_manager_; | 466 scoped_refptr<QuotaManager> quota_manager_; |
470 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; | 467 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; |
471 | 468 |
472 QuotaStatusCode quota_status_; | 469 QuotaStatusCode quota_status_; |
473 UsageInfoEntries usage_info_; | 470 UsageInfoEntries usage_info_; |
474 int64_t usage_; | 471 int64_t usage_; |
475 int64_t limited_usage_; | 472 int64_t limited_usage_; |
476 int64_t unlimited_usage_; | 473 int64_t unlimited_usage_; |
477 int64_t quota_; | 474 int64_t quota_; |
475 int64_t total_space_; | |
478 int64_t available_space_; | 476 int64_t available_space_; |
479 GURL eviction_origin_; | 477 GURL eviction_origin_; |
480 std::set<GURL> modified_origins_; | 478 std::set<GURL> modified_origins_; |
481 StorageType modified_origins_type_; | 479 StorageType modified_origins_type_; |
482 QuotaTableEntries quota_entries_; | 480 QuotaTableEntries quota_entries_; |
483 OriginInfoTableEntries origin_info_entries_; | 481 OriginInfoTableEntries origin_info_entries_; |
482 storage::QuotaSettings settings_; | |
484 int status_callback_count_; | 483 int status_callback_count_; |
485 | 484 |
486 int additional_callback_count_; | 485 int additional_callback_count_; |
487 | 486 |
488 int mock_time_counter_; | 487 int mock_time_counter_; |
489 | 488 |
490 base::WeakPtrFactory<QuotaManagerTest> weak_factory_; | 489 base::WeakPtrFactory<QuotaManagerTest> weak_factory_; |
491 | 490 |
492 DISALLOW_COPY_AND_ASSIGN(QuotaManagerTest); | 491 DISALLOW_COPY_AND_ASSIGN(QuotaManagerTest); |
493 }; | 492 }; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 { "http://foo.com:8080/", kTemp, 20 }, | 625 { "http://foo.com:8080/", kTemp, 20 }, |
627 { "http://bar.com/", kTemp, 5 }, | 626 { "http://bar.com/", kTemp, 5 }, |
628 { "https://bar.com/", kTemp, 7 }, | 627 { "https://bar.com/", kTemp, 7 }, |
629 { "http://baz.com/", kTemp, 30 }, | 628 { "http://baz.com/", kTemp, 30 }, |
630 { "http://foo.com/", kPerm, 40 }, | 629 { "http://foo.com/", kPerm, 40 }, |
631 }; | 630 }; |
632 RegisterClient(CreateClient(kData, arraysize(kData), | 631 RegisterClient(CreateClient(kData, arraysize(kData), |
633 QuotaClient::kFileSystem)); | 632 QuotaClient::kFileSystem)); |
634 | 633 |
635 // This time explicitly sets a temporary global quota. | 634 // This time explicitly sets a temporary global quota. |
636 SetTemporaryGlobalQuota(100); | 635 const int kPoolSize = 100; |
637 base::RunLoop().RunUntilIdle(); | 636 const int kPerHostQuota = 20; |
638 EXPECT_EQ(kQuotaStatusOk, status()); | 637 SetQuotaSettings(kPoolSize, kPerHostQuota, kMustRemainAvailableForSystem); |
639 EXPECT_EQ(100, quota()); | |
640 | 638 |
641 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 639 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
642 base::RunLoop().RunUntilIdle(); | 640 base::RunLoop().RunUntilIdle(); |
643 EXPECT_EQ(kQuotaStatusOk, status()); | 641 EXPECT_EQ(kQuotaStatusOk, status()); |
644 EXPECT_EQ(10 + 20, usage()); | 642 EXPECT_EQ(10 + 20, usage()); |
645 | 643 |
646 const int kPerHostQuota = 100 / kPerHostTemporaryPortion; | |
647 | |
648 // The host's quota should be its full portion of the global quota | 644 // The host's quota should be its full portion of the global quota |
649 // since global usage is under the global quota. | 645 // since there's plenty of diskspace. |
650 EXPECT_EQ(kPerHostQuota, quota()); | 646 EXPECT_EQ(kPerHostQuota, quota()); |
651 | 647 |
652 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp); | 648 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp); |
653 base::RunLoop().RunUntilIdle(); | 649 base::RunLoop().RunUntilIdle(); |
654 EXPECT_EQ(kQuotaStatusOk, status()); | 650 EXPECT_EQ(kQuotaStatusOk, status()); |
655 EXPECT_EQ(5 + 7, usage()); | 651 EXPECT_EQ(5 + 7, usage()); |
656 EXPECT_EQ(kPerHostQuota, quota()); | 652 EXPECT_EQ(kPerHostQuota, quota()); |
657 } | 653 } |
658 | 654 |
659 TEST_F(QuotaManagerTest, GetUsage_MultipleClients) { | 655 TEST_F(QuotaManagerTest, GetUsage_MultipleClients) { |
660 static const MockOriginData kData1[] = { | 656 static const MockOriginData kData1[] = { |
661 { "http://foo.com/", kTemp, 1 }, | 657 { "http://foo.com/", kTemp, 1 }, |
662 { "http://bar.com/", kTemp, 2 }, | 658 { "http://bar.com/", kTemp, 2 }, |
663 { "http://bar.com/", kPerm, 4 }, | 659 { "http://bar.com/", kPerm, 4 }, |
664 { "http://unlimited/", kPerm, 8 }, | 660 { "http://unlimited/", kPerm, 8 }, |
665 { "http://installed/", kPerm, 16 }, | |
666 }; | 661 }; |
667 static const MockOriginData kData2[] = { | 662 static const MockOriginData kData2[] = { |
668 { "https://foo.com/", kTemp, 128 }, | 663 { "https://foo.com/", kTemp, 128 }, |
669 { "http://example.com/", kPerm, 256 }, | 664 { "http://example.com/", kPerm, 256 }, |
670 { "http://unlimited/", kTemp, 512 }, | 665 { "http://unlimited/", kTemp, 512 }, |
671 { "http://installed/", kTemp, 1024 }, | |
672 }; | 666 }; |
673 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); | 667 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); |
674 mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); | |
675 RegisterClient(CreateClient(kData1, arraysize(kData1), | 668 RegisterClient(CreateClient(kData1, arraysize(kData1), |
676 QuotaClient::kFileSystem)); | 669 QuotaClient::kFileSystem)); |
677 RegisterClient(CreateClient(kData2, arraysize(kData2), | 670 RegisterClient(CreateClient(kData2, arraysize(kData2), |
678 QuotaClient::kDatabase)); | 671 QuotaClient::kDatabase)); |
679 | 672 |
680 const int64_t kTempQuotaBase = | 673 const int64_t kPoolSize = GetAvailableDiskSpaceForTest(); |
681 GetAvailableDiskSpaceForTest() / kPerHostTemporaryPortion; | 674 const int64_t kPerHostQuota = kPoolSize / 5; |
675 SetQuotaSettings(kPoolSize, kPerHostQuota, kMustRemainAvailableForSystem); | |
682 | 676 |
683 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 677 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
684 base::RunLoop().RunUntilIdle(); | 678 base::RunLoop().RunUntilIdle(); |
685 EXPECT_EQ(kQuotaStatusOk, status()); | 679 EXPECT_EQ(kQuotaStatusOk, status()); |
686 EXPECT_EQ(1 + 128, usage()); | 680 EXPECT_EQ(1 + 128, usage()); |
681 EXPECT_EQ(kPerHostQuota, quota()); | |
687 | 682 |
688 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kPerm); | 683 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kPerm); |
689 base::RunLoop().RunUntilIdle(); | 684 base::RunLoop().RunUntilIdle(); |
690 EXPECT_EQ(kQuotaStatusOk, status()); | 685 EXPECT_EQ(kQuotaStatusOk, status()); |
691 EXPECT_EQ(4, usage()); | 686 EXPECT_EQ(4, usage()); |
687 EXPECT_EQ(0, quota()); | |
692 | 688 |
693 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp); | 689 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp); |
694 base::RunLoop().RunUntilIdle(); | 690 base::RunLoop().RunUntilIdle(); |
695 EXPECT_EQ(kQuotaStatusOk, status()); | 691 EXPECT_EQ(kQuotaStatusOk, status()); |
696 EXPECT_EQ(512, usage()); | 692 EXPECT_EQ(512, usage()); |
697 EXPECT_EQ(std::min(kAvailableSpaceForApp, kTempQuotaBase) + usage(), quota()); | 693 EXPECT_EQ(kAvailableSpaceForApp + usage(), quota()); |
698 | 694 |
699 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kPerm); | 695 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kPerm); |
700 base::RunLoop().RunUntilIdle(); | 696 base::RunLoop().RunUntilIdle(); |
701 EXPECT_EQ(kQuotaStatusOk, status()); | 697 EXPECT_EQ(kQuotaStatusOk, status()); |
702 EXPECT_EQ(8, usage()); | 698 EXPECT_EQ(8, usage()); |
703 EXPECT_EQ(kAvailableSpaceForApp + usage(), quota()); | 699 EXPECT_EQ(kAvailableSpaceForApp + usage(), quota()); |
704 | 700 |
705 GetAvailableSpace(); | |
706 base::RunLoop().RunUntilIdle(); | |
707 EXPECT_EQ(kQuotaStatusOk, status()); | |
708 EXPECT_LE(0, available_space()); | |
709 | |
710 GetUsageAndQuotaForWebApps(GURL("http://installed/"), kTemp); | |
711 base::RunLoop().RunUntilIdle(); | |
712 EXPECT_EQ(kQuotaStatusOk, status()); | |
713 EXPECT_EQ(1024, usage()); | |
714 EXPECT_EQ(std::min(kAvailableSpaceForApp, kTempQuotaBase) + usage(), quota()); | |
715 | |
716 GetUsageAndQuotaForWebApps(GURL("http://installed/"), kPerm); | |
717 base::RunLoop().RunUntilIdle(); | |
718 EXPECT_EQ(kQuotaStatusOk, status()); | |
719 EXPECT_EQ(16, usage()); | |
720 EXPECT_EQ(usage(), quota()); // Over-budget case. | |
721 | |
722 GetGlobalUsage(kTemp); | 701 GetGlobalUsage(kTemp); |
723 base::RunLoop().RunUntilIdle(); | 702 base::RunLoop().RunUntilIdle(); |
724 EXPECT_EQ(kQuotaStatusOk, status()); | 703 EXPECT_EQ(kQuotaStatusOk, status()); |
725 EXPECT_EQ(1 + 2 + 128 + 512 + 1024, usage()); | 704 EXPECT_EQ(1 + 2 + 128 + 512, usage()); |
726 EXPECT_EQ(512, unlimited_usage()); | 705 EXPECT_EQ(512, unlimited_usage()); |
727 | 706 |
728 GetGlobalUsage(kPerm); | 707 GetGlobalUsage(kPerm); |
729 base::RunLoop().RunUntilIdle(); | 708 base::RunLoop().RunUntilIdle(); |
730 EXPECT_EQ(kQuotaStatusOk, status()); | 709 EXPECT_EQ(kQuotaStatusOk, status()); |
731 EXPECT_EQ(4 + 8 + 16 + 256, usage()); | 710 EXPECT_EQ(4 + 8 + 256, usage()); |
732 EXPECT_EQ(8, unlimited_usage()); | 711 EXPECT_EQ(8, unlimited_usage()); |
733 } | 712 } |
734 | 713 |
735 void QuotaManagerTest::GetUsage_WithModifyTestBody(const StorageType type) { | 714 void QuotaManagerTest::GetUsage_WithModifyTestBody(const StorageType type) { |
736 const MockOriginData data[] = { | 715 const MockOriginData data[] = { |
737 { "http://foo.com/", type, 10 }, | 716 { "http://foo.com/", type, 10 }, |
738 { "http://foo.com:1/", type, 20 }, | 717 { "http://foo.com:1/", type, 20 }, |
739 }; | 718 }; |
740 MockStorageClient* client = CreateClient(data, arraysize(data), | 719 MockStorageClient* client = CreateClient(data, arraysize(data), |
741 QuotaClient::kFileSystem); | 720 QuotaClient::kFileSystem); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 | 753 |
775 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_WithAdditionalTasks) { | 754 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_WithAdditionalTasks) { |
776 static const MockOriginData kData[] = { | 755 static const MockOriginData kData[] = { |
777 { "http://foo.com/", kTemp, 10 }, | 756 { "http://foo.com/", kTemp, 10 }, |
778 { "http://foo.com:8080/", kTemp, 20 }, | 757 { "http://foo.com:8080/", kTemp, 20 }, |
779 { "http://bar.com/", kTemp, 13 }, | 758 { "http://bar.com/", kTemp, 13 }, |
780 { "http://foo.com/", kPerm, 40 }, | 759 { "http://foo.com/", kPerm, 40 }, |
781 }; | 760 }; |
782 RegisterClient(CreateClient(kData, arraysize(kData), | 761 RegisterClient(CreateClient(kData, arraysize(kData), |
783 QuotaClient::kFileSystem)); | 762 QuotaClient::kFileSystem)); |
784 SetTemporaryGlobalQuota(100); | |
785 base::RunLoop().RunUntilIdle(); | |
786 | 763 |
787 const int kPerHostQuota = 100 / QuotaManager::kPerHostTemporaryPortion; | 764 const int kPoolSize = 100; |
765 const int kPerHostQuota = 20; | |
766 SetQuotaSettings(kPoolSize, kPerHostQuota, kMustRemainAvailableForSystem); | |
788 | 767 |
789 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 768 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
790 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 769 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
791 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 770 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
792 base::RunLoop().RunUntilIdle(); | 771 base::RunLoop().RunUntilIdle(); |
793 EXPECT_EQ(kQuotaStatusOk, status()); | 772 EXPECT_EQ(kQuotaStatusOk, status()); |
794 EXPECT_EQ(10 + 20, usage()); | 773 EXPECT_EQ(10 + 20, usage()); |
795 EXPECT_EQ(kPerHostQuota, quota()); | 774 EXPECT_EQ(kPerHostQuota, quota()); |
796 | 775 |
797 set_additional_callback_count(0); | 776 set_additional_callback_count(0); |
(...skipping 10 matching lines...) Expand all Loading... | |
808 | 787 |
809 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_NukeManager) { | 788 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_NukeManager) { |
810 static const MockOriginData kData[] = { | 789 static const MockOriginData kData[] = { |
811 { "http://foo.com/", kTemp, 10 }, | 790 { "http://foo.com/", kTemp, 10 }, |
812 { "http://foo.com:8080/", kTemp, 20 }, | 791 { "http://foo.com:8080/", kTemp, 20 }, |
813 { "http://bar.com/", kTemp, 13 }, | 792 { "http://bar.com/", kTemp, 13 }, |
814 { "http://foo.com/", kPerm, 40 }, | 793 { "http://foo.com/", kPerm, 40 }, |
815 }; | 794 }; |
816 RegisterClient(CreateClient(kData, arraysize(kData), | 795 RegisterClient(CreateClient(kData, arraysize(kData), |
817 QuotaClient::kFileSystem)); | 796 QuotaClient::kFileSystem)); |
818 SetTemporaryGlobalQuota(100); | 797 const int kPoolSize = 100; |
819 base::RunLoop().RunUntilIdle(); | 798 const int kPerHostQuota = 20; |
799 SetQuotaSettings(kPoolSize, kPerHostQuota, kMustRemainAvailableForSystem); | |
820 | 800 |
821 set_additional_callback_count(0); | 801 set_additional_callback_count(0); |
822 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 802 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
823 RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"), | 803 RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"), |
824 kTemp); | 804 kTemp); |
825 RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), | 805 RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), |
826 kTemp); | 806 kTemp); |
827 | 807 |
828 DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients); | 808 DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients); |
829 DeleteOriginData(GURL("http://bar.com/"), kTemp, kAllClients); | 809 DeleteOriginData(GURL("http://bar.com/"), kTemp, kAllClients); |
830 | 810 |
831 // Nuke before waiting for callbacks. | 811 // Nuke before waiting for callbacks. |
832 set_quota_manager(NULL); | 812 set_quota_manager(NULL); |
833 base::RunLoop().RunUntilIdle(); | 813 base::RunLoop().RunUntilIdle(); |
834 EXPECT_EQ(kQuotaErrorAbort, status()); | 814 EXPECT_EQ(kQuotaErrorAbort, status()); |
835 } | 815 } |
836 | 816 |
837 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Overbudget) { | 817 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Overbudget) { |
838 static const MockOriginData kData[] = { | 818 static const MockOriginData kData[] = { |
839 { "http://usage1/", kTemp, 1 }, | 819 { "http://usage1/", kTemp, 1 }, |
840 { "http://usage10/", kTemp, 10 }, | 820 { "http://usage10/", kTemp, 10 }, |
841 { "http://usage200/", kTemp, 200 }, | 821 { "http://usage200/", kTemp, 200 }, |
842 }; | 822 }; |
843 RegisterClient(CreateClient(kData, arraysize(kData), | 823 RegisterClient(CreateClient(kData, arraysize(kData), |
844 QuotaClient::kFileSystem)); | 824 QuotaClient::kFileSystem)); |
845 SetTemporaryGlobalQuota(100); | 825 const int kPoolSize = 100; |
826 const int kPerHostQuota = 20; | |
827 SetQuotaSettings(kPoolSize, kPerHostQuota, kMustRemainAvailableForSystem); | |
828 | |
829 // Provided diskspace is not tight,. global usage does not affect the | |
kinuko
2016/11/14 14:50:20
nit: ,. -> ,
michaeln
2016/11/15 01:31:32
Done.
| |
830 // quota calculations for an individual origin, so despite global usage | |
831 // in excess of our poolsize, we still get the nominal quota value. | |
832 GetStorageCapacity(); | |
846 base::RunLoop().RunUntilIdle(); | 833 base::RunLoop().RunUntilIdle(); |
847 | 834 EXPECT_LE(kMustRemainAvailableForSystem, available_space()); |
848 const int kPerHostQuota = 100 / QuotaManager::kPerHostTemporaryPortion; | |
849 | 835 |
850 GetUsageAndQuotaForWebApps(GURL("http://usage1/"), kTemp); | 836 GetUsageAndQuotaForWebApps(GURL("http://usage1/"), kTemp); |
851 base::RunLoop().RunUntilIdle(); | 837 base::RunLoop().RunUntilIdle(); |
852 EXPECT_EQ(kQuotaStatusOk, status()); | 838 EXPECT_EQ(kQuotaStatusOk, status()); |
853 EXPECT_EQ(1, usage()); | 839 EXPECT_EQ(1, usage()); |
854 EXPECT_EQ(1, quota()); // should be clamped to our current usage | 840 EXPECT_EQ(kPerHostQuota, quota()); |
855 | 841 |
856 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); | 842 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); |
857 base::RunLoop().RunUntilIdle(); | 843 base::RunLoop().RunUntilIdle(); |
858 EXPECT_EQ(kQuotaStatusOk, status()); | 844 EXPECT_EQ(kQuotaStatusOk, status()); |
859 EXPECT_EQ(10, usage()); | 845 EXPECT_EQ(10, usage()); |
860 EXPECT_EQ(10, quota()); | 846 EXPECT_EQ(kPerHostQuota, quota()); |
861 | 847 |
862 GetUsageAndQuotaForWebApps(GURL("http://usage200/"), kTemp); | 848 GetUsageAndQuotaForWebApps(GURL("http://usage200/"), kTemp); |
863 base::RunLoop().RunUntilIdle(); | 849 base::RunLoop().RunUntilIdle(); |
864 EXPECT_EQ(kQuotaStatusOk, status()); | 850 EXPECT_EQ(kQuotaStatusOk, status()); |
865 EXPECT_EQ(200, usage()); | 851 EXPECT_EQ(200, usage()); |
866 EXPECT_EQ(kPerHostQuota, quota()); // should be clamped to the nominal quota | 852 EXPECT_EQ(kPerHostQuota, quota()); // should be clamped to the nominal quota |
867 } | 853 } |
868 | 854 |
869 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) { | 855 TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) { |
870 static const MockOriginData kData[] = { | 856 static const MockOriginData kData[] = { |
871 { "http://usage10/", kTemp, 10 }, | 857 { "http://usage10/", kTemp, 10 }, |
872 { "http://usage50/", kTemp, 50 }, | 858 { "http://usage50/", kTemp, 50 }, |
873 { "http://unlimited/", kTemp, 4000 }, | 859 { "http://unlimited/", kTemp, 4000 }, |
874 }; | 860 }; |
875 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); | 861 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); |
876 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 862 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
877 QuotaClient::kFileSystem); | 863 QuotaClient::kFileSystem); |
878 RegisterClient(client); | 864 RegisterClient(client); |
879 | 865 |
880 // Test when not overbugdet. | 866 // Test when not overbugdet. |
881 SetTemporaryGlobalQuota(1000); | 867 const int kPerHostQuotaFor1000 = 200; |
882 base::RunLoop().RunUntilIdle(); | 868 SetQuotaSettings(1000, kPerHostQuotaFor1000, kMustRemainAvailableForSystem); |
883 | 869 |
884 GetGlobalUsage(kTemp); | 870 GetGlobalUsage(kTemp); |
885 base::RunLoop().RunUntilIdle(); | 871 base::RunLoop().RunUntilIdle(); |
886 EXPECT_EQ(10 + 50 + 4000, usage()); | 872 EXPECT_EQ(10 + 50 + 4000, usage()); |
887 EXPECT_EQ(4000, unlimited_usage()); | 873 EXPECT_EQ(4000, unlimited_usage()); |
888 | 874 |
889 const int kPerHostQuotaFor1000 = | |
890 1000 / QuotaManager::kPerHostTemporaryPortion; | |
891 | |
892 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); | 875 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); |
893 base::RunLoop().RunUntilIdle(); | 876 base::RunLoop().RunUntilIdle(); |
894 EXPECT_EQ(kQuotaStatusOk, status()); | 877 EXPECT_EQ(kQuotaStatusOk, status()); |
895 EXPECT_EQ(10, usage()); | 878 EXPECT_EQ(10, usage()); |
896 EXPECT_EQ(kPerHostQuotaFor1000, quota()); | 879 EXPECT_EQ(kPerHostQuotaFor1000, quota()); |
897 | 880 |
898 GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp); | 881 GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp); |
899 base::RunLoop().RunUntilIdle(); | 882 base::RunLoop().RunUntilIdle(); |
900 EXPECT_EQ(kQuotaStatusOk, status()); | 883 EXPECT_EQ(kQuotaStatusOk, status()); |
901 EXPECT_EQ(50, usage()); | 884 EXPECT_EQ(50, usage()); |
902 EXPECT_EQ(kPerHostQuotaFor1000, quota()); | 885 EXPECT_EQ(kPerHostQuotaFor1000, quota()); |
903 | 886 |
904 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp); | 887 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp); |
905 base::RunLoop().RunUntilIdle(); | 888 base::RunLoop().RunUntilIdle(); |
906 EXPECT_EQ(kQuotaStatusOk, status()); | 889 EXPECT_EQ(kQuotaStatusOk, status()); |
907 EXPECT_EQ(4000, usage()); | 890 EXPECT_EQ(4000, usage()); |
908 EXPECT_EQ(kAvailableSpaceForApp + usage(), quota()); | 891 EXPECT_EQ(kAvailableSpaceForApp + usage(), quota()); |
909 | 892 |
910 GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kTemp); | 893 GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kTemp); |
911 base::RunLoop().RunUntilIdle(); | 894 base::RunLoop().RunUntilIdle(); |
912 EXPECT_EQ(kQuotaStatusOk, status()); | 895 EXPECT_EQ(kQuotaStatusOk, status()); |
913 EXPECT_EQ(0, usage()); | 896 EXPECT_EQ(0, usage()); |
914 EXPECT_EQ(QuotaManager::kNoLimit, quota()); | 897 EXPECT_EQ(QuotaManager::kNoLimit, quota()); |
915 | 898 |
916 // Test when overbugdet. | 899 // Test when overbugdet. |
917 SetTemporaryGlobalQuota(100); | 900 const int kPerHostQuotaFor100 = 20; |
918 base::RunLoop().RunUntilIdle(); | 901 SetQuotaSettings(100, kPerHostQuotaFor100, kMustRemainAvailableForSystem); |
919 | |
920 const int kPerHostQuotaFor100 = | |
921 100 / QuotaManager::kPerHostTemporaryPortion; | |
922 | 902 |
923 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); | 903 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); |
924 base::RunLoop().RunUntilIdle(); | 904 base::RunLoop().RunUntilIdle(); |
925 EXPECT_EQ(kQuotaStatusOk, status()); | 905 EXPECT_EQ(kQuotaStatusOk, status()); |
926 EXPECT_EQ(10, usage()); | 906 EXPECT_EQ(10, usage()); |
927 EXPECT_EQ(kPerHostQuotaFor100, quota()); | 907 EXPECT_EQ(kPerHostQuotaFor100, quota()); |
928 | 908 |
929 GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp); | 909 GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp); |
930 base::RunLoop().RunUntilIdle(); | 910 base::RunLoop().RunUntilIdle(); |
931 EXPECT_EQ(kQuotaStatusOk, status()); | 911 EXPECT_EQ(kQuotaStatusOk, status()); |
(...skipping 18 matching lines...) Expand all Loading... | |
950 | 930 |
951 GetGlobalUsage(kTemp); | 931 GetGlobalUsage(kTemp); |
952 base::RunLoop().RunUntilIdle(); | 932 base::RunLoop().RunUntilIdle(); |
953 EXPECT_EQ(10 + 50 + 4000, usage()); | 933 EXPECT_EQ(10 + 50 + 4000, usage()); |
954 EXPECT_EQ(0, unlimited_usage()); | 934 EXPECT_EQ(0, unlimited_usage()); |
955 | 935 |
956 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); | 936 GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp); |
957 base::RunLoop().RunUntilIdle(); | 937 base::RunLoop().RunUntilIdle(); |
958 EXPECT_EQ(kQuotaStatusOk, status()); | 938 EXPECT_EQ(kQuotaStatusOk, status()); |
959 EXPECT_EQ(10, usage()); | 939 EXPECT_EQ(10, usage()); |
960 EXPECT_EQ(10, quota()); // should be clamped to our current usage | 940 EXPECT_EQ(kPerHostQuotaFor100, quota()); |
961 | 941 |
962 GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp); | 942 GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp); |
963 base::RunLoop().RunUntilIdle(); | 943 base::RunLoop().RunUntilIdle(); |
964 EXPECT_EQ(kQuotaStatusOk, status()); | 944 EXPECT_EQ(kQuotaStatusOk, status()); |
965 EXPECT_EQ(50, usage()); | 945 EXPECT_EQ(50, usage()); |
966 EXPECT_EQ(kPerHostQuotaFor100, quota()); | 946 EXPECT_EQ(kPerHostQuotaFor100, quota()); |
967 | 947 |
968 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp); | 948 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp); |
969 base::RunLoop().RunUntilIdle(); | 949 base::RunLoop().RunUntilIdle(); |
970 EXPECT_EQ(kQuotaStatusOk, status()); | 950 EXPECT_EQ(kQuotaStatusOk, status()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1036 EXPECT_EQ(0, usage()); | 1016 EXPECT_EQ(0, usage()); |
1037 EXPECT_EQ(0, quota()); | 1017 EXPECT_EQ(0, quota()); |
1038 | 1018 |
1039 SetPersistentHostQuota("foo.com", 100); | 1019 SetPersistentHostQuota("foo.com", 100); |
1040 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); | 1020 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); |
1041 base::RunLoop().RunUntilIdle(); | 1021 base::RunLoop().RunUntilIdle(); |
1042 EXPECT_EQ(kQuotaStatusOk, status()); | 1022 EXPECT_EQ(kQuotaStatusOk, status()); |
1043 EXPECT_EQ(0, usage()); | 1023 EXPECT_EQ(0, usage()); |
1044 EXPECT_EQ(100, quota()); | 1024 EXPECT_EQ(100, quota()); |
1045 | 1025 |
1046 // For installed app GetUsageAndQuotaForWebApps returns the capped quota. | 1026 // The actual space avaialble is given to 'unlimited' origins as their quota. |
1047 mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); | |
1048 SetPersistentHostQuota("installed", kAvailableSpaceForApp + 100); | |
1049 GetUsageAndQuotaForWebApps(GURL("http://installed/"), kPerm); | |
1050 base::RunLoop().RunUntilIdle(); | |
1051 EXPECT_EQ(kAvailableSpaceForApp, quota()); | |
1052 | |
1053 // Ditto for unlimited apps. | |
1054 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); | 1027 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); |
1055 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kPerm); | 1028 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kPerm); |
1056 base::RunLoop().RunUntilIdle(); | 1029 base::RunLoop().RunUntilIdle(); |
1057 EXPECT_EQ(kAvailableSpaceForApp, quota()); | 1030 EXPECT_EQ(kAvailableSpaceForApp, quota()); |
1058 | 1031 |
1059 // GetUsageAndQuotaForStorageClient should just return 0 usage and | 1032 // GetUsageAndQuotaForStorageClient should just return 0 usage and |
1060 // kNoLimit quota. | 1033 // kNoLimit quota. |
1061 GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kPerm); | 1034 GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kPerm); |
1062 base::RunLoop().RunUntilIdle(); | 1035 base::RunLoop().RunUntilIdle(); |
1063 EXPECT_EQ(0, usage()); | 1036 EXPECT_EQ(0, usage()); |
1064 EXPECT_EQ(QuotaManager::kNoLimit, quota()); | 1037 EXPECT_EQ(QuotaManager::kNoLimit, quota()); |
1065 } | 1038 } |
1066 | 1039 |
1067 TEST_F(QuotaManagerTest, GetSyncableQuota) { | 1040 TEST_F(QuotaManagerTest, GetSyncableQuota) { |
1068 RegisterClient(CreateClient(NULL, 0, QuotaClient::kFileSystem)); | 1041 RegisterClient(CreateClient(NULL, 0, QuotaClient::kFileSystem)); |
1069 | 1042 |
1070 // Pre-condition check: available disk space (for testing) is less than | 1043 // Pre-condition check: available disk space (for testing) is less than |
1071 // the default quota for syncable storage. | 1044 // the default quota for syncable storage. |
1072 EXPECT_LE(kAvailableSpaceForApp, | 1045 EXPECT_LE(kAvailableSpaceForApp, |
1073 QuotaManager::kSyncableStorageDefaultHostQuota); | 1046 QuotaManager::kSyncableStorageDefaultHostQuota); |
1074 | 1047 |
1075 // For installed apps the quota manager should return | 1048 // For unlimited origins the quota manager should return |
1076 // kAvailableSpaceForApp as syncable quota (because of the pre-condition). | 1049 // kAvailableSpaceForApp as syncable quota (because of the pre-condition). |
1077 mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); | 1050 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); |
1078 GetUsageAndQuotaForWebApps(GURL("http://installed/"), kSync); | 1051 GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kSync); |
1079 base::RunLoop().RunUntilIdle(); | 1052 base::RunLoop().RunUntilIdle(); |
1080 EXPECT_EQ(kQuotaStatusOk, status()); | 1053 EXPECT_EQ(kQuotaStatusOk, status()); |
1081 EXPECT_EQ(0, usage()); | 1054 EXPECT_EQ(0, usage()); |
1082 EXPECT_EQ(kAvailableSpaceForApp, quota()); | 1055 EXPECT_EQ(kAvailableSpaceForApp, quota()); |
1083 | |
1084 // If it's not installed (which shouldn't happen in real case) it | |
1085 // should just return the default host quota for syncable. | |
1086 GetUsageAndQuotaForWebApps(GURL("http://foo/"), kSync); | |
1087 base::RunLoop().RunUntilIdle(); | |
1088 EXPECT_EQ(kQuotaStatusOk, status()); | |
1089 EXPECT_EQ(0, usage()); | |
1090 EXPECT_EQ(QuotaManager::kSyncableStorageDefaultHostQuota, quota()); | |
1091 } | 1056 } |
1092 | 1057 |
1093 TEST_F(QuotaManagerTest, GetPersistentUsageAndQuota_MultiOrigins) { | 1058 TEST_F(QuotaManagerTest, GetPersistentUsageAndQuota_MultiOrigins) { |
1094 static const MockOriginData kData[] = { | 1059 static const MockOriginData kData[] = { |
1095 { "http://foo.com/", kPerm, 10 }, | 1060 { "http://foo.com/", kPerm, 10 }, |
1096 { "http://foo.com:8080/", kPerm, 20 }, | 1061 { "http://foo.com:8080/", kPerm, 20 }, |
1097 { "https://foo.com/", kPerm, 13 }, | 1062 { "https://foo.com/", kPerm, 13 }, |
1098 { "https://foo.com:8081/", kPerm, 19 }, | 1063 { "https://foo.com:8081/", kPerm, 19 }, |
1099 { "http://bar.com/", kPerm, 5 }, | 1064 { "http://bar.com/", kPerm, 5 }, |
1100 { "https://bar.com/", kPerm, 7 }, | 1065 { "https://bar.com/", kPerm, 7 }, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 | 1252 |
1288 GetHostUsage("foo.com", kTemp); | 1253 GetHostUsage("foo.com", kTemp); |
1289 base::RunLoop().RunUntilIdle(); | 1254 base::RunLoop().RunUntilIdle(); |
1290 EXPECT_EQ(predelete_host_tmp - 1, usage()); | 1255 EXPECT_EQ(predelete_host_tmp - 1, usage()); |
1291 | 1256 |
1292 GetHostUsage("foo.com", kPerm); | 1257 GetHostUsage("foo.com", kPerm); |
1293 base::RunLoop().RunUntilIdle(); | 1258 base::RunLoop().RunUntilIdle(); |
1294 EXPECT_EQ(predelete_host_pers, usage()); | 1259 EXPECT_EQ(predelete_host_pers, usage()); |
1295 } | 1260 } |
1296 | 1261 |
1297 TEST_F(QuotaManagerTest, GetAvailableSpaceTest) { | 1262 TEST_F(QuotaManagerTest, GetStorageCapacity) { |
1298 GetAvailableSpace(); | 1263 GetStorageCapacity(); |
1299 base::RunLoop().RunUntilIdle(); | 1264 base::RunLoop().RunUntilIdle(); |
1300 EXPECT_EQ(kQuotaStatusOk, status()); | 1265 EXPECT_LE(0, total_space()); |
1301 EXPECT_LE(0, available_space()); | 1266 EXPECT_LE(0, available_space()); |
1302 } | 1267 } |
1303 | 1268 |
1304 TEST_F(QuotaManagerTest, SetTemporaryStorageEvictionPolicy) { | 1269 TEST_F(QuotaManagerTest, SetTemporaryStorageEvictionPolicy) { |
1305 quota_manager()->SetTemporaryStorageEvictionPolicy( | 1270 quota_manager()->SetTemporaryStorageEvictionPolicy( |
1306 base::WrapUnique(new TestEvictionPolicy)); | 1271 base::WrapUnique(new TestEvictionPolicy)); |
1307 | 1272 |
1308 GetEvictionOrigin(kTemp); | 1273 GetEvictionOrigin(kTemp); |
1309 base::RunLoop().RunUntilIdle(); | 1274 base::RunLoop().RunUntilIdle(); |
1310 EXPECT_EQ(kTestEvictionOrigin, eviction_origin()); | 1275 EXPECT_EQ(kTestEvictionOrigin, eviction_origin()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1522 | 1487 |
1523 GetHostUsage("foo.com", kTemp); | 1488 GetHostUsage("foo.com", kTemp); |
1524 base::RunLoop().RunUntilIdle(); | 1489 base::RunLoop().RunUntilIdle(); |
1525 EXPECT_EQ(predelete_host_tmp, usage()); | 1490 EXPECT_EQ(predelete_host_tmp, usage()); |
1526 | 1491 |
1527 GetHostUsage("foo.com", kPerm); | 1492 GetHostUsage("foo.com", kPerm); |
1528 base::RunLoop().RunUntilIdle(); | 1493 base::RunLoop().RunUntilIdle(); |
1529 EXPECT_EQ(predelete_host_pers, usage()); | 1494 EXPECT_EQ(predelete_host_pers, usage()); |
1530 } | 1495 } |
1531 | 1496 |
1532 TEST_F(QuotaManagerTest, GetUsageAndQuotaForEviction) { | 1497 TEST_F(QuotaManagerTest, GetEvictionRoundInfo) { |
1533 static const MockOriginData kData[] = { | 1498 static const MockOriginData kData[] = { |
1534 { "http://foo.com/", kTemp, 1 }, | 1499 { "http://foo.com/", kTemp, 1 }, |
1535 { "http://foo.com:1/", kTemp, 20 }, | 1500 { "http://foo.com:1/", kTemp, 20 }, |
1536 { "http://foo.com/", kPerm, 300 }, | 1501 { "http://foo.com/", kPerm, 300 }, |
1537 { "http://unlimited/", kTemp, 4000 }, | 1502 { "http://unlimited/", kTemp, 4000 }, |
1538 }; | 1503 }; |
1539 | 1504 |
1540 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); | 1505 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); |
1541 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1506 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
1542 QuotaClient::kFileSystem); | 1507 QuotaClient::kFileSystem); |
1543 RegisterClient(client); | 1508 RegisterClient(client); |
1544 | 1509 |
1545 SetTemporaryGlobalQuota(10000000); | 1510 const int kPoolSize = 10000000; |
1546 base::RunLoop().RunUntilIdle(); | 1511 const int kPerHostQuota = kPoolSize / 5; |
1512 SetQuotaSettings(kPoolSize, kPerHostQuota, kMustRemainAvailableForSystem); | |
1547 | 1513 |
1548 GetUsageAndQuotaForEviction(); | 1514 GetEvictionRoundInfo(); |
1549 base::RunLoop().RunUntilIdle(); | 1515 base::RunLoop().RunUntilIdle(); |
1550 EXPECT_EQ(kQuotaStatusOk, status()); | 1516 EXPECT_EQ(kQuotaStatusOk, status()); |
1551 EXPECT_EQ(21, limited_usage()); | 1517 EXPECT_EQ(21, usage()); |
1552 EXPECT_EQ(10000000, quota()); | 1518 EXPECT_EQ(kPoolSize, settings().pool_size); |
1553 EXPECT_LE(0, available_space()); | 1519 EXPECT_LE(0, available_space()); |
1554 } | 1520 } |
1555 | 1521 |
1556 TEST_F(QuotaManagerTest, DeleteHostDataSimple) { | 1522 TEST_F(QuotaManagerTest, DeleteHostDataSimple) { |
1557 static const MockOriginData kData[] = { | 1523 static const MockOriginData kData[] = { |
1558 { "http://foo.com/", kTemp, 1 }, | 1524 { "http://foo.com/", kTemp, 1 }, |
1559 }; | 1525 }; |
1560 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1526 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
1561 QuotaClient::kFileSystem); | 1527 QuotaClient::kFileSystem); |
1562 RegisterClient(client); | 1528 RegisterClient(client); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1761 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
1796 QuotaClient::kFileSystem); | 1762 QuotaClient::kFileSystem); |
1797 RegisterClient(client); | 1763 RegisterClient(client); |
1798 | 1764 |
1799 // TODO(kinuko): Be careful when we add cache pruner. | 1765 // TODO(kinuko): Be careful when we add cache pruner. |
1800 | 1766 |
1801 std::set<GURL> origins; | 1767 std::set<GURL> origins; |
1802 GetCachedOrigins(kTemp, &origins); | 1768 GetCachedOrigins(kTemp, &origins); |
1803 EXPECT_TRUE(origins.empty()); | 1769 EXPECT_TRUE(origins.empty()); |
1804 | 1770 |
1805 // No matter how we make queries the quota manager tries to cache all | |
1806 // the origins at startup. | |
1807 GetHostUsage("a.com", kTemp); | 1771 GetHostUsage("a.com", kTemp); |
1808 base::RunLoop().RunUntilIdle(); | 1772 base::RunLoop().RunUntilIdle(); |
1809 GetCachedOrigins(kTemp, &origins); | 1773 GetCachedOrigins(kTemp, &origins); |
1810 EXPECT_EQ(3U, origins.size()); | 1774 EXPECT_EQ(2U, origins.size()); |
1811 | 1775 |
1812 GetHostUsage("b.com", kTemp); | 1776 GetHostUsage("b.com", kTemp); |
1813 base::RunLoop().RunUntilIdle(); | 1777 base::RunLoop().RunUntilIdle(); |
1814 GetCachedOrigins(kTemp, &origins); | 1778 GetCachedOrigins(kTemp, &origins); |
1779 EXPECT_EQ(2U, origins.size()); | |
1780 | |
1781 GetHostUsage("c.com", kTemp); | |
1782 base::RunLoop().RunUntilIdle(); | |
1783 GetCachedOrigins(kTemp, &origins); | |
1815 EXPECT_EQ(3U, origins.size()); | 1784 EXPECT_EQ(3U, origins.size()); |
1816 | 1785 |
1817 GetCachedOrigins(kPerm, &origins); | 1786 GetCachedOrigins(kPerm, &origins); |
1818 EXPECT_TRUE(origins.empty()); | 1787 EXPECT_TRUE(origins.empty()); |
1819 | 1788 |
1820 GetGlobalUsage(kTemp); | 1789 GetGlobalUsage(kTemp); |
1821 base::RunLoop().RunUntilIdle(); | 1790 base::RunLoop().RunUntilIdle(); |
1822 GetCachedOrigins(kTemp, &origins); | 1791 GetCachedOrigins(kTemp, &origins); |
1823 EXPECT_EQ(3U, origins.size()); | 1792 EXPECT_EQ(3U, origins.size()); |
1824 | 1793 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2261 TEST_F(QuotaManagerTest, GetUsageAndQuota_Incognito) { | 2230 TEST_F(QuotaManagerTest, GetUsageAndQuota_Incognito) { |
2262 ResetQuotaManager(true); | 2231 ResetQuotaManager(true); |
2263 | 2232 |
2264 static const MockOriginData kData[] = { | 2233 static const MockOriginData kData[] = { |
2265 { "http://foo.com/", kTemp, 10 }, | 2234 { "http://foo.com/", kTemp, 10 }, |
2266 { "http://foo.com/", kPerm, 80 }, | 2235 { "http://foo.com/", kPerm, 80 }, |
2267 }; | 2236 }; |
2268 RegisterClient(CreateClient(kData, arraysize(kData), | 2237 RegisterClient(CreateClient(kData, arraysize(kData), |
2269 QuotaClient::kFileSystem)); | 2238 QuotaClient::kFileSystem)); |
2270 | 2239 |
2240 // Query global usage to warmup the usage tracker caching. | |
2241 GetGlobalUsage(kTemp); | |
2242 GetGlobalUsage(kPerm); | |
2243 base::RunLoop().RunUntilIdle(); | |
2244 | |
2271 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); | 2245 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); |
2272 base::RunLoop().RunUntilIdle(); | 2246 base::RunLoop().RunUntilIdle(); |
2273 EXPECT_EQ(kQuotaStatusOk, status()); | 2247 EXPECT_EQ(kQuotaStatusOk, status()); |
2274 EXPECT_EQ(80, usage()); | 2248 EXPECT_EQ(80, usage()); |
2275 EXPECT_EQ(0, quota()); | 2249 EXPECT_EQ(0, quota()); |
2276 | 2250 |
2277 SetTemporaryGlobalQuota(100); | 2251 const int kPoolSize = 1000; |
2252 const int kPerHostQuota = kPoolSize / 5; | |
2253 SetQuotaSettings(kPoolSize, kPerHostQuota, INT64_C(0)); | |
2254 | |
2255 GetStorageCapacity(); | |
2256 base::RunLoop().RunUntilIdle(); | |
2257 EXPECT_EQ(kPoolSize, total_space()); | |
2258 EXPECT_EQ(kPoolSize - 80 - 10, available_space()); | |
2259 | |
2278 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2260 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
2279 base::RunLoop().RunUntilIdle(); | 2261 base::RunLoop().RunUntilIdle(); |
2280 EXPECT_EQ(kQuotaStatusOk, status()); | 2262 EXPECT_EQ(kQuotaStatusOk, status()); |
2281 EXPECT_EQ(10, usage()); | 2263 EXPECT_EQ(10, usage()); |
2282 EXPECT_LE(std::min(static_cast<int64_t>(100 / kPerHostTemporaryPortion), | 2264 EXPECT_LE(kPerHostQuota, quota()); |
2283 QuotaManager::kIncognitoDefaultQuotaLimit), | |
2284 quota()); | |
2285 | 2265 |
2286 mock_special_storage_policy()->AddUnlimited(GURL("http://foo.com/")); | 2266 mock_special_storage_policy()->AddUnlimited(GURL("http://foo.com/")); |
2287 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); | 2267 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); |
2288 base::RunLoop().RunUntilIdle(); | 2268 base::RunLoop().RunUntilIdle(); |
2289 EXPECT_EQ(kQuotaStatusOk, status()); | 2269 EXPECT_EQ(kQuotaStatusOk, status()); |
2290 EXPECT_EQ(80, usage()); | 2270 EXPECT_EQ(80, usage()); |
2291 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2271 EXPECT_EQ(available_space() + usage(), quota()); |
2292 | 2272 |
2293 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2273 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
2294 base::RunLoop().RunUntilIdle(); | 2274 base::RunLoop().RunUntilIdle(); |
2295 EXPECT_EQ(kQuotaStatusOk, status()); | 2275 EXPECT_EQ(kQuotaStatusOk, status()); |
2296 EXPECT_EQ(10, usage()); | 2276 EXPECT_EQ(10, usage()); |
2297 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2277 EXPECT_EQ(available_space() + usage(), quota()); |
2298 } | |
2299 | |
2300 TEST_F(QuotaManagerTest, GetVolumeInfo) { | |
2301 // We aren't actually testing that it's correct, just that it's sane. | |
2302 base::FilePath tmp_dir; | |
2303 ASSERT_TRUE(base::GetTempDir(&tmp_dir)); | |
2304 uint64_t available_space = 0; | |
2305 uint64_t total_size = 0; | |
2306 EXPECT_TRUE(GetVolumeInfo(tmp_dir, &available_space, &total_size)); | |
2307 EXPECT_GT(available_space, 0u) << tmp_dir.value(); | |
2308 EXPECT_GT(total_size, 0u) << tmp_dir.value(); | |
2309 } | 2278 } |
2310 | 2279 |
2311 } // namespace content | 2280 } // namespace content |
OLD | NEW |