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 #if defined(OS_CHROMEOS) | |
asargent_no_longer_on_chrome
2015/05/11 19:03:05
Can we remove the OS_CHROMEOS ifdef here too?
Dmitry Polukhin
2015/05/12 14:52:18
Done. Sorry, I forgot about this ifdef.
| |
5540 // Test min_profile_created_by_version. | |
5541 MockProviderVisitor min_profile_created_by_version_visitor(base_path); | |
5542 json_data = | |
5543 "{" | |
5544 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" | |
5545 " \"external_crx\": \"RandomExtension.crx\"," | |
5546 " \"external_version\": \"1.0\"," | |
5547 " \"min_profile_created_by_version\": \"42.0.0.1\"" | |
5548 " }," | |
5549 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" | |
5550 " \"external_crx\": \"RandomExtension2.crx\"," | |
5551 " \"external_version\": \"1.0\"," | |
5552 " \"min_profile_created_by_version\": \"43.0.0.1\"" | |
5553 " }," | |
5554 " \"cccccccccccccccccccccccccccccccc\": {" | |
5555 " \"external_crx\": \"RandomExtension3.crx\"," | |
5556 " \"external_version\": \"3.0\"," | |
5557 " \"min_profile_created_by_version\": \"44.0.0.1\"" | |
5558 " }" | |
5559 "}"; | |
5560 min_profile_created_by_version_visitor.profile()->GetPrefs()->SetString( | |
5561 prefs::kProfileCreatedByVersion, "40.0.0.1"); | |
5562 EXPECT_EQ(0, min_profile_created_by_version_visitor.Visit(json_data)); | |
5563 min_profile_created_by_version_visitor.profile()->GetPrefs()->SetString( | |
5564 prefs::kProfileCreatedByVersion, "43.0.0.1"); | |
5565 EXPECT_EQ(2, min_profile_created_by_version_visitor.Visit(json_data)); | |
5566 min_profile_created_by_version_visitor.profile()->GetPrefs()->SetString( | |
5567 prefs::kProfileCreatedByVersion, "45.0.0.1"); | |
5568 EXPECT_EQ(3, min_profile_created_by_version_visitor.Visit(json_data)); | |
5569 #endif // OS_CHROMEOS | |
5536 } | 5570 } |
5537 | 5571 |
5538 // Test loading good extensions from the profile directory. | 5572 // Test loading good extensions from the profile directory. |
5539 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { | 5573 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { |
5540 // Ensure we're testing in "en" and leave global state untouched. | 5574 // Ensure we're testing in "en" and leave global state untouched. |
5541 extension_l10n_util::ScopedLocaleForTest testLocale("en"); | 5575 extension_l10n_util::ScopedLocaleForTest testLocale("en"); |
5542 | 5576 |
5543 // Initialize the test dir with a good Preferences/extensions. | 5577 // Initialize the test dir with a good Preferences/extensions. |
5544 base::FilePath source_install_dir = data_dir().AppendASCII("l10n"); | 5578 base::FilePath source_install_dir = data_dir().AppendASCII("l10n"); |
5545 base::FilePath pref_path = | 5579 base::FilePath pref_path = |
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7771 | 7805 |
7772 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7806 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
7773 content::Source<Profile>(profile()), | 7807 content::Source<Profile>(profile()), |
7774 content::NotificationService::NoDetails()); | 7808 content::NotificationService::NoDetails()); |
7775 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7809 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
7776 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 7810 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
7777 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 7811 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
7778 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 7812 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
7779 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 7813 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
7780 } | 7814 } |
OLD | NEW |