| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/test/testsupport/fileutils.h" | 11 #include "webrtc/test/testsupport/fileutils.h" |
| 12 | 12 |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 | 14 |
| 15 #include <list> | 15 #include <list> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "webrtc/test/testsupport/gtest_disable.h" | |
| 20 | 19 |
| 21 #ifdef WIN32 | 20 #ifdef WIN32 |
| 22 #define chdir _chdir | 21 #define chdir _chdir |
| 23 static const char* kPathDelimiter = "\\"; | 22 static const char* kPathDelimiter = "\\"; |
| 24 #else | 23 #else |
| 25 static const char* kPathDelimiter = "/"; | 24 static const char* kPathDelimiter = "/"; |
| 26 #endif | 25 #endif |
| 27 | 26 |
| 28 static const std::string kResourcesDir = "resources"; | 27 static const std::string kResourcesDir = "resources"; |
| 29 static const std::string kTestName = "fileutils_unittest"; | 28 static const std::string kTestName = "fileutils_unittest"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 // directory that is automatically set when the test executable is launched. | 58 // directory that is automatically set when the test executable is launched. |
| 60 // The test is not fully testing the implementation, since we cannot be sure | 59 // The test is not fully testing the implementation, since we cannot be sure |
| 61 // of where the executable was launched from. | 60 // of where the executable was launched from. |
| 62 TEST_F(FileUtilsTest, ProjectRootPath) { | 61 TEST_F(FileUtilsTest, ProjectRootPath) { |
| 63 std::string project_root = webrtc::test::ProjectRootPath(); | 62 std::string project_root = webrtc::test::ProjectRootPath(); |
| 64 // Not very smart, but at least tests something. | 63 // Not very smart, but at least tests something. |
| 65 ASSERT_GT(project_root.length(), 0u); | 64 ASSERT_GT(project_root.length(), 0u); |
| 66 } | 65 } |
| 67 | 66 |
| 68 // Similar to the above test, but for the output dir | 67 // Similar to the above test, but for the output dir |
| 69 TEST_F(FileUtilsTest, DISABLED_ON_ANDROID(OutputPathFromUnchangedWorkingDir)) { | 68 #if defined(WEBRTC_ANDROID) |
| 69 TEST_F(FileUtilsTest, DISABLED_OutputPathFromUnchangedWorkingDir) { |
| 70 #else |
| 71 TEST_F(FileUtilsTest, OutputPathFromUnchangedWorkingDir) { |
| 72 #endif |
| 70 std::string path = webrtc::test::OutputPath(); | 73 std::string path = webrtc::test::OutputPath(); |
| 71 std::string expected_end = "out"; | 74 std::string expected_end = "out"; |
| 72 expected_end = kPathDelimiter + expected_end + kPathDelimiter; | 75 expected_end = kPathDelimiter + expected_end + kPathDelimiter; |
| 73 ASSERT_EQ(path.length() - expected_end.length(), path.find(expected_end)); | 76 ASSERT_EQ(path.length() - expected_end.length(), path.find(expected_end)); |
| 74 } | 77 } |
| 75 | 78 |
| 76 // Tests with current working directory set to a directory higher up in the | 79 // Tests with current working directory set to a directory higher up in the |
| 77 // directory tree than the project root dir. | 80 // directory tree than the project root dir. |
| 78 TEST_F(FileUtilsTest, DISABLED_ON_ANDROID(OutputPathFromRootWorkingDir)) { | 81 #if defined(WEBRTC_ANDROID) |
| 82 TEST_F(FileUtilsTest, DISABLED_OutputPathFromRootWorkingDir) { |
| 83 #else |
| 84 TEST_F(FileUtilsTest, OutputPathFromRootWorkingDir) { |
| 85 #endif |
| 79 ASSERT_EQ(0, chdir(kPathDelimiter)); | 86 ASSERT_EQ(0, chdir(kPathDelimiter)); |
| 80 ASSERT_EQ("./", webrtc::test::OutputPath()); | 87 ASSERT_EQ("./", webrtc::test::OutputPath()); |
| 81 } | 88 } |
| 82 | 89 |
| 83 TEST_F(FileUtilsTest, TempFilename) { | 90 TEST_F(FileUtilsTest, TempFilename) { |
| 84 std::string temp_filename = webrtc::test::TempFilename( | 91 std::string temp_filename = webrtc::test::TempFilename( |
| 85 webrtc::test::OutputPath(), "TempFilenameTest"); | 92 webrtc::test::OutputPath(), "TempFilenameTest"); |
| 86 ASSERT_TRUE(webrtc::test::FileExists(temp_filename)) | 93 ASSERT_TRUE(webrtc::test::FileExists(temp_filename)) |
| 87 << "Couldn't find file: " << temp_filename; | 94 << "Couldn't find file: " << temp_filename; |
| 88 remove(temp_filename.c_str()); | 95 remove(temp_filename.c_str()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 fclose(file); | 140 fclose(file); |
| 134 ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u); | 141 ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u); |
| 135 remove(temp_filename.c_str()); | 142 remove(temp_filename.c_str()); |
| 136 } | 143 } |
| 137 | 144 |
| 138 TEST_F(FileUtilsTest, GetFileSizeNonExistingFile) { | 145 TEST_F(FileUtilsTest, GetFileSizeNonExistingFile) { |
| 139 ASSERT_EQ(0u, webrtc::test::GetFileSize("non-existing-file.tmp")); | 146 ASSERT_EQ(0u, webrtc::test::GetFileSize("non-existing-file.tmp")); |
| 140 } | 147 } |
| 141 | 148 |
| 142 } // namespace webrtc | 149 } // namespace webrtc |
| OLD | NEW |