diff options
author | arihc <arihc@google.com> | 2015-08-12 16:45:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 23:46:25 +0000 |
commit | e89963accb5f3a9d93b8007b22fc79c0120eb794 (patch) | |
tree | de8053cb18dd25f839b1d3768f7543ab85368feb | |
parent | 99c0fd59d4f7d6251a876cc8bef39d38378dfdf2 (diff) | |
download | chromium_src-e89963accb5f3a9d93b8007b22fc79c0120eb794.zip chromium_src-e89963accb5f3a9d93b8007b22fc79c0120eb794.tar.gz chromium_src-e89963accb5f3a9d93b8007b22fc79c0120eb794.tar.bz2 |
Updates to base unittests so they run correctly in libchrome on Android
Parallel change to https://android-review.googlesource.com/#/c/163293/
(does not include changes being made to base/command_line_unittest
that are fixing temporary runner issues, since the runner is fine here)
BUG= 22884411, 22947438
Review URL: https://codereview.chromium.org/1273243002
Cr-Commit-Position: refs/heads/master@{#343126}
-rw-r--r-- | base/command_line_unittest.cc | 3 | ||||
-rw-r--r-- | base/files/dir_reader_posix_unittest.cc | 6 | ||||
-rw-r--r-- | base/files/file_path_unittest.cc | 8 | ||||
-rw-r--r-- | base/strings/sys_string_conversions_unittest.cc | 6 |
4 files changed, 18 insertions, 5 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index 018d83f..ac8a395 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -378,6 +378,9 @@ TEST(CommandLineTest, ProgramQuotes) { // Calling Init multiple times should not modify the previous CommandLine. TEST(CommandLineTest, Init) { + // Call Init without checking output once so we know it's been called + // whether or not the test runner does so. + CommandLine::Init(0, NULL); CommandLine* initial = CommandLine::ForCurrentProcess(); EXPECT_FALSE(CommandLine::Init(0, NULL)); CommandLine* current = CommandLine::ForCurrentProcess(); diff --git a/base/files/dir_reader_posix_unittest.cc b/base/files/dir_reader_posix_unittest.cc index 0685031..2e181b3 100644 --- a/base/files/dir_reader_posix_unittest.cc +++ b/base/files/dir_reader_posix_unittest.cc @@ -10,6 +10,7 @@ #include <string.h> #include <unistd.h> +#include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,8 +26,9 @@ TEST(DirReaderPosixUnittest, Read) { if (DirReaderPosix::IsFallback()) return; - char kDirTemplate[] = "/tmp/org.chromium.dir-reader-posix-XXXXXX"; - const char* dir = mkdtemp(kDirTemplate); + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + const char* dir = temp_dir.path().value().c_str(); ASSERT_TRUE(dir); const int prev_wd = open(".", O_RDONLY | O_DIRECTORY); diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc index 60eaa8f..bc0e843 100644 --- a/base/files/file_path_unittest.cc +++ b/base/files/file_path_unittest.cc @@ -10,6 +10,10 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +#if defined(OS_POSIX) +#include "base/test/scoped_locale.h" +#endif + // This macro helps avoid wrapped lines in the test structs. #define FPL(x) FILE_PATH_LITERAL(x) @@ -1126,6 +1130,10 @@ TEST_F(FilePathTest, FromUTF8Unsafe_And_AsUTF8Unsafe) { "\xEF\xBC\xA1\xEF\xBC\xA2\xEF\xBC\xA3.txt" }, }; +#if !defined(SYSTEM_NATIVE_UTF8) && defined(OS_LINUX) + ScopedLocale locale("en_US.UTF-8"); +#endif + for (size_t i = 0; i < arraysize(cases); ++i) { // Test FromUTF8Unsafe() works. FilePath from_utf8 = FilePath::FromUTF8Unsafe(cases[i].utf8); diff --git a/base/strings/sys_string_conversions_unittest.cc b/base/strings/sys_string_conversions_unittest.cc index 0cdd428..90c4767 100644 --- a/base/strings/sys_string_conversions_unittest.cc +++ b/base/strings/sys_string_conversions_unittest.cc @@ -76,7 +76,7 @@ TEST(SysStrings, SysUTF8ToWide) { TEST(SysStrings, SysWideToNativeMB) { #if !defined(SYSTEM_NATIVE_UTF8) - ScopedLocale locale("en_US.utf-8"); + ScopedLocale locale("en_US.UTF-8"); #endif EXPECT_EQ("Hello, world", SysWideToNativeMB(L"Hello, world")); EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToNativeMB(L"\x4f60\x597d")); @@ -108,7 +108,7 @@ TEST(SysStrings, SysWideToNativeMB) { // We assume the test is running in a UTF8 locale. TEST(SysStrings, SysNativeMBToWide) { #if !defined(SYSTEM_NATIVE_UTF8) - ScopedLocale locale("en_US.utf-8"); + ScopedLocale locale("en_US.UTF-8"); #endif EXPECT_EQ(L"Hello, world", SysNativeMBToWide("Hello, world")); EXPECT_EQ(L"\x4f60\x597d", SysNativeMBToWide("\xe4\xbd\xa0\xe5\xa5\xbd")); @@ -164,7 +164,7 @@ static const wchar_t* const kConvertRoundtripCases[] = { TEST(SysStrings, SysNativeMBAndWide) { #if !defined(SYSTEM_NATIVE_UTF8) - ScopedLocale locale("en_US.utf-8"); + ScopedLocale locale("en_US.UTF-8"); #endif for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) { std::wstring wide = kConvertRoundtripCases[i]; |