summaryrefslogtreecommitdiffstats
path: root/net/test/python_utils_unittest.cc
diff options
context:
space:
mode:
authorlzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 17:00:38 +0000
committerlzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 17:00:38 +0000
commit3b27adfc7ed75f2b5501039895ea9ec05f7266df (patch)
treee23d348bf776ee5efef5d7ebeff28ecacf1f21b0 /net/test/python_utils_unittest.cc
parentc22edd63437194368b171c30cd6be75ba035c2e5 (diff)
downloadchromium_src-3b27adfc7ed75f2b5501039895ea9ec05f7266df.zip
chromium_src-3b27adfc7ed75f2b5501039895ea9ec05f7266df.tar.gz
chromium_src-3b27adfc7ed75f2b5501039895ea9ec05f7266df.tar.bz2
Refactor test_server so some python related functions could be shared by other test servers.
BUG=none TEST=python_utils_unittest.cc Review URL: http://codereview.chromium.org/3366026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59671 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test/python_utils_unittest.cc')
-rw-r--r--net/test/python_utils_unittest.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/net/test/python_utils_unittest.cc b/net/test/python_utils_unittest.cc
new file mode 100644
index 0000000..4026840
--- /dev/null
+++ b/net/test/python_utils_unittest.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/environment.h"
+#include "base/file_path.h"
+#include "base/scoped_ptr.h"
+#include "net/test/python_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(PythonUtils, Append) {
+ const FilePath::CharType kAppendDir1[] =
+ FILE_PATH_LITERAL("test/path_append1");
+ const FilePath::CharType kAppendDir2[] =
+ FILE_PATH_LITERAL("test/path_append2");
+
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ std::string python_path;
+ FilePath append_path1(kAppendDir1);
+ FilePath append_path2(kAppendDir2);
+
+ // Get a clean start
+ env->UnSetVar(kPythonPathEnv);
+
+ // Append the path
+ AppendToPythonPath(append_path1);
+ env->GetVar(kPythonPathEnv, &python_path);
+ ASSERT_EQ(python_path, "test/path_append1");
+
+ // Append the safe path again, nothing changes
+ AppendToPythonPath(append_path2);
+ env->GetVar(kPythonPathEnv, &python_path);
+#if defined(OS_WIN)
+ ASSERT_EQ(std::string("test/path_append1;test/path_append2"), python_path);
+#elif defined(OS_POSIX)
+ ASSERT_EQ(std::string("test/path_append1:test/path_append2"), python_path);
+#endif
+}
+
+TEST(PythonUtils, PythonRunTime) {
+ FilePath dir;
+ EXPECT_TRUE(GetPythonRunTime(&dir));
+#if defined(OS_WIN)
+ EXPECT_NE(std::wstring::npos,
+ dir.value().find(L"third_party\\python_24\\python.exe"));
+#elif defined(OS_POSIX)
+ EXPECT_NE(std::string::npos, dir.value().find("python"));
+#endif
+}
+