#include "base/callback.h"
#include "base/lazy_instance.h"
+#include "cc/blink/web_layer_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/gpu/image_transport_surface.h"
+#include "content/public/common/page_state.h"
+#include "content/public/renderer/renderer_gamepad_provider.h"
+#include "content/renderer/fetchers/manifest_fetcher.h"
+#include "content/renderer/history_entry.h"
+#include "content/renderer/history_serialization.h"
+#include "content/renderer/render_frame_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
#include "content/renderer/renderer_webkitplatformsupport_impl.h"
-#include "content/test/test_media_stream_client.h"
+#include "content/shell/renderer/test_runner/test_common.h"
+#include "content/shell/renderer/test_runner/web_frame_test_proxy.h"
+#include "content/shell/renderer/test_runner/web_test_proxy.h"
+#include "third_party/WebKit/public/platform/WebBatteryStatus.h"
#include "third_party/WebKit/public/platform/WebDeviceMotionData.h"
#include "third_party/WebKit/public/platform/WebDeviceOrientationData.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
-#include "third_party/WebKit/public/testing/WebFrameTestProxy.h"
-#include "third_party/WebKit/public/testing/WebTestProxy.h"
-
-#if defined(OS_WIN) && !defined(USE_AURA)
-#include "content/browser/web_contents/web_contents_drag_win.h"
-#endif
+#include "third_party/WebKit/public/web/WebHistoryItem.h"
+#include "third_party/WebKit/public/web/WebView.h"
#if defined(OS_MACOSX)
-#include "content/browser/renderer_host/popup_menu_helper_mac.h"
+#include "content/browser/frame_host/popup_menu_helper_mac.h"
#endif
-using WebKit::WebDeviceMotionData;
-using WebKit::WebDeviceOrientationData;
-using WebKit::WebGamepads;
-using WebKit::WebRect;
-using WebKit::WebSize;
-using WebTestRunner::WebFrameTestProxy;
-using WebTestRunner::WebTestProxy;
-using WebTestRunner::WebTestProxyBase;
+using blink::WebBatteryStatus;
+using blink::WebDeviceMotionData;
+using blink::WebDeviceOrientationData;
+using blink::WebGamepad;
+using blink::WebGamepads;
+using blink::WebRect;
+using blink::WebSize;
namespace content {
RenderViewImpl* CreateWebTestProxy(RenderViewImplParams* params) {
typedef WebTestProxy<RenderViewImpl, RenderViewImplParams*> ProxyType;
- ProxyType* render_view_proxy = new ProxyType(
- reinterpret_cast<RenderViewImplParams*>(params));
+ ProxyType* render_view_proxy = new ProxyType(params);
if (g_callback == 0)
return render_view_proxy;
- g_callback.Get().Run(
- static_cast<RenderView*>(render_view_proxy), render_view_proxy);
+ g_callback.Get().Run(render_view_proxy, render_view_proxy);
return render_view_proxy;
}
typedef WebFrameTestProxy<RenderFrameImpl, RenderViewImpl*, int32> FrameProxy;
FrameProxy* render_frame_proxy = new FrameProxy(render_view, routing_id);
- render_frame_proxy->setBaseProxy(GetWebTestProxyBase(render_view));
- render_frame_proxy->setVersion(3);
+ render_frame_proxy->set_base_proxy(GetWebTestProxyBase(render_view));
return render_frame_proxy;
}
RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy);
}
-void SetMockGamepads(const WebGamepads& pads) {
- RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(pads);
+void FetchManifestDoneCallback(
+ scoped_ptr<ManifestFetcher> fetcher,
+ const FetchManifestCallback& callback,
+ const blink::WebURLResponse& response,
+ const std::string& data) {
+ // |fetcher| will be autodeleted here as it is going out of scope.
+ callback.Run(response, data);
+}
+
+void FetchManifest(blink::WebView* view, const GURL& url,
+ const FetchManifestCallback& callback) {
+ scoped_ptr<ManifestFetcher> fetcher(new ManifestFetcher(url));
+
+ fetcher->Start(view->mainFrame(),
+ base::Bind(&FetchManifestDoneCallback,
+ base::Passed(&fetcher),
+ callback));
+}
+
+void SetMockGamepadProvider(scoped_ptr<RendererGamepadProvider> provider) {
+ RenderThreadImpl::current()->webkit_platform_support()->
+ SetPlatformEventObserverForTesting(
+ blink::WebPlatformEventGamepad,
+ provider.PassAs<PlatformEventObserverBase>());
+}
+
+void SetMockDeviceLightData(const double data) {
+ RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting(data);
}
void SetMockDeviceMotionData(const WebDeviceMotionData& data) {
SetMockDeviceOrientationDataForTesting(data);
}
+void MockBatteryStatusChanged(const WebBatteryStatus& status) {
+ RenderThreadImpl::current()->webkit_platform_support()->
+ MockBatteryStatusChangedForTesting(status);
+}
+
void EnableRendererLayoutTestMode() {
RenderThreadImpl::current()->set_layout_test_mode(true);
}
#if defined(OS_MACOSX)
ImageTransportSurface::SetAllowOSMesaForTesting(true);
PopupMenuHelper::DontShowPopupMenuForTesting();
-#elif defined(OS_WIN) && !defined(USE_AURA)
- WebContentsDragWin::DisableDragDropForTesting();
#endif
RenderWidgetHostImpl::DisableResizeAckCheckForTesting();
}
const WebSize& new_size) {
RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
render_view_impl->ForceResizeForTesting(new_size);
- GetWebTestProxyBase(render_view_impl)->didForceResize();
}
void SetDeviceScaleFactor(RenderView* render_view, float factor) {
SetDeviceScaleFactorForTesting(factor);
}
+void SetDeviceColorProfile(RenderView* render_view, const std::string& name) {
+ if (name == "reset") {
+ static_cast<RenderViewImpl*>(render_view)->
+ ResetDeviceColorProfileForTesting();
+ return;
+ }
+
+ std::vector<char> color_profile;
+
+ struct TestColorProfile {
+ char* data() {
+ static unsigned char color_profile_data[] = {
+ 0x00,0x00,0x01,0xea,0x54,0x45,0x53,0x54,0x00,0x00,0x00,0x00,
+ 0x6d,0x6e,0x74,0x72,0x52,0x47,0x42,0x20,0x58,0x59,0x5a,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x61,0x63,0x73,0x70,0x74,0x65,0x73,0x74,0x00,0x00,0x00,0x00,
+ 0x74,0x65,0x73,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0xd6,
+ 0x00,0x01,0x00,0x00,0x00,0x00,0xd3,0x2d,0x74,0x65,0x73,0x74,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,
+ 0x63,0x70,0x72,0x74,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x0d,
+ 0x64,0x65,0x73,0x63,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x8c,
+ 0x77,0x74,0x70,0x74,0x00,0x00,0x01,0x8c,0x00,0x00,0x00,0x14,
+ 0x72,0x58,0x59,0x5a,0x00,0x00,0x01,0xa0,0x00,0x00,0x00,0x14,
+ 0x67,0x58,0x59,0x5a,0x00,0x00,0x01,0xb4,0x00,0x00,0x00,0x14,
+ 0x62,0x58,0x59,0x5a,0x00,0x00,0x01,0xc8,0x00,0x00,0x00,0x14,
+ 0x72,0x54,0x52,0x43,0x00,0x00,0x01,0xdc,0x00,0x00,0x00,0x0e,
+ 0x67,0x54,0x52,0x43,0x00,0x00,0x01,0xdc,0x00,0x00,0x00,0x0e,
+ 0x62,0x54,0x52,0x43,0x00,0x00,0x01,0xdc,0x00,0x00,0x00,0x0e,
+ 0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x64,0x65,0x73,0x63,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x10,0x77,0x68,0x61,0x63,0x6b,0x65,0x64,0x2e,
+ 0x69,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xf3,0x52,
+ 0x00,0x01,0x00,0x00,0x00,0x01,0x16,0xcc,0x58,0x59,0x5a,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x8d,0x00,0x00,0xa0,0x2c,
+ 0x00,0x00,0x0f,0x95,0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x26,0x31,0x00,0x00,0x10,0x2f,0x00,0x00,0xbe,0x9b,
+ 0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0x18,
+ 0x00,0x00,0x4f,0xa5,0x00,0x00,0x04,0xfc,0x63,0x75,0x72,0x76,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x33
+ };
+
+ return reinterpret_cast<char*>(color_profile_data);
+ }
+
+ size_t size() {
+ const size_t kTestColorProfileSizeInBytes = 490u;
+ return kTestColorProfileSizeInBytes;
+ }
+ };
+
+ struct AdobeRGBColorProfile {
+ char* data() {
+ static unsigned char color_profile_data[] = {
+ 0x00,0x00,0x02,0x30,0x41,0x44,0x42,0x45,0x02,0x10,0x00,0x00,
+ 0x6d,0x6e,0x74,0x72,0x52,0x47,0x42,0x20,0x58,0x59,0x5a,0x20,
+ 0x07,0xd0,0x00,0x08,0x00,0x0b,0x00,0x13,0x00,0x33,0x00,0x3b,
+ 0x61,0x63,0x73,0x70,0x41,0x50,0x50,0x4c,0x00,0x00,0x00,0x00,
+ 0x6e,0x6f,0x6e,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0xd6,
+ 0x00,0x01,0x00,0x00,0x00,0x00,0xd3,0x2d,0x41,0x44,0x42,0x45,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,
+ 0x63,0x70,0x72,0x74,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x32,
+ 0x64,0x65,0x73,0x63,0x00,0x00,0x01,0x30,0x00,0x00,0x00,0x6b,
+ 0x77,0x74,0x70,0x74,0x00,0x00,0x01,0x9c,0x00,0x00,0x00,0x14,
+ 0x62,0x6b,0x70,0x74,0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x14,
+ 0x72,0x54,0x52,0x43,0x00,0x00,0x01,0xc4,0x00,0x00,0x00,0x0e,
+ 0x67,0x54,0x52,0x43,0x00,0x00,0x01,0xd4,0x00,0x00,0x00,0x0e,
+ 0x62,0x54,0x52,0x43,0x00,0x00,0x01,0xe4,0x00,0x00,0x00,0x0e,
+ 0x72,0x58,0x59,0x5a,0x00,0x00,0x01,0xf4,0x00,0x00,0x00,0x14,
+ 0x67,0x58,0x59,0x5a,0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x14,
+ 0x62,0x58,0x59,0x5a,0x00,0x00,0x02,0x1c,0x00,0x00,0x00,0x14,
+ 0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x43,0x6f,0x70,0x79,
+ 0x72,0x69,0x67,0x68,0x74,0x20,0x32,0x30,0x30,0x30,0x20,0x41,
+ 0x64,0x6f,0x62,0x65,0x20,0x53,0x79,0x73,0x74,0x65,0x6d,0x73,
+ 0x20,0x49,0x6e,0x63,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x65,
+ 0x64,0x00,0x00,0x00,0x64,0x65,0x73,0x63,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x11,0x41,0x64,0x6f,0x62,0x65,0x20,0x52,0x47,
+ 0x42,0x20,0x28,0x31,0x39,0x39,0x38,0x29,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf3,0x51,0x00,0x01,0x00,0x00,0x00,0x01,0x16,0xcc,
+ 0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x75,0x72,0x76,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x33,0x00,0x00,
+ 0x63,0x75,0x72,0x76,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
+ 0x02,0x33,0x00,0x00,0x63,0x75,0x72,0x76,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x01,0x02,0x33,0x00,0x00,0x58,0x59,0x5a,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0x18,0x00,0x00,0x4f,0xa5,
+ 0x00,0x00,0x04,0xfc,0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x34,0x8d,0x00,0x00,0xa0,0x2c,0x00,0x00,0x0f,0x95,
+ 0x58,0x59,0x5a,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x31,
+ 0x00,0x00,0x10,0x2f,0x00,0x00,0xbe,0x9c
+ };
+
+ return reinterpret_cast<char*>(color_profile_data);
+ }
+
+ size_t size() {
+ const size_t kAdobeRGBColorProfileSizeInBytes = 560u;
+ return kAdobeRGBColorProfileSizeInBytes;
+ }
+ };
+
+ if (name == "sRGB") {
+ color_profile.assign(name.data(), name.data() + name.size());
+ } else if (name == "test") {
+ TestColorProfile test;
+ color_profile.assign(test.data(), test.data() + test.size());
+ } else if (name == "adobeRGB") {
+ AdobeRGBColorProfile test;
+ color_profile.assign(test.data(), test.data() + test.size());
+ }
+
+ static_cast<RenderViewImpl*>(render_view)->
+ SetDeviceColorProfileForTesting(color_profile);
+}
+
void UseSynchronousResizeMode(RenderView* render_view, bool enable) {
static_cast<RenderViewImpl*>(render_view)->
UseSynchronousResizeModeForTesting(enable);
DisableAutoResizeForTesting(new_size);
}
-void UseMockMediaStreams(RenderView* render_view) {
- RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
- render_view_impl->SetMediaStreamClientForTesting(
- new TestMediaStreamClient(render_view_impl));
+struct ToLower {
+ base::char16 operator()(base::char16 c) { return tolower(c); }
+};
+
+// Returns True if node1 < node2.
+bool HistoryEntryCompareLess(HistoryEntry::HistoryNode* node1,
+ HistoryEntry::HistoryNode* node2) {
+ base::string16 target1 = node1->item().target();
+ base::string16 target2 = node2->item().target();
+ std::transform(target1.begin(), target1.end(), target1.begin(), ToLower());
+ std::transform(target2.begin(), target2.end(), target2.begin(), ToLower());
+ return target1 < target2;
+}
+
+std::string DumpHistoryItem(HistoryEntry::HistoryNode* node,
+ int indent,
+ bool is_current_index) {
+ std::string result;
+
+ const blink::WebHistoryItem& item = node->item();
+ if (is_current_index) {
+ result.append("curr->");
+ result.append(indent - 6, ' '); // 6 == "curr->".length()
+ } else {
+ result.append(indent, ' ');
+ }
+
+ std::string url = NormalizeLayoutTestURL(item.urlString().utf8());
+ result.append(url);
+ if (!item.target().isEmpty()) {
+ result.append(" (in frame \"");
+ result.append(item.target().utf8());
+ result.append("\")");
+ }
+ result.append("\n");
+
+ std::vector<HistoryEntry::HistoryNode*> children = node->children();
+ if (!children.empty()) {
+ std::sort(children.begin(), children.end(), HistoryEntryCompareLess);
+ for (size_t i = 0; i < children.size(); ++i)
+ result += DumpHistoryItem(children[i], indent + 4, false);
+ }
+
+ return result;
+}
+
+std::string DumpBackForwardList(std::vector<PageState>& page_state,
+ size_t current_index) {
+ std::string result;
+ result.append("\n============== Back Forward List ==============\n");
+ for (size_t index = 0; index < page_state.size(); ++index) {
+ scoped_ptr<HistoryEntry> entry(
+ PageStateToHistoryEntry(page_state[index]));
+ result.append(
+ DumpHistoryItem(entry->root_history_node(),
+ 8,
+ index == current_index));
+ }
+ result.append("===============================================\n");
+ return result;
+}
+
+blink::WebLayer* InstantiateWebLayer(scoped_refptr<cc::TextureLayer> layer) {
+ return new cc_blink::WebLayerImpl(layer);
}
} // namespace content