| 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 "chrome/browser/chromeos/mock_system_access.h" | 7 #include "chrome/browser/chromeos/mock_system_access.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 using ::testing::SetArgumentPointee; | 78 using ::testing::SetArgumentPointee; |
| 79 | 79 |
| 80 TEST(StartupCustomizationDocumentTest, Basic) { | 80 TEST(StartupCustomizationDocumentTest, Basic) { |
| 81 MockSystemAccess mock_system_access; | 81 MockSystemAccess mock_system_access; |
| 82 EXPECT_CALL(mock_system_access, GetMachineStatistic(_, NotNull())) | 82 EXPECT_CALL(mock_system_access, GetMachineStatistic(_, NotNull())) |
| 83 .WillRepeatedly(Return(false)); | 83 .WillRepeatedly(Return(false)); |
| 84 EXPECT_CALL(mock_system_access, | 84 EXPECT_CALL(mock_system_access, |
| 85 GetMachineStatistic(std::string("hwid"), NotNull())) | 85 GetMachineStatistic(std::string("hwid"), NotNull())) |
| 86 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Mario 12345")), | 86 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Mario 12345")), |
| 87 Return(true))); | 87 Return(true))); |
| 88 StartupCustomizationDocument customization(&mock_system_access); | 88 StartupCustomizationDocument customization(&mock_system_access, |
| 89 EXPECT_TRUE(customization.LoadManifestFromString(kGoodStartupManifest)); | 89 kGoodStartupManifest); |
| 90 EXPECT_EQ(customization.initial_locale(), "ru-RU"); | 90 EXPECT_EQ(customization.initial_locale(), "ru-RU"); |
| 91 EXPECT_EQ(customization.initial_timezone(), "Europe/Moscow"); | 91 EXPECT_EQ(customization.initial_timezone(), "Europe/Moscow"); |
| 92 EXPECT_EQ(customization.keyboard_layout(), "xkb:ru::rus"); | 92 EXPECT_EQ(customization.keyboard_layout(), "xkb:ru::rus"); |
| 93 EXPECT_EQ(customization.registration_url(), "http://www.google.com"); | 93 EXPECT_EQ(customization.registration_url(), "http://www.google.com"); |
| 94 | 94 |
| 95 EXPECT_EQ(customization.GetHelpPage("en-US"), | 95 EXPECT_EQ(customization.GetHelpPage("en-US"), |
| 96 "file:///opt/oem/help/en-US/help.html"); | 96 "file:///opt/oem/help/en-US/help.html"); |
| 97 EXPECT_EQ(customization.GetHelpPage("ru-RU"), | 97 EXPECT_EQ(customization.GetHelpPage("ru-RU"), |
| 98 "file:///opt/oem/help/ru-RU/help.html"); | 98 "file:///opt/oem/help/ru-RU/help.html"); |
| 99 EXPECT_EQ(customization.GetHelpPage("ja"), | 99 EXPECT_EQ(customization.GetHelpPage("ja"), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 118 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("ja")), | 118 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("ja")), |
| 119 Return(true))); | 119 Return(true))); |
| 120 EXPECT_CALL(mock_system_access, | 120 EXPECT_CALL(mock_system_access, |
| 121 GetMachineStatistic(std::string("initial_timezone"), NotNull())) | 121 GetMachineStatistic(std::string("initial_timezone"), NotNull())) |
| 122 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Asia/Tokyo")), | 122 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("Asia/Tokyo")), |
| 123 Return(true))); | 123 Return(true))); |
| 124 EXPECT_CALL(mock_system_access, | 124 EXPECT_CALL(mock_system_access, |
| 125 GetMachineStatistic(std::string("keyboard_layout"), NotNull())) | 125 GetMachineStatistic(std::string("keyboard_layout"), NotNull())) |
| 126 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("mozc-jp")), | 126 .WillOnce(DoAll(SetArgumentPointee<1>(std::string("mozc-jp")), |
| 127 Return(true))); | 127 Return(true))); |
| 128 StartupCustomizationDocument customization(&mock_system_access); | 128 StartupCustomizationDocument customization(&mock_system_access, |
| 129 EXPECT_TRUE(customization.LoadManifestFromString(kGoodStartupManifest)); | 129 kGoodStartupManifest); |
| 130 EXPECT_TRUE(customization.IsReady()); |
| 130 EXPECT_EQ(customization.initial_locale(), "ja"); | 131 EXPECT_EQ(customization.initial_locale(), "ja"); |
| 131 EXPECT_EQ(customization.initial_timezone(), "Asia/Tokyo"); | 132 EXPECT_EQ(customization.initial_timezone(), "Asia/Tokyo"); |
| 132 EXPECT_EQ(customization.keyboard_layout(), "mozc-jp"); | 133 EXPECT_EQ(customization.keyboard_layout(), "mozc-jp"); |
| 133 } | 134 } |
| 134 | 135 |
| 135 TEST(StartupCustomizationDocumentTest, BadManifest) { | 136 TEST(StartupCustomizationDocumentTest, BadManifest) { |
| 136 MockSystemAccess mock_system_access; | 137 MockSystemAccess mock_system_access; |
| 137 StartupCustomizationDocument customization(&mock_system_access); | 138 StartupCustomizationDocument customization(&mock_system_access, kBadManifest); |
| 138 EXPECT_FALSE(customization.LoadManifestFromString(kBadManifest)); | 139 EXPECT_FALSE(customization.IsReady()); |
| 139 } | 140 } |
| 140 | 141 |
| 141 TEST(ServicesCustomizationDocumentTest, Basic) { | 142 TEST(ServicesCustomizationDocumentTest, Basic) { |
| 142 chromeos::ServicesCustomizationDocument customization; | 143 ServicesCustomizationDocument customization(kGoodServicesManifest); |
| 143 EXPECT_TRUE(customization.LoadManifestFromString(kGoodServicesManifest)); | 144 EXPECT_TRUE(customization.IsReady()); |
| 144 | 145 |
| 145 EXPECT_EQ(customization.GetInitialStartPage("en-US"), | 146 EXPECT_EQ(customization.GetInitialStartPage("en-US"), |
| 146 "http://mario/promo"); | 147 "http://mario/promo"); |
| 147 EXPECT_EQ(customization.GetInitialStartPage("ru-RU"), | 148 EXPECT_EQ(customization.GetInitialStartPage("ru-RU"), |
| 148 "http://mario/ru/promo"); | 149 "http://mario/ru/promo"); |
| 149 EXPECT_EQ(customization.GetInitialStartPage("ja"), | 150 EXPECT_EQ(customization.GetInitialStartPage("ja"), |
| 150 "http://mario/global/promo"); | 151 "http://mario/global/promo"); |
| 151 | 152 |
| 152 | |
| 153 EXPECT_EQ(customization.GetSupportPage("en-US"), | 153 EXPECT_EQ(customization.GetSupportPage("en-US"), |
| 154 "http://mario/us"); | 154 "http://mario/us"); |
| 155 EXPECT_EQ(customization.GetSupportPage("ru-RU"), | 155 EXPECT_EQ(customization.GetSupportPage("ru-RU"), |
| 156 "http://mario/ru"); | 156 "http://mario/ru"); |
| 157 EXPECT_EQ(customization.GetSupportPage("ja"), | 157 EXPECT_EQ(customization.GetSupportPage("ja"), |
| 158 "http://mario/global"); | 158 "http://mario/global"); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST(ServicesCustomizationDocumentTest, BadManifest) { | 161 TEST(ServicesCustomizationDocumentTest, BadManifest) { |
| 162 chromeos::ServicesCustomizationDocument customization; | 162 ServicesCustomizationDocument customization(kBadManifest); |
| 163 EXPECT_FALSE(customization.LoadManifestFromString(kBadManifest)); | 163 EXPECT_FALSE(customization.IsReady()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace chromeos | 166 } // namespace chromeos |
| OLD | NEW |