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

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

Issue 9583036: Revert 124817 - Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
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 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_split.h" 13 #include "base/string_split.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "chrome/browser/extensions/crx_installer.h" 18 #include "chrome/browser/extensions/crx_installer.h"
19 #include "chrome/browser/extensions/extension_error_reporter.h" 19 #include "chrome/browser/extensions/extension_error_reporter.h"
20 #include "chrome/browser/extensions/extension_sync_data.h" 20 #include "chrome/browser/extensions/extension_sync_data.h"
21 #include "chrome/browser/extensions/extension_system.h"
22 #include "chrome/browser/extensions/extension_system_factory.h"
23 #include "chrome/browser/extensions/extension_updater.h" 21 #include "chrome/browser/extensions/extension_updater.h"
24 #include "chrome/browser/extensions/test_extension_prefs.h" 22 #include "chrome/browser/extensions/test_extension_prefs.h"
25 #include "chrome/browser/extensions/test_extension_service.h" 23 #include "chrome/browser/extensions/test_extension_service.h"
26 #include "chrome/browser/extensions/test_extension_system.h"
27 #include "chrome/browser/google/google_util.h" 24 #include "chrome/browser/google/google_util.h"
28 #include "chrome/browser/prefs/pref_service.h" 25 #include "chrome/browser/prefs/pref_service.h"
29 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
30 #include "chrome/common/extensions/extension_constants.h" 27 #include "chrome/common/extensions/extension_constants.h"
31 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
32 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
33 #include "content/test/test_browser_thread.h" 30 #include "content/test/test_browser_thread.h"
34 #include "content/test/test_url_fetcher_factory.h" 31 #include "content/test/test_url_fetcher_factory.h"
35 #include "libxml/globals.h" 32 #include "libxml/globals.h"
36 #include "net/base/escape.h" 33 #include "net/base/escape.h"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 fetcher = factory.GetFetcherByID(ExtensionUpdater::kExtensionFetcherId); 805 fetcher = factory.GetFetcherByID(ExtensionUpdater::kExtensionFetcherId);
809 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); 806 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL);
810 EXPECT_TRUE(fetcher->GetLoadFlags() == expected_load_flags); 807 EXPECT_TRUE(fetcher->GetLoadFlags() == expected_load_flags);
811 808
812 // We need some CrxInstallers, and CrxInstallers require a real 809 // We need some CrxInstallers, and CrxInstallers require a real
813 // ExtensionService. Create one on the testing profile. Any action 810 // ExtensionService. Create one on the testing profile. Any action
814 // the CrxInstallers take is on the testing profile's extension 811 // the CrxInstallers take is on the testing profile's extension
815 // service, not on our mock |service|. This allows us to fake 812 // service, not on our mock |service|. This allows us to fake
816 // the CrxInstaller actions we want. 813 // the CrxInstaller actions we want.
817 TestingProfile profile; 814 TestingProfile profile;
818 static_cast<TestExtensionSystem*>( 815 profile.CreateExtensionService(
819 ExtensionSystemFactory::GetForProfile(&profile))-> 816 CommandLine::ForCurrentProcess(),
820 CreateExtensionService( 817 FilePath(),
821 CommandLine::ForCurrentProcess(), 818 false);
822 FilePath(), 819 profile.GetExtensionService()->set_extensions_enabled(true);
823 false); 820 profile.GetExtensionService()->set_show_extensions_prompts(false);
824 ExtensionService* extension_service =
825 ExtensionSystemFactory::GetForProfile(&profile)->extension_service();
826 extension_service->set_extensions_enabled(true);
827 extension_service->set_show_extensions_prompts(false);
828 821
829 scoped_refptr<CrxInstaller> fake_crx1( 822 scoped_refptr<CrxInstaller> fake_crx1(
830 CrxInstaller::Create(extension_service, NULL)); 823 CrxInstaller::Create(profile.GetExtensionService(), NULL));
831 scoped_refptr<CrxInstaller> fake_crx2( 824 scoped_refptr<CrxInstaller> fake_crx2(
832 CrxInstaller::Create(extension_service, NULL)); 825 CrxInstaller::Create(profile.GetExtensionService(), NULL));
833 826
834 if (updates_start_running) { 827 if (updates_start_running) {
835 // Add fake CrxInstaller to be returned by service.UpdateExtension(). 828 // Add fake CrxInstaller to be returned by service.UpdateExtension().
836 service.AddFakeCrxInstaller(id1, fake_crx1.get()); 829 service.AddFakeCrxInstaller(id1, fake_crx1.get());
837 service.AddFakeCrxInstaller(id2, fake_crx2.get()); 830 service.AddFakeCrxInstaller(id2, fake_crx2.get());
838 } else { 831 } else {
839 // If we don't add fake CRX installers, the mock service fakes a failure 832 // If we don't add fake CRX installers, the mock service fakes a failure
840 // starting the install. 833 // starting the install.
841 } 834 }
842 835
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 1261
1269 // TODO(asargent) - (http://crbug.com/12780) add tests for: 1262 // TODO(asargent) - (http://crbug.com/12780) add tests for:
1270 // -prodversionmin (shouldn't update if browser version too old) 1263 // -prodversionmin (shouldn't update if browser version too old)
1271 // -manifests & updates arriving out of order / interleaved 1264 // -manifests & updates arriving out of order / interleaved
1272 // -malformed update url (empty, file://, has query, has a # fragment, etc.) 1265 // -malformed update url (empty, file://, has query, has a # fragment, etc.)
1273 // -An extension gets uninstalled while updates are in progress (so it doesn't 1266 // -An extension gets uninstalled while updates are in progress (so it doesn't
1274 // "come back from the dead") 1267 // "come back from the dead")
1275 // -An extension gets manually updated to v3 while we're downloading v2 (ie 1268 // -An extension gets manually updated to v3 while we're downloading v2 (ie
1276 // you don't get downgraded accidentally) 1269 // you don't get downgraded accidentally)
1277 // -An update manifest mentions multiple updates 1270 // -An update manifest mentions multiple updates
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system_factory.cc ('k') | chrome/browser/extensions/test_extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698