summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/test/content_test_suite.cc25
-rw-r--r--content/test/content_test_suite_base.cc2
2 files changed, 25 insertions, 2 deletions
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc
index 1fc9d35..03d21db 100644
--- a/content/test/content_test_suite.cc
+++ b/content/test/content_test_suite.cc
@@ -4,9 +4,15 @@
#include "content/test/content_test_suite.h"
+#if defined(OS_CHROMEOS)
+#include <stdio.h>
+#include <unistd.h>
+#endif
+
#include "base/logging.h"
#include "content/public/test/test_content_client_initializer.h"
#include "content/test/test_content_client.h"
+#include "media/base/media.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_AURA)
@@ -53,6 +59,19 @@ ContentTestSuite::ContentTestSuite(int argc, char** argv)
ContentTestSuite::~ContentTestSuite() {
}
+static bool IsCrosPythonProcess() {
+#if defined(OS_CHROMEOS)
+ char buf[80];
+ int num_read = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
+ if (num_read == -1)
+ return false;
+ buf[num_read] = 0;
+ const char kPythonPrefix[] = "/python";
+ return !strncmp(strrchr(buf, '/'), kPythonPrefix, sizeof(kPythonPrefix) - 1);
+#endif // defined(OS_CHROMEOS)
+ return false;
+}
+
void ContentTestSuite::Initialize() {
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool autorelease_pool;
@@ -60,6 +79,12 @@ void ContentTestSuite::Initialize() {
ContentTestSuiteBase::Initialize();
+ // Initialize media library for unit tests. If we are auto test
+ // (python process under chrome os), media library will be loaded to
+ // chrome directly so don't load it here.
+ if (!IsCrosPythonProcess())
+ media::InitializeMediaLibraryForTesting();
+
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
listeners.Append(new TestInitializationListener);
diff --git a/content/test/content_test_suite_base.cc b/content/test/content_test_suite_base.cc
index 3274f1b..adf2079 100644
--- a/content/test/content_test_suite_base.cc
+++ b/content/test/content_test_suite_base.cc
@@ -11,7 +11,6 @@
#include "content/common/url_schemes.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_paths.h"
-#include "media/base/media.h"
#include "ui/base/ui_base_paths.h"
#include "ui/compositor/compositor_setup.h"
@@ -23,7 +22,6 @@ ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv)
void ContentTestSuiteBase::Initialize() {
base::TestSuite::Initialize();
- media::InitializeMediaLibraryForTesting();
scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization());
SetContentClient(client_for_init.get());