| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
| 6 #include "base/time.h" | 6 #include "base/time.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/web_resource/web_resource_service.h" | 10 #include "chrome/browser/web_resource/web_resource_service.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 base::JSONReader::Read(json, false))); | 87 base::JSONReader::Read(json, false))); |
| 88 | 88 |
| 89 // Check that prefs are set correctly. | 89 // Check that prefs are set correctly. |
| 90 web_resource_service->UnpackLogoSignal(*(test_json.get())); | 90 web_resource_service->UnpackLogoSignal(*(test_json.get())); |
| 91 logo_start = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoStart); | 91 logo_start = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoStart); |
| 92 ASSERT_EQ(logo_start, 0); // date value reset to 0; | 92 ASSERT_EQ(logo_start, 0); // date value reset to 0; |
| 93 logo_end = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoEnd); | 93 logo_end = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoEnd); |
| 94 ASSERT_EQ(logo_end, 0); // date value reset to 0; | 94 ASSERT_EQ(logo_end, 0); // date value reset to 0; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Crashing. See http://crbug.com/65462. | 97 TEST_F(WebResourceServiceTest, UnpackPromoSignal) { |
| 98 TEST_F(WebResourceServiceTest, DISABLED_UnpackPromoSignal) { | |
| 99 // Set up a testing profile and create a web resource service. | 98 // Set up a testing profile and create a web resource service. |
| 100 TestingProfile profile; | 99 TestingProfile profile; |
| 101 scoped_refptr<WebResourceService> web_resource_service( | 100 scoped_refptr<WebResourceService> web_resource_service( |
| 102 new WebResourceService(&profile)); | 101 new WebResourceService(&profile)); |
| 103 | 102 |
| 104 // Set up start and end dates and promo line in a Dictionary as if parsed | 103 // Set up start and end dates and promo line in a Dictionary as if parsed |
| 105 // from the service. | 104 // from the service. |
| 106 std::string json = "{ " | 105 std::string json = "{ " |
| 107 " \"topic\": {" | 106 " \"topic\": {" |
| 108 " \"answers\": [" | 107 " \"answers\": [" |
| 109 " {" | 108 " {" |
| 110 " \"name\": \"promo_start\"," | 109 " \"name\": \"promo_start\"," |
| 111 " \"tooltip\": \"Eat more pie!\"," | 110 " \"tooltip\": \"Eat more pie!\"," |
| 112 " \"inproduct\": \"31/01/10 01:00 GMT\"" | 111 " \"inproduct\": \"31/01/10 01:00 GMT\"" |
| 113 " }," | 112 " }," |
| 114 " {" | 113 " {" |
| 115 " \"name\": \"promo_end\"," | 114 " \"name\": \"promo_end\"," |
| 116 " \"inproduct\": \"31/01/12 01:00 GMT\"" | 115 " \"inproduct\": \"31/01/12 01:00 GMT\"" |
| 117 " }" | 116 " }" |
| 118 " ]" | 117 " ]" |
| 119 " }" | 118 " }" |
| 120 "}"; | 119 "}"; |
| 121 scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( | 120 scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( |
| 122 base::JSONReader::Read(json, false))); | 121 base::JSONReader::Read(json, false))); |
| 123 | 122 |
| 123 // Initialize a message loop for this to run on. |
| 124 MessageLoop loop; |
| 125 |
| 124 // Check that prefs are set correctly. | 126 // Check that prefs are set correctly. |
| 125 web_resource_service->UnpackPromoSignal(*(test_json.get())); | 127 web_resource_service->UnpackPromoSignal(*(test_json.get())); |
| 126 double promo_start = | 128 double promo_start = |
| 127 profile.GetPrefs()->GetReal(prefs::kNTPPromoStart); | 129 profile.GetPrefs()->GetReal(prefs::kNTPPromoStart); |
| 128 ASSERT_EQ(promo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT. | 130 ASSERT_EQ(promo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT. |
| 129 double promo_end = | 131 double promo_end = |
| 130 profile.GetPrefs()->GetReal(prefs::kNTPPromoEnd); | 132 profile.GetPrefs()->GetReal(prefs::kNTPPromoEnd); |
| 131 ASSERT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT. | 133 ASSERT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT. |
| 132 std::string promo_line = profile.GetPrefs()->GetString(prefs::kNTPPromoLine); | 134 std::string promo_line = profile.GetPrefs()->GetString(prefs::kNTPPromoLine); |
| 133 ASSERT_EQ(promo_line, "Eat more pie!"); | 135 ASSERT_EQ(promo_line, "Eat more pie!"); |
| 134 } | 136 } |
| 135 | 137 |
| OLD | NEW |