diff --git a/talk/base/gunit.h b/talk/base/gunit.h index 181150a87..e56dd6f61 100644 --- a/talk/base/gunit.h +++ b/talk/base/gunit.h @@ -36,11 +36,6 @@ #include "testing/base/public/gunit.h" #endif -// forward declarations -namespace talk_base { -class Pathname; -} - // Wait until "ex" is true, or "timeout" expires. #define WAIT(ex, timeout) \ for (uint32 start = talk_base::Time(); \ @@ -107,7 +102,4 @@ class Pathname; } \ } while (0); -talk_base::Pathname GetGoogle3Directory(); -talk_base::Pathname GetTalkDirectory(); - #endif // TALK_BASE_GUNIT_H_ diff --git a/talk/base/testutils.h b/talk/base/testutils.h index 363fb4cff..86e946fc0 100644 --- a/talk/base/testutils.h +++ b/talk/base/testutils.h @@ -45,6 +45,7 @@ #include "talk/base/common.h" #include "talk/base/gunit.h" #include "talk/base/nethelpers.h" +#include "talk/base/pathutils.h" #include "talk/base/stream.h" #include "talk/base/stringencode.h" #include "talk/base/stringutils.h" @@ -451,6 +452,30 @@ inline bool ReadFile(const char* filename, std::string* contents) { return success; } +// Look in parent dir for parallel directory. +inline talk_base::Pathname GetSiblingDirectory( + const std::string& parallel_dir) { + talk_base::Pathname path = talk_base::Filesystem::GetCurrentDirectory(); + while (!path.empty()) { + talk_base::Pathname potential_parallel_dir = path; + potential_parallel_dir.AppendFolder(parallel_dir); + if (talk_base::Filesystem::IsFolder(potential_parallel_dir)) { + return potential_parallel_dir; + } + + path.SetFolder(path.parent_folder()); + } + return path; +} + +inline talk_base::Pathname GetGoogle3Directory() { + return GetSiblingDirectory("google3"); +} + +inline talk_base::Pathname GetTalkDirectory() { + return GetSiblingDirectory("talk"); +} + /////////////////////////////////////////////////////////////////////////////// // Unittest predicates which are similar to STREQ, but for raw memory /////////////////////////////////////////////////////////////////////////////// diff --git a/talk/base/unittest_main.cc b/talk/base/unittest_main.cc index 94f7f6c74..def763c30 100644 --- a/talk/base/unittest_main.cc +++ b/talk/base/unittest_main.cc @@ -12,7 +12,6 @@ #include "talk/base/fileutils.h" #include "talk/base/gunit.h" #include "talk/base/logging.h" -#include "talk/base/pathutils.h" DEFINE_bool(help, false, "prints this message"); DEFINE_string(log, "", "logging options to use"); @@ -47,30 +46,6 @@ int TestCrtReportHandler(int report_type, char* msg, int* retval) { } #endif // WIN32 -// Look in parent dir for parallel directory. -talk_base::Pathname GetSiblingDirectory( - const std::string& parallel_dir) { - talk_base::Pathname path = talk_base::Filesystem::GetCurrentDirectory(); - while (!path.empty()) { - talk_base::Pathname potential_parallel_dir = path; - potential_parallel_dir.AppendFolder(parallel_dir); - if (talk_base::Filesystem::IsFolder(potential_parallel_dir)) { - return potential_parallel_dir; - } - - path.SetFolder(path.parent_folder()); - } - return path; -} - -talk_base::Pathname GetGoogle3Directory() { - return GetSiblingDirectory("google3"); -} - -talk_base::Pathname GetTalkDirectory() { - return GetSiblingDirectory("talk"); -} - int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); FlagList::SetFlagsFromCommandLine(&argc, argv, false); diff --git a/talk/media/base/testutils.cc b/talk/media/base/testutils.cc index 9b1b16d21..732061384 100644 --- a/talk/media/base/testutils.cc +++ b/talk/media/base/testutils.cc @@ -35,6 +35,7 @@ #include "talk/base/pathutils.h" #include "talk/base/stream.h" #include "talk/base/stringutils.h" +#include "talk/base/testutils.h" #include "talk/media/base/rtpdump.h" #include "talk/media/base/videocapturer.h" #include "talk/media/base/videoframe.h" @@ -254,7 +255,7 @@ void VideoCapturerListener::OnFrameCaptured(VideoCapturer* capturer, // Returns the absolute path to a file in the testdata/ directory. std::string GetTestFilePath(const std::string& filename) { // Locate test data directory. - talk_base::Pathname path = GetTalkDirectory(); + talk_base::Pathname path = testing::GetTalkDirectory(); EXPECT_FALSE(path.empty()); // must be run from inside "talk" path.AppendFolder("media"); path.AppendFolder("testdata");