diff options
-rw-r--r-- | chrome/browser/safe_browsing/protocol_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_test.cc | 20 | ||||
-rw-r--r-- | net/test/python_utils.cc | 30 | ||||
-rw-r--r-- | net/test/python_utils.h | 4 | ||||
-rw-r--r-- | net/test/test_server.cc | 29 |
5 files changed, 45 insertions, 40 deletions
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc index ab8ad5c..d76cd7a 100644 --- a/chrome/browser/safe_browsing/protocol_manager.cc +++ b/chrome/browser/safe_browsing/protocol_manager.cc @@ -76,7 +76,7 @@ SafeBrowsingProtocolManager::SafeBrowsingProtocolManager( next_update_sec_ = base::RandInt(60, kSbTimerStartIntervalSec); chrome::VersionInfo version_info; - if (!version_info.is_valid()) + if (!version_info.is_valid() || version_info.Version().empty()) version_ = "0.1"; else version_ = version_info.Version(); diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc index 5c1f3e3..84df59c 100644 --- a/chrome/browser/safe_browsing/safe_browsing_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_test.cc @@ -128,11 +128,10 @@ class SafeBrowsingTestServer { FILE_PATH_LITERAL("safebrowsing_test_server.py")); FilePath pyproto_code_dir; - if (!PathService::Get(base::DIR_EXE, &pyproto_code_dir)) { - LOG(ERROR) << "Failed to get DIR_EXE"; + if (!GetPyProtoPath(&pyproto_code_dir)) { + LOG(ERROR) << "Failed to get generated python protobuf dir"; return false; } - pyproto_code_dir = pyproto_code_dir.Append(FILE_PATH_LITERAL("pyproto")); AppendToPythonPath(pyproto_code_dir); pyproto_code_dir = pyproto_code_dir.Append(FILE_PATH_LITERAL("google")); AppendToPythonPath(pyproto_code_dir); @@ -520,11 +519,6 @@ class SafeBrowsingServiceTestHelper DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTestHelper); }; - -#if defined(OS_MACOSX) -// TODO(lzheng): http://crbug.com/62415, can not start on MacOS. -#define SafeBrowsingSystemTest DISABLED_SafeBrowsingSystemTest -#endif IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, SafeBrowsingSystemTest) { LOG(INFO) << "Start test"; const char* server_host = SafeBrowsingTestServer::Host(); @@ -633,10 +627,10 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, SafeBrowsingSystemTest) { // the latest data in the next revision. // Verifies with server if test is done and waits till server responses. - // EXPECT_EQ(URLRequestStatus::SUCCESS, - // safe_browsing_helper->VerifyTestComplete(server_host, - // server_port, - // last_step)); - // EXPECT_EQ("yes", safe_browsing_helper->response_data()); + // EXPECT_EQ(URLRequestStatus::SUCCESS, + // safe_browsing_helper->VerifyTestComplete(server_host, + // server_port, + // last_step)); + // EXPECT_EQ("yes", safe_browsing_helper->response_data()); test_server.Stop(); } diff --git a/net/test/python_utils.cc b/net/test/python_utils.cc index 438c3d7..3a1068f 100644 --- a/net/test/python_utils.cc +++ b/net/test/python_utils.cc @@ -7,6 +7,7 @@ #include "base/base_paths.h" #include "base/environment.h" #include "base/file_path.h" +#include "base/file_util.h" #include "base/path_service.h" #include "base/scoped_ptr.h" #include "base/utf_string_conversions.h" @@ -36,6 +37,34 @@ void AppendToPythonPath(const FilePath& dir) { } } +bool GetPyProtoPath(FilePath* dir) { + // Locate the Python code generated by the protocol buffers compiler. + FilePath generated_code_dir; + if (!PathService::Get(base::DIR_EXE, &generated_code_dir)) { + return false; + } + + const FilePath kPyProto(FILE_PATH_LITERAL("pyproto")); + +#if defined(OS_MACOSX) + // On Mac, DIR_EXE might be pointing deep into the Release/ (or Debug/) + // directory and we can't depend on how far down it goes. So we walk upwards + // from DIR_EXE until we find a likely looking spot. + while (!file_util::DirectoryExists(generated_code_dir.Append(kPyProto))) { + FilePath parent = generated_code_dir.DirName(); + if (parent == generated_code_dir) { + // We hit the root directory. Maybe we didn't build any targets which + // produced Python protocol buffers. + PathService::Get(base::DIR_EXE, &generated_code_dir); + return false; + } + generated_code_dir = parent; + } +#endif + *dir = generated_code_dir.Append(kPyProto); + return true; +} + bool GetPythonRunTime(FilePath* dir) { #if defined(OS_WIN) if (!PathService::Get(base::DIR_SOURCE_ROOT, dir)) @@ -48,4 +77,3 @@ bool GetPythonRunTime(FilePath* dir) { #endif return true; } - diff --git a/net/test/python_utils.h b/net/test/python_utils.h index 215569c..bc3bdb1 100644 --- a/net/test/python_utils.h +++ b/net/test/python_utils.h @@ -16,8 +16,10 @@ extern const char kPythonPathEnv[]; // Appends the dir to python path environment variable. void AppendToPythonPath(const FilePath& dir); +// Return the location of the compiler-generated python protobuf. +bool GetPyProtoPath(FilePath* dir); + // Returns the path that should be used to launch Python. bool GetPythonRunTime(FilePath* path) WARN_UNUSED_RESULT; #endif // NET_TEST_PYTHON_UTILS_H_ - diff --git a/net/test/test_server.cc b/net/test/test_server.cc index 4b426eb..f5592a2 100644 --- a/net/test/test_server.cc +++ b/net/test/test_server.cc @@ -284,33 +284,14 @@ bool TestServer::SetPythonPath() { AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("pyftpdlib"))); // Locate the Python code generated by the protocol buffers compiler. - FilePath generated_code_dir; - if (!PathService::Get(base::DIR_EXE, &generated_code_dir)) { - LOG(ERROR) << "Failed to get DIR_EXE"; + FilePath pyproto_code_dir; + if (!GetPyProtoPath(&pyproto_code_dir)) { + LOG(ERROR) << "Failed to get python dir for generated code."; return false; } - static const FilePath kPyProto(FILE_PATH_LITERAL("pyproto")); - -#if defined(OS_MACOSX) - // On Mac, DIR_EXE might be pointing deep into the Release/ (or Debug/) - // directory and we can't depend on how far down it goes. So we walk upwards - // from DIR_EXE until we find a likely looking spot. - while (!file_util::DirectoryExists(generated_code_dir.Append(kPyProto))) { - FilePath parent = generated_code_dir.DirName(); - if (parent == generated_code_dir) { - // We hit the root directory. Maybe we didn't build any targets which - // produced Python protocol buffers. - PathService::Get(base::DIR_EXE, &generated_code_dir); - break; - } - generated_code_dir = parent; - } -#endif - - AppendToPythonPath(generated_code_dir.Append(kPyProto)); - AppendToPythonPath(generated_code_dir.Append(kPyProto). - Append(FILE_PATH_LITERAL("sync_pb"))); + AppendToPythonPath(pyproto_code_dir); + AppendToPythonPath(pyproto_code_dir.Append(FILE_PATH_LITERAL("sync_pb"))); return true; } |