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

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

Issue 23744004: Move the rest of extension_manifest_constants to top-level extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 7 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "chrome/browser/prefs/pref_service_syncable.h" 65 #include "chrome/browser/prefs/pref_service_syncable.h"
66 #include "chrome/browser/prefs/scoped_user_pref_update.h" 66 #include "chrome/browser/prefs/scoped_user_pref_update.h"
67 #include "chrome/common/chrome_constants.h" 67 #include "chrome/common/chrome_constants.h"
68 #include "chrome/common/chrome_paths.h" 68 #include "chrome/common/chrome_paths.h"
69 #include "chrome/common/chrome_switches.h" 69 #include "chrome/common/chrome_switches.h"
70 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 70 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
71 #include "chrome/common/extensions/background_info.h" 71 #include "chrome/common/extensions/background_info.h"
72 #include "chrome/common/extensions/extension.h" 72 #include "chrome/common/extensions/extension.h"
73 #include "chrome/common/extensions/extension_builder.h" 73 #include "chrome/common/extensions/extension_builder.h"
74 #include "chrome/common/extensions/extension_l10n_util.h" 74 #include "chrome/common/extensions/extension_l10n_util.h"
75 #include "chrome/common/extensions/extension_manifest_constants.h"
76 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 75 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
77 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 76 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
78 #include "chrome/common/extensions/manifest_url_handler.h" 77 #include "chrome/common/extensions/manifest_url_handler.h"
79 #include "chrome/common/extensions/permissions/permission_set.h" 78 #include "chrome/common/extensions/permissions/permission_set.h"
80 #include "chrome/common/extensions/value_builder.h" 79 #include "chrome/common/extensions/value_builder.h"
81 #include "chrome/common/pref_names.h" 80 #include "chrome/common/pref_names.h"
82 #include "chrome/common/url_constants.h" 81 #include "chrome/common/url_constants.h"
83 #include "chrome/test/base/scoped_browser_locale.h" 82 #include "chrome/test/base/scoped_browser_locale.h"
84 #include "chrome/test/base/testing_profile.h" 83 #include "chrome/test/base/testing_profile.h"
85 #include "components/user_prefs/pref_registry_syncable.h" 84 #include "components/user_prefs/pref_registry_syncable.h"
86 #include "content/public/browser/dom_storage_context.h" 85 #include "content/public/browser/dom_storage_context.h"
87 #include "content/public/browser/gpu_data_manager.h" 86 #include "content/public/browser/gpu_data_manager.h"
88 #include "content/public/browser/indexed_db_context.h" 87 #include "content/public/browser/indexed_db_context.h"
89 #include "content/public/browser/notification_registrar.h" 88 #include "content/public/browser/notification_registrar.h"
90 #include "content/public/browser/notification_service.h" 89 #include "content/public/browser/notification_service.h"
91 #include "content/public/browser/plugin_service.h" 90 #include "content/public/browser/plugin_service.h"
92 #include "content/public/browser/render_process_host.h" 91 #include "content/public/browser/render_process_host.h"
93 #include "content/public/browser/storage_partition.h" 92 #include "content/public/browser/storage_partition.h"
94 #include "content/public/common/content_constants.h" 93 #include "content/public/common/content_constants.h"
95 #include "content/public/test/test_utils.h" 94 #include "content/public/test/test_utils.h"
96 #include "extensions/common/constants.h" 95 #include "extensions/common/constants.h"
97 #include "extensions/common/extension_resource.h" 96 #include "extensions/common/extension_resource.h"
97 #include "extensions/common/manifest_constants.h"
98 #include "extensions/common/url_pattern.h" 98 #include "extensions/common/url_pattern.h"
99 #include "gpu/config/gpu_info.h" 99 #include "gpu/config/gpu_info.h"
100 #include "grit/browser_resources.h" 100 #include "grit/browser_resources.h"
101 #include "net/cookies/canonical_cookie.h" 101 #include "net/cookies/canonical_cookie.h"
102 #include "net/cookies/cookie_monster.h" 102 #include "net/cookies/cookie_monster.h"
103 #include "net/cookies/cookie_options.h" 103 #include "net/cookies/cookie_options.h"
104 #include "net/url_request/url_request_context.h" 104 #include "net/url_request/url_request_context.h"
105 #include "net/url_request/url_request_context_getter.h" 105 #include "net/url_request/url_request_context_getter.h"
106 #include "sync/api/string_ordinal.h" 106 #include "sync/api/string_ordinal.h"
107 #include "sync/api/sync_error_factory.h" 107 #include "sync/api/sync_error_factory.h"
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 1337
1338 InitializeInstalledExtensionService(pref_path, source_install_dir); 1338 InitializeInstalledExtensionService(pref_path, source_install_dir);
1339 1339
1340 service_->Init(); 1340 service_->Init();
1341 1341
1342 ASSERT_EQ(4u, GetErrors().size()); 1342 ASSERT_EQ(4u, GetErrors().size());
1343 ASSERT_EQ(0u, loaded_.size()); 1343 ASSERT_EQ(0u, loaded_.size());
1344 1344
1345 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[0]), 1345 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[0]),
1346 std::string("Could not load extension from '*'. ") + 1346 std::string("Could not load extension from '*'. ") +
1347 extension_manifest_errors::kManifestUnreadable)) << 1347 extensions::manifest_errors::kManifestUnreadable)) <<
1348 UTF16ToUTF8(GetErrors()[0]); 1348 UTF16ToUTF8(GetErrors()[0]);
1349 1349
1350 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[1]), 1350 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[1]),
1351 std::string("Could not load extension from '*'. ") + 1351 std::string("Could not load extension from '*'. ") +
1352 extension_manifest_errors::kManifestUnreadable)) << 1352 extensions::manifest_errors::kManifestUnreadable)) <<
1353 UTF16ToUTF8(GetErrors()[1]); 1353 UTF16ToUTF8(GetErrors()[1]);
1354 1354
1355 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[2]), 1355 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[2]),
1356 std::string("Could not load extension from '*'. ") + 1356 std::string("Could not load extension from '*'. ") +
1357 extension_manifest_errors::kMissingFile)) << 1357 extensions::manifest_errors::kMissingFile)) <<
1358 UTF16ToUTF8(GetErrors()[2]); 1358 UTF16ToUTF8(GetErrors()[2]);
1359 1359
1360 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[3]), 1360 EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[3]),
1361 std::string("Could not load extension from '*'. ") + 1361 std::string("Could not load extension from '*'. ") +
1362 extension_manifest_errors::kManifestUnreadable)) << 1362 extensions::manifest_errors::kManifestUnreadable)) <<
1363 UTF16ToUTF8(GetErrors()[3]); 1363 UTF16ToUTF8(GetErrors()[3]);
1364 }; 1364 };
1365 1365
1366 // Test that partially deleted extensions are cleaned up during startup 1366 // Test that partially deleted extensions are cleaned up during startup
1367 // Test loading bad extensions from the profile directory. 1367 // Test loading bad extensions from the profile directory.
1368 TEST_F(ExtensionServiceTest, CleanupOnStartup) { 1368 TEST_F(ExtensionServiceTest, CleanupOnStartup) {
1369 InitPluginService(); 1369 InitPluginService();
1370 1370
1371 base::FilePath source_install_dir = data_dir_ 1371 base::FilePath source_install_dir = data_dir_
1372 .AppendASCII("good") 1372 .AppendASCII("good")
(...skipping 3696 matching lines...) Expand 10 before | Expand all | Expand 10 after
5069 5069
5070 // Reload all extensions, and make sure it comes back. 5070 // Reload all extensions, and make sure it comes back.
5071 std::string extension_id = (*service_->extensions()->begin())->id(); 5071 std::string extension_id = (*service_->extensions()->begin())->id();
5072 loaded_.clear(); 5072 loaded_.clear();
5073 service_->ReloadExtensions(); 5073 service_->ReloadExtensions();
5074 ASSERT_EQ(1u, service_->extensions()->size()); 5074 ASSERT_EQ(1u, service_->extensions()->size());
5075 EXPECT_EQ(extension_id, (*service_->extensions()->begin())->id()); 5075 EXPECT_EQ(extension_id, (*service_->extensions()->begin())->id());
5076 } 5076 }
5077 5077
5078 namespace { 5078 namespace {
5079 class TestSyncProcessorStub : public syncer::SyncChangeProcessor {
5080 virtual syncer::SyncError ProcessSyncChanges(
5081 const tracked_objects::Location& from_here,
5082 const syncer::SyncChangeList& change_list) OVERRIDE {
5083 return syncer::SyncError();
5084 }
5085 5079
5086 virtual syncer::SyncDataList GetAllSyncData( 5080 class TestSyncProcessorStub : public syncer::SyncChangeProcessor {
5087 syncer::ModelType type) const OVERRIDE { 5081 virtual syncer::SyncError ProcessSyncChanges(
5088 return syncer::SyncDataList(); 5082 const tracked_objects::Location& from_here,
5089 } 5083 const syncer::SyncChangeList& change_list) OVERRIDE {
5090 }; 5084 return syncer::SyncError();
5091 } 5085 }
5086
5087 virtual syncer::SyncDataList GetAllSyncData(
5088 syncer::ModelType type) const OVERRIDE {
5089 return syncer::SyncDataList();
5090 }
5091 };
5092
5093 } // namespace
5092 5094
5093 TEST_F(ExtensionServiceTest, DeferredSyncStartupPreInstalledComponent) { 5095 TEST_F(ExtensionServiceTest, DeferredSyncStartupPreInstalledComponent) {
5094 InitializeEmptyExtensionService(); 5096 InitializeEmptyExtensionService();
5095 5097
5096 bool flare_was_called = false; 5098 bool flare_was_called = false;
5097 syncer::ModelType triggered_type(syncer::UNSPECIFIED); 5099 syncer::ModelType triggered_type(syncer::UNSPECIFIED);
5098 base::WeakPtrFactory<ExtensionServiceTest> factory(this); 5100 base::WeakPtrFactory<ExtensionServiceTest> factory(this);
5099 service_->SetSyncStartFlare( 5101 service_->SetSyncStartFlare(
5100 base::Bind(&ExtensionServiceTest::MockSyncStartFlare, 5102 base::Bind(&ExtensionServiceTest::MockSyncStartFlare,
5101 factory.GetWeakPtr(), 5103 factory.GetWeakPtr(),
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
6375 EXPECT_TRUE(notifications.CheckNotifications( 6377 EXPECT_TRUE(notifications.CheckNotifications(
6376 chrome::NOTIFICATION_EXTENSION_INSTALLED)); 6378 chrome::NOTIFICATION_EXTENSION_INSTALLED));
6377 6379
6378 EXPECT_TRUE(service_->GetInstalledExtension(id)); 6380 EXPECT_TRUE(service_->GetInstalledExtension(id));
6379 EXPECT_FALSE(service_->extensions()->Contains(id)); 6381 EXPECT_FALSE(service_->extensions()->Contains(id));
6380 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); 6382 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id));
6381 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); 6383 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id));
6382 EXPECT_TRUE( 6384 EXPECT_TRUE(
6383 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); 6385 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id));
6384 } 6386 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698