| OLD | NEW |
| 1 // Copyright (c) 2011 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 "net/test/python_utils.h" |
| 6 |
| 7 #include <memory> |
| 5 #include <string> | 8 #include <string> |
| 6 | 9 |
| 7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 8 #include "base/environment.h" | 11 #include "base/environment.h" |
| 9 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
| 12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 14 #include "net/test/python_utils.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 TEST(PythonUtils, Append) { | 18 TEST(PythonUtils, Append) { |
| 18 const base::FilePath::CharType kAppendDir1[] = | 19 const base::FilePath::CharType kAppendDir1[] = |
| 19 FILE_PATH_LITERAL("test/path_append1"); | 20 FILE_PATH_LITERAL("test/path_append1"); |
| 20 const base::FilePath::CharType kAppendDir2[] = | 21 const base::FilePath::CharType kAppendDir2[] = |
| 21 FILE_PATH_LITERAL("test/path_append2"); | 22 FILE_PATH_LITERAL("test/path_append2"); |
| 22 | 23 |
| 23 scoped_ptr<base::Environment> env(base::Environment::Create()); | 24 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 24 | 25 |
| 25 std::string python_path; | 26 std::string python_path; |
| 26 base::FilePath append_path1(kAppendDir1); | 27 base::FilePath append_path1(kAppendDir1); |
| 27 base::FilePath append_path2(kAppendDir2); | 28 base::FilePath append_path2(kAppendDir2); |
| 28 | 29 |
| 29 // Get a clean start | 30 // Get a clean start |
| 30 env->UnSetVar(kPythonPathEnv); | 31 env->UnSetVar(kPythonPathEnv); |
| 31 | 32 |
| 32 // Append the path | 33 // Append the path |
| 33 AppendToPythonPath(append_path1); | 34 AppendToPythonPath(append_path1); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 // we want. | 58 // we want. |
| 58 cmd_line.AppendArg("-c"); | 59 cmd_line.AppendArg("-c"); |
| 59 std::string input("PythonUtilsTest"); | 60 std::string input("PythonUtilsTest"); |
| 60 std::string python_cmd = base::StringPrintf("print '%s';", input.c_str()); | 61 std::string python_cmd = base::StringPrintf("print '%s';", input.c_str()); |
| 61 cmd_line.AppendArg(python_cmd); | 62 cmd_line.AppendArg(python_cmd); |
| 62 std::string output; | 63 std::string output; |
| 63 EXPECT_TRUE(base::GetAppOutput(cmd_line, &output)); | 64 EXPECT_TRUE(base::GetAppOutput(cmd_line, &output)); |
| 64 base::TrimWhitespaceASCII(output, base::TRIM_TRAILING, &output); | 65 base::TrimWhitespaceASCII(output, base::TRIM_TRAILING, &output); |
| 65 EXPECT_EQ(input, output); | 66 EXPECT_EQ(input, output); |
| 66 } | 67 } |
| OLD | NEW |