summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 10:42:47 +0000
committerrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 10:42:47 +0000
commit193559b81078baed256db62d9c53df1ea1e00c54 (patch)
tree61f6a3a9b78e86cb18c7fda00e25372603876585 /content
parent01ea752739447788d28824cc40f40215e7a527b3 (diff)
downloadchromium_src-193559b81078baed256db62d9c53df1ea1e00c54.zip
chromium_src-193559b81078baed256db62d9c53df1ea1e00c54.tar.gz
chromium_src-193559b81078baed256db62d9c53df1ea1e00c54.tar.bz2
Re-implement the screensaver to use WebView instead of ExtensionDialogHost.
Use WebView to render the screensaver extension instead of ExtensionDialogHost. Using the RenderViewGone override to detect termination of the renderer process to restart it. Added browser tests. R=ben@chromium.org,sky@chromium.org BUG=chromium-os:28211 TEST=Tested that the screensaver comes up; tested the reload via crashing the extension renderer with SIG_ABRT; also ran browser tests. Review URL: http://codereview.chromium.org/10191010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/content_tests.gypi4
-rw-r--r--content/test/content_test_suite.cc35
-rw-r--r--content/test/test_content_client_initializer.cc35
-rw-r--r--content/test/test_content_client_initializer.h37
-rw-r--r--content/test/test_render_view_host_factory.cc39
-rw-r--r--content/test/test_render_view_host_factory.h53
-rw-r--r--content/test/test_renderer_host.cc61
7 files changed, 179 insertions, 85 deletions
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index df47b5e0..88c7400 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -90,6 +90,8 @@
'test/test_browser_thread.h',
'test/test_content_client.cc',
'test/test_content_client.h',
+ 'test/test_content_client_initializer.cc',
+ 'test/test_content_client_initializer.h',
'test/test_file_error_injector.cc',
'test/test_file_error_injector.h',
'test/test_navigation_observer.cc',
@@ -98,6 +100,8 @@
'test/test_notification_tracker.h',
'test/test_renderer_host.cc',
'test/test_renderer_host.h',
+ 'test/test_render_view_host_factory.cc',
+ 'test/test_render_view_host_factory.h',
'test/test_url_fetcher_factory.cc',
'test/test_url_fetcher_factory.h',
'test/test_web_contents_view.cc',
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc
index 4272a9c..a81b816b 100644
--- a/content/test/content_test_suite.cc
+++ b/content/test/content_test_suite.cc
@@ -5,13 +5,11 @@
#include "content/test/content_test_suite.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "content/browser/mock_content_browser_client.h"
-#include "content/browser/notification_service_impl.h"
-#include "content/public/common/content_client.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/url_constants.h"
#include "content/test/test_content_client.h"
+#include "content/test/test_content_client_initializer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_paths.h"
@@ -20,40 +18,27 @@
#endif
#include "ui/gfx/compositor/compositor_setup.h"
+
namespace {
-class TestContentClientInitializer : public testing::EmptyTestEventListener {
+class TestInitializationListener : public testing::EmptyTestEventListener {
public:
- TestContentClientInitializer() {
+ TestInitializationListener() : test_content_client_initializer_(NULL) {
}
virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
- notification_service_.reset(new NotificationServiceImpl());
-
- DCHECK(!content::GetContentClient());
- content_client_.reset(new TestContentClient);
- content::SetContentClient(content_client_.get());
-
- content_browser_client_.reset(new content::MockContentBrowserClient());
- content_client_->set_browser(content_browser_client_.get());
+ test_content_client_initializer_ =
+ new content::TestContentClientInitializer();
}
virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
- notification_service_.reset();
-
- DCHECK_EQ(content_client_.get(), content::GetContentClient());
- content::SetContentClient(NULL);
- content_client_.reset();
-
- content_browser_client_.reset();
+ delete test_content_client_initializer_;
}
private:
- scoped_ptr<NotificationServiceImpl> notification_service_;
- scoped_ptr<content::ContentClient> content_client_;
- scoped_ptr<content::ContentBrowserClient> content_browser_client_;
+ content::TestContentClientInitializer* test_content_client_initializer_;
- DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer);
+ DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
};
} // namespace
@@ -85,6 +70,6 @@ void ContentTestSuite::Initialize() {
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
- listeners.Append(new TestContentClientInitializer);
+ listeners.Append(new TestInitializationListener);
}
diff --git a/content/test/test_content_client_initializer.cc b/content/test/test_content_client_initializer.cc
new file mode 100644
index 0000000..26cd3aa
--- /dev/null
+++ b/content/test/test_content_client_initializer.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 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 "content/test/test_content_client_initializer.h"
+
+#include "content/browser/mock_content_browser_client.h"
+#include "content/browser/notification_service_impl.h"
+#include "content/public/common/content_client.h"
+#include "content/test/test_content_client.h"
+
+namespace content {
+
+TestContentClientInitializer::TestContentClientInitializer() {
+ notification_service_.reset(new NotificationServiceImpl());
+
+ DCHECK(!content::GetContentClient());
+ content_client_.reset(new TestContentClient);
+ content::SetContentClient(content_client_.get());
+
+ content_browser_client_.reset(new content::MockContentBrowserClient());
+ content_client_->set_browser(content_browser_client_.get());
+}
+
+TestContentClientInitializer::~TestContentClientInitializer() {
+ notification_service_.reset();
+
+ DCHECK_EQ(content_client_.get(), content::GetContentClient());
+ content::SetContentClient(NULL);
+ content_client_.reset();
+
+ content_browser_client_.reset();
+}
+
+} // namespace content
diff --git a/content/test/test_content_client_initializer.h b/content/test/test_content_client_initializer.h
new file mode 100644
index 0000000..fbbdd80
--- /dev/null
+++ b/content/test/test_content_client_initializer.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 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.
+
+#ifndef CONTENT_TEST_TEST_CONTENT_CLIENT_INITIALIZER_
+#define CONTENT_TEST_TEST_CONTENT_CLIENT_INITIALIZER_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+
+class NotificationServiceImpl;
+
+namespace content {
+
+class ContentClient;
+class ContentBrowserClient;
+
+// Initializes various objects needed to run unit tests that use content::
+// objects. Currently this includes setting up the notification service,
+// creating and setting the content client and the content browser client.
+class TestContentClientInitializer {
+ public:
+ TestContentClientInitializer();
+ ~TestContentClientInitializer();
+
+ private:
+ scoped_ptr<NotificationServiceImpl> notification_service_;
+ scoped_ptr<content::ContentClient> content_client_;
+ scoped_ptr<content::ContentBrowserClient> content_browser_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer);
+};
+
+} // namespace content
+
+#endif // CONTENT_TEST_TEST_CONTENT_CLIENT_INITIALIZER_
diff --git a/content/test/test_render_view_host_factory.cc b/content/test/test_render_view_host_factory.cc
new file mode 100644
index 0000000..429922c
--- /dev/null
+++ b/content/test/test_render_view_host_factory.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 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 "content/test/test_render_view_host_factory.h"
+
+#include "content/browser/renderer_host/test_render_view_host.h"
+#include "content/browser/site_instance_impl.h"
+#include "content/public/browser/render_process_host_factory.h"
+
+namespace content {
+
+TestRenderViewHostFactory::TestRenderViewHostFactory(
+ content::RenderProcessHostFactory* rph_factory)
+ : render_process_host_factory_(rph_factory) {
+ RenderViewHostFactory::RegisterFactory(this);
+}
+
+TestRenderViewHostFactory::~TestRenderViewHostFactory() {
+ RenderViewHostFactory::UnregisterFactory();
+}
+
+void TestRenderViewHostFactory::set_render_process_host_factory(
+ content::RenderProcessHostFactory* rph_factory) {
+ render_process_host_factory_ = rph_factory;
+}
+
+content::RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost(
+ SiteInstance* instance,
+ RenderViewHostDelegate* delegate,
+ int routing_id,
+ SessionStorageNamespace* session_storage) {
+ // See declaration of render_process_host_factory_ below.
+ static_cast<SiteInstanceImpl*>(instance)->
+ set_render_process_host_factory(render_process_host_factory_);
+ return new TestRenderViewHost(instance, delegate, routing_id);
+}
+
+} // namespace content
diff --git a/content/test/test_render_view_host_factory.h b/content/test/test_render_view_host_factory.h
new file mode 100644
index 0000000..406d1c2
--- /dev/null
+++ b/content/test/test_render_view_host_factory.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 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.
+
+#ifndef CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_
+#define CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/browser/renderer_host/render_view_host_factory.h"
+
+namespace content {
+
+class SiteInstance;
+class RenderViewHostDelegate;
+class RenderProcessHostFactory;
+class SessionStorageNamespace;
+
+// Manages creation of the RenderViewHosts using our special subclass. This
+// automatically registers itself when it goes in scope, and unregisters itself
+// when it goes out of scope. Since you can't have more than one factory
+// registered at a time, you can only have one of these objects at a time.
+class TestRenderViewHostFactory : public RenderViewHostFactory {
+ public:
+ explicit TestRenderViewHostFactory(
+ content::RenderProcessHostFactory* rph_factory);
+ virtual ~TestRenderViewHostFactory();
+
+ virtual void set_render_process_host_factory(
+ content::RenderProcessHostFactory* rph_factory);
+ virtual content::RenderViewHost* CreateRenderViewHost(
+ content::SiteInstance* instance,
+ content::RenderViewHostDelegate* delegate,
+ int routing_id,
+ content::SessionStorageNamespace* session_storage) OVERRIDE;
+
+ private:
+ // This is a bit of a hack. With the current design of the site instances /
+ // browsing instances, it's difficult to pass a RenderProcessHostFactory
+ // around properly.
+ //
+ // Instead, we set it right before we create a new RenderViewHost, which
+ // happens before the RenderProcessHost is created. This way, the instance
+ // has the correct factory and creates our special RenderProcessHosts.
+ content::RenderProcessHostFactory* render_process_host_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory);
+};
+
+} // namespace content
+
+#endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_
diff --git a/content/test/test_renderer_host.cc b/content/test/test_renderer_host.cc
index cd9aa34..0921774 100644
--- a/content/test/test_renderer_host.cc
+++ b/content/test/test_renderer_host.cc
@@ -12,6 +12,7 @@
#include "content/public/browser/web_contents.h"
#include "content/test/mock_render_process_host.h"
#include "content/test/test_browser_context.h"
+#include "content/test/test_render_view_host_factory.h"
#if defined(USE_AURA)
#include "ui/aura/env.h"
@@ -25,66 +26,6 @@
namespace content {
-// Manages creation of the RenderViewHosts using our special subclass. This
-// automatically registers itself when it goes in scope, and unregisters itself
-// when it goes out of scope. Since you can't have more than one factory
-// registered at a time, you can only have one of these objects at a time.
-//
-// This is an implementation detail of this file and used only via
-// RenderViewHostTestEnabler.
-class TestRenderViewHostFactory : public RenderViewHostFactory {
- public:
- explicit TestRenderViewHostFactory(
- content::RenderProcessHostFactory* rph_factory);
- virtual ~TestRenderViewHostFactory();
-
- virtual void set_render_process_host_factory(
- content::RenderProcessHostFactory* rph_factory);
- virtual content::RenderViewHost* CreateRenderViewHost(
- content::SiteInstance* instance,
- content::RenderViewHostDelegate* delegate,
- int routing_id,
- content::SessionStorageNamespace* session_storage) OVERRIDE;
-
- private:
- // This is a bit of a hack. With the current design of the site instances /
- // browsing instances, it's difficult to pass a RenderProcessHostFactory
- // around properly.
- //
- // Instead, we set it right before we create a new RenderViewHost, which
- // happens before the RenderProcessHost is created. This way, the instance
- // has the correct factory and creates our special RenderProcessHosts.
- content::RenderProcessHostFactory* render_process_host_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory);
-};
-
-TestRenderViewHostFactory::TestRenderViewHostFactory(
- content::RenderProcessHostFactory* rph_factory)
- : render_process_host_factory_(rph_factory) {
- RenderViewHostFactory::RegisterFactory(this);
-}
-
-TestRenderViewHostFactory::~TestRenderViewHostFactory() {
- RenderViewHostFactory::UnregisterFactory();
-}
-
-void TestRenderViewHostFactory::set_render_process_host_factory(
- content::RenderProcessHostFactory* rph_factory) {
- render_process_host_factory_ = rph_factory;
-}
-
-content::RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost(
- SiteInstance* instance,
- RenderViewHostDelegate* delegate,
- int routing_id,
- SessionStorageNamespace* session_storage) {
- // See declaration of render_process_host_factory_ below.
- static_cast<SiteInstanceImpl*>(instance)->
- set_render_process_host_factory(render_process_host_factory_);
- return new TestRenderViewHost(instance, delegate, routing_id);
-}
-
// static
RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) {
return static_cast<TestRenderViewHost*>(host);