Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / base / chrome_render_view_test.cc
blob4f47f69eb007c99a4b791220cd01c23e595b2ae5
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 "chrome/test/base/chrome_render_view_test.h"
7 #include "base/debug/leak_annotations.h"
8 #include "chrome/browser/chrome_content_browser_client.h"
9 #include "chrome/common/chrome_content_client.h"
10 #include "chrome/common/render_messages.h"
11 #include "chrome/renderer/chrome_content_renderer_client.h"
12 #include "chrome/renderer/spellchecker/spellcheck.h"
13 #include "chrome/test/base/chrome_unit_test_suite.h"
14 #include "components/autofill/content/renderer/autofill_agent.h"
15 #include "components/autofill/content/renderer/password_autofill_agent.h"
16 #include "components/autofill/content/renderer/test_password_autofill_agent.h"
17 #include "components/autofill/content/renderer/test_password_generation_agent.h"
18 #include "content/public/browser/native_web_keyboard_event.h"
19 #include "content/public/common/renderer_preferences.h"
20 #include "content/public/renderer/render_view.h"
21 #include "third_party/WebKit/public/platform/WebURLRequest.h"
22 #include "third_party/WebKit/public/web/WebFrame.h"
23 #include "third_party/WebKit/public/web/WebInputEvent.h"
24 #include "third_party/WebKit/public/web/WebKit.h"
25 #include "third_party/WebKit/public/web/WebScriptController.h"
26 #include "third_party/WebKit/public/web/WebScriptSource.h"
27 #include "third_party/WebKit/public/web/WebView.h"
29 #if defined(ENABLE_EXTENSIONS)
30 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h"
31 #include "extensions/browser/extension_function_dispatcher.h"
32 #include "extensions/common/extension.h"
33 #include "extensions/renderer/dispatcher.h"
34 #include "extensions/renderer/event_bindings.h"
35 #endif
37 using autofill::AutofillAgent;
38 using autofill::PasswordAutofillAgent;
39 using autofill::PasswordGenerationAgent;
40 using blink::WebFrame;
41 using blink::WebInputEvent;
42 using blink::WebMouseEvent;
43 using blink::WebScriptController;
44 using blink::WebScriptSource;
45 using blink::WebString;
46 using blink::WebURLRequest;
48 ChromeRenderViewTest::ChromeRenderViewTest()
49 : password_autofill_agent_(NULL),
50 password_generation_(NULL),
51 autofill_agent_(NULL),
52 chrome_render_thread_(NULL) {
55 ChromeRenderViewTest::~ChromeRenderViewTest() {
58 void ChromeRenderViewTest::SetUp() {
59 ChromeUnitTestSuite::InitializeProviders();
60 ChromeUnitTestSuite::InitializeResourceBundle();
62 chrome_render_thread_ = new ChromeMockRenderThread();
63 render_thread_.reset(chrome_render_thread_);
65 content::RenderViewTest::SetUp();
67 // RenderFrame doesn't expose its Agent objects, because it has no need to
68 // store them directly (they're stored as RenderFrameObserver*). So just
69 // create another set.
70 password_autofill_agent_ =
71 new autofill::TestPasswordAutofillAgent(view_->GetMainRenderFrame());
72 password_generation_ =
73 new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame());
74 autofill_agent_ =
75 new AutofillAgent(view_->GetMainRenderFrame(), password_autofill_agent_,
76 password_generation_);
79 void ChromeRenderViewTest::TearDown() {
80 #if defined(ENABLE_EXTENSIONS)
81 ChromeContentRendererClient* client =
82 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get());
83 client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown();
84 #endif
86 #if defined(LEAK_SANITIZER)
87 // Do this before shutting down V8 in RenderViewTest::TearDown().
88 // http://crbug.com/328552
89 __lsan_do_leak_check();
90 #endif
91 content::RenderViewTest::TearDown();
94 content::ContentClient* ChromeRenderViewTest::CreateContentClient() {
95 return new ChromeContentClient();
98 content::ContentBrowserClient*
99 ChromeRenderViewTest::CreateContentBrowserClient() {
100 return new chrome::ChromeContentBrowserClient();
103 content::ContentRendererClient*
104 ChromeRenderViewTest::CreateContentRendererClient() {
105 ChromeContentRendererClient* client = new ChromeContentRendererClient();
106 #if defined(ENABLE_EXTENSIONS)
107 extension_dispatcher_delegate_.reset(
108 new ChromeExtensionsDispatcherDelegate());
109 client->SetExtensionDispatcherForTest(
110 new extensions::Dispatcher(extension_dispatcher_delegate_.get()));
111 #endif
112 #if defined(ENABLE_SPELLCHECK)
113 client->SetSpellcheck(new SpellCheck());
114 #endif
115 return client;