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

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: 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_info.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 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 InitializeEmptyExtensionService(); 2919 InitializeEmptyExtensionService();
2919 2920
2920 FilePath path = data_dir_.AppendASCII("good.crx"); 2921 FilePath path = data_dir_.AppendASCII("good.crx");
2921 const Extension* good = InstallCRX(path, INSTALL_NEW); 2922 const Extension* good = InstallCRX(path, INSTALL_NEW);
2922 ASSERT_EQ(1u, service_->extensions()->size()); 2923 ASSERT_EQ(1u, service_->extensions()->size());
2923 2924
2924 EXPECT_FALSE(good->is_theme()); 2925 EXPECT_FALSE(good->is_theme());
2925 2926
2926 // Use AddExtensionImpl() as AddFrom*() would balk. 2927 // Use AddExtensionImpl() as AddFrom*() would balk.
2927 service_->pending_extension_manager()->AddExtensionImpl( 2928 service_->pending_extension_manager()->AddExtensionImpl(
2928 good->id(), good->update_url(), Version(), &IsExtension, 2929 good->id(), extensions::ManifestURLInfo::GetUpdateURL(good),
2929 kGoodIsFromSync, kGoodInstallSilently, Extension::INTERNAL); 2930 Version(), &IsExtension, kGoodIsFromSync,
2931 kGoodInstallSilently, Extension::INTERNAL);
2930 UpdateExtension(good->id(), path, ENABLED); 2932 UpdateExtension(good->id(), path, ENABLED);
2931 2933
2932 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); 2934 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId));
2933 } 2935 }
2934 2936
2935 // Test pref settings for blacklist and unblacklist extensions. 2937 // Test pref settings for blacklist and unblacklist extensions.
2936 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { 2938 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) {
2937 InitializeEmptyExtensionService(); 2939 InitializeEmptyExtensionService();
2938 std::vector<std::string> blacklist; 2940 std::vector<std::string> blacklist;
2939 blacklist.push_back(good0); 2941 blacklist.push_back(good0);
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after
4690 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 4692 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
4691 4693
4692 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS); 4694 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS);
4693 ASSERT_EQ(list.size(), 1U); 4695 ASSERT_EQ(list.size(), 1U);
4694 extensions::ExtensionSyncData data(list[0]); 4696 extensions::ExtensionSyncData data(list[0]);
4695 EXPECT_EQ(extension->id(), data.id()); 4697 EXPECT_EQ(extension->id(), data.id());
4696 EXPECT_FALSE(data.uninstalled()); 4698 EXPECT_FALSE(data.uninstalled());
4697 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled()); 4699 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled());
4698 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled()); 4700 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled());
4699 EXPECT_TRUE(data.version().Equals(*extension->version())); 4701 EXPECT_TRUE(data.version().Equals(*extension->version()));
4700 EXPECT_EQ(extension->update_url(), data.update_url()); 4702 EXPECT_EQ(extensions::ManifestURLInfo::GetUpdateURL(extension),
4703 data.update_url());
4701 EXPECT_EQ(extension->name(), data.name()); 4704 EXPECT_EQ(extension->name(), data.name());
4702 } 4705 }
4703 4706
4704 TEST_F(ExtensionServiceTest, GetSyncDataTerminated) { 4707 TEST_F(ExtensionServiceTest, GetSyncDataTerminated) {
4705 InitializeEmptyExtensionService(); 4708 InitializeEmptyExtensionService();
4706 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 4709 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
4707 TerminateExtension(good_crx); 4710 TerminateExtension(good_crx);
4708 const Extension* extension = service_->GetInstalledExtension(good_crx); 4711 const Extension* extension = service_->GetInstalledExtension(good_crx);
4709 ASSERT_TRUE(extension); 4712 ASSERT_TRUE(extension);
4710 4713
4711 TestSyncProcessorStub processor; 4714 TestSyncProcessorStub processor;
4712 service_->MergeDataAndStartSyncing( 4715 service_->MergeDataAndStartSyncing(
4713 syncer::EXTENSIONS, syncer::SyncDataList(), 4716 syncer::EXTENSIONS, syncer::SyncDataList(),
4714 scoped_ptr<syncer::SyncChangeProcessor>(new TestSyncProcessorStub), 4717 scoped_ptr<syncer::SyncChangeProcessor>(new TestSyncProcessorStub),
4715 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 4718 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
4716 4719
4717 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS); 4720 syncer::SyncDataList list = service_->GetAllSyncData(syncer::EXTENSIONS);
4718 ASSERT_EQ(list.size(), 1U); 4721 ASSERT_EQ(list.size(), 1U);
4719 extensions::ExtensionSyncData data(list[0]); 4722 extensions::ExtensionSyncData data(list[0]);
4720 EXPECT_EQ(extension->id(), data.id()); 4723 EXPECT_EQ(extension->id(), data.id());
4721 EXPECT_FALSE(data.uninstalled()); 4724 EXPECT_FALSE(data.uninstalled());
4722 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled()); 4725 EXPECT_EQ(service_->IsExtensionEnabled(good_crx), data.enabled());
4723 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled()); 4726 EXPECT_EQ(service_->IsIncognitoEnabled(good_crx), data.incognito_enabled());
4724 EXPECT_TRUE(data.version().Equals(*extension->version())); 4727 EXPECT_TRUE(data.version().Equals(*extension->version()));
4725 EXPECT_EQ(extension->update_url(), data.update_url()); 4728 EXPECT_EQ(extensions::ManifestURLInfo::GetUpdateURL(extension),
4729 data.update_url());
4726 EXPECT_EQ(extension->name(), data.name()); 4730 EXPECT_EQ(extension->name(), data.name());
4727 } 4731 }
4728 4732
4729 TEST_F(ExtensionServiceTest, GetSyncDataFilter) { 4733 TEST_F(ExtensionServiceTest, GetSyncDataFilter) {
4730 InitializeEmptyExtensionService(); 4734 InitializeEmptyExtensionService();
4731 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 4735 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
4732 const Extension* extension = service_->GetInstalledExtension(good_crx); 4736 const Extension* extension = service_->GetInstalledExtension(good_crx);
4733 ASSERT_TRUE(extension); 4737 ASSERT_TRUE(extension);
4734 4738
4735 TestSyncProcessorStub processor; 4739 TestSyncProcessorStub processor;
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
5796 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5800 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5797 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); 5801 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
5798 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); 5802 EXPECT_TRUE(service_->IsExtensionEnabled(page_action));
5799 5803
5800 ExtensionPrefs* prefs = service_->extension_prefs(); 5804 ExtensionPrefs* prefs = service_->extension_prefs();
5801 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & 5805 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) &
5802 Extension::DISABLE_SIDELOAD_WIPEOUT); 5806 Extension::DISABLE_SIDELOAD_WIPEOUT);
5803 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & 5807 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) &
5804 Extension::DISABLE_SIDELOAD_WIPEOUT); 5808 Extension::DISABLE_SIDELOAD_WIPEOUT);
5805 } 5809 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698