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 "chrome/browser/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 ResettableSettingsSnapshot nonorganic_snap(profile()); | 719 ResettableSettingsSnapshot nonorganic_snap(profile()); |
720 EXPECT_EQ(ResettableSettingsSnapshot::ALL_FIELDS, | 720 EXPECT_EQ(ResettableSettingsSnapshot::ALL_FIELDS, |
721 empty_snap.FindDifferentFields(nonorganic_snap)); | 721 empty_snap.FindDifferentFields(nonorganic_snap)); |
722 empty_snap.Subtract(nonorganic_snap); | 722 empty_snap.Subtract(nonorganic_snap); |
723 EXPECT_TRUE(empty_snap.startup_urls().empty()); | 723 EXPECT_TRUE(empty_snap.startup_urls().empty()); |
724 EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), | 724 EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), |
725 empty_snap.startup_type()); | 725 empty_snap.startup_type()); |
726 EXPECT_TRUE(empty_snap.homepage().empty()); | 726 EXPECT_TRUE(empty_snap.homepage().empty()); |
727 EXPECT_TRUE(empty_snap.homepage_is_ntp()); | 727 EXPECT_TRUE(empty_snap.homepage_is_ntp()); |
728 EXPECT_NE(std::string::npos, empty_snap.dse_url().find("{google:baseURL}")); | 728 EXPECT_NE(std::string::npos, empty_snap.dse_url().find("{google:baseURL}")); |
729 EXPECT_EQ(std::vector<std::string>(), empty_snap.enabled_extensions()); | 729 EXPECT_EQ(ResettableSettingsSnapshot::ExtensionList(), |
| 730 empty_snap.enabled_extensions()); |
730 | 731 |
731 // Reset to organic defaults. | 732 // Reset to organic defaults. |
732 ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | | 733 ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | |
733 ProfileResetter::HOMEPAGE | | 734 ProfileResetter::HOMEPAGE | |
734 ProfileResetter::STARTUP_PAGES | | 735 ProfileResetter::STARTUP_PAGES | |
735 ProfileResetter::EXTENSIONS); | 736 ProfileResetter::EXTENSIONS); |
736 | 737 |
737 ResettableSettingsSnapshot organic_snap(profile()); | 738 ResettableSettingsSnapshot organic_snap(profile()); |
738 EXPECT_EQ(ResettableSettingsSnapshot::ALL_FIELDS, | 739 EXPECT_EQ(ResettableSettingsSnapshot::ALL_FIELDS, |
739 nonorganic_snap.FindDifferentFields(organic_snap)); | 740 nonorganic_snap.FindDifferentFields(organic_snap)); |
740 nonorganic_snap.Subtract(organic_snap); | 741 nonorganic_snap.Subtract(organic_snap); |
741 const GURL urls[] = {GURL("http://foo.de"), GURL("http://goo.gl")}; | 742 const GURL urls[] = {GURL("http://foo.de"), GURL("http://goo.gl")}; |
742 EXPECT_EQ(std::vector<GURL>(urls, urls + arraysize(urls)), | 743 EXPECT_EQ(std::vector<GURL>(urls, urls + arraysize(urls)), |
743 nonorganic_snap.startup_urls()); | 744 nonorganic_snap.startup_urls()); |
744 EXPECT_EQ(SessionStartupPref::URLS, nonorganic_snap.startup_type()); | 745 EXPECT_EQ(SessionStartupPref::URLS, nonorganic_snap.startup_type()); |
745 EXPECT_EQ("http://www.foo.com", nonorganic_snap.homepage()); | 746 EXPECT_EQ("http://www.foo.com", nonorganic_snap.homepage()); |
746 EXPECT_FALSE(nonorganic_snap.homepage_is_ntp()); | 747 EXPECT_FALSE(nonorganic_snap.homepage_is_ntp()); |
747 EXPECT_EQ("http://www.foo.com/s?q={searchTerms}", nonorganic_snap.dse_url()); | 748 EXPECT_EQ("http://www.foo.com/s?q={searchTerms}", nonorganic_snap.dse_url()); |
748 EXPECT_EQ(std::vector<std::string>(1, ext_id), | 749 EXPECT_EQ(ResettableSettingsSnapshot::ExtensionList( |
749 nonorganic_snap.enabled_extensions()); | 750 1, std::make_pair(ext_id, "example")), |
| 751 nonorganic_snap.enabled_extensions()); |
750 } | 752 } |
751 | 753 |
752 TEST_F(ProfileResetterTest, FeedbackSerializtionTest) { | 754 TEST_F(ProfileResetterTest, FeedbackSerializtionTest) { |
753 // Reset to non organic defaults. | 755 // Reset to non organic defaults. |
754 ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | | 756 ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | |
755 ProfileResetter::HOMEPAGE | | 757 ProfileResetter::HOMEPAGE | |
756 ProfileResetter::STARTUP_PAGES, kDistributionConfig); | 758 ProfileResetter::STARTUP_PAGES, kDistributionConfig); |
757 | 759 |
758 scoped_refptr<Extension> ext = CreateExtension( | 760 scoped_refptr<Extension> ext = CreateExtension( |
759 "example", | 761 "example", |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::HOMEPAGE_IS_NTP), | 798 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::HOMEPAGE_IS_NTP), |
797 dict->GetBoolean("homepage_is_ntp", &homepage_is_ntp)); | 799 dict->GetBoolean("homepage_is_ntp", &homepage_is_ntp)); |
798 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::DSE_URL), | 800 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::DSE_URL), |
799 dict->GetString("default_search_engine", &default_search_engine)); | 801 dict->GetString("default_search_engine", &default_search_engine)); |
800 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::EXTENSIONS), | 802 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::EXTENSIONS), |
801 dict->GetList("enabled_extensions", &extensions)); | 803 dict->GetList("enabled_extensions", &extensions)); |
802 } | 804 } |
803 } | 805 } |
804 | 806 |
805 } // namespace | 807 } // namespace |
OLD | NEW |