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

Side by Side Diff: base/files/file_path_unittest.cc

Issue 1273243002: Updates to base unittests so they run correctly in libchrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/scoped_locale.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
12 13
13 // This macro helps avoid wrapped lines in the test structs. 14 // This macro helps avoid wrapped lines in the test structs.
14 #define FPL(x) FILE_PATH_LITERAL(x) 15 #define FPL(x) FILE_PATH_LITERAL(x)
15 16
16 // This macro constructs strings which can contain NULs. 17 // This macro constructs strings which can contain NULs.
17 #define FPS(x) FilePath::StringType(FPL(x), arraysize(FPL(x)) - 1) 18 #define FPS(x) FilePath::StringType(FPL(x), arraysize(FPL(x)) - 1)
18 19
19 namespace base { 20 namespace base {
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 TEST_F(FilePathTest, FromUTF8Unsafe_And_AsUTF8Unsafe) { 1120 TEST_F(FilePathTest, FromUTF8Unsafe_And_AsUTF8Unsafe) {
1120 const struct UTF8TestData cases[] = { 1121 const struct UTF8TestData cases[] = {
1121 { FPL("foo.txt"), "foo.txt" }, 1122 { FPL("foo.txt"), "foo.txt" },
1122 // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them. 1123 // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them.
1123 { FPL("\u00E0\u00E8\u00F2.txt"), "\xC3\xA0\xC3\xA8\xC3\xB2.txt" }, 1124 { FPL("\u00E0\u00E8\u00F2.txt"), "\xC3\xA0\xC3\xA8\xC3\xB2.txt" },
1124 // Full-width "ABC". 1125 // Full-width "ABC".
1125 { FPL("\uFF21\uFF22\uFF23.txt"), 1126 { FPL("\uFF21\uFF22\uFF23.txt"),
1126 "\xEF\xBC\xA1\xEF\xBC\xA2\xEF\xBC\xA3.txt" }, 1127 "\xEF\xBC\xA1\xEF\xBC\xA2\xEF\xBC\xA3.txt" },
1127 }; 1128 };
1128 1129
1130 #if !defined(SYSTEM_NATIVE_UTF8)
1131 ScopedLocale locale("en_US.UTF-8");
1132 #endif
1133
1129 for (size_t i = 0; i < arraysize(cases); ++i) { 1134 for (size_t i = 0; i < arraysize(cases); ++i) {
1130 // Test FromUTF8Unsafe() works. 1135 // Test FromUTF8Unsafe() works.
1131 FilePath from_utf8 = FilePath::FromUTF8Unsafe(cases[i].utf8); 1136 FilePath from_utf8 = FilePath::FromUTF8Unsafe(cases[i].utf8);
1132 EXPECT_EQ(cases[i].native, from_utf8.value()) 1137 EXPECT_EQ(cases[i].native, from_utf8.value())
1133 << "i: " << i << ", input: " << cases[i].native; 1138 << "i: " << i << ", input: " << cases[i].native;
1134 // Test AsUTF8Unsafe() works. 1139 // Test AsUTF8Unsafe() works.
1135 FilePath from_native = FilePath(cases[i].native); 1140 FilePath from_native = FilePath(cases[i].native);
1136 EXPECT_EQ(cases[i].utf8, from_native.AsUTF8Unsafe()) 1141 EXPECT_EQ(cases[i].utf8, from_native.AsUTF8Unsafe())
1137 << "i: " << i << ", input: " << cases[i].native; 1142 << "i: " << i << ", input: " << cases[i].native;
1138 // Test the two file paths are identical. 1143 // Test the two file paths are identical.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 // Test the PrintTo overload for FilePath (used when a test fails to compare two 1283 // Test the PrintTo overload for FilePath (used when a test fails to compare two
1279 // FilePaths). 1284 // FilePaths).
1280 TEST_F(FilePathTest, PrintTo) { 1285 TEST_F(FilePathTest, PrintTo) {
1281 std::stringstream ss; 1286 std::stringstream ss;
1282 FilePath fp(FPL("foo")); 1287 FilePath fp(FPL("foo"));
1283 base::PrintTo(fp, &ss); 1288 base::PrintTo(fp, &ss);
1284 EXPECT_EQ("foo", ss.str()); 1289 EXPECT_EQ("foo", ss.str());
1285 } 1290 }
1286 1291
1287 } // namespace base 1292 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698