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

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

Issue 660113: Reset the default quota limit for extensions to 5MB, but add a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions_service_unittest.h" 5 #include "chrome/browser/extensions/extensions_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/string16.h"
15 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/task.h"
16 #include "chrome/browser/extensions/crx_installer.h" 19 #include "chrome/browser/extensions/crx_installer.h"
17 #include "chrome/browser/extensions/extension_creator.h" 20 #include "chrome/browser/extensions/extension_creator.h"
18 #include "chrome/browser/extensions/extensions_service.h" 21 #include "chrome/browser/extensions/extensions_service.h"
19 #include "chrome/browser/extensions/external_extension_provider.h" 22 #include "chrome/browser/extensions/external_extension_provider.h"
20 #include "chrome/browser/extensions/external_pref_extension_provider.h" 23 #include "chrome/browser/extensions/external_pref_extension_provider.h"
21 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
22 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
23 #include "chrome/common/extensions/url_pattern.h" 26 #include "chrome/common/extensions/url_pattern.h"
24 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/extensions/extension_error_reporter.h" 29 #include "chrome/common/extensions/extension_error_reporter.h"
27 #include "chrome/common/json_value_serializer.h" 30 #include "chrome/common/json_value_serializer.h"
28 #include "chrome/common/notification_registrar.h" 31 #include "chrome/common/notification_registrar.h"
29 #include "chrome/common/notification_service.h" 32 #include "chrome/common/notification_service.h"
30 #include "chrome/common/notification_type.h" 33 #include "chrome/common/notification_type.h"
31 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/common/url_constants.h"
32 #include "chrome/test/testing_profile.h" 36 #include "chrome/test/testing_profile.h"
37 #include "googleurl/src/gurl.h"
33 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
34 #include "testing/platform_test.h" 39 #include "testing/platform_test.h"
40 #include "webkit/database/database_tracker.h"
41 #include "webkit/database/database_util.h"
35 42
36 namespace keys = extension_manifest_keys; 43 namespace keys = extension_manifest_keys;
37 44
38 namespace { 45 namespace {
39 46
40 // Extension ids used during testing. 47 // Extension ids used during testing.
41 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 48 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
42 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; 49 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
43 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj"; 50 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj";
44 const char* const good1 = "hpiknbiabeeppbpihjehijgoemciehgk"; 51 const char* const good1 = "hpiknbiabeeppbpihjehijgoemciehgk";
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1633
1627 recorder.set_ready(false); 1634 recorder.set_ready(false);
1628 command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); 1635 command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY));
1629 service = new ExtensionsService(&profile, command_line.get(), 1636 service = new ExtensionsService(&profile, command_line.get(),
1630 profile.GetPrefs(), install_dir, false); 1637 profile.GetPrefs(), install_dir, false);
1631 EXPECT_FALSE(service->extensions_enabled()); 1638 EXPECT_FALSE(service->extensions_enabled());
1632 service->Init(); 1639 service->Init();
1633 loop.RunAllPending(); 1640 loop.RunAllPending();
1634 EXPECT_TRUE(recorder.ready()); 1641 EXPECT_TRUE(recorder.ready());
1635 } 1642 }
1643
1644 // Test loading extensions that require limited and unlimited storage quotas.
1645 TEST_F(ExtensionsServiceTest, StorageQuota) {
1646 InitializeEmptyExtensionsService();
1647
1648 FilePath extensions_path;
1649 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1650 extensions_path = extensions_path.AppendASCII("extensions")
1651 .AppendASCII("storage_quota");
1652
1653 FilePath limited_quota_ext = extensions_path.AppendASCII("limited_quota")
1654 .AppendASCII("1.0");
1655 FilePath unlimited_quota_ext = extensions_path.AppendASCII("unlimited_quota")
1656 .AppendASCII("1.0");
1657 service_->LoadExtension(limited_quota_ext);
1658 service_->LoadExtension(unlimited_quota_ext);
1659 loop_.RunAllPending();
1660
1661 EXPECT_EQ(2u, loaded_.size());
1662 EXPECT_TRUE(profile_.get());
1663 EXPECT_FALSE(profile_->IsOffTheRecord());
1664
1665 // Open a database in each origin to make the tracker aware
1666 // of the existance of these origins and to get their quotas.
1667 int64 limited_quota = -1;
1668 int64 unlimited_quota = -1;
1669 string16 limited_quota_identifier =
1670 webkit_database::DatabaseUtil::GetOriginIdentifier(loaded_[0]->url());
1671 string16 unlimited_quota_identifier =
1672 webkit_database::DatabaseUtil::GetOriginIdentifier(loaded_[1]->url());
1673 string16 db_name = UTF8ToUTF16("db");
1674 string16 description = UTF8ToUTF16("db_description");
1675 int64 database_size;
1676 webkit_database::DatabaseTracker* db_tracker = profile_->GetDatabaseTracker();
1677 db_tracker->DatabaseOpened(limited_quota_identifier, db_name, description,
1678 1, &database_size, &limited_quota);
1679 db_tracker->DatabaseClosed(limited_quota_identifier, db_name);
1680 db_tracker->DatabaseOpened(unlimited_quota_identifier, db_name, description,
1681 1, &database_size, &unlimited_quota);
1682 db_tracker->DatabaseClosed(unlimited_quota_identifier, db_name);
1683
1684 EXPECT_EQ(profile_->GetDatabaseTracker()->GetDefaultQuota(), limited_quota);
1685 EXPECT_EQ(kint64max, unlimited_quota);
1686 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698