Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: third_party/libaddressinput/chromium/cpp/test/localization_test.cc

Issue 110533002: [rac] Temporarily copy libaddressinput to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid redefinition of basictypes.h Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (C) 2013 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <libaddressinput/localization.h>
16
17 #include <string>
18
19 #include <gtest/gtest.h>
20
21 #include "grit.h"
22 #include "messages.h"
23
24 namespace {
25
26 using i18n::addressinput::INVALID_MESSAGE_ID;
27 using i18n::addressinput::Localization;
28
29 // Tests for Localization object.
30 class LocalizationTest : public testing::TestWithParam<int> {
31 protected:
32 Localization localization_;
33 };
34
35 // Verifies that a custom message getter can be used.
36 const char kValidMessage[] = "Data";
37 std::string GetValidMessage(int message_id) { return kValidMessage; }
38 TEST_P(LocalizationTest, ValidStringGetterCanBeUsed) {
39 localization_.SetGetter(&GetValidMessage);
40 EXPECT_EQ(kValidMessage, localization_.GetString(GetParam()));
41 }
42
43 // Verifies that the default language for messages does not have empty strings.
44 TEST_P(LocalizationTest, DefaultStringIsNotEmpty) {
45 EXPECT_FALSE(localization_.GetString(GetParam()).empty());
46 }
47
48 // Verifies that English is the default language.
49 TEST_P(LocalizationTest, EnglishIsDefaultLanguage) {
50 std::string default_string = localization_.GetString(GetParam());
51 localization_.SetLanguage("en");
52 EXPECT_EQ(default_string, localization_.GetString(GetParam()));
53 }
54
55 // Tests all message identifiers.
56 INSTANTIATE_TEST_CASE_P(
57 AllMessages, LocalizationTest,
58 testing::Values(IDS_LIBADDRESSINPUT_I18N_COUNTRY_LABEL,
59 IDS_LIBADDRESSINPUT_I18N_LOCALITY_LABEL,
60 IDS_LIBADDRESSINPUT_I18N_DEPENDENT_LOCALITY_LABEL,
61 IDS_LIBADDRESSINPUT_I18N_ORGANIZATION_LABEL,
62 IDS_LIBADDRESSINPUT_I18N_RECIPIENT_LABEL,
63 IDS_LIBADDRESSINPUT_I18N_ADDRESS_LINE1_LABEL,
64 IDS_LIBADDRESSINPUT_I18N_POSTAL_CODE_LABEL,
65 IDS_LIBADDRESSINPUT_I18N_ZIP_CODE_LABEL,
66 IDS_LIBADDRESSINPUT_I18N_CEDEX_LABEL,
67 IDS_LIBADDRESSINPUT_I18N_AREA,
68 IDS_LIBADDRESSINPUT_I18N_COUNTY_LABEL,
69 IDS_LIBADDRESSINPUT_I18N_DEPARTMENT,
70 IDS_LIBADDRESSINPUT_I18N_DO_SI,
71 IDS_LIBADDRESSINPUT_I18N_EMIRATE,
72 IDS_LIBADDRESSINPUT_I18N_ISLAND,
73 IDS_LIBADDRESSINPUT_I18N_PARISH,
74 IDS_LIBADDRESSINPUT_I18N_PREFECTURE,
75 IDS_LIBADDRESSINPUT_I18N_PROVINCE,
76 IDS_LIBADDRESSINPUT_I18N_STATE_LABEL));
77
78 // Verifies that an invalid message identifier results in an empty string in the
79 // default configuration.
80 TEST_F(LocalizationTest, InvalidMessageIsEmptyString) {
81 EXPECT_TRUE(localization_.GetString(INVALID_MESSAGE_ID).empty());
82 }
83
84 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698