 Chromium Code Reviews
 Chromium Code Reviews Issue 10696114:
  Upstreaming diffs in os_compat_android.cc  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master
    
  
    Issue 10696114:
  Upstreaming diffs in os_compat_android.cc  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@master| Index: base/os_compat_android_unittest.cc | 
| diff --git a/base/os_compat_android_unittest.cc b/base/os_compat_android_unittest.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..4c698c21d152d0d253d9acca6cd0f478772b2864 | 
| --- /dev/null | 
| +++ b/base/os_compat_android_unittest.cc | 
| @@ -0,0 +1,39 @@ | 
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include "base/os_compat_android.h" | 
| + | 
| +#include "base/file_util.h" | 
| +#include "testing/gtest/include/gtest/gtest.h" | 
| + | 
| +namespace base { | 
| + | 
| +typedef testing::Test OsCompatAndroidTest; | 
| + | 
| +// Keep this Unittest DISABLED_ , because it actually creates a directory in the | 
| +// device and it may be source of flakyness. For any changes in the mkdtemp | 
| +// function, you should run this unittest in your local machine to check if it | 
| +// passes. | 
| +TEST_F(OsCompatAndroidTest, DISABLED_TestMkdTemp) { | 
| + // Not six XXXXXX at the suffix of the path. | 
| + char invalid_path[] = "/tmp/foobarXX"; | 
| 
digit1
2012/07/13 10:34:04
the reason this test doesn't work is because there
 | 
| + EXPECT_EQ(NULL, mkdtemp(invalid_path)); | 
| + | 
| + // Directory does not exist | 
| + char invalid_path2[] = "doesntoexist/foobarXXXXXX"; | 
| + EXPECT_EQ(NULL, mkdtemp(invalid_path2)); | 
| + | 
| + // Successfully create a tmp dir. | 
| + FilePath tmp_dir; | 
| + EXPECT_TRUE(file_util::GetTempDir(&tmp_dir)); | 
| + | 
| + FilePath sub_dir = tmp_dir.Append("XXXXXX"); | 
| + std::string sub_dir_string = sub_dir.value(); | 
| + | 
| + // this should be OK since mkdtemp just replaces characters in place | 
| + char* buffer = const_cast<char*>(sub_dir_string.c_str()); | 
| + EXPECT_TRUE(mkdtemp(buffer) != NULL); | 
| +} | 
| + | 
| +} // namespace base |