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

Side by Side Diff: chrome/common/extensions/extension_unittest.cc

Issue 10855190: Disable sync for default apps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 4 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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 USER_SCRIPT, 1048 USER_SCRIPT,
1049 THEME 1049 THEME
1050 }; 1050 };
1051 1051
1052 static scoped_refptr<Extension> MakeSyncTestExtension( 1052 static scoped_refptr<Extension> MakeSyncTestExtension(
1053 SyncTestExtensionType type, 1053 SyncTestExtensionType type,
1054 const GURL& update_url, 1054 const GURL& update_url,
1055 const GURL& launch_url, 1055 const GURL& launch_url,
1056 Extension::Location location, 1056 Extension::Location location,
1057 int num_plugins, 1057 int num_plugins,
1058 const FilePath& extension_path) { 1058 const FilePath& extension_path,
1059 int creation_flags=Extension::NO_FLAGS) {
Mihai Parparita -not on Chrome 2012/08/24 21:05:23 Our style guide forbids default arguments: http://
1059 DictionaryValue source; 1060 DictionaryValue source;
1060 source.SetString(extension_manifest_keys::kName, 1061 source.SetString(extension_manifest_keys::kName,
1061 "PossiblySyncableExtension"); 1062 "PossiblySyncableExtension");
1062 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); 1063 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0");
1063 if (type == APP) 1064 if (type == APP)
1064 source.SetString(extension_manifest_keys::kApp, "true"); 1065 source.SetString(extension_manifest_keys::kApp, "true");
1065 if (type == THEME) 1066 if (type == THEME)
1066 source.Set(extension_manifest_keys::kTheme, new DictionaryValue()); 1067 source.Set(extension_manifest_keys::kTheme, new DictionaryValue());
1067 if (!update_url.is_empty()) { 1068 if (!update_url.is_empty()) {
1068 source.SetString(extension_manifest_keys::kUpdateURL, 1069 source.SetString(extension_manifest_keys::kUpdateURL,
(...skipping 10 matching lines...) Expand all
1079 for (int i = 0; i < num_plugins; ++i) { 1080 for (int i = 0; i < num_plugins; ++i) {
1080 DictionaryValue* plugin = new DictionaryValue(); 1081 DictionaryValue* plugin = new DictionaryValue();
1081 plugin->SetString(extension_manifest_keys::kPluginsPath, ""); 1082 plugin->SetString(extension_manifest_keys::kPluginsPath, "");
1082 plugins->Set(i, plugin); 1083 plugins->Set(i, plugin);
1083 } 1084 }
1084 source.Set(extension_manifest_keys::kPlugins, plugins); 1085 source.Set(extension_manifest_keys::kPlugins, plugins);
1085 } 1086 }
1086 1087
1087 std::string error; 1088 std::string error;
1088 scoped_refptr<Extension> extension = Extension::Create( 1089 scoped_refptr<Extension> extension = Extension::Create(
1089 extension_path, location, source, Extension::NO_FLAGS, &error); 1090 extension_path, location, source, creation_flags, &error);
1090 EXPECT_TRUE(extension); 1091 EXPECT_TRUE(extension);
1091 EXPECT_EQ("", error); 1092 EXPECT_EQ("", error);
1092 return extension; 1093 return extension;
1093 } 1094 }
1094 1095
1095 static const char kValidUpdateUrl1[] = 1096 static const char kValidUpdateUrl1[] =
1096 "http://clients2.google.com/service/update2/crx"; 1097 "http://clients2.google.com/service/update2/crx";
1097 static const char kValidUpdateUrl2[] = 1098 static const char kValidUpdateUrl2[] =
1098 "https://clients2.google.com/service/update2/crx"; 1099 "https://clients2.google.com/service/update2/crx";
1099 } 1100 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), 1166 MakeSyncTestExtension(EXTENSION, GURL(), GURL(),
1166 Extension::INTERNAL, 0, FilePath())); 1167 Extension::INTERNAL, 0, FilePath()));
1167 EXPECT_TRUE(extension_internal->IsSyncable()); 1168 EXPECT_TRUE(extension_internal->IsSyncable());
1168 1169
1169 scoped_refptr<Extension> extension_noninternal( 1170 scoped_refptr<Extension> extension_noninternal(
1170 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), 1171 MakeSyncTestExtension(EXTENSION, GURL(), GURL(),
1171 Extension::COMPONENT, 0, FilePath())); 1172 Extension::COMPONENT, 0, FilePath()));
1172 EXPECT_FALSE(extension_noninternal->IsSyncable()); 1173 EXPECT_FALSE(extension_noninternal->IsSyncable());
1173 } 1174 }
1174 1175
1176 TEST(ExtensionTest, DontSyncDefault) {
1177 scoped_refptr<Extension> extension_default(
1178 MakeSyncTestExtension(EXTENSION, GURL(), GURL(),
1179 Extension::INTERNAL, 0, FilePath(),
1180 Extension::FROM_DEFAULT));
1181 EXPECT_FALSE(extension_default->IsSyncable());
1182 }
1183
1175 // These last 2 tests don't make sense on Chrome OS, where extension plugins 1184 // These last 2 tests don't make sense on Chrome OS, where extension plugins
1176 // are not allowed. 1185 // are not allowed.
1177 #if !defined(OS_CHROMEOS) 1186 #if !defined(OS_CHROMEOS)
1178 TEST(ExtensionTest, GetSyncTypeExtensionWithPlugin) { 1187 TEST(ExtensionTest, GetSyncTypeExtensionWithPlugin) {
1179 scoped_refptr<Extension> extension( 1188 scoped_refptr<Extension> extension(
1180 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), 1189 MakeSyncTestExtension(EXTENSION, GURL(), GURL(),
1181 Extension::INTERNAL, 1, FilePath())); 1190 Extension::INTERNAL, 1, FilePath()));
1182 if (extension) 1191 if (extension)
1183 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); 1192 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE);
1184 } 1193 }
1185 1194
1186 TEST(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { 1195 TEST(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) {
1187 scoped_refptr<Extension> extension( 1196 scoped_refptr<Extension> extension(
1188 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), 1197 MakeSyncTestExtension(EXTENSION, GURL(), GURL(),
1189 Extension::INTERNAL, 2, FilePath())); 1198 Extension::INTERNAL, 2, FilePath()));
1190 if (extension) 1199 if (extension)
1191 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); 1200 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE);
1192 } 1201 }
1193 #endif // !defined(OS_CHROMEOS) 1202 #endif // !defined(OS_CHROMEOS)
OLDNEW
« chrome/common/extensions/extension.cc ('K') | « chrome/common/extensions/extension.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698