Chromium Code Reviews| 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/shell/renderer/webkit_test_runner.h" | 5 #include "content/shell/renderer/webkit_test_runner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <clocale> | 8 #include <clocale> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/debug/debugger.h" | 12 #include "base/debug/debugger.h" |
| 13 #include "base/md5.h" | 13 #include "base/md5.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
| 22 #include "content/public/renderer/render_view_visitor.h" | 22 #include "content/public/renderer/render_view_visitor.h" |
| 23 #include "content/public/test/layouttest_support.h" | 23 #include "content/public/test/layouttest_support.h" |
| 24 #include "content/shell/common/shell_messages.h" | 24 #include "content/shell/common/shell_messages.h" |
| 25 #include "content/shell/common/webkit_test_helpers.h" | 25 #include "content/shell/common/webkit_test_helpers.h" |
| 26 #include "content/shell/renderer/shell_render_process_observer.h" | 26 #include "content/shell/renderer/shell_render_process_observer.h" |
| 27 #include "media/base/media_log.h" | |
| 27 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
| 28 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| 29 #include "skia/ext/platform_canvas.h" | 30 #include "skia/ext/platform_canvas.h" |
| 30 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" | 31 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" |
| 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" | 32 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" |
| 32 #include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" | 33 #include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" |
| 33 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 34 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
| 34 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 35 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 35 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 36 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 36 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 37 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 53 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web Task.h" | 54 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web Task.h" |
| 54 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h" | 55 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h" |
| 55 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h" | 56 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h" |
| 56 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestRunner.h" | 57 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestRunner.h" |
| 57 #include "ui/gfx/rect.h" | 58 #include "ui/gfx/rect.h" |
| 58 #include "webkit/base/file_path_string_conversions.h" | 59 #include "webkit/base/file_path_string_conversions.h" |
| 59 #include "webkit/glue/glue_serialize.h" | 60 #include "webkit/glue/glue_serialize.h" |
| 60 #include "webkit/glue/webkit_glue.h" | 61 #include "webkit/glue/webkit_glue.h" |
| 61 #include "webkit/glue/webpreferences.h" | 62 #include "webkit/glue/webpreferences.h" |
| 63 #include "webkit/media/webmediaplayer_impl.h" | |
| 64 #include "webkit/media/webmediaplayer_ms.h" | |
| 65 #include "webkit/media/webmediaplayer_params.h" | |
| 62 #include "webkit/mocks/test_media_stream_client.h" | 66 #include "webkit/mocks/test_media_stream_client.h" |
| 63 | 67 |
| 64 using WebKit::Platform; | 68 using WebKit::Platform; |
| 65 using WebKit::WebArrayBufferView; | 69 using WebKit::WebArrayBufferView; |
| 66 using WebKit::WebContextMenuData; | 70 using WebKit::WebContextMenuData; |
| 67 using WebKit::WebDevToolsAgent; | 71 using WebKit::WebDevToolsAgent; |
| 68 using WebKit::WebDeviceOrientation; | 72 using WebKit::WebDeviceOrientation; |
| 69 using WebKit::WebElement; | 73 using WebKit::WebElement; |
| 70 using WebKit::WebFrame; | 74 using WebKit::WebFrame; |
| 71 using WebKit::WebGamepads; | 75 using WebKit::WebGamepads; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 }; | 188 }; |
| 185 | 189 |
| 186 } // namespace | 190 } // namespace |
| 187 | 191 |
| 188 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) | 192 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) |
| 189 : RenderViewObserver(render_view), | 193 : RenderViewObserver(render_view), |
| 190 RenderViewObserverTracker<WebKitTestRunner>(render_view), | 194 RenderViewObserverTracker<WebKitTestRunner>(render_view), |
| 191 proxy_(NULL), | 195 proxy_(NULL), |
| 192 focused_view_(NULL), | 196 focused_view_(NULL), |
| 193 is_main_window_(false), | 197 is_main_window_(false), |
| 194 focus_on_next_commit_(false) { | 198 focus_on_next_commit_(false), |
| 199 media_thread_("Media") { | |
| 195 } | 200 } |
| 196 | 201 |
| 197 WebKitTestRunner::~WebKitTestRunner() { | 202 WebKitTestRunner::~WebKitTestRunner() { |
| 198 } | 203 } |
| 199 | 204 |
| 200 // WebTestDelegate ----------------------------------------------------------- | 205 // WebTestDelegate ----------------------------------------------------------- |
| 201 | 206 |
| 202 void WebKitTestRunner::clearEditCommand() { | 207 void WebKitTestRunner::clearEditCommand() { |
| 203 render_view()->ClearEditCommands(); | 208 render_view()->ClearEditCommands(); |
| 204 } | 209 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 history->swap(result); | 522 history->swap(result); |
| 518 } | 523 } |
| 519 | 524 |
| 520 WebMediaPlayer* WebKitTestRunner::createWebMediaPlayer( | 525 WebMediaPlayer* WebKitTestRunner::createWebMediaPlayer( |
| 521 WebFrame* frame, const WebURL& url, WebMediaPlayerClient* client) | 526 WebFrame* frame, const WebURL& url, WebMediaPlayerClient* client) |
| 522 { | 527 { |
| 523 if (!test_media_stream_client_) { | 528 if (!test_media_stream_client_) { |
| 524 test_media_stream_client_.reset( | 529 test_media_stream_client_.reset( |
| 525 new webkit_glue::TestMediaStreamClient()); | 530 new webkit_glue::TestMediaStreamClient()); |
| 526 } | 531 } |
| 527 return webkit_glue::CreateMediaPlayer( | 532 |
| 528 frame, url, client, test_media_stream_client_.get()); | 533 if (test_media_stream_client_->IsMediaStream(url)) { |
|
scherkus (not reviewing)
2013/05/09 21:59:32
jochen: I didn't see a strong reason to stick webk
| |
| 534 return new webkit_media::WebMediaPlayerMS( | |
| 535 frame, | |
| 536 client, | |
| 537 base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | |
| 538 test_media_stream_client_.get(), | |
| 539 new media::MediaLog()); | |
| 540 } | |
| 541 | |
| 542 #if defined(OS_ANDROID) | |
| 543 return NULL; | |
| 544 #else | |
| 545 // TODO(scherkus): Use RenderViewImpl::createMediaPlayer() instead of | |
| 546 // duplicating code here. | |
| 547 if (!media_thread_.IsRunning()) | |
| 548 media_thread_.Start(); | |
|
jochen (gone - plz use gerrit)
2013/05/10 07:37:34
why don't you use the RenderThread's media thread?
scherkus (not reviewing)
2013/05/10 18:27:06
This was exactly the sort of plumbing I was lookin
| |
| 549 | |
| 550 webkit_media::WebMediaPlayerParams params( | |
| 551 media_thread_.message_loop_proxy(), NULL, NULL, new media::MediaLog()); | |
| 552 return new webkit_media::WebMediaPlayerImpl( | |
| 553 frame, | |
| 554 client, | |
| 555 base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | |
| 556 params); | |
| 557 #endif | |
| 529 } | 558 } |
| 530 | 559 |
| 531 // RenderViewObserver -------------------------------------------------------- | 560 // RenderViewObserver -------------------------------------------------------- |
| 532 | 561 |
| 533 void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { | 562 void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { |
| 534 WebTestingSupport::injectInternalsObject(frame); | 563 WebTestingSupport::injectInternalsObject(frame); |
| 535 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); | 564 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); |
| 536 } | 565 } |
| 537 | 566 |
| 538 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { | 567 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 ->loadRequest(WebURLRequest(GURL("about:blank"))); | 725 ->loadRequest(WebURLRequest(GURL("about:blank"))); |
| 697 Send(new ShellViewHostMsg_ResetDone(routing_id())); | 726 Send(new ShellViewHostMsg_ResetDone(routing_id())); |
| 698 } | 727 } |
| 699 | 728 |
| 700 void WebKitTestRunner::OnNotifyDone() { | 729 void WebKitTestRunner::OnNotifyDone() { |
| 701 render_view()->GetWebView()->mainFrame()->executeScript( | 730 render_view()->GetWebView()->mainFrame()->executeScript( |
| 702 WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();"))); | 731 WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();"))); |
| 703 } | 732 } |
| 704 | 733 |
| 705 } // namespace content | 734 } // namespace content |
| OLD | NEW |