OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/customization_document.h" | 5 #include "chrome/browser/chromeos/customization_document.h" |
6 | 6 |
7 #include "chromeos/system/mock_statistics_provider.h" | 7 #include "chromeos/system/mock_statistics_provider.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 " }," | 40 " }," |
41 " {" | 41 " {" |
42 " \"hwid_mask\": \"Mario 1?3*\"," | 42 " \"hwid_mask\": \"Mario 1?3*\"," |
43 " \"initial_locale\" : \"ru-RU\"," | 43 " \"initial_locale\" : \"ru-RU\"," |
44 " \"initial_timezone\" : \"Europe/Moscow\"," | 44 " \"initial_timezone\" : \"Europe/Moscow\"," |
45 " \"keyboard_layout\" : \"xkb:ru::rus\"," | 45 " \"keyboard_layout\" : \"xkb:ru::rus\"," |
46 " }," | 46 " }," |
47 " ]," | 47 " ]," |
48 "}"; | 48 "}"; |
49 | 49 |
| 50 const char kMultiLanguageStartupManifest[] = |
| 51 "{\n" |
| 52 " \"version\": \"1.0\",\n" |
| 53 " \"initial_locale\" : \"en-US,de,fr,it\",\n" |
| 54 " \"initial_timezone\" : \"Europe/Zurich\",\n" |
| 55 " \"keyboard_layout\" : \"xkb:us::eng\",\n" |
| 56 " \"registration_url\" : \"http://www.google.com\",\n" |
| 57 " \"setup_content\" : {\n" |
| 58 " \"default\" : {\n" |
| 59 " \"help_page\" : \"file:///opt/oem/help/en-US/help.html\",\n" |
| 60 " \"eula_page\" : \"file:///opt/oem/eula/en-US/eula.html\",\n" |
| 61 " },\n" |
| 62 " }," |
| 63 "}"; |
| 64 |
50 const char kBadManifest[] = "{\"version\": \"1\"}"; | 65 const char kBadManifest[] = "{\"version\": \"1\"}"; |
51 | 66 |
52 const char kGoodServicesManifest[] = | 67 const char kGoodServicesManifest[] = |
53 "{" | 68 "{" |
54 " \"version\": \"1.0\"," | 69 " \"version\": \"1.0\"," |
55 " \"app_content\" : {" | 70 " \"app_content\" : {" |
56 " \"en-US\" : {" | 71 " \"en-US\" : {" |
57 " \"initial_start_page\": \"http://mario/promo\"," | 72 " \"initial_start_page\": \"http://mario/promo\"," |
58 " \"support_page\": \"http://mario/us\"," | 73 " \"support_page\": \"http://mario/us\"," |
59 " }," | 74 " }," |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 EXPECT_EQ("http://mario/ru/promo", | 165 EXPECT_EQ("http://mario/ru/promo", |
151 customization.GetInitialStartPage("ru-RU")); | 166 customization.GetInitialStartPage("ru-RU")); |
152 EXPECT_EQ("http://mario/global/promo", | 167 EXPECT_EQ("http://mario/global/promo", |
153 customization.GetInitialStartPage("ja")); | 168 customization.GetInitialStartPage("ja")); |
154 | 169 |
155 EXPECT_EQ("http://mario/us", customization.GetSupportPage("en-US")); | 170 EXPECT_EQ("http://mario/us", customization.GetSupportPage("en-US")); |
156 EXPECT_EQ("http://mario/ru", customization.GetSupportPage("ru-RU")); | 171 EXPECT_EQ("http://mario/ru", customization.GetSupportPage("ru-RU")); |
157 EXPECT_EQ("http://mario/global", customization.GetSupportPage("ja")); | 172 EXPECT_EQ("http://mario/global", customization.GetSupportPage("ja")); |
158 } | 173 } |
159 | 174 |
| 175 #define EXPECT_LOCALE_ENTRY(i, value) \ |
| 176 if (customization.configured_locales().size() > i) \ |
| 177 EXPECT_EQ(value, customization.configured_locales()[i]) \ |
| 178 << "Bad locale value at index " << i |
| 179 |
| 180 TEST(ServicesCustomizationDocumentTest, MultiLanguage) { |
| 181 system::MockStatisticsProvider mock_statistics_provider; |
| 182 StartupCustomizationDocument customization(&mock_statistics_provider, |
| 183 kMultiLanguageStartupManifest); |
| 184 EXPECT_TRUE(customization.IsReady()); |
| 185 |
| 186 EXPECT_EQ("en-US,de,fr,it", customization.initial_locale()); |
| 187 EXPECT_EQ("en-US", customization.initial_locale_default()); |
| 188 EXPECT_EQ(4u, customization.configured_locales().size()); |
| 189 |
| 190 EXPECT_LOCALE_ENTRY(0, "en-US"); |
| 191 EXPECT_LOCALE_ENTRY(1, "de"); |
| 192 EXPECT_LOCALE_ENTRY(2, "fr"); |
| 193 EXPECT_LOCALE_ENTRY(3, "it"); |
| 194 } |
| 195 |
160 TEST(ServicesCustomizationDocumentTest, BadManifest) { | 196 TEST(ServicesCustomizationDocumentTest, BadManifest) { |
161 ServicesCustomizationDocument customization(kBadManifest); | 197 ServicesCustomizationDocument customization(kBadManifest); |
162 EXPECT_FALSE(customization.IsReady()); | 198 EXPECT_FALSE(customization.IsReady()); |
163 } | 199 } |
164 | 200 |
165 } // namespace chromeos | 201 } // namespace chromeos |
OLD | NEW |