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

Side by Side Diff: chrome/browser/extensions/updater/extension_updater_unittest.cc

Issue 9959040: Reland 125805 - Reland 124817 - A profile-keyed service for Extensions, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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) 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_split.h" 15 #include "base/string_split.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "base/version.h" 19 #include "base/version.h"
20 #include "chrome/browser/extensions/crx_installer.h" 20 #include "chrome/browser/extensions/crx_installer.h"
21 #include "chrome/browser/extensions/extension_error_reporter.h" 21 #include "chrome/browser/extensions/extension_error_reporter.h"
22 #include "chrome/browser/extensions/extension_sync_data.h" 22 #include "chrome/browser/extensions/extension_sync_data.h"
23 #include "chrome/browser/extensions/extension_system.h"
24 #include "chrome/browser/extensions/extension_system_factory.h"
23 #include "chrome/browser/extensions/test_extension_prefs.h" 25 #include "chrome/browser/extensions/test_extension_prefs.h"
24 #include "chrome/browser/extensions/test_extension_service.h" 26 #include "chrome/browser/extensions/test_extension_service.h"
27 #include "chrome/browser/extensions/test_extension_system.h"
25 #include "chrome/browser/extensions/updater/extension_downloader.h" 28 #include "chrome/browser/extensions/updater/extension_downloader.h"
26 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" 29 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h"
27 #include "chrome/browser/extensions/updater/extension_updater.h" 30 #include "chrome/browser/extensions/updater/extension_updater.h"
28 #include "chrome/browser/extensions/updater/manifest_fetch_data.h" 31 #include "chrome/browser/extensions/updater/manifest_fetch_data.h"
29 #include "chrome/browser/google/google_util.h" 32 #include "chrome/browser/google/google_util.h"
30 #include "chrome/browser/prefs/pref_service.h" 33 #include "chrome/browser/prefs/pref_service.h"
31 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
33 #include "chrome/common/extensions/extension_manifest_constants.h" 36 #include "chrome/common/extensions/extension_manifest_constants.h"
34 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId); 979 fetcher = factory.GetFetcherByID(ExtensionDownloader::kExtensionFetcherId);
977 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); 980 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL);
978 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); 981 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags);
979 982
980 // We need some CrxInstallers, and CrxInstallers require a real 983 // We need some CrxInstallers, and CrxInstallers require a real
981 // ExtensionService. Create one on the testing profile. Any action 984 // ExtensionService. Create one on the testing profile. Any action
982 // the CrxInstallers take is on the testing profile's extension 985 // the CrxInstallers take is on the testing profile's extension
983 // service, not on our mock |service|. This allows us to fake 986 // service, not on our mock |service|. This allows us to fake
984 // the CrxInstaller actions we want. 987 // the CrxInstaller actions we want.
985 TestingProfile profile; 988 TestingProfile profile;
986 profile.CreateExtensionService( 989 static_cast<TestExtensionSystem*>(
987 CommandLine::ForCurrentProcess(), 990 ExtensionSystemFactory::GetForProfile(&profile))->
988 FilePath(), 991 CreateExtensionService(
989 false); 992 CommandLine::ForCurrentProcess(),
990 profile.GetExtensionService()->set_extensions_enabled(true); 993 FilePath(),
991 profile.GetExtensionService()->set_show_extensions_prompts(false); 994 false);
995 ExtensionService* extension_service =
996 ExtensionSystemFactory::GetForProfile(&profile)->extension_service();
997 extension_service->set_extensions_enabled(true);
998 extension_service->set_show_extensions_prompts(false);
992 999
993 scoped_refptr<CrxInstaller> fake_crx1( 1000 scoped_refptr<CrxInstaller> fake_crx1(
994 CrxInstaller::Create(profile.GetExtensionService(), NULL)); 1001 CrxInstaller::Create(extension_service, NULL));
995 scoped_refptr<CrxInstaller> fake_crx2( 1002 scoped_refptr<CrxInstaller> fake_crx2(
996 CrxInstaller::Create(profile.GetExtensionService(), NULL)); 1003 CrxInstaller::Create(extension_service, NULL));
997 1004
998 if (updates_start_running) { 1005 if (updates_start_running) {
999 // Add fake CrxInstaller to be returned by service.UpdateExtension(). 1006 // Add fake CrxInstaller to be returned by service.UpdateExtension().
1000 service.AddFakeCrxInstaller(id1, fake_crx1.get()); 1007 service.AddFakeCrxInstaller(id1, fake_crx1.get());
1001 service.AddFakeCrxInstaller(id2, fake_crx2.get()); 1008 service.AddFakeCrxInstaller(id2, fake_crx2.get());
1002 } else { 1009 } else {
1003 // If we don't add fake CRX installers, the mock service fakes a failure 1010 // If we don't add fake CRX installers, the mock service fakes a failure
1004 // starting the install. 1011 // starting the install.
1005 } 1012 }
1006 1013
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 // -prodversionmin (shouldn't update if browser version too old) 1506 // -prodversionmin (shouldn't update if browser version too old)
1500 // -manifests & updates arriving out of order / interleaved 1507 // -manifests & updates arriving out of order / interleaved
1501 // -malformed update url (empty, file://, has query, has a # fragment, etc.) 1508 // -malformed update url (empty, file://, has query, has a # fragment, etc.)
1502 // -An extension gets uninstalled while updates are in progress (so it doesn't 1509 // -An extension gets uninstalled while updates are in progress (so it doesn't
1503 // "come back from the dead") 1510 // "come back from the dead")
1504 // -An extension gets manually updated to v3 while we're downloading v2 (ie 1511 // -An extension gets manually updated to v3 while we're downloading v2 (ie
1505 // you don't get downgraded accidentally) 1512 // you don't get downgraded accidentally)
1506 // -An update manifest mentions multiple updates 1513 // -An update manifest mentions multiple updates
1507 1514
1508 } // namespace extensions 1515 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/test_extension_system.cc ('k') | chrome/browser/intents/web_intents_registry_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698