| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 public: | 207 public: |
| 208 CustomizationVPDTest() | 208 CustomizationVPDTest() |
| 209 : statistics_provider_(new system::FakeStatisticsProvider()) { | 209 : statistics_provider_(new system::FakeStatisticsProvider()) { |
| 210 // Set the instance returned by GetInstance() for testing. | 210 // Set the instance returned by GetInstance() for testing. |
| 211 system::StatisticsProvider::SetTestProvider(statistics_provider_.get()); | 211 system::StatisticsProvider::SetTestProvider(statistics_provider_.get()); |
| 212 statistics_provider_->SetMachineStatistic("initial_locale", GetParam()); | 212 statistics_provider_->SetMachineStatistic("initial_locale", GetParam()); |
| 213 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); | 213 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); |
| 214 } | 214 } |
| 215 | 215 |
| 216 private: | 216 private: |
| 217 scoped_ptr<system::FakeStatisticsProvider> statistics_provider_; | 217 std::unique_ptr<system::FakeStatisticsProvider> statistics_provider_; |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 IN_PROC_BROWSER_TEST_P(CustomizationVPDTest, GetUILanguageList) { | 220 IN_PROC_BROWSER_TEST_P(CustomizationVPDTest, GetUILanguageList) { |
| 221 std::vector<std::string> locales = base::SplitString( | 221 std::vector<std::string> locales = base::SplitString( |
| 222 GetParam(), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 222 GetParam(), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 223 | 223 |
| 224 for (std::string& l : locales) { | 224 for (std::string& l : locales) { |
| 225 base::TrimString(l, " ", &l); | 225 base::TrimString(l, " ", &l); |
| 226 } | 226 } |
| 227 EXPECT_EQ(locales, | 227 EXPECT_EQ(locales, |
| 228 StartupCustomizationDocument::GetInstance()->configured_locales()) | 228 StartupCustomizationDocument::GetInstance()->configured_locales()) |
| 229 << "Test failed for initial_locale='" << GetParam() | 229 << "Test failed for initial_locale='" << GetParam() |
| 230 << "', locales=" << Print(locales); | 230 << "', locales=" << Print(locales); |
| 231 | 231 |
| 232 scoped_ptr<base::ListValue> ui_language_list = GetUILanguageList(NULL, ""); | 232 std::unique_ptr<base::ListValue> ui_language_list = |
| 233 GetUILanguageList(NULL, ""); |
| 233 EXPECT_GE(ui_language_list->GetSize(), locales.size()) | 234 EXPECT_GE(ui_language_list->GetSize(), locales.size()) |
| 234 << "Test failed for initial_locale='" << GetParam() << "'"; | 235 << "Test failed for initial_locale='" << GetParam() << "'"; |
| 235 | 236 |
| 236 for (size_t i = 0; i < ui_language_list->GetSize(); ++i) { | 237 for (size_t i = 0; i < ui_language_list->GetSize(); ++i) { |
| 237 base::DictionaryValue* language_info = NULL; | 238 base::DictionaryValue* language_info = NULL; |
| 238 ASSERT_TRUE(ui_language_list->GetDictionary(i, &language_info)) | 239 ASSERT_TRUE(ui_language_list->GetDictionary(i, &language_info)) |
| 239 << "Test failed for initial_locale='" << GetParam() << "', i=" << i; | 240 << "Test failed for initial_locale='" << GetParam() << "', i=" << i; |
| 240 | 241 |
| 241 std::string value; | 242 std::string value; |
| 242 ASSERT_TRUE(language_info->GetString("value", &value)) | 243 ASSERT_TRUE(language_info->GetString("value", &value)) |
| 243 << "Test failed for initial_locale='" << GetParam() << "', i=" << i; | 244 << "Test failed for initial_locale='" << GetParam() << "', i=" << i; |
| 244 | 245 |
| 245 if (i < locales.size()) { | 246 if (i < locales.size()) { |
| 246 EXPECT_EQ(locales[i], value) << "Test failed for initial_locale='" | 247 EXPECT_EQ(locales[i], value) << "Test failed for initial_locale='" |
| 247 << GetParam() << "', i=" << i; | 248 << GetParam() << "', i=" << i; |
| 248 } else { | 249 } else { |
| 249 EXPECT_EQ(kMostRelevantLanguagesDivider, value) | 250 EXPECT_EQ(kMostRelevantLanguagesDivider, value) |
| 250 << "Test failed for initial_locale='" << GetParam() << "', i=" << i; | 251 << "Test failed for initial_locale='" << GetParam() << "', i=" << i; |
| 251 break; | 252 break; |
| 252 } | 253 } |
| 253 } | 254 } |
| 254 } | 255 } |
| 255 | 256 |
| 256 INSTANTIATE_TEST_CASE_P(StringSequence, | 257 INSTANTIATE_TEST_CASE_P(StringSequence, |
| 257 CustomizationVPDTest, | 258 CustomizationVPDTest, |
| 258 testing::ValuesIn(kVPDInitialLocales)); | 259 testing::ValuesIn(kVPDInitialLocales)); |
| 259 | 260 |
| 260 } // namespace chromeos | 261 } // namespace chromeos |
| OLD | NEW |