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 #define MAYBE_OutputPathFromUnchangedWorkingDir \ |
| 70 DISABLED_OutputPathFromUnchangedWorkingDir |
| 71 #else |
| 72 #define MAYBE_OutputPathFromUnchangedWorkingDir \ |
| 73 OutputPathFromUnchangedWorkingDir |
| 74 #endif |
| 75 TEST_F(FileUtilsTest, MAYBE_OutputPathFromUnchangedWorkingDir) { |
70 std::string path = webrtc::test::OutputPath(); | 76 std::string path = webrtc::test::OutputPath(); |
71 std::string expected_end = "out"; | 77 std::string expected_end = "out"; |
72 expected_end = kPathDelimiter + expected_end + kPathDelimiter; | 78 expected_end = kPathDelimiter + expected_end + kPathDelimiter; |
73 ASSERT_EQ(path.length() - expected_end.length(), path.find(expected_end)); | 79 ASSERT_EQ(path.length() - expected_end.length(), path.find(expected_end)); |
74 } | 80 } |
75 | 81 |
76 // Tests with current working directory set to a directory higher up in the | 82 // Tests with current working directory set to a directory higher up in the |
77 // directory tree than the project root dir. | 83 // directory tree than the project root dir. |
78 TEST_F(FileUtilsTest, DISABLED_ON_ANDROID(OutputPathFromRootWorkingDir)) { | 84 #if defined(WEBRTC_ANDROID) |
| 85 #define MAYBE_OutputPathFromRootWorkingDir DISABLED_OutputPathFromRootWorkingDir |
| 86 #else |
| 87 #define MAYBE_OutputPathFromRootWorkingDir OutputPathFromRootWorkingDir |
| 88 #endif |
| 89 TEST_F(FileUtilsTest, MAYBE_OutputPathFromRootWorkingDir) { |
79 ASSERT_EQ(0, chdir(kPathDelimiter)); | 90 ASSERT_EQ(0, chdir(kPathDelimiter)); |
80 ASSERT_EQ("./", webrtc::test::OutputPath()); | 91 ASSERT_EQ("./", webrtc::test::OutputPath()); |
81 } | 92 } |
82 | 93 |
83 TEST_F(FileUtilsTest, TempFilename) { | 94 TEST_F(FileUtilsTest, TempFilename) { |
84 std::string temp_filename = webrtc::test::TempFilename( | 95 std::string temp_filename = webrtc::test::TempFilename( |
85 webrtc::test::OutputPath(), "TempFilenameTest"); | 96 webrtc::test::OutputPath(), "TempFilenameTest"); |
86 ASSERT_TRUE(webrtc::test::FileExists(temp_filename)) | 97 ASSERT_TRUE(webrtc::test::FileExists(temp_filename)) |
87 << "Couldn't find file: " << temp_filename; | 98 << "Couldn't find file: " << temp_filename; |
88 remove(temp_filename.c_str()); | 99 remove(temp_filename.c_str()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 fclose(file); | 144 fclose(file); |
134 ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u); | 145 ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u); |
135 remove(temp_filename.c_str()); | 146 remove(temp_filename.c_str()); |
136 } | 147 } |
137 | 148 |
138 TEST_F(FileUtilsTest, GetFileSizeNonExistingFile) { | 149 TEST_F(FileUtilsTest, GetFileSizeNonExistingFile) { |
139 ASSERT_EQ(0u, webrtc::test::GetFileSize("non-existing-file.tmp")); | 150 ASSERT_EQ(0u, webrtc::test::GetFileSize("non-existing-file.tmp")); |
140 } | 151 } |
141 | 152 |
142 } // namespace webrtc | 153 } // namespace webrtc |
OLD | NEW |