OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 } | 454 } |
455 return true; | 455 return true; |
456 } | 456 } |
457 | 457 |
458 void OnExternalProviderReady( | 458 void OnExternalProviderReady( |
459 const extensions::ExternalProviderInterface* provider) override { | 459 const extensions::ExternalProviderInterface* provider) override { |
460 EXPECT_EQ(provider, provider_.get()); | 460 EXPECT_EQ(provider, provider_.get()); |
461 EXPECT_TRUE(provider->IsReady()); | 461 EXPECT_TRUE(provider->IsReady()); |
462 } | 462 } |
463 | 463 |
| 464 Profile* profile() { return profile_.get(); } |
| 465 |
464 private: | 466 private: |
465 int ids_found_; | 467 int ids_found_; |
466 base::FilePath fake_base_path_; | 468 base::FilePath fake_base_path_; |
467 int expected_creation_flags_; | 469 int expected_creation_flags_; |
468 scoped_ptr<extensions::ExternalProviderImpl> provider_; | 470 scoped_ptr<extensions::ExternalProviderImpl> provider_; |
469 scoped_ptr<base::DictionaryValue> prefs_; | 471 scoped_ptr<base::DictionaryValue> prefs_; |
470 scoped_ptr<TestingProfile> profile_; | 472 scoped_ptr<TestingProfile> profile_; |
471 | 473 |
472 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); | 474 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); |
473 }; | 475 }; |
(...skipping 5052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5526 base_path, Extension::WAS_INSTALLED_BY_OEM); | 5528 base_path, Extension::WAS_INSTALLED_BY_OEM); |
5527 json_data = | 5529 json_data = |
5528 "{" | 5530 "{" |
5529 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" | 5531 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" |
5530 " \"external_crx\": \"RandomExtension.crx\"," | 5532 " \"external_crx\": \"RandomExtension.crx\"," |
5531 " \"external_version\": \"1.0\"," | 5533 " \"external_version\": \"1.0\"," |
5532 " \"was_installed_by_oem\": true" | 5534 " \"was_installed_by_oem\": true" |
5533 " }" | 5535 " }" |
5534 "}"; | 5536 "}"; |
5535 EXPECT_EQ(1, was_installed_by_eom_visitor.Visit(json_data)); | 5537 EXPECT_EQ(1, was_installed_by_eom_visitor.Visit(json_data)); |
| 5538 |
| 5539 // Test min_profile_created_by_version. |
| 5540 MockProviderVisitor min_profile_created_by_version_visitor(base_path); |
| 5541 json_data = |
| 5542 "{" |
| 5543 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" |
| 5544 " \"external_crx\": \"RandomExtension.crx\"," |
| 5545 " \"external_version\": \"1.0\"," |
| 5546 " \"min_profile_created_by_version\": \"42.0.0.1\"" |
| 5547 " }," |
| 5548 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" |
| 5549 " \"external_crx\": \"RandomExtension2.crx\"," |
| 5550 " \"external_version\": \"1.0\"," |
| 5551 " \"min_profile_created_by_version\": \"43.0.0.1\"" |
| 5552 " }," |
| 5553 " \"cccccccccccccccccccccccccccccccc\": {" |
| 5554 " \"external_crx\": \"RandomExtension3.crx\"," |
| 5555 " \"external_version\": \"3.0\"," |
| 5556 " \"min_profile_created_by_version\": \"44.0.0.1\"" |
| 5557 " }" |
| 5558 "}"; |
| 5559 min_profile_created_by_version_visitor.profile()->GetPrefs()->SetString( |
| 5560 prefs::kProfileCreatedByVersion, "40.0.0.1"); |
| 5561 EXPECT_EQ(0, min_profile_created_by_version_visitor.Visit(json_data)); |
| 5562 min_profile_created_by_version_visitor.profile()->GetPrefs()->SetString( |
| 5563 prefs::kProfileCreatedByVersion, "43.0.0.1"); |
| 5564 EXPECT_EQ(2, min_profile_created_by_version_visitor.Visit(json_data)); |
| 5565 min_profile_created_by_version_visitor.profile()->GetPrefs()->SetString( |
| 5566 prefs::kProfileCreatedByVersion, "45.0.0.1"); |
| 5567 EXPECT_EQ(3, min_profile_created_by_version_visitor.Visit(json_data)); |
5536 } | 5568 } |
5537 | 5569 |
5538 // Test loading good extensions from the profile directory. | 5570 // Test loading good extensions from the profile directory. |
5539 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { | 5571 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { |
5540 // Ensure we're testing in "en" and leave global state untouched. | 5572 // Ensure we're testing in "en" and leave global state untouched. |
5541 extension_l10n_util::ScopedLocaleForTest testLocale("en"); | 5573 extension_l10n_util::ScopedLocaleForTest testLocale("en"); |
5542 | 5574 |
5543 // Initialize the test dir with a good Preferences/extensions. | 5575 // Initialize the test dir with a good Preferences/extensions. |
5544 base::FilePath source_install_dir = data_dir().AppendASCII("l10n"); | 5576 base::FilePath source_install_dir = data_dir().AppendASCII("l10n"); |
5545 base::FilePath pref_path = | 5577 base::FilePath pref_path = |
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7771 | 7803 |
7772 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7804 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
7773 content::Source<Profile>(profile()), | 7805 content::Source<Profile>(profile()), |
7774 content::NotificationService::NoDetails()); | 7806 content::NotificationService::NoDetails()); |
7775 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7807 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
7776 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 7808 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
7777 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 7809 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
7778 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 7810 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
7779 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 7811 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
7780 } | 7812 } |
OLD | NEW |