Make sure webrtc::VideoSourceInterface is released on the main render thread.
[chromium-blink-merge.git] / content / public / test / content_test_suite_base.cc
blob9307e536252d7edfd1c6b8e3f0f3eb6f4594ddc8
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
3 // found in the LICENSE file.
5 #include "content/public/test/content_test_suite_base.h"
7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/test/test_suite.h"
11 #include "base/threading/sequenced_worker_pool.h"
12 #include "content/browser/browser_thread_impl.h"
13 #include "content/common/url_schemes.h"
14 #include "content/gpu/in_process_gpu_thread.h"
15 #include "content/public/common/content_client.h"
16 #include "content/renderer/in_process_renderer_thread.h"
17 #include "content/utility/in_process_utility_thread.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/base/ui_base_paths.h"
21 #if !defined(OS_IOS)
22 #include "content/browser/gpu/gpu_process_host.h"
23 #include "content/browser/renderer_host/render_process_host_impl.h"
24 #include "content/browser/utility_process_host_impl.h"
25 #endif
27 #if defined(OS_ANDROID)
28 #include "base/android/jni_android.h"
29 #include "content/browser/android/browser_jni_registrar.h"
30 #include "content/common/android/common_jni_registrar.h"
31 #include "media/base/android/media_jni_registrar.h"
32 #include "net/android/net_jni_registrar.h"
33 #include "ui/base/android/ui_base_jni_registrar.h"
34 #include "ui/gfx/android/gfx_jni_registrar.h"
35 #include "ui/gl/android/gl_jni_registrar.h"
36 #include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
37 #endif
39 namespace content {
41 class ContentTestSuiteBaseListener : public testing::EmptyTestEventListener {
42 public:
43 ContentTestSuiteBaseListener() {
45 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
46 BrowserThreadImpl::FlushThreadPoolHelper();
48 private:
49 DISALLOW_COPY_AND_ASSIGN(ContentTestSuiteBaseListener);
52 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv)
53 : base::TestSuite(argc, argv) {
56 void ContentTestSuiteBase::Initialize() {
57 base::TestSuite::Initialize();
59 #if defined(OS_ANDROID)
60 // Register JNI bindings for android.
61 JNIEnv* env = base::android::AttachCurrentThread();
62 content::android::RegisterCommonJni(env);
63 content::android::RegisterBrowserJni(env);
64 gfx::android::RegisterJni(env);
65 media::RegisterJni(env);
66 net::android::RegisterJni(env);
67 ui::android::RegisterJni(env);
68 ui::shell_dialogs::RegisterJni(env);
69 #endif
71 testing::UnitTest::GetInstance()->listeners().Append(
72 new ContentTestSuiteBaseListener);
75 void ContentTestSuiteBase::RegisterContentSchemes(
76 ContentClient* content_client) {
77 SetContentClient(content_client);
78 content::RegisterContentSchemes(false);
79 SetContentClient(NULL);
82 void ContentTestSuiteBase::RegisterInProcessThreads() {
83 #if !defined(OS_IOS)
84 UtilityProcessHostImpl::RegisterUtilityMainThreadFactory(
85 CreateInProcessUtilityThread);
86 RenderProcessHostImpl::RegisterRendererMainThreadFactory(
87 CreateInProcessRendererThread);
88 GpuProcessHost::RegisterGpuMainThreadFactory(CreateInProcessGpuThread);
89 #endif
92 } // namespace content