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

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

Issue 11726002: Move the parsing of 'update_url' & 'options_page' URLs out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_parse
Patch Set: fixed HomepageURLManifestTest.GetHomepageURL Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012 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 "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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "chrome/browser/prefs/pref_service_mock_builder.h" 59 #include "chrome/browser/prefs/pref_service_mock_builder.h"
60 #include "chrome/browser/prefs/scoped_user_pref_update.h" 60 #include "chrome/browser/prefs/scoped_user_pref_update.h"
61 #include "chrome/common/chrome_constants.h" 61 #include "chrome/common/chrome_constants.h"
62 #include "chrome/common/chrome_notification_types.h" 62 #include "chrome/common/chrome_notification_types.h"
63 #include "chrome/common/chrome_paths.h" 63 #include "chrome/common/chrome_paths.h"
64 #include "chrome/common/chrome_switches.h" 64 #include "chrome/common/chrome_switches.h"
65 #include "chrome/common/extensions/extension.h" 65 #include "chrome/common/extensions/extension.h"
66 #include "chrome/common/extensions/extension_l10n_util.h" 66 #include "chrome/common/extensions/extension_l10n_util.h"
67 #include "chrome/common/extensions/extension_manifest_constants.h" 67 #include "chrome/common/extensions/extension_manifest_constants.h"
68 #include "chrome/common/extensions/extension_resource.h" 68 #include "chrome/common/extensions/extension_resource.h"
69 #include "chrome/common/extensions/manifest_url_handler.h"
69 #include "chrome/common/extensions/permissions/permission_set.h" 70 #include "chrome/common/extensions/permissions/permission_set.h"
70 #include "chrome/common/pref_names.h" 71 #include "chrome/common/pref_names.h"
71 #include "chrome/common/url_constants.h" 72 #include "chrome/common/url_constants.h"
72 #include "chrome/test/base/testing_profile.h" 73 #include "chrome/test/base/testing_profile.h"
73 #include "content/public/browser/dom_storage_context.h" 74 #include "content/public/browser/dom_storage_context.h"
74 #include "content/public/browser/gpu_data_manager.h" 75 #include "content/public/browser/gpu_data_manager.h"
75 #include "content/public/browser/indexed_db_context.h" 76 #include "content/public/browser/indexed_db_context.h"
76 #include "content/public/browser/notification_registrar.h" 77 #include "content/public/browser/notification_registrar.h"
77 #include "content/public/browser/notification_service.h" 78 #include "content/public/browser/notification_service.h"
78 #include "content/public/browser/plugin_service.h" 79 #include "content/public/browser/plugin_service.h"
(...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 InitializeEmptyExtensionService(); 2932 InitializeEmptyExtensionService();
2932 2933
2933 FilePath path = data_dir_.AppendASCII("good.crx"); 2934 FilePath path = data_dir_.AppendASCII("good.crx");
2934 const Extension* good = InstallCRX(path, INSTALL_NEW); 2935 const Extension* good = InstallCRX(path, INSTALL_NEW);
2935 ASSERT_EQ(1u, service_->extensions()->size()); 2936 ASSERT_EQ(1u, service_->extensions()->size());
2936 2937
2937 EXPECT_FALSE(good->is_theme()); 2938 EXPECT_FALSE(good->is_theme());
2938 2939
2939 // Use AddExtensionImpl() as AddFrom*() would balk. 2940 // Use AddExtensionImpl() as AddFrom*() would balk.
2940 service_->pending_extension_manager()->AddExtensionImpl( 2941 service_->pending_extension_manager()->AddExtensionImpl(
2941 good->id(), good->update_url(), Version(), &IsExtension, 2942 good->id(), extensions::ManifestURL::GetUpdateURL(good),
2942 kGoodIsFromSync, kGoodInstallSilently, Extension::INTERNAL); 2943 Version(), &IsExtension, kGoodIsFromSync,
2944 kGoodInstallSilently, Extension::INTERNAL);
2943 UpdateExtension(good->id(), path, ENABLED); 2945 UpdateExtension(good->id(), path, ENABLED);
2944 2946
2945 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); 2947 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId));
2946 } 2948 }
2947 2949
2948 // Test pref settings for blacklist and unblacklist extensions. 2950 // Test pref settings for blacklist and unblacklist extensions.
2949 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { 2951 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) {
2950 InitializeEmptyExtensionService(); 2952 InitializeEmptyExtensionService();
2951 std::vector<std::string> blacklist; 2953 std::vector<std::string> blacklist;
2952 blacklist.push_back(good0); 2954 blacklist.push_back(good0);
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
4715 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 4717 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
4716 4718
4717 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS); 4719 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS);
4718 ASSERT_EQ(list.size(), 1U); 4720 ASSERT_EQ(list.size(), 1U);
4719 extensions::ExtensionSyncData data(list[0]); 4721 extensions::ExtensionSyncData data(list[0]);
4720 EXPECT_EQ(extension->id(), data.id()); 4722 EXPECT_EQ(extension->id(), data.id());
4721 EXPECT_FALSE(data.uninstalled()); 4723 EXPECT_FALSE(data.uninstalled());
4722 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled()); 4724 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled());
4723 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled()); 4725 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled());
4724 EXPECT_TRUE(data.version().Equals(*extension->version())); 4726 EXPECT_TRUE(data.version().Equals(*extension->version()));
4725 EXPECT_EQ(extension->update_url(), data.update_url()); 4727 EXPECT_EQ(extensions::ManifestURL::GetUpdateURL(extension),
4728 data.update_url());
4726 EXPECT_EQ(extension->name(), data.name()); 4729 EXPECT_EQ(extension->name(), data.name());
4727 } 4730 }
4728 4731
4729 TEST_F(ExtensionServiceTest, GetSyncDataTerminated) { 4732 TEST_F(ExtensionServiceTest, GetSyncDataTerminated) {
4730 InitializeEmptyExtensionService(); 4733 InitializeEmptyExtensionService();
4731 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 4734 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
4732 TerminateExtension(good_crx); 4735 TerminateExtension(good_crx);
4733 const Extension* extension = service_->GetInstalledExtension(good_crx); 4736 const Extension* extension = service_->GetInstalledExtension(good_crx);
4734 ASSERT_TRUE(extension); 4737 ASSERT_TRUE(extension);
4735 4738
4736 TestSyncProcessorStub processor; 4739 TestSyncProcessorStub processor;
4737 service_->MergeDataAndStartSyncing( 4740 service_->MergeDataAndStartSyncing(
4738 syncer::EXTENSIONS, syncer::SyncDataList(), 4741 syncer::EXTENSIONS, syncer::SyncDataList(),
4739 scoped_ptr<syncer::SyncChangeProcessor>(new TestSyncProcessorStub), 4742 scoped_ptr<syncer::SyncChangeProcessor>(new TestSyncProcessorStub),
4740 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 4743 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
4741 4744
4742 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS); 4745 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS);
4743 ASSERT_EQ(list.size(), 1U); 4746 ASSERT_EQ(list.size(), 1U);
4744 extensions::ExtensionSyncData data(list[0]); 4747 extensions::ExtensionSyncData data(list[0]);
4745 EXPECT_EQ(extension->id(), data.id()); 4748 EXPECT_EQ(extension->id(), data.id());
4746 EXPECT_FALSE(data.uninstalled()); 4749 EXPECT_FALSE(data.uninstalled());
4747 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled()); 4750 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled());
4748 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled()); 4751 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled());
4749 EXPECT_TRUE(data.version().Equals(*extension->version())); 4752 EXPECT_TRUE(data.version().Equals(*extension->version()));
4750 EXPECT_EQ(extension->update_url(), data.update_url()); 4753 EXPECT_EQ(extensions::ManifestURL::GetUpdateURL(extension),
4754 data.update_url());
4751 EXPECT_EQ(extension->name(), data.name()); 4755 EXPECT_EQ(extension->name(), data.name());
4752 } 4756 }
4753 4757
4754 TEST_F(ExtensionServiceTest, GetSyncDataFilter) { 4758 TEST_F(ExtensionServiceTest, GetSyncDataFilter) {
4755 InitializeEmptyExtensionService(); 4759 InitializeEmptyExtensionService();
4756 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 4760 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
4757 const Extension* extension = service_->GetInstalledExtension(good_crx); 4761 const Extension* extension = service_->GetInstalledExtension(good_crx);
4758 ASSERT_TRUE(extension); 4762 ASSERT_TRUE(extension);
4759 4763
4760 TestSyncProcessorStub processor; 4764 TestSyncProcessorStub processor;
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
5819 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5823 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5820 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); 5824 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
5821 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); 5825 EXPECT_TRUE(service_->IsExtensionEnabled(page_action));
5822 5826
5823 ExtensionPrefs* prefs = service_->extension_prefs(); 5827 ExtensionPrefs* prefs = service_->extension_prefs();
5824 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & 5828 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) &
5825 Extension::DISABLE_SIDELOAD_WIPEOUT); 5829 Extension::DISABLE_SIDELOAD_WIPEOUT);
5826 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & 5830 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) &
5827 Extension::DISABLE_SIDELOAD_WIPEOUT); 5831 Extension::DISABLE_SIDELOAD_WIPEOUT);
5828 } 5832 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_sync_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698