Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/public/test/content_test_suite_base.h" | 5 #include "content/public/test/content_test_suite_base.h" |
| 6 | 6 |
| 7 #if defined(OS_CHROMEOS) | |
| 8 #include <stdio.h> | |
| 9 #include <unistd.h> | |
| 10 #endif // defined(OS_CHROMEOS) | |
| 11 | |
| 7 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/test/test_suite.h" | 15 #include "base/test/test_suite.h" |
| 11 #include "content/common/url_schemes.h" | 16 #include "content/common/url_schemes.h" |
| 12 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 13 #include "content/public/common/content_paths.h" | 18 #include "content/public/common/content_paths.h" |
| 14 #include "media/base/media.h" | 19 #include "media/base/media.h" |
| 15 #include "ui/base/ui_base_paths.h" | 20 #include "ui/base/ui_base_paths.h" |
| 16 #include "ui/compositor/compositor_setup.h" | 21 #include "ui/compositor/compositor_setup.h" |
| 17 | 22 |
| 18 namespace content { | 23 namespace content { |
| 19 | 24 |
| 20 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) | 25 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) |
| 21 : base::TestSuite(argc, argv) { | 26 : base::TestSuite(argc, argv) { |
| 22 } | 27 } |
| 23 | 28 |
| 29 static bool IsPythonProcess() { | |
| 30 #if defined(OS_CHROMEOS) | |
| 31 char buf[80]; | |
| 32 int num_read = readlink("/proc/self/exe", buf, sizeof(buf) - 1); | |
| 33 if (num_read == -1) | |
| 34 return false; | |
| 35 buf[num_read] = 0; | |
| 36 const char kPythonPrefix[] = "/python"; | |
| 37 return !strncmp(strrchr(buf, '/'), kPythonPrefix, sizeof(kPythonPrefix) - 1); | |
| 38 #endif // defined(OS_CHROMEOS) | |
| 39 return false; | |
|
Nirnimesh
2012/07/20 01:57:37
This statement is not true for non-chromeos. At le
glotov
2012/07/20 16:28:57
Done.
| |
| 40 } | |
| 41 | |
| 24 void ContentTestSuiteBase::Initialize() { | 42 void ContentTestSuiteBase::Initialize() { |
| 25 base::TestSuite::Initialize(); | 43 base::TestSuite::Initialize(); |
| 26 media::InitializeMediaLibraryForTesting(); | 44 |
| 45 // Initialize media library for unit tests. If we are auto test | |
| 46 // (python process), media library will be loaded to chrome directly | |
| 47 // so don't load it here. | |
| 48 if (!IsPythonProcess()) | |
| 49 media::InitializeMediaLibraryForTesting(); | |
| 27 | 50 |
| 28 scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); | 51 scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); |
| 29 SetContentClient(client_for_init.get()); | 52 SetContentClient(client_for_init.get()); |
| 30 RegisterContentSchemes(false); | 53 RegisterContentSchemes(false); |
| 31 SetContentClient(NULL); | 54 SetContentClient(NULL); |
| 32 | 55 |
| 33 RegisterPathProvider(); | 56 RegisterPathProvider(); |
| 34 ui::RegisterPathProvider(); | 57 ui::RegisterPathProvider(); |
| 35 | 58 |
| 36 // Mock out the compositor on platforms that use it. | 59 // Mock out the compositor on platforms that use it. |
| 37 ui::SetupTestCompositor(); | 60 ui::SetupTestCompositor(); |
| 38 } | 61 } |
| 39 | 62 |
| 40 } // namespace content | 63 } // namespace content |
| OLD | NEW |