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

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

Issue 3063002: Merge 53127 - Added checks to handle unsyncable extensions.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 5 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions_service_unittest.h" 5 #include "chrome/browser/extensions/extensions_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 ASSERT_TRUE(extension); 1274 ASSERT_TRUE(extension);
1275 1275
1276 bool enabled = service_->GetExtensionById(kGoodId, false); 1276 bool enabled = service_->GetExtensionById(kGoodId, false);
1277 EXPECT_EQ(kGoodInitialState == Extension::ENABLED, enabled); 1277 EXPECT_EQ(kGoodInitialState == Extension::ENABLED, enabled);
1278 EXPECT_EQ(kGoodInitialState, 1278 EXPECT_EQ(kGoodInitialState,
1279 service_->extension_prefs()->GetExtensionState(extension->id())); 1279 service_->extension_prefs()->GetExtensionState(extension->id()));
1280 EXPECT_EQ(kGoodInitialIncognitoEnabled, 1280 EXPECT_EQ(kGoodInitialIncognitoEnabled,
1281 service_->IsIncognitoEnabled(extension)); 1281 service_->IsIncognitoEnabled(extension));
1282 } 1282 }
1283 1283
1284 // Test updating a pending theme.
1285 TEST_F(ExtensionsServiceTest, UpdatePendingTheme) {
1286 InitializeEmptyExtensionsService();
1287 service_->AddPendingExtension(
1288 theme_crx, GURL(), true, false, Extension::ENABLED, false);
1289 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), theme_crx));
1290
1291 FilePath extensions_path;
1292 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1293 extensions_path = extensions_path.AppendASCII("extensions");
1294 FilePath path = extensions_path.AppendASCII("theme.crx");
1295 UpdateExtension(theme_crx, path, ENABLED);
1296
1297 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), theme_crx));
1298
1299 Extension* extension = service_->GetExtensionById(theme_crx, true);
1300 ASSERT_TRUE(extension);
1301
1302 EXPECT_EQ(Extension::ENABLED,
1303 service_->extension_prefs()->GetExtensionState(extension->id()));
1304 EXPECT_FALSE(service_->IsIncognitoEnabled(extension));
1305 }
1306
1284 // TODO(akalin): Test updating a pending extension non-silently once 1307 // TODO(akalin): Test updating a pending extension non-silently once
1285 // we can mock out ExtensionInstallUI and inject our version into 1308 // we can mock out ExtensionInstallUI and inject our version into
1286 // UpdateExtension(). 1309 // UpdateExtension().
1287 1310
1288 // Test updating a pending extension with wrong is_theme. 1311 // Test updating a pending extension with wrong is_theme.
1289 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionWrongIsTheme) { 1312 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionWrongIsTheme) {
1290 InitializeEmptyExtensionsService(); 1313 InitializeEmptyExtensionsService();
1291 // Add pending extension with a flipped is_theme. 1314 // Add pending extension with a flipped is_theme.
1292 service_->AddPendingExtension( 1315 service_->AddPendingExtension(
1293 kGoodId, GURL(kGoodUpdateURL), !kGoodIsTheme, 1316 kGoodId, GURL(kGoodUpdateURL), !kGoodIsTheme,
1294 kGoodInstallSilently, kGoodInitialState, 1317 kGoodInstallSilently, kGoodInitialState,
1295 kGoodInitialIncognitoEnabled); 1318 kGoodInitialIncognitoEnabled);
1296 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId)); 1319 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId));
1297 1320
1298 FilePath extensions_path; 1321 FilePath extensions_path;
1299 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1322 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1300 extensions_path = extensions_path.AppendASCII("extensions"); 1323 extensions_path = extensions_path.AppendASCII("extensions");
1301 FilePath path = extensions_path.AppendASCII("good.crx"); 1324 FilePath path = extensions_path.AppendASCII("good.crx");
1302 UpdateExtension(kGoodId, path, UPDATED); 1325 UpdateExtension(kGoodId, path, UPDATED);
1303 1326
1304 // TODO(akalin): Figure out how to check that the extensions 1327 // TODO(akalin): Figure out how to check that the extensions
1305 // directory is cleaned up properly in OnExtensionInstalled(). 1328 // directory is cleaned up properly in OnExtensionInstalled().
1306 1329
1307 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId)); 1330 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId));
1308 } 1331 }
1309 1332
1333 // TODO(akalin): Figure out how to test that installs of pending
1334 // unsyncable extensions are blocked.
1335
1310 // Test updating a pending extension for one that is not pending. 1336 // Test updating a pending extension for one that is not pending.
1311 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionNotPending) { 1337 TEST_F(ExtensionsServiceTest, UpdatePendingExtensionNotPending) {
1312 InitializeEmptyExtensionsService(); 1338 InitializeEmptyExtensionsService();
1313 1339
1314 FilePath extensions_path; 1340 FilePath extensions_path;
1315 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1341 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1316 extensions_path = extensions_path.AppendASCII("extensions"); 1342 extensions_path = extensions_path.AppendASCII("extensions");
1317 FilePath path = extensions_path.AppendASCII("good.crx"); 1343 FilePath path = extensions_path.AppendASCII("good.crx");
1318 UpdateExtension(kGoodId, path, UPDATED); 1344 UpdateExtension(kGoodId, path, UPDATED);
1319 1345
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 // Component extensions shouldn't get recourded in the prefs. 2120 // Component extensions shouldn't get recourded in the prefs.
2095 ValidatePrefKeyCount(0); 2121 ValidatePrefKeyCount(0);
2096 2122
2097 // Reload all extensions, and make sure it comes back. 2123 // Reload all extensions, and make sure it comes back.
2098 std::string extension_id = service_->extensions()->at(0)->id(); 2124 std::string extension_id = service_->extensions()->at(0)->id();
2099 loaded_.clear(); 2125 loaded_.clear();
2100 service_->ReloadExtensions(); 2126 service_->ReloadExtensions();
2101 ASSERT_EQ(1u, service_->extensions()->size()); 2127 ASSERT_EQ(1u, service_->extensions()->size());
2102 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); 2128 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id());
2103 } 2129 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/sync/glue/extension_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698