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/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 void BrowserPluginTest::TearDown() { | 106 void BrowserPluginTest::TearDown() { |
107 BrowserPluginManager::set_factory_for_testing( | 107 BrowserPluginManager::set_factory_for_testing( |
108 TestBrowserPluginManagerFactory::GetInstance()); | 108 TestBrowserPluginManagerFactory::GetInstance()); |
109 content::RenderViewTest::TearDown(); | 109 content::RenderViewTest::TearDown(); |
110 test_content_renderer_client_.reset(); | 110 test_content_renderer_client_.reset(); |
111 } | 111 } |
112 | 112 |
113 std::string BrowserPluginTest::ExecuteScriptAndReturnString( | 113 std::string BrowserPluginTest::ExecuteScriptAndReturnString( |
114 const std::string& script) { | 114 const std::string& script) { |
115 v8::HandleScope handle_scope; | 115 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
116 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( | 116 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( |
117 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); | 117 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); |
118 if (value.IsEmpty() || !value->IsString()) | 118 if (value.IsEmpty() || !value->IsString()) |
119 return std::string(); | 119 return std::string(); |
120 | 120 |
121 v8::Local<v8::String> v8_str = value->ToString(); | 121 v8::Local<v8::String> v8_str = value->ToString(); |
122 int length = v8_str->Utf8Length() + 1; | 122 int length = v8_str->Utf8Length() + 1; |
123 scoped_ptr<char[]> str(new char[length]); | 123 scoped_ptr<char[]> str(new char[length]); |
124 v8_str->WriteUtf8(str.get(), length); | 124 v8_str->WriteUtf8(str.get(), length); |
125 return str.get(); | 125 return str.get(); |
126 } | 126 } |
127 | 127 |
128 int BrowserPluginTest::ExecuteScriptAndReturnInt( | 128 int BrowserPluginTest::ExecuteScriptAndReturnInt( |
129 const std::string& script) { | 129 const std::string& script) { |
130 v8::HandleScope handle_scope; | 130 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
131 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( | 131 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( |
132 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); | 132 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); |
133 if (value.IsEmpty() || !value->IsInt32()) | 133 if (value.IsEmpty() || !value->IsInt32()) |
134 return 0; | 134 return 0; |
135 | 135 |
136 return value->Int32Value(); | 136 return value->Int32Value(); |
137 } | 137 } |
138 | 138 |
139 // A return value of false means that a value was not present. The return value | 139 // A return value of false means that a value was not present. The return value |
140 // of the script is stored in |result| | 140 // of the script is stored in |result| |
141 bool BrowserPluginTest::ExecuteScriptAndReturnBool( | 141 bool BrowserPluginTest::ExecuteScriptAndReturnBool( |
142 const std::string& script, bool* result) { | 142 const std::string& script, bool* result) { |
143 v8::HandleScope handle_scope; | 143 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
144 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( | 144 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( |
145 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); | 145 WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str()))); |
146 if (value.IsEmpty() || !value->IsBoolean()) | 146 if (value.IsEmpty() || !value->IsBoolean()) |
147 return false; | 147 return false; |
148 | 148 |
149 *result = value->BooleanValue(); | 149 *result = value->BooleanValue(); |
150 return true; | 150 return true; |
151 } | 151 } |
152 | 152 |
153 MockBrowserPlugin* BrowserPluginTest::GetCurrentPlugin() { | 153 MockBrowserPlugin* BrowserPluginTest::GetCurrentPlugin() { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 // These value are not populated (as an optimization) if autosize is | 623 // These value are not populated (as an optimization) if autosize is |
624 // disabled. | 624 // disabled. |
625 EXPECT_EQ(0, auto_size_params.min_size.width()); | 625 EXPECT_EQ(0, auto_size_params.min_size.width()); |
626 EXPECT_EQ(0, auto_size_params.min_size.height()); | 626 EXPECT_EQ(0, auto_size_params.min_size.height()); |
627 EXPECT_EQ(0, auto_size_params.max_size.width()); | 627 EXPECT_EQ(0, auto_size_params.max_size.width()); |
628 EXPECT_EQ(0, auto_size_params.max_size.height()); | 628 EXPECT_EQ(0, auto_size_params.max_size.height()); |
629 } | 629 } |
630 } | 630 } |
631 | 631 |
632 } // namespace content | 632 } // namespace content |
OLD | NEW |