| 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/renderer/browser_plugin/browser_plugin_browsertest.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/singleton.h" |
| 9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 10 #include "content/common/browser_plugin_messages.h" | 11 #include "content/common/browser_plugin_messages.h" |
| 11 #include "content/public/common/content_constants.h" | 12 #include "content/public/common/content_constants.h" |
| 12 #include "content/renderer/browser_plugin/browser_plugin.h" | 13 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 14 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" |
| 13 #include "content/renderer/browser_plugin/mock_browser_plugin.h" | 15 #include "content/renderer/browser_plugin/mock_browser_plugin.h" |
| 14 #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h" | 16 #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h" |
| 15 #include "content/renderer/render_thread_impl.h" | 17 #include "content/renderer/render_thread_impl.h" |
| 16 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 18 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 17 #include "skia/ext/platform_canvas.h" | 19 #include "skia/ext/platform_canvas.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 41 | 43 |
| 42 std::string GetHTMLForBrowserPluginObject() { | 44 std::string GetHTMLForBrowserPluginObject() { |
| 43 return StringPrintf(kHTMLForBrowserPluginObject, | 45 return StringPrintf(kHTMLForBrowserPluginObject, |
| 44 content::kBrowserPluginMimeType); | 46 content::kBrowserPluginMimeType); |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace | 49 } // namespace |
| 48 | 50 |
| 49 namespace content { | 51 namespace content { |
| 50 | 52 |
| 53 // Test factory for creating test instances of BrowserPluginManager. |
| 54 class TestBrowserPluginManagerFactory : public BrowserPluginManagerFactory { |
| 55 public: |
| 56 virtual MockBrowserPluginManager* CreateBrowserPluginManager( |
| 57 RenderViewImpl* render_view) OVERRIDE { |
| 58 return new MockBrowserPluginManager(render_view); |
| 59 } |
| 60 |
| 61 // Singleton getter. |
| 62 static TestBrowserPluginManagerFactory* GetInstance() { |
| 63 return Singleton<TestBrowserPluginManagerFactory>::get(); |
| 64 } |
| 65 |
| 66 protected: |
| 67 TestBrowserPluginManagerFactory() {} |
| 68 virtual ~TestBrowserPluginManagerFactory() {} |
| 69 |
| 70 private: |
| 71 // For Singleton. |
| 72 friend struct DefaultSingletonTraits<TestBrowserPluginManagerFactory>; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(TestBrowserPluginManagerFactory); |
| 75 }; |
| 76 |
| 51 BrowserPluginTest::BrowserPluginTest() {} | 77 BrowserPluginTest::BrowserPluginTest() {} |
| 52 | 78 |
| 53 BrowserPluginTest::~BrowserPluginTest() {} | 79 BrowserPluginTest::~BrowserPluginTest() {} |
| 54 | 80 |
| 55 void BrowserPluginTest::SetUp() { | 81 void BrowserPluginTest::SetUp() { |
| 56 GetContentClient()->set_renderer_for_testing(&content_renderer_client_); | 82 GetContentClient()->set_renderer_for_testing(&content_renderer_client_); |
| 83 BrowserPluginManager::set_factory_for_testing( |
| 84 TestBrowserPluginManagerFactory::GetInstance()); |
| 57 content::RenderViewTest::SetUp(); | 85 content::RenderViewTest::SetUp(); |
| 58 browser_plugin_manager_.reset(new MockBrowserPluginManager()); | 86 |
| 59 } | 87 } |
| 60 | 88 |
| 61 void BrowserPluginTest::TearDown() { | 89 void BrowserPluginTest::TearDown() { |
| 62 browser_plugin_manager_->Cleanup(); | 90 browser_plugin_manager()->Cleanup(); |
| 91 BrowserPluginManager::set_factory_for_testing( |
| 92 TestBrowserPluginManagerFactory::GetInstance()); |
| 63 content::RenderViewTest::TearDown(); | 93 content::RenderViewTest::TearDown(); |
| 64 } | 94 } |
| 65 | 95 |
| 66 std::string BrowserPluginTest::ExecuteScriptAndReturnString( | 96 std::string BrowserPluginTest::ExecuteScriptAndReturnString( |
| 67 const std::string& script) { | 97 const std::string& script) { |
| 68 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( | 98 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( |
| 69 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); | 99 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); |
| 70 if (value.IsEmpty() || !value->IsString()) | 100 if (value.IsEmpty() || !value->IsString()) |
| 71 return std::string(); | 101 return std::string(); |
| 72 | 102 |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 set_auto_size_params.b; | 768 set_auto_size_params.b; |
| 739 EXPECT_FALSE(auto_size_params.enable); | 769 EXPECT_FALSE(auto_size_params.enable); |
| 740 EXPECT_EQ(42, auto_size_params.min_size.width()); | 770 EXPECT_EQ(42, auto_size_params.min_size.width()); |
| 741 EXPECT_EQ(43, auto_size_params.min_size.height()); | 771 EXPECT_EQ(43, auto_size_params.min_size.height()); |
| 742 EXPECT_EQ(1337, auto_size_params.max_size.width()); | 772 EXPECT_EQ(1337, auto_size_params.max_size.width()); |
| 743 EXPECT_EQ(1338, auto_size_params.max_size.height()); | 773 EXPECT_EQ(1338, auto_size_params.max_size.height()); |
| 744 } | 774 } |
| 745 } | 775 } |
| 746 | 776 |
| 747 } // namespace content | 777 } // namespace content |
| OLD | NEW |