| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dir_reader_posix.h" | 5 #include "base/dir_reader_posix.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using base::DirReaderPosix; | 16 namespace base { |
| 17 | |
| 18 namespace { | |
| 19 typedef testing::Test DirReaderPosixUnittest; | |
| 20 | 17 |
| 21 TEST(DirReaderPosixUnittest, Read) { | 18 TEST(DirReaderPosixUnittest, Read) { |
| 22 static const unsigned kNumFiles = 100; | 19 static const unsigned kNumFiles = 100; |
| 23 | 20 |
| 24 if (DirReaderPosix::IsFallback()) | 21 if (DirReaderPosix::IsFallback()) |
| 25 return; | 22 return; |
| 26 | 23 |
| 27 char kDirTemplate[] = "/tmp/org.chromium.dir-reader-posix-XXXXXX"; | 24 char kDirTemplate[] = "/tmp/org.chromium.dir-reader-posix-XXXXXX"; |
| 28 const char* dir = mkdtemp(kDirTemplate); | 25 const char* dir = mkdtemp(kDirTemplate); |
| 29 CHECK(dir); | 26 CHECK(dir); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 PCHECK(rmdir(dir) == 0); | 78 PCHECK(rmdir(dir) == 0); |
| 82 | 79 |
| 83 PCHECK(fchdir(prev_wd) == 0); | 80 PCHECK(fchdir(prev_wd) == 0); |
| 84 PCHECK(close(prev_wd) == 0); | 81 PCHECK(close(prev_wd) == 0); |
| 85 | 82 |
| 86 EXPECT_TRUE(seen_dot); | 83 EXPECT_TRUE(seen_dot); |
| 87 EXPECT_TRUE(seen_dotdot); | 84 EXPECT_TRUE(seen_dotdot); |
| 88 EXPECT_EQ(kNumFiles, seen.size()); | 85 EXPECT_EQ(kNumFiles, seen.size()); |
| 89 } | 86 } |
| 90 | 87 |
| 91 } // anonymous namespace | 88 } // namespace base |
| OLD | NEW |