OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/i18n/rtl.h" | 5 #include "base/i18n/rtl.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 { L"test", L"\x202atest\x202c" }, | 210 { L"test", L"\x202atest\x202c" }, |
211 { L"test.html", L"\x202atest.html\x202c" }, | 211 { L"test.html", L"\x202atest.html\x202c" }, |
212 { L"\x05d0\x05d1\x05d2", L"\x202a\x05d0\x05d1\x05d2\x202c" }, | 212 { L"\x05d0\x05d1\x05d2", L"\x202a\x05d0\x05d1\x05d2\x202c" }, |
213 { L"\x05d0\x05d1\x05d2.txt", L"\x202a\x05d0\x05d1\x05d2.txt\x202c" }, | 213 { L"\x05d0\x05d1\x05d2.txt", L"\x202a\x05d0\x05d1\x05d2.txt\x202c" }, |
214 { L"\x05d0"L"abc", L"\x202a\x05d0"L"abc\x202c" }, | 214 { L"\x05d0"L"abc", L"\x202a\x05d0"L"abc\x202c" }, |
215 { L"\x05d0"L"abc.txt", L"\x202a\x05d0"L"abc.txt\x202c" }, | 215 { L"\x05d0"L"abc.txt", L"\x202a\x05d0"L"abc.txt\x202c" }, |
216 { L"abc\x05d0\x05d1", L"\x202a"L"abc\x05d0\x05d1\x202c" }, | 216 { L"abc\x05d0\x05d1", L"\x202a"L"abc\x05d0\x05d1\x202c" }, |
217 { L"abc\x05d0\x05d1.jpg", L"\x202a"L"abc\x05d0\x05d1.jpg\x202c" }, | 217 { L"abc\x05d0\x05d1.jpg", L"\x202a"L"abc\x05d0\x05d1.jpg\x202c" }, |
218 }; | 218 }; |
219 for (unsigned int i = 0; i < arraysize(test_data); ++i) { | 219 for (unsigned int i = 0; i < arraysize(test_data); ++i) { |
220 std::wstring input = test_data[i].raw_filename; | 220 string16 input = WideToUTF16(test_data[i].raw_filename); |
221 std::wstring expected = | 221 string16 expected = base::i18n::GetDisplayStringInLTRDirectionality(input); |
222 base::i18n::GetDisplayStringInLTRDirectionality(&input); | |
223 if (base::i18n::IsRTL()) | 222 if (base::i18n::IsRTL()) |
224 EXPECT_EQ(test_data[i].display_string, expected); | 223 EXPECT_EQ(expected, WideToUTF16(test_data[i].display_string)); |
225 else | 224 else |
226 EXPECT_EQ(input, expected); | 225 EXPECT_EQ(expected, input); |
227 } | 226 } |
228 } | 227 } |
229 | 228 |
230 TEST_F(RTLTest, GetTextDirection) { | 229 TEST_F(RTLTest, GetTextDirection) { |
231 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("ar")); | 230 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("ar")); |
232 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("ar_EG")); | 231 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("ar_EG")); |
233 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("he")); | 232 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("he")); |
234 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("he_IL")); | 233 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("he_IL")); |
235 // iw is an obsolete code for Hebrew. | 234 // iw is an obsolete code for Hebrew. |
236 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("iw")); | 235 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, GetTextDirection("iw")); |
(...skipping 13 matching lines...) Expand all Loading... |
250 // Chinese in China with '-'. | 249 // Chinese in China with '-'. |
251 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("zh-CN")); | 250 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("zh-CN")); |
252 // Filipino : 3-letter code | 251 // Filipino : 3-letter code |
253 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("fil")); | 252 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("fil")); |
254 // Russian | 253 // Russian |
255 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("ru")); | 254 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("ru")); |
256 // Japanese that uses multiple scripts | 255 // Japanese that uses multiple scripts |
257 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("ja")); | 256 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, GetTextDirection("ja")); |
258 } | 257 } |
259 | 258 |
OLD | NEW |