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/language_usage_metrics.h" | 5 #include "components/language_usage_metrics/language_usage_metrics.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
| 9 namespace language_usage_metrics { |
| 10 |
9 TEST(LanguageUsageMetricsTest, ParseAcceptLanguages) { | 11 TEST(LanguageUsageMetricsTest, ParseAcceptLanguages) { |
10 std::set<int> language_set; | 12 std::set<int> language_set; |
11 std::set<int>::const_iterator it; | 13 std::set<int>::const_iterator it; |
12 | 14 |
13 const int ENGLISH = 25966; | 15 const int ENGLISH = 25966; |
14 const int SPANISH = 25971; | 16 const int SPANISH = 25971; |
15 const int JAPANESE = 27233; | 17 const int JAPANESE = 27233; |
16 | 18 |
17 // Basic single language case. | 19 // Basic single language case. |
18 LanguageUsageMetrics::ParseAcceptLanguages("ja", &language_set); | 20 LanguageUsageMetrics::ParseAcceptLanguages("ja", &language_set); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 EXPECT_EQ(JAPANESE, LanguageUsageMetrics::ToLanguageCode("ja-JP")); | 96 EXPECT_EQ(JAPANESE, LanguageUsageMetrics::ToLanguageCode("ja-JP")); |
95 | 97 |
96 // Invalid locales are considered as unknown language. | 98 // Invalid locales are considered as unknown language. |
97 EXPECT_EQ(0, LanguageUsageMetrics::ToLanguageCode(std::string())); | 99 EXPECT_EQ(0, LanguageUsageMetrics::ToLanguageCode(std::string())); |
98 EXPECT_EQ(0, LanguageUsageMetrics::ToLanguageCode("1234")); | 100 EXPECT_EQ(0, LanguageUsageMetrics::ToLanguageCode("1234")); |
99 | 101 |
100 // "xx" is not acceptable because it doesn't exist in ISO 639-1 table. | 102 // "xx" is not acceptable because it doesn't exist in ISO 639-1 table. |
101 // However, LanguageUsageMetrics doesn't tell what code is valid. | 103 // However, LanguageUsageMetrics doesn't tell what code is valid. |
102 EXPECT_EQ(30840, LanguageUsageMetrics::ToLanguageCode("xx")); | 104 EXPECT_EQ(30840, LanguageUsageMetrics::ToLanguageCode("xx")); |
103 } | 105 } |
| 106 |
| 107 } // namespace language_usage_metrics |
OLD | NEW |