Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Side by Side Diff: chrome/browser/chromeos/mobile_config_unittest.cc

Issue 10141006: [cros] Add support for locale specific configuration in mobile config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/mobile_config.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/mobile_config.h" 5 #include "chrome/browser/chromeos/mobile_config.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 28 matching lines...) Expand all
39 " \"notification_text\" : \"3G connectivity : Carrier.\",\n" 39 " \"notification_text\" : \"3G connectivity : Carrier.\",\n"
40 " },\n" 40 " },\n"
41 " \"default\" : {\n" 41 " \"default\" : {\n"
42 " \"notification_text\" : \"default_text.\",\n" 42 " \"notification_text\" : \"default_text.\",\n"
43 " },\n" 43 " },\n"
44 " },\n" 44 " },\n"
45 " },\n" 45 " },\n"
46 " ],\n" 46 " ],\n"
47 " }," 47 " },"
48 " }," 48 " },"
49 " \"initial_locales\" : {\n"
50 " \"en-US\" : {\n"
51 " \"setup_url\" : \"accounts.carrier.com\",\n"
52 " },"
53 " },"
49 "}"; 54 "}";
50 55
51 const char kOldDealMobileConfig[] = 56 const char kOldDealMobileConfig[] =
52 "{" 57 "{"
53 " \"version\": \"1.0\"," 58 " \"version\": \"1.0\","
54 " \"carriers\" : {\n" 59 " \"carriers\" : {\n"
55 " \"Carrier (country)\" : {\n" 60 " \"Carrier (country)\" : {\n"
56 " \"top_up_url\" : \"http://www.carrier.com/\",\n" 61 " \"top_up_url\" : \"http://www.carrier.com/\",\n"
57 " \"deals\" : [\n" 62 " \"deals\" : [\n"
58 " {\n" 63 " {\n"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 " \"en-GB\" : {\n" 104 " \"en-GB\" : {\n"
100 " \"notification_text\" : \"3G connectivity : Carrier.\",\n" 105 " \"notification_text\" : \"3G connectivity : Carrier.\",\n"
101 " },\n" 106 " },\n"
102 " \"default\" : {\n" 107 " \"default\" : {\n"
103 " \"notification_text\" : \"default_text from local.\",\n" 108 " \"notification_text\" : \"default_text from local.\",\n"
104 " },\n" 109 " },\n"
105 " },\n" 110 " },\n"
106 " },\n" 111 " },\n"
107 " ],\n" 112 " ],\n"
108 " }," 113 " },"
109 " }," 114 " },"
115 " \"initial_locales\" : {\n"
116 " \"en-US\" : {\n"
117 " \"setup_url\" : \"accounts.carrier.com/localized/\",\n"
118 " },"
119 " },"
110 "}"; 120 "}";
111 121
112 } // anonymous namespace 122 } // anonymous namespace
113 123
114 namespace chromeos { 124 namespace chromeos {
115 125
116 TEST(MobileConfigTest, Basic) { 126 TEST(MobileConfigTest, Basic) {
117 MobileConfig config(kGoodMobileConfig, "en-US"); 127 MobileConfig config(kGoodMobileConfig, "en-US");
118 EXPECT_TRUE(config.IsReady()); 128 EXPECT_TRUE(config.IsReady());
119 129
(...skipping 12 matching lines...) Expand all
132 EXPECT_EQ("en-US", deal->locales()[0]); 142 EXPECT_EQ("en-US", deal->locales()[0]);
133 EXPECT_EQ(1, deal->notification_count()); 143 EXPECT_EQ(1, deal->notification_count());
134 EXPECT_EQ("3G connectivity : Carrier.", 144 EXPECT_EQ("3G connectivity : Carrier.",
135 deal->GetLocalizedString("en-US", "notification_text")); 145 deal->GetLocalizedString("en-US", "notification_text"));
136 EXPECT_EQ("default_text.", 146 EXPECT_EQ("default_text.",
137 deal->GetLocalizedString("en", "notification_text")); 147 deal->GetLocalizedString("en", "notification_text"));
138 148
139 base::Time reference_time; 149 base::Time reference_time;
140 base::Time::FromString("31/12/12 0:00", &reference_time); 150 base::Time::FromString("31/12/12 0:00", &reference_time);
141 EXPECT_EQ(reference_time, deal->expire_date()); 151 EXPECT_EQ(reference_time, deal->expire_date());
152
153 const MobileConfig::LocaleConfig* locale_config;
154 locale_config = config.GetLocaleConfig();
155 EXPECT_TRUE(locale_config != NULL);
156 EXPECT_EQ("accounts.carrier.com", locale_config->setup_url());
157
158 // Check same manifest but with another initial locale.
159 MobileConfig config_uk(kGoodMobileConfig, "en-GB");
160 EXPECT_TRUE(config_uk.IsReady());
161 locale_config = config_uk.GetLocaleConfig();
162 EXPECT_TRUE(locale_config == NULL);
142 } 163 }
143 164
144 TEST(MobileConfigTest, OldDeal) { 165 TEST(MobileConfigTest, OldDeal) {
145 MobileConfig config(kOldDealMobileConfig, "en-US"); 166 MobileConfig config(kOldDealMobileConfig, "en-US");
146 EXPECT_TRUE(config.IsReady()); 167 EXPECT_TRUE(config.IsReady());
147 const MobileConfig::Carrier* carrier; 168 const MobileConfig::Carrier* carrier;
148 carrier = config.GetCarrier("Carrier (country)"); 169 carrier = config.GetCarrier("Carrier (country)");
149 EXPECT_TRUE(carrier != NULL); 170 EXPECT_TRUE(carrier != NULL);
150 // Check default value. 171 // Check default value.
151 EXPECT_EQ(false, carrier->show_portal_button()); 172 EXPECT_EQ(false, carrier->show_portal_button());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_TRUE(deal != NULL); 227 EXPECT_TRUE(deal != NULL);
207 EXPECT_EQ("en-GB", deal->locales()[0]); 228 EXPECT_EQ("en-GB", deal->locales()[0]);
208 EXPECT_EQ(2, deal->notification_count()); 229 EXPECT_EQ(2, deal->notification_count());
209 EXPECT_EQ("3G connectivity : Carrier.", 230 EXPECT_EQ("3G connectivity : Carrier.",
210 deal->GetLocalizedString("en-GB", "notification_text")); 231 deal->GetLocalizedString("en-GB", "notification_text"));
211 EXPECT_EQ("default_text from local.", 232 EXPECT_EQ("default_text from local.",
212 deal->GetLocalizedString("en", "notification_text")); 233 deal->GetLocalizedString("en", "notification_text"));
213 base::Time reference_time; 234 base::Time reference_time;
214 base::Time::FromString("31/12/13 0:00", &reference_time); 235 base::Time::FromString("31/12/13 0:00", &reference_time);
215 EXPECT_EQ(reference_time, deal->expire_date()); 236 EXPECT_EQ(reference_time, deal->expire_date());
237
238 // Now reload same global/local config files but with proper initial locale.
239 MobileConfig config_us(kGoodMobileConfig, "en-US");
240 EXPECT_TRUE(config_us.IsReady());
241 config_us.LoadManifestFromString(kLocalMobileConfig);
242 EXPECT_TRUE(config_us.IsReady());
243 const MobileConfig::LocaleConfig* locale_config;
244 locale_config = config_us.GetLocaleConfig();
245 EXPECT_TRUE(locale_config != NULL);
246 EXPECT_EQ("accounts.carrier.com/localized/", locale_config->setup_url());
216 } 247 }
217 248
218 } // namespace chromeos 249 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/mobile_config.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698