| 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 11 matching lines...) Expand all  Loading... | 
| 22 #include "chrome/browser/themes/theme_service_factory.h" | 22 #include "chrome/browser/themes/theme_service_factory.h" | 
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" | 
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" | 
| 26 #include "chrome/test/base/browser_with_test_window_test.h" | 26 #include "chrome/test/base/browser_with_test_window_test.h" | 
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" | 
| 28 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" | 
| 29 #include "extensions/common/manifest_constants.h" | 29 #include "extensions/common/manifest_constants.h" | 
| 30 #include "net/http/http_response_headers.h" | 30 #include "net/http/http_response_headers.h" | 
| 31 #include "net/url_request/test_url_fetcher_factory.h" | 31 #include "net/url_request/test_url_fetcher_factory.h" | 
|  | 32 #include "url/gurl.h" | 
| 32 | 33 | 
| 33 | 34 | 
| 34 namespace { | 35 namespace { | 
| 35 | 36 | 
| 36 const char kDistributionConfig[] = "{" | 37 const char kDistributionConfig[] = "{" | 
| 37     " \"homepage\" : \"http://www.foo.com\"," | 38     " \"homepage\" : \"http://www.foo.com\"," | 
| 38     " \"homepage_is_newtabpage\" : false," | 39     " \"homepage_is_newtabpage\" : false," | 
| 39     " \"browser\" : {" | 40     " \"browser\" : {" | 
| 40     "   \"show_home_button\" : true" | 41     "   \"show_home_button\" : true" | 
| 41     "  }," | 42     "  }," | 
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 642 | 643 | 
| 643 TEST_F(ProfileResetterTest, ResetFewFlags) { | 644 TEST_F(ProfileResetterTest, ResetFewFlags) { | 
| 644   // mock_object_ is a StrictMock, so we verify that it is called only once. | 645   // mock_object_ is a StrictMock, so we verify that it is called only once. | 
| 645   ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | | 646   ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE | | 
| 646                ProfileResetter::HOMEPAGE | | 647                ProfileResetter::HOMEPAGE | | 
| 647                ProfileResetter::CONTENT_SETTINGS); | 648                ProfileResetter::CONTENT_SETTINGS); | 
| 648 } | 649 } | 
| 649 | 650 | 
| 650 // Tries to load unavailable config file. | 651 // Tries to load unavailable config file. | 
| 651 TEST_F(ConfigParserTest, NoConnectivity) { | 652 TEST_F(ConfigParserTest, NoConnectivity) { | 
| 652   const std::string url("http://test"); | 653   const GURL url("http://test"); | 
| 653   factory().SetFakeResponse(url, "", false); | 654   factory().SetFakeResponse(url, "", false); | 
| 654 | 655 | 
| 655   scoped_ptr<BrandcodeConfigFetcher> fetcher = WaitForRequest(GURL(url)); | 656   scoped_ptr<BrandcodeConfigFetcher> fetcher = WaitForRequest(GURL(url)); | 
| 656   EXPECT_FALSE(fetcher->GetSettings()); | 657   EXPECT_FALSE(fetcher->GetSettings()); | 
| 657 } | 658 } | 
| 658 | 659 | 
| 659 // Tries to load available config file. | 660 // Tries to load available config file. | 
| 660 TEST_F(ConfigParserTest, ParseConfig) { | 661 TEST_F(ConfigParserTest, ParseConfig) { | 
| 661   const std::string url("http://test"); | 662   const GURL url("http://test"); | 
| 662   std::string xml_config(kXmlConfig); | 663   std::string xml_config(kXmlConfig); | 
| 663   ReplaceString(&xml_config, "placeholder_for_data", kDistributionConfig); | 664   ReplaceString(&xml_config, "placeholder_for_data", kDistributionConfig); | 
| 664   ReplaceString(&xml_config, | 665   ReplaceString(&xml_config, | 
| 665                 "placeholder_for_id", | 666                 "placeholder_for_id", | 
| 666                 "abbaabbaabbaabbaabbaabbaabbaabba"); | 667                 "abbaabbaabbaabbaabbaabbaabbaabba"); | 
| 667   factory().SetFakeResponse(url, xml_config, true); | 668   factory().SetFakeResponse(url, xml_config, true); | 
| 668 | 669 | 
| 669   scoped_ptr<BrandcodeConfigFetcher> fetcher = WaitForRequest(GURL(url)); | 670   scoped_ptr<BrandcodeConfigFetcher> fetcher = WaitForRequest(GURL(url)); | 
| 670   scoped_ptr<BrandcodedDefaultSettings> settings = fetcher->GetSettings(); | 671   scoped_ptr<BrandcodedDefaultSettings> settings = fetcher->GetSettings(); | 
| 671   ASSERT_TRUE(settings); | 672   ASSERT_TRUE(settings); | 
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 798     EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::HOMEPAGE_IS_NTP), | 799     EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::HOMEPAGE_IS_NTP), | 
| 799               dict->GetBoolean("homepage_is_ntp", &homepage_is_ntp)); | 800               dict->GetBoolean("homepage_is_ntp", &homepage_is_ntp)); | 
| 800     EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::DSE_URL), | 801     EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::DSE_URL), | 
| 801               dict->GetString("default_search_engine", &default_search_engine)); | 802               dict->GetString("default_search_engine", &default_search_engine)); | 
| 802     EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::EXTENSIONS), | 803     EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::EXTENSIONS), | 
| 803               dict->GetList("enabled_extensions", &extensions)); | 804               dict->GetList("enabled_extensions", &extensions)); | 
| 804   } | 805   } | 
| 805 } | 806 } | 
| 806 | 807 | 
| 807 }  // namespace | 808 }  // namespace | 
| OLD | NEW | 
|---|