| 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 "base/time.h" | 7 #include "base/time.h" |
| 8 #include "chrome/browser/chromeos/mock_system_access.h" | 8 #include "chrome/browser/chromeos/system/mock_statistics_provider.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 const char kGoodStartupManifest[] = | 13 const char kGoodStartupManifest[] = |
| 14 "{" | 14 "{" |
| 15 " \"version\": \"1.0\"," | 15 " \"version\": \"1.0\"," |
| 16 " \"initial_locale\" : \"en-US\"," | 16 " \"initial_locale\" : \"en-US\"," |
| 17 " \"initial_timezone\" : \"US/Pacific\"," | 17 " \"initial_timezone\" : \"US/Pacific\"," |
| 18 " \"keyboard_layout\" : \"xkb:us::eng\"," | 18 " \"keyboard_layout\" : \"xkb:us::eng\"," |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 namespace chromeos { | 110 namespace chromeos { |
| 111 | 111 |
| 112 using ::testing::_; | 112 using ::testing::_; |
| 113 using ::testing::DoAll; | 113 using ::testing::DoAll; |
| 114 using ::testing::NotNull; | 114 using ::testing::NotNull; |
| 115 using ::testing::Return; | 115 using ::testing::Return; |
| 116 using ::testing::SetArgumentPointee; | 116 using ::testing::SetArgumentPointee; |
| 117 | 117 |
| 118 TEST(StartupCustomizationDocumentTest, Basic) { | 118 TEST(StartupCustomizationDocumentTest, Basic) { |
| 119 MockSystemAccess mock_system_access; | 119 MockStatisticsProvider mock_statistics_provider; |
| 120 EXPECT_CALL(mock_system_access, GetMachineStatistic(_, NotNull())) | 120 EXPECT_CALL(mock_statistics_provider, GetMachineStatistic(_, NotNull())) |
| 121 .WillRepeatedly(Return(false)); | 121 .WillRepeatedly(Return(false)); |
| 122 EXPECT_CALL(mock_system_access, | 122 EXPECT_CALL(mock_statistics_provider, |
| 123 GetMachineStatistic(std::string("hardware_class"), NotNull())) | 123 GetMachineStatistic(std::string("hardware_class"), NotNull())) |
| 124 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Mario 12345")), | 124 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Mario 12345")), |
| 125 Return(true))); | 125 Return(true))); |
| 126 StartupCustomizationDocument customization(&mock_system_access, | 126 StartupCustomizationDocument customization(&mock_statistics_provider, |
| 127 kGoodStartupManifest); | 127 kGoodStartupManifest); |
| 128 EXPECT_EQ("ru-RU", customization.initial_locale()); | 128 EXPECT_EQ("ru-RU", customization.initial_locale()); |
| 129 EXPECT_EQ("Europe/Moscow", customization.initial_timezone()); | 129 EXPECT_EQ("Europe/Moscow", customization.initial_timezone()); |
| 130 EXPECT_EQ("xkb:ru::rus", customization.keyboard_layout()); | 130 EXPECT_EQ("xkb:ru::rus", customization.keyboard_layout()); |
| 131 EXPECT_EQ("http://www.google.com", customization.registration_url()); | 131 EXPECT_EQ("http://www.google.com", customization.registration_url()); |
| 132 | 132 |
| 133 EXPECT_EQ("file:///opt/oem/help/en-US/help.html", | 133 EXPECT_EQ("file:///opt/oem/help/en-US/help.html", |
| 134 customization.GetHelpPage("en-US")); | 134 customization.GetHelpPage("en-US")); |
| 135 EXPECT_EQ("file:///opt/oem/help/ru-RU/help.html", | 135 EXPECT_EQ("file:///opt/oem/help/ru-RU/help.html", |
| 136 customization.GetHelpPage("ru-RU")); | 136 customization.GetHelpPage("ru-RU")); |
| 137 EXPECT_EQ("file:///opt/oem/help/en/help.html", | 137 EXPECT_EQ("file:///opt/oem/help/en/help.html", |
| 138 customization.GetHelpPage("ja")); | 138 customization.GetHelpPage("ja")); |
| 139 | 139 |
| 140 EXPECT_EQ("file:///opt/oem/eula/en-US/eula.html", | 140 EXPECT_EQ("file:///opt/oem/eula/en-US/eula.html", |
| 141 customization.GetEULAPage("en-US")); | 141 customization.GetEULAPage("en-US")); |
| 142 EXPECT_EQ("file:///opt/oem/eula/ru-RU/eula.html", | 142 EXPECT_EQ("file:///opt/oem/eula/ru-RU/eula.html", |
| 143 customization.GetEULAPage("ru-RU")); | 143 customization.GetEULAPage("ru-RU")); |
| 144 EXPECT_EQ("file:///opt/oem/eula/en/eula.html", | 144 EXPECT_EQ("file:///opt/oem/eula/en/eula.html", |
| 145 customization.GetEULAPage("ja")); | 145 customization.GetEULAPage("ja")); |
| 146 } | 146 } |
| 147 | 147 |
| 148 TEST(StartupCustomizationDocumentTest, VPD) { | 148 TEST(StartupCustomizationDocumentTest, VPD) { |
| 149 MockSystemAccess mock_system_access; | 149 MockStatisticsProvider mock_statistics_provider; |
| 150 EXPECT_CALL(mock_system_access, | 150 EXPECT_CALL(mock_statistics_provider, |
| 151 GetMachineStatistic(std::string("hardware_class"), NotNull())) | 151 GetMachineStatistic(std::string("hardware_class"), NotNull())) |
| 152 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Mario 12345")), | 152 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Mario 12345")), |
| 153 Return(true))); | 153 Return(true))); |
| 154 EXPECT_CALL(mock_system_access, | 154 EXPECT_CALL(mock_statistics_provider, |
| 155 GetMachineStatistic(std::string("initial_locale"), NotNull())) | 155 GetMachineStatistic(std::string("initial_locale"), NotNull())) |
| 156 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("ja")), | 156 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("ja")), |
| 157 Return(true))); | 157 Return(true))); |
| 158 EXPECT_CALL(mock_system_access, | 158 EXPECT_CALL(mock_statistics_provider, |
| 159 GetMachineStatistic(std::string("initial_timezone"), NotNull())) | 159 GetMachineStatistic(std::string("initial_timezone"), NotNull())) |
| 160 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Asia/Tokyo")), | 160 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Asia/Tokyo")), |
| 161 Return(true))); | 161 Return(true))); |
| 162 EXPECT_CALL(mock_system_access, | 162 EXPECT_CALL(mock_statistics_provider, |
| 163 GetMachineStatistic(std::string("keyboard_layout"), NotNull())) | 163 GetMachineStatistic(std::string("keyboard_layout"), NotNull())) |
| 164 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("mozc-jp")), | 164 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("mozc-jp")), |
| 165 Return(true))); | 165 Return(true))); |
| 166 StartupCustomizationDocument customization(&mock_system_access, | 166 StartupCustomizationDocument customization(&mock_statistics_provider, |
| 167 kGoodStartupManifest); | 167 kGoodStartupManifest); |
| 168 EXPECT_TRUE(customization.IsReady()); | 168 EXPECT_TRUE(customization.IsReady()); |
| 169 EXPECT_EQ("ja", customization.initial_locale()); | 169 EXPECT_EQ("ja", customization.initial_locale()); |
| 170 EXPECT_EQ("Asia/Tokyo", customization.initial_timezone()); | 170 EXPECT_EQ("Asia/Tokyo", customization.initial_timezone()); |
| 171 EXPECT_EQ("mozc-jp", customization.keyboard_layout()); | 171 EXPECT_EQ("mozc-jp", customization.keyboard_layout()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST(StartupCustomizationDocumentTest, BadManifest) { | 174 TEST(StartupCustomizationDocumentTest, BadManifest) { |
| 175 MockSystemAccess mock_system_access; | 175 MockStatisticsProvider mock_statistics_provider; |
| 176 StartupCustomizationDocument customization(&mock_system_access, kBadManifest); | 176 StartupCustomizationDocument customization(&mock_statistics_provider, |
| 177 kBadManifest); |
| 177 EXPECT_FALSE(customization.IsReady()); | 178 EXPECT_FALSE(customization.IsReady()); |
| 178 } | 179 } |
| 179 | 180 |
| 180 TEST(ServicesCustomizationDocumentTest, Basic) { | 181 TEST(ServicesCustomizationDocumentTest, Basic) { |
| 181 ServicesCustomizationDocument customization(kGoodServicesManifest, "en-US"); | 182 ServicesCustomizationDocument customization(kGoodServicesManifest, "en-US"); |
| 182 EXPECT_TRUE(customization.IsReady()); | 183 EXPECT_TRUE(customization.IsReady()); |
| 183 | 184 |
| 184 EXPECT_EQ("http://mario/promo", | 185 EXPECT_EQ("http://mario/promo", |
| 185 customization.GetInitialStartPage("en-US")); | 186 customization.GetInitialStartPage("en-US")); |
| 186 EXPECT_EQ("http://mario/ru/promo", | 187 EXPECT_EQ("http://mario/ru/promo", |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 EXPECT_TRUE(deal != NULL); | 244 EXPECT_TRUE(deal != NULL); |
| 244 | 245 |
| 245 ServicesCustomizationDocument customization_old_deal(kOldDealServicesManifest, | 246 ServicesCustomizationDocument customization_old_deal(kOldDealServicesManifest, |
| 246 "en-US"); | 247 "en-US"); |
| 247 EXPECT_TRUE(customization_old_deal.IsReady()); | 248 EXPECT_TRUE(customization_old_deal.IsReady()); |
| 248 deal = customization_old_deal.GetCarrierDeal("Carrier (country)", false); | 249 deal = customization_old_deal.GetCarrierDeal("Carrier (country)", false); |
| 249 EXPECT_TRUE(deal != NULL); | 250 EXPECT_TRUE(deal != NULL); |
| 250 } | 251 } |
| 251 | 252 |
| 252 } // namespace chromeos | 253 } // namespace chromeos |
| OLD | NEW |