Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1020)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 7056025: More WebSQLDatabase and QuotaManager integration. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 net::CookieOptions options; 2691 net::CookieOptions options;
2692 cookie_monster->SetCookieWithOptions(ext_url, "dummy=value", options); 2692 cookie_monster->SetCookieWithOptions(ext_url, "dummy=value", options);
2693 net::CookieList list = cookie_monster->GetAllCookiesForURL(ext_url); 2693 net::CookieList list = cookie_monster->GetAllCookiesForURL(ext_url);
2694 EXPECT_EQ(1U, list.size()); 2694 EXPECT_EQ(1U, list.size());
2695 2695
2696 // Open a database. 2696 // Open a database.
2697 webkit_database::DatabaseTracker* db_tracker = profile_->GetDatabaseTracker(); 2697 webkit_database::DatabaseTracker* db_tracker = profile_->GetDatabaseTracker();
2698 string16 db_name = UTF8ToUTF16("db"); 2698 string16 db_name = UTF8ToUTF16("db");
2699 string16 description = UTF8ToUTF16("db_description"); 2699 string16 description = UTF8ToUTF16("db_description");
2700 int64 size; 2700 int64 size;
2701 int64 available; 2701 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size);
2702 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size,
2703 &available);
2704 db_tracker->DatabaseClosed(origin_id, db_name); 2702 db_tracker->DatabaseClosed(origin_id, db_name);
2705 std::vector<webkit_database::OriginInfo> origins; 2703 std::vector<webkit_database::OriginInfo> origins;
2706 db_tracker->GetAllOriginsInfo(&origins); 2704 db_tracker->GetAllOriginsInfo(&origins);
2707 EXPECT_EQ(1U, origins.size()); 2705 EXPECT_EQ(1U, origins.size());
2708 EXPECT_EQ(origin_id, origins[0].GetOrigin()); 2706 EXPECT_EQ(origin_id, origins[0].GetOrigin());
2709 2707
2710 // Create local storage. We only simulate this by creating the backing file 2708 // Create local storage. We only simulate this by creating the backing file
2711 // since webkit is not initialized. 2709 // since webkit is not initialized.
2712 DOMStorageContext* context = 2710 DOMStorageContext* context =
2713 profile_->GetWebKitContext()->dom_storage_context(); 2711 profile_->GetWebKitContext()->dom_storage_context();
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
3344 extensions_path.AppendASCII("unlimited_quota") 3342 extensions_path.AppendASCII("unlimited_quota")
3345 .AppendASCII("2.0"); 3343 .AppendASCII("2.0");
3346 service_->LoadExtension(limited_quota_ext); 3344 service_->LoadExtension(limited_quota_ext);
3347 service_->LoadExtension(unlimited_quota_ext); 3345 service_->LoadExtension(unlimited_quota_ext);
3348 service_->LoadExtension(unlimited_quota_ext2); 3346 service_->LoadExtension(unlimited_quota_ext2);
3349 loop_.RunAllPending(); 3347 loop_.RunAllPending();
3350 3348
3351 ASSERT_EQ(3u, loaded_.size()); 3349 ASSERT_EQ(3u, loaded_.size());
3352 EXPECT_TRUE(profile_.get()); 3350 EXPECT_TRUE(profile_.get());
3353 EXPECT_FALSE(profile_->IsOffTheRecord()); 3351 EXPECT_FALSE(profile_->IsOffTheRecord());
3354 3352 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
3355 // Open the database from each origin to make the tracker aware 3353 loaded_[0]->url()));
3356 // of the existence of these origins and to get their quotas. 3354 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
3357 int64 limited_quota = -1; 3355 loaded_[1]->url()));
3358 int64 unlimited_quota = -1; 3356 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
3359 string16 limited_quota_identifier = 3357 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 } 3358 }
3387 3359
3388 // Tests ExtensionService::register_component_extension(). 3360 // Tests ExtensionService::register_component_extension().
3389 TEST_F(ExtensionServiceTest, ComponentExtensions) { 3361 TEST_F(ExtensionServiceTest, ComponentExtensions) {
3390 InitializeEmptyExtensionService(); 3362 InitializeEmptyExtensionService();
3391 3363
3392 // Component extensions should work even when extensions are disabled. 3364 // Component extensions should work even when extensions are disabled.
3393 set_extensions_enabled(false); 3365 set_extensions_enabled(false);
3394 3366
3395 FilePath path = data_dir_ 3367 FilePath path = data_dir_
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3828 ASSERT_FALSE(AddPendingSyncInstall()); 3800 ASSERT_FALSE(AddPendingSyncInstall());
3829 3801
3830 // Wait for the external source to install. 3802 // Wait for the external source to install.
3831 WaitForCrxInstall(crx_path_, true); 3803 WaitForCrxInstall(crx_path_, true);
3832 ASSERT_TRUE(IsCrxInstalled()); 3804 ASSERT_TRUE(IsCrxInstalled());
3833 3805
3834 // Now that the extension is installed, sync request should fail 3806 // Now that the extension is installed, sync request should fail
3835 // because the extension is already installed. 3807 // because the extension is already installed.
3836 ASSERT_FALSE(AddPendingSyncInstall()); 3808 ASSERT_FALSE(AddPendingSyncInstall());
3837 } 3809 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698