Chromium Code Reviews| 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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <set> | 8 #include <set> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 #include "content/common/notification_service.h" | 58 #include "content/common/notification_service.h" | 
| 59 #include "content/common/notification_type.h" | 59 #include "content/common/notification_type.h" | 
| 60 #include "googleurl/src/gurl.h" | 60 #include "googleurl/src/gurl.h" | 
| 61 #include "net/base/cookie_monster.h" | 61 #include "net/base/cookie_monster.h" | 
| 62 #include "net/base/cookie_options.h" | 62 #include "net/base/cookie_options.h" | 
| 63 #include "net/url_request/url_request_context.h" | 63 #include "net/url_request/url_request_context.h" | 
| 64 #include "net/url_request/url_request_context_getter.h" | 64 #include "net/url_request/url_request_context_getter.h" | 
| 65 #include "testing/gtest/include/gtest/gtest.h" | 65 #include "testing/gtest/include/gtest/gtest.h" | 
| 66 #include "testing/platform_test.h" | 66 #include "testing/platform_test.h" | 
| 67 #include "webkit/database/database_tracker.h" | 67 #include "webkit/database/database_tracker.h" | 
| 68 #include "webkit/database/database_util.h" | 68 #include "webkit/database/database_util.h" | 
| 
 
michaeln
2011/05/26 00:17:26
remove some includes
 
 | |
| 69 #include "webkit/quota/quota_manager.h" | 69 #include "webkit/quota/quota_manager.h" | 
| 70 | 70 | 
| 71 namespace keys = extension_manifest_keys; | 71 namespace keys = extension_manifest_keys; | 
| 72 | 72 | 
| 73 namespace { | 73 namespace { | 
| 74 | 74 | 
| 75 // Extension ids used during testing. | 75 // Extension ids used during testing. | 
| 76 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 76 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 
| 77 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; | 77 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; | 
| 78 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 78 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 
| (...skipping 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3344 extensions_path.AppendASCII("unlimited_quota") | 3344 extensions_path.AppendASCII("unlimited_quota") | 
| 3345 .AppendASCII("2.0"); | 3345 .AppendASCII("2.0"); | 
| 3346 service_->LoadExtension(limited_quota_ext); | 3346 service_->LoadExtension(limited_quota_ext); | 
| 3347 service_->LoadExtension(unlimited_quota_ext); | 3347 service_->LoadExtension(unlimited_quota_ext); | 
| 3348 service_->LoadExtension(unlimited_quota_ext2); | 3348 service_->LoadExtension(unlimited_quota_ext2); | 
| 3349 loop_.RunAllPending(); | 3349 loop_.RunAllPending(); | 
| 3350 | 3350 | 
| 3351 ASSERT_EQ(3u, loaded_.size()); | 3351 ASSERT_EQ(3u, loaded_.size()); | 
| 3352 EXPECT_TRUE(profile_.get()); | 3352 EXPECT_TRUE(profile_.get()); | 
| 3353 EXPECT_FALSE(profile_->IsOffTheRecord()); | 3353 EXPECT_FALSE(profile_->IsOffTheRecord()); | 
| 3354 | 3354 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( | 
| 3355 // Open the database from each origin to make the tracker aware | 3355 loaded_[0]->url())); | 
| 3356 // of the existence of these origins and to get their quotas. | 3356 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( | 
| 3357 int64 limited_quota = -1; | 3357 loaded_[1]->url())); | 
| 3358 int64 unlimited_quota = -1; | 3358 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( | 
| 3359 string16 limited_quota_identifier = | 3359 loaded_[2]->url())); | 
| 3360 webkit_database::DatabaseUtil::GetOriginIdentifier(loaded_[0]->url()); | |
| 3361 string16 unlimited_quota_identifier = | |
| 3362 webkit_database::DatabaseUtil::GetOriginIdentifier(loaded_[1]->url()); | |
| 3363 string16 unlimited_quota_identifier2 = | |
| 3364 webkit_database::DatabaseUtil::GetOriginIdentifier(loaded_[2]->url()); | |
| 3365 string16 db_name = UTF8ToUTF16("db"); | |
| 3366 string16 description = UTF8ToUTF16("db_description"); | |
| 3367 int64 database_size; | |
| 3368 webkit_database::DatabaseTracker* db_tracker = profile_->GetDatabaseTracker(); | |
| 3369 | |
| 3370 // First check the normal limited quota extension. | |
| 3371 db_tracker->DatabaseOpened(limited_quota_identifier, db_name, description, | |
| 3372 1, &database_size, &limited_quota); | |
| 3373 db_tracker->DatabaseClosed(limited_quota_identifier, db_name); | |
| 3374 EXPECT_EQ(profile_->GetDatabaseTracker()->GetDefaultQuota(), limited_quota); | |
| 3375 | |
| 3376 // Now check the two unlimited quota ones. | |
| 3377 db_tracker->DatabaseOpened(unlimited_quota_identifier, db_name, description, | |
| 3378 1, &database_size, &unlimited_quota); | |
| 3379 db_tracker->DatabaseClosed(unlimited_quota_identifier, db_name); | |
| 3380 EXPECT_EQ(kint64max, unlimited_quota); | |
| 3381 db_tracker->DatabaseOpened(unlimited_quota_identifier2, db_name, description, | |
| 3382 1, &database_size, &unlimited_quota); | |
| 3383 db_tracker->DatabaseClosed(unlimited_quota_identifier2, db_name); | |
| 3384 | |
| 3385 EXPECT_EQ(kint64max, unlimited_quota); | |
| 3386 } | 3360 } | 
| 3387 | 3361 | 
| 3388 // Tests ExtensionService::register_component_extension(). | 3362 // Tests ExtensionService::register_component_extension(). | 
| 3389 TEST_F(ExtensionServiceTest, ComponentExtensions) { | 3363 TEST_F(ExtensionServiceTest, ComponentExtensions) { | 
| 3390 InitializeEmptyExtensionService(); | 3364 InitializeEmptyExtensionService(); | 
| 3391 | 3365 | 
| 3392 // Component extensions should work even when extensions are disabled. | 3366 // Component extensions should work even when extensions are disabled. | 
| 3393 set_extensions_enabled(false); | 3367 set_extensions_enabled(false); | 
| 3394 | 3368 | 
| 3395 FilePath path = data_dir_ | 3369 FilePath path = data_dir_ | 
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3828 ASSERT_FALSE(AddPendingSyncInstall()); | 3802 ASSERT_FALSE(AddPendingSyncInstall()); | 
| 3829 | 3803 | 
| 3830 // Wait for the external source to install. | 3804 // Wait for the external source to install. | 
| 3831 WaitForCrxInstall(crx_path_, true); | 3805 WaitForCrxInstall(crx_path_, true); | 
| 3832 ASSERT_TRUE(IsCrxInstalled()); | 3806 ASSERT_TRUE(IsCrxInstalled()); | 
| 3833 | 3807 | 
| 3834 // Now that the extension is installed, sync request should fail | 3808 // Now that the extension is installed, sync request should fail | 
| 3835 // because the extension is already installed. | 3809 // because the extension is already installed. | 
| 3836 ASSERT_FALSE(AddPendingSyncInstall()); | 3810 ASSERT_FALSE(AddPendingSyncInstall()); | 
| 3837 } | 3811 } | 
| OLD | NEW |