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

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

Issue 100543005: Update all users of base::Version to explicitly specify the namespace, and clean up the header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: someday it will work Created 7 years 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) 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 void RemoveExtension(const std::string& id) { 242 void RemoveExtension(const std::string& id) {
243 extension_map_.erase(id); 243 extension_map_.erase(id);
244 } 244 }
245 245
246 // ExternalProvider implementation: 246 // ExternalProvider implementation:
247 virtual void VisitRegisteredExtension() OVERRIDE { 247 virtual void VisitRegisteredExtension() OVERRIDE {
248 visit_count_++; 248 visit_count_++;
249 for (DataMap::const_iterator i = extension_map_.begin(); 249 for (DataMap::const_iterator i = extension_map_.begin();
250 i != extension_map_.end(); ++i) { 250 i != extension_map_.end(); ++i) {
251 Version version(i->second.first); 251 base::Version version(i->second.first);
252 252
253 visitor_->OnExternalExtensionFileFound( 253 visitor_->OnExternalExtensionFileFound(
254 i->first, &version, i->second.second, location_, 254 i->first, &version, i->second.second, location_,
255 Extension::NO_FLAGS, false); 255 Extension::NO_FLAGS, false);
256 } 256 }
257 visitor_->OnExternalProviderReady(this); 257 visitor_->OnExternalProviderReady(this);
258 } 258 }
259 259
260 virtual bool HasExtension(const std::string& id) const OVERRIDE { 260 virtual bool HasExtension(const std::string& id) const OVERRIDE {
261 return extension_map_.find(id) != extension_map_.end(); 261 return extension_map_.find(id) != extension_map_.end();
262 } 262 }
263 263
264 virtual bool GetExtensionDetails( 264 virtual bool GetExtensionDetails(
265 const std::string& id, 265 const std::string& id,
266 Manifest::Location* location, 266 Manifest::Location* location,
267 scoped_ptr<Version>* version) const OVERRIDE { 267 scoped_ptr<base::Version>* version) const OVERRIDE {
268 DataMap::const_iterator it = extension_map_.find(id); 268 DataMap::const_iterator it = extension_map_.find(id);
269 if (it == extension_map_.end()) 269 if (it == extension_map_.end())
270 return false; 270 return false;
271 271
272 if (version) 272 if (version)
273 version->reset(new Version(it->second.first)); 273 version->reset(new base::Version(it->second.first));
274 274
275 if (location) 275 if (location)
276 *location = location_; 276 *location = location_;
277 277
278 return true; 278 return true;
279 } 279 }
280 280
281 virtual bool IsReady() const OVERRIDE { 281 virtual bool IsReady() const OVERRIDE {
282 return true; 282 return true;
283 } 283 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 // Reset our counter. 353 // Reset our counter.
354 ids_found_ = 0; 354 ids_found_ = 0;
355 // Ask the provider to look up all extensions and return them. 355 // Ask the provider to look up all extensions and return them.
356 provider_->VisitRegisteredExtension(); 356 provider_->VisitRegisteredExtension();
357 357
358 return ids_found_; 358 return ids_found_;
359 } 359 }
360 360
361 virtual bool OnExternalExtensionFileFound(const std::string& id, 361 virtual bool OnExternalExtensionFileFound(const std::string& id,
362 const Version* version, 362 const base::Version* version,
363 const base::FilePath& path, 363 const base::FilePath& path,
364 Manifest::Location unused, 364 Manifest::Location unused,
365 int creation_flags, 365 int creation_flags,
366 bool mark_acknowledged) OVERRIDE { 366 bool mark_acknowledged) OVERRIDE {
367 EXPECT_EQ(expected_creation_flags_, creation_flags); 367 EXPECT_EQ(expected_creation_flags_, creation_flags);
368 368
369 ++ids_found_; 369 ++ids_found_;
370 base::DictionaryValue* pref; 370 base::DictionaryValue* pref;
371 // This tests is to make sure that the provider only notifies us of the 371 // This tests is to make sure that the provider only notifies us of the
372 // values we gave it. So if the id we doesn't exist in our internal 372 // values we gave it. So if the id we doesn't exist in our internal
373 // dictionary then something is wrong. 373 // dictionary then something is wrong.
374 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) 374 EXPECT_TRUE(prefs_->GetDictionary(id, &pref))
375 << "Got back ID (" << id.c_str() << ") we weren't expecting"; 375 << "Got back ID (" << id.c_str() << ") we weren't expecting";
376 376
377 EXPECT_TRUE(path.IsAbsolute()); 377 EXPECT_TRUE(path.IsAbsolute());
378 if (!fake_base_path_.empty()) 378 if (!fake_base_path_.empty())
379 EXPECT_TRUE(fake_base_path_.IsParent(path)); 379 EXPECT_TRUE(fake_base_path_.IsParent(path));
380 380
381 if (pref) { 381 if (pref) {
382 EXPECT_TRUE(provider_->HasExtension(id)); 382 EXPECT_TRUE(provider_->HasExtension(id));
383 383
384 // Ask provider if the extension we got back is registered. 384 // Ask provider if the extension we got back is registered.
385 Manifest::Location location = Manifest::INVALID_LOCATION; 385 Manifest::Location location = Manifest::INVALID_LOCATION;
386 scoped_ptr<Version> v1; 386 scoped_ptr<base::Version> v1;
387 base::FilePath crx_path; 387 base::FilePath crx_path;
388 388
389 EXPECT_TRUE(provider_->GetExtensionDetails(id, NULL, &v1)); 389 EXPECT_TRUE(provider_->GetExtensionDetails(id, NULL, &v1));
390 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str()); 390 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str());
391 391
392 scoped_ptr<Version> v2; 392 scoped_ptr<base::Version> v2;
393 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location, &v2)); 393 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location, &v2));
394 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str()); 394 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str());
395 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str()); 395 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str());
396 EXPECT_EQ(Manifest::EXTERNAL_PREF, location); 396 EXPECT_EQ(Manifest::EXTERNAL_PREF, location);
397 397
398 // Remove it so we won't count it ever again. 398 // Remove it so we won't count it ever again.
399 prefs_->Remove(id, NULL); 399 prefs_->Remove(id, NULL);
400 } 400 }
401 return true; 401 return true;
402 } 402 }
403 403
404 virtual bool OnExternalExtensionUpdateUrlFound( 404 virtual bool OnExternalExtensionUpdateUrlFound(
405 const std::string& id, const GURL& update_url, 405 const std::string& id, const GURL& update_url,
406 Manifest::Location location, 406 Manifest::Location location,
407 int creation_flags, 407 int creation_flags,
408 bool mark_acknowledged) OVERRIDE { 408 bool mark_acknowledged) OVERRIDE {
409 ++ids_found_; 409 ++ids_found_;
410 base::DictionaryValue* pref; 410 base::DictionaryValue* pref;
411 // This tests is to make sure that the provider only notifies us of the 411 // This tests is to make sure that the provider only notifies us of the
412 // values we gave it. So if the id we doesn't exist in our internal 412 // values we gave it. So if the id we doesn't exist in our internal
413 // dictionary then something is wrong. 413 // dictionary then something is wrong.
414 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) 414 EXPECT_TRUE(prefs_->GetDictionary(id, &pref))
415 << L"Got back ID (" << id.c_str() << ") we weren't expecting"; 415 << L"Got back ID (" << id.c_str() << ") we weren't expecting";
416 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location); 416 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location);
417 417
418 if (pref) { 418 if (pref) {
419 EXPECT_TRUE(provider_->HasExtension(id)); 419 EXPECT_TRUE(provider_->HasExtension(id));
420 420
421 // External extensions with update URLs do not have versions. 421 // External extensions with update URLs do not have versions.
422 scoped_ptr<Version> v1; 422 scoped_ptr<base::Version> v1;
423 Manifest::Location location1 = Manifest::INVALID_LOCATION; 423 Manifest::Location location1 = Manifest::INVALID_LOCATION;
424 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1)); 424 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1));
425 EXPECT_FALSE(v1.get()); 425 EXPECT_FALSE(v1.get());
426 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1); 426 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1);
427 427
428 // Remove it so we won't count it again. 428 // Remove it so we won't count it again.
429 prefs_->Remove(id, NULL); 429 prefs_->Remove(id, NULL);
430 } 430 }
431 return true; 431 return true;
432 } 432 }
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 // extension object. 1768 // extension object.
1769 TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) { 1769 TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) {
1770 const char kPrefFromBookmark[] = "from_bookmark"; 1770 const char kPrefFromBookmark[] = "from_bookmark";
1771 1771
1772 InitializeEmptyExtensionService(); 1772 InitializeEmptyExtensionService();
1773 1773
1774 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1774 base::FilePath path = data_dir_.AppendASCII("good.crx");
1775 set_extensions_enabled(true); 1775 set_extensions_enabled(true);
1776 1776
1777 // Register and install an external extension. 1777 // Register and install an external extension.
1778 Version version("1.0.0.0"); 1778 base::Version version("1.0.0.0");
1779 content::WindowedNotificationObserver observer( 1779 content::WindowedNotificationObserver observer(
1780 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 1780 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
1781 content::NotificationService::AllSources()); 1781 content::NotificationService::AllSources());
1782 if (service_->OnExternalExtensionFileFound( 1782 if (service_->OnExternalExtensionFileFound(
1783 good_crx, 1783 good_crx,
1784 &version, 1784 &version,
1785 path, 1785 path,
1786 Manifest::EXTERNAL_PREF, 1786 Manifest::EXTERNAL_PREF,
1787 Extension::FROM_BOOKMARK, 1787 Extension::FROM_BOOKMARK,
1788 false /* mark_acknowledged */)) { 1788 false /* mark_acknowledged */)) {
(...skipping 15 matching lines...) Expand all
1804 } 1804 }
1805 1805
1806 // Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED 1806 // Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED
1807 TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { 1807 TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
1808 InitializeEmptyExtensionService(); 1808 InitializeEmptyExtensionService();
1809 1809
1810 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1810 base::FilePath path = data_dir_.AppendASCII("good.crx");
1811 set_extensions_enabled(true); 1811 set_extensions_enabled(true);
1812 1812
1813 // Install an external extension. 1813 // Install an external extension.
1814 Version version("1.0.0.0"); 1814 base::Version version("1.0.0.0");
1815 content::WindowedNotificationObserver observer( 1815 content::WindowedNotificationObserver observer(
1816 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 1816 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
1817 content::NotificationService::AllSources()); 1817 content::NotificationService::AllSources());
1818 if (service_->OnExternalExtensionFileFound(good_crx, &version, 1818 if (service_->OnExternalExtensionFileFound(good_crx, &version,
1819 path, Manifest::EXTERNAL_PREF, 1819 path, Manifest::EXTERNAL_PREF,
1820 Extension::NO_FLAGS, false)) { 1820 Extension::NO_FLAGS, false)) {
1821 observer.Wait(); 1821 observer.Wait();
1822 } 1822 }
1823 1823
1824 ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); 1824 ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
1825 1825
1826 // Uninstall it and check that its killbit gets set. 1826 // Uninstall it and check that its killbit gets set.
1827 UninstallExtension(good_crx, false); 1827 UninstallExtension(good_crx, false);
1828 ValidateIntegerPref(good_crx, "location", 1828 ValidateIntegerPref(good_crx, "location",
1829 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1829 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1830 1830
1831 // Try to re-install it externally. This should fail because of the killbit. 1831 // Try to re-install it externally. This should fail because of the killbit.
1832 service_->OnExternalExtensionFileFound(good_crx, &version, 1832 service_->OnExternalExtensionFileFound(good_crx, &version,
1833 path, Manifest::EXTERNAL_PREF, 1833 path, Manifest::EXTERNAL_PREF,
1834 Extension::NO_FLAGS, false); 1834 Extension::NO_FLAGS, false);
1835 base::RunLoop().RunUntilIdle(); 1835 base::RunLoop().RunUntilIdle();
1836 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1836 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1837 ValidateIntegerPref(good_crx, "location", 1837 ValidateIntegerPref(good_crx, "location",
1838 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1838 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1839 1839
1840 version = Version("1.0.0.1"); 1840 version = base::Version("1.0.0.1");
1841 // Repeat the same thing with a newer version of the extension. 1841 // Repeat the same thing with a newer version of the extension.
1842 path = data_dir_.AppendASCII("good2.crx"); 1842 path = data_dir_.AppendASCII("good2.crx");
1843 service_->OnExternalExtensionFileFound(good_crx, &version, 1843 service_->OnExternalExtensionFileFound(good_crx, &version,
1844 path, Manifest::EXTERNAL_PREF, 1844 path, Manifest::EXTERNAL_PREF,
1845 Extension::NO_FLAGS, false); 1845 Extension::NO_FLAGS, false);
1846 base::RunLoop().RunUntilIdle(); 1846 base::RunLoop().RunUntilIdle();
1847 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1847 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1848 ValidateIntegerPref(good_crx, "location", 1848 ValidateIntegerPref(good_crx, "location",
1849 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1849 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1850 1850
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 MockExtensionProvider provider(NULL, Manifest::EXTERNAL_REGISTRY); 1886 MockExtensionProvider provider(NULL, Manifest::EXTERNAL_REGISTRY);
1887 service_->OnExternalProviderReady(&provider); 1887 service_->OnExternalProviderReady(&provider);
1888 } 1888 }
1889 1889
1890 // Test that external extensions with incorrect IDs are not installed. 1890 // Test that external extensions with incorrect IDs are not installed.
1891 TEST_F(ExtensionServiceTest, FailOnWrongId) { 1891 TEST_F(ExtensionServiceTest, FailOnWrongId) {
1892 InitializeEmptyExtensionService(); 1892 InitializeEmptyExtensionService();
1893 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1893 base::FilePath path = data_dir_.AppendASCII("good.crx");
1894 set_extensions_enabled(true); 1894 set_extensions_enabled(true);
1895 1895
1896 Version version("1.0.0.0"); 1896 base::Version version("1.0.0.0");
1897 1897
1898 const std::string wrong_id = all_zero; 1898 const std::string wrong_id = all_zero;
1899 const std::string correct_id = good_crx; 1899 const std::string correct_id = good_crx;
1900 ASSERT_NE(correct_id, wrong_id); 1900 ASSERT_NE(correct_id, wrong_id);
1901 1901
1902 // Install an external extension with an ID from the external 1902 // Install an external extension with an ID from the external
1903 // source that is not equal to the ID in the extension manifest. 1903 // source that is not equal to the ID in the extension manifest.
1904 content::WindowedNotificationObserver observer( 1904 content::WindowedNotificationObserver observer(
1905 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 1905 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
1906 content::NotificationService::AllSources()); 1906 content::NotificationService::AllSources());
(...skipping 17 matching lines...) Expand all
1924 } 1924 }
1925 1925
1926 // Test that external extensions with incorrect versions are not installed. 1926 // Test that external extensions with incorrect versions are not installed.
1927 TEST_F(ExtensionServiceTest, FailOnWrongVersion) { 1927 TEST_F(ExtensionServiceTest, FailOnWrongVersion) {
1928 InitializeEmptyExtensionService(); 1928 InitializeEmptyExtensionService();
1929 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1929 base::FilePath path = data_dir_.AppendASCII("good.crx");
1930 set_extensions_enabled(true); 1930 set_extensions_enabled(true);
1931 1931
1932 // Install an external extension with a version from the external 1932 // Install an external extension with a version from the external
1933 // source that is not equal to the version in the extension manifest. 1933 // source that is not equal to the version in the extension manifest.
1934 Version wrong_version("1.2.3.4"); 1934 base::Version wrong_version("1.2.3.4");
1935 content::WindowedNotificationObserver observer( 1935 content::WindowedNotificationObserver observer(
1936 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 1936 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
1937 content::NotificationService::AllSources()); 1937 content::NotificationService::AllSources());
1938 service_->OnExternalExtensionFileFound( 1938 service_->OnExternalExtensionFileFound(
1939 good_crx, &wrong_version, path, Manifest::EXTERNAL_PREF, 1939 good_crx, &wrong_version, path, Manifest::EXTERNAL_PREF,
1940 Extension::NO_FLAGS, false); 1940 Extension::NO_FLAGS, false);
1941 1941
1942 observer.Wait(); 1942 observer.Wait();
1943 ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); 1943 ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
1944 1944
1945 // Try again with the right version. Expect success. 1945 // Try again with the right version. Expect success.
1946 service_->pending_extension_manager()->Remove(good_crx); 1946 service_->pending_extension_manager()->Remove(good_crx);
1947 Version correct_version("1.0.0.0"); 1947 base::Version correct_version("1.0.0.0");
1948 content::WindowedNotificationObserver observer2( 1948 content::WindowedNotificationObserver observer2(
1949 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 1949 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
1950 content::NotificationService::AllSources()); 1950 content::NotificationService::AllSources());
1951 if (service_->OnExternalExtensionFileFound( 1951 if (service_->OnExternalExtensionFileFound(
1952 good_crx, &correct_version, path, Manifest::EXTERNAL_PREF, 1952 good_crx, &correct_version, path, Manifest::EXTERNAL_PREF,
1953 Extension::NO_FLAGS, false)) { 1953 Extension::NO_FLAGS, false)) {
1954 observer2.Wait(); 1954 observer2.Wait();
1955 } 1955 }
1956 ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); 1956 ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
1957 } 1957 }
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
3342 3342
3343 base::FilePath path = data_dir_.AppendASCII("good.crx"); 3343 base::FilePath path = data_dir_.AppendASCII("good.crx");
3344 const Extension* good = InstallCRX(path, INSTALL_NEW); 3344 const Extension* good = InstallCRX(path, INSTALL_NEW);
3345 ASSERT_EQ(1u, service_->extensions()->size()); 3345 ASSERT_EQ(1u, service_->extensions()->size());
3346 3346
3347 EXPECT_FALSE(good->is_theme()); 3347 EXPECT_FALSE(good->is_theme());
3348 3348
3349 // Use AddExtensionImpl() as AddFrom*() would balk. 3349 // Use AddExtensionImpl() as AddFrom*() would balk.
3350 service_->pending_extension_manager()->AddExtensionImpl( 3350 service_->pending_extension_manager()->AddExtensionImpl(
3351 good->id(), extensions::ManifestURL::GetUpdateURL(good), 3351 good->id(), extensions::ManifestURL::GetUpdateURL(good),
3352 Version(), &IsExtension, kGoodIsFromSync, 3352 base::Version(), &IsExtension, kGoodIsFromSync,
3353 kGoodInstallSilently, Manifest::INTERNAL, 3353 kGoodInstallSilently, Manifest::INTERNAL,
3354 Extension::NO_FLAGS, false); 3354 Extension::NO_FLAGS, false);
3355 UpdateExtension(good->id(), path, ENABLED); 3355 UpdateExtension(good->id(), path, ENABLED);
3356 3356
3357 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); 3357 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId));
3358 } 3358 }
3359 3359
3360 #if defined(ENABLE_BLACKLIST_TESTS) 3360 #if defined(ENABLE_BLACKLIST_TESTS)
3361 // Tests blacklisting then unblacklisting extensions after the service has been 3361 // Tests blacklisting then unblacklisting extensions after the service has been
3362 // initialized. 3362 // initialized.
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after
6057 // Skip install when the location has the same priority as the installed 6057 // Skip install when the location has the same priority as the installed
6058 // location. 6058 // location.
6059 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound( 6059 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(
6060 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL, 6060 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL,
6061 Extension::NO_FLAGS, false)); 6061 Extension::NO_FLAGS, false));
6062 6062
6063 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6063 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6064 } 6064 }
6065 6065
6066 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) { 6066 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) {
6067 Version older_version("0.1.0.0"); 6067 base::Version older_version("0.1.0.0");
6068 Version newer_version("2.0.0.0"); 6068 base::Version newer_version("2.0.0.0");
6069 6069
6070 // We don't want the extension to be installed. A path that doesn't 6070 // We don't want the extension to be installed. A path that doesn't
6071 // point to a valid CRX ensures this. 6071 // point to a valid CRX ensures this.
6072 const base::FilePath kInvalidPathToCrx = base::FilePath(); 6072 const base::FilePath kInvalidPathToCrx = base::FilePath();
6073 6073
6074 const int kCreationFlags = 0; 6074 const int kCreationFlags = 0;
6075 const bool kDontMarkAcknowledged = false; 6075 const bool kDontMarkAcknowledged = false;
6076 6076
6077 InitializeEmptyExtensionService(); 6077 InitializeEmptyExtensionService();
6078 6078
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
6236 // Because EXTERNAL_PREF is a lower priority source than EXTERNAL_REGISTRY, 6236 // Because EXTERNAL_PREF is a lower priority source than EXTERNAL_REGISTRY,
6237 // adding from external pref will now fail. 6237 // adding from external pref will now fail.
6238 EXPECT_FALSE( 6238 EXPECT_FALSE(
6239 service_->OnExternalExtensionFileFound( 6239 service_->OnExternalExtensionFileFound(
6240 kGoodId, &newer_version, kInvalidPathToCrx, 6240 kGoodId, &newer_version, kInvalidPathToCrx,
6241 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 6241 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
6242 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 6242 EXPECT_TRUE(pending->IsIdPending(kGoodId));
6243 } 6243 }
6244 6244
6245 TEST_F(ExtensionServiceTest, ConcurrentExternalLocalFile) { 6245 TEST_F(ExtensionServiceTest, ConcurrentExternalLocalFile) {
6246 Version kVersion123("1.2.3"); 6246 base::Version kVersion123("1.2.3");
6247 Version kVersion124("1.2.4"); 6247 base::Version kVersion124("1.2.4");
6248 Version kVersion125("1.2.5"); 6248 base::Version kVersion125("1.2.5");
6249 const base::FilePath kInvalidPathToCrx = base::FilePath(); 6249 const base::FilePath kInvalidPathToCrx = base::FilePath();
6250 const int kCreationFlags = 0; 6250 const int kCreationFlags = 0;
6251 const bool kDontMarkAcknowledged = false; 6251 const bool kDontMarkAcknowledged = false;
6252 6252
6253 InitializeEmptyExtensionService(); 6253 InitializeEmptyExtensionService();
6254 6254
6255 extensions::PendingExtensionManager* pending = 6255 extensions::PendingExtensionManager* pending =
6256 service_->pending_extension_manager(); 6256 service_->pending_extension_manager();
6257 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6257 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6258 6258
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
6342 6342
6343 // Fake an external source adding a URL to fetch an extension from. 6343 // Fake an external source adding a URL to fetch an extension from.
6344 bool AddPendingExternalPrefUrl() { 6344 bool AddPendingExternalPrefUrl() {
6345 return service_->pending_extension_manager()->AddFromExternalUpdateUrl( 6345 return service_->pending_extension_manager()->AddFromExternalUpdateUrl(
6346 crx_id_, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD, 6346 crx_id_, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD,
6347 Extension::NO_FLAGS, false); 6347 Extension::NO_FLAGS, false);
6348 } 6348 }
6349 6349
6350 // Fake an external file from external_extensions.json. 6350 // Fake an external file from external_extensions.json.
6351 bool AddPendingExternalPrefFileInstall() { 6351 bool AddPendingExternalPrefFileInstall() {
6352 Version version("1.0.0.0"); 6352 base::Version version("1.0.0.0");
6353 6353
6354 return service_->OnExternalExtensionFileFound( 6354 return service_->OnExternalExtensionFileFound(
6355 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF, 6355 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF,
6356 Extension::NO_FLAGS, false); 6356 Extension::NO_FLAGS, false);
6357 } 6357 }
6358 6358
6359 // Fake a request from sync to install an extension. 6359 // Fake a request from sync to install an extension.
6360 bool AddPendingSyncInstall() { 6360 bool AddPendingSyncInstall() {
6361 return service_->pending_extension_manager()->AddFromSync( 6361 return service_->pending_extension_manager()->AddFromSync(
6362 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently); 6362 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
6766 // ReconcileKnownDisabled(). 6766 // ReconcileKnownDisabled().
6767 service_->EnableExtension(good2); 6767 service_->EnableExtension(good2);
6768 service_->ReconcileKnownDisabled(); 6768 service_->ReconcileKnownDisabled();
6769 expected_extensions.insert(good2); 6769 expected_extensions.insert(good2);
6770 expected_disabled_extensions.erase(good2); 6770 expected_disabled_extensions.erase(good2);
6771 6771
6772 EXPECT_EQ(expected_extensions, service_->extensions()->GetIDs()); 6772 EXPECT_EQ(expected_extensions, service_->extensions()->GetIDs());
6773 EXPECT_EQ(expected_disabled_extensions, 6773 EXPECT_EQ(expected_disabled_extensions,
6774 service_->disabled_extensions()->GetIDs()); 6774 service_->disabled_extensions()->GetIDs());
6775 } 6775 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_sync_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698