本文整理汇总了C++中frametesthelpers::WebViewHelper类的典型用法代码示例。如果您正苦于以下问题:C++ WebViewHelper类的具体用法?C++ WebViewHelper怎么用?C++ WebViewHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebViewHelper类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: platformKeyboardEventC
// Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
// the clipboard.
TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
{
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("plugin_container.html"));
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
ASSERT(webView);
webView->settings()->setPluginsEnabled(true);
webView->resize(WebSize(300, 300));
webView->updateAllLifecyclePhases();
runPendingTasks();
WebElement pluginContainerOneElement = webView->mainFrame()->document().getElementById(WebString::fromUTF8("translated-plugin"));
PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft);
#if OS(MACOSX)
modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft);
#endif
PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", "", "", 67, 0, false, modifierKey, 0.0);
RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0);
toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventC.get());
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
// Clearing |Clipboard::Buffer()|.
Platform::current()->clipboard()->writePlainText(WebString(""));
EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", "", "", 45, 0, false, modifierKey, 0.0);
RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboardEventInsert, 0);
toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventInsert.get());
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
}
示例2: registerMockedHttpURLLoad
TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale)
{
registerMockedHttpURLLoad("long_scroll.html");
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, 0);
webView->resize(WebSize(1000, 1000));
webView->updateAllLifecyclePhases();
WebViewImpl* webViewImpl = toWebViewImpl(webView);
FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader();
loader.setLoadType(FrameLoadTypeBackForward);
webViewImpl->setPageScaleFactor(3.0f);
webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500));
loader.documentLoader()->initialScrollState().wasScrolledByUser = false;
loader.currentItem()->setPageScaleFactor(2);
loader.currentItem()->setScrollPoint(WebPoint(0, 200));
// Flip back the wasScrolledByUser flag which was set to true by setPageScaleFactor
// because otherwise FrameLoader::restoreScrollPositionAndViewState does nothing.
loader.documentLoader()->initialScrollState().wasScrolledByUser = false;
loader.restoreScrollPositionAndViewState();
// Expect that both scroll and scale were restored.
EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height);
}
示例3: ASSERT
TEST_F(WebPluginContainerTest, LocalToWindowPointTest)
{
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
ASSERT(webView);
webView->settings()->setPluginsEnabled(true);
webView->resize(WebSize(300, 300));
webView->updateAllLifecyclePhases();
runPendingTasks();
WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebString::fromUTF8("translated-plugin"));
ASSERT(pluginContainerOne);
WebPoint point1 = pluginContainerOne->localToRootFramePoint(WebPoint(0, 0));
ASSERT_EQ(10, point1.x);
ASSERT_EQ(10, point1.y);
WebPoint point2 = pluginContainerOne->localToRootFramePoint(WebPoint(90, 90));
ASSERT_EQ(100, point2.x);
ASSERT_EQ(100, point2.y);
WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebString::fromUTF8("rotated-plugin"));
ASSERT(pluginContainerTwo);
WebPoint point3 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 0));
ASSERT_EQ(0, point3.x);
ASSERT_EQ(10, point3.y);
WebPoint point4 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 10));
ASSERT_EQ(-10, point4.x);
ASSERT_EQ(10, point4.y);
}
示例4: topmostRect
TEST_F(WebPluginContainerTest, TopmostAfterDetachTest)
{
static WebRect topmostRect(10, 10, 40, 40);
// Plugin that checks isRectTopmost in destroy().
class TopmostPlugin : public FakeWebPlugin {
public:
TopmostPlugin(WebFrame* frame, const WebPluginParams& params)
: FakeWebPlugin(frame, params) {}
bool isRectTopmost()
{
return container()->isRectTopmost(topmostRect);
}
void destroy() override
{
// In destroy, isRectTopmost is no longer valid.
EXPECT_FALSE(container()->isRectTopmost(topmostRect));
FakeWebPlugin::destroy();
}
};
class TopmostPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& params) override
{
return new TopmostPlugin(frame, params);
}
};
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
TopmostPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
ASSERT(webView);
webView->settings()->setPluginsEnabled(true);
webView->resize(WebSize(300, 300));
webView->updateAllLifecyclePhases();
runPendingTasks();
RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl =
toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromUTF8("translated-plugin")));
pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));
EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect));
TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl->plugin());
EXPECT_TRUE(testPlugin->isRectTopmost());
// Cause the plugin's frame to be detached.
webViewHelper.reset();
EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect));
}
示例5: baseURL
TEST(LinkHighlightImplTest, verifyWebViewImplIntegration)
{
FrameTestHelpers::UseMockScrollbarSettings mockScrollbarSettings;
const std::string baseURL("http://www.test.com/");
const std::string fileName("test_touch_link_highlight.html");
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("test_touch_link_highlight.html"));
FrameTestHelpers::WebViewHelper webViewHelper;
WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true);
int pageWidth = 640;
int pageHeight = 480;
webViewImpl->resize(WebSize(pageWidth, pageHeight));
webViewImpl->updateAllLifecyclePhases();
WebGestureEvent touchEvent;
touchEvent.type = WebInputEvent::GestureShowPress;
touchEvent.sourceDevice = WebGestureDeviceTouchscreen;
// The coordinates below are linked to absolute positions in the referenced .html file.
touchEvent.x = 20;
touchEvent.y = 20;
ASSERT_TRUE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));
touchEvent.y = 40;
EXPECT_FALSE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));
touchEvent.y = 20;
// Shouldn't crash.
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
EXPECT_TRUE(webViewImpl->linkHighlight(0));
EXPECT_TRUE(webViewImpl->linkHighlight(0)->contentLayer());
EXPECT_TRUE(webViewImpl->linkHighlight(0)->clipLayer());
// Find a target inside a scrollable div
touchEvent.y = 100;
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
ASSERT_TRUE(webViewImpl->linkHighlight(0));
// Don't highlight if no "hand cursor"
touchEvent.y = 220; // An A-link with cross-hair cursor.
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
touchEvent.y = 260; // A text input box.
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
}
示例6: runImeOnFocusTest
void ImeOnFocusTest::runImeOnFocusTest(std::string fileName, int expectedImeRequestCount, IntPoint tapPoint, const AtomicString& focusElement, std::string frame)
{
ImeRequestTrackingWebViewClient client;
registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(fileName));
WebViewImpl* webView = m_webViewHelper.initialize(true, 0, &client);
webView->resize(WebSize(800, 1200));
loadFrame(webView->mainFrame(), m_baseURL + fileName);
m_document = m_webViewHelper.webViewImpl()->mainFrameImpl()->document().unwrap<Document>();
if (!focusElement.isNull())
focus(focusElement);
EXPECT_EQ(0, client.imeRequestCount());
if (tapPoint.x() >= 0 && tapPoint.y() >= 0)
sendGestureTap(webView, tapPoint);
if (!frame.empty()) {
registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(frame));
WebFrame* childFrame = webView->mainFrame()->firstChild();
loadFrame(childFrame, m_baseURL + frame);
}
if (!focusElement.isNull())
focus(focusElement);
EXPECT_EQ(expectedImeRequestCount, client.imeRequestCount());
m_webViewHelper.reset();
}
示例7: runShadowDOMTest
void TouchActionTest::runShadowDOMTest(std::string file) {
TouchActionTrackingWebViewClient client;
WebView* webView = setupTest(file, client);
TrackExceptionState es;
// Oilpan: see runTouchActionTest() comment why these are persistent
// references.
Persistent<Document> document =
static_cast<Document*>(webView->mainFrame()->document());
Persistent<StaticElementList> hostNodes =
document->querySelectorAll("[shadow-host]", es);
ASSERT_FALSE(es.hadException());
ASSERT_GE(hostNodes->length(), 1u);
for (unsigned index = 0; index < hostNodes->length(); index++) {
ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot();
runTestOnTree(shadowRoot, webView, client);
}
// Projections show up in the main document.
runTestOnTree(document.get(), webView, client);
// Explicitly reset to break dependency on locally scoped client.
m_webViewHelper.reset();
}
示例8: runIFrameTest
void TouchActionTest::runIFrameTest(std::string file) {
TouchActionTrackingWebViewClient client;
WebView* webView = setupTest(file, client);
WebFrame* curFrame = webView->mainFrame()->firstChild();
ASSERT_TRUE(curFrame);
for (; curFrame; curFrame = curFrame->nextSibling()) {
// Oilpan: see runTouchActionTest() comment why these are persistent
// references.
Persistent<Document> contentDoc =
static_cast<Document*>(curFrame->document());
runTestOnTree(contentDoc.get(), webView, client);
}
// Explicitly reset to break dependency on locally scoped client.
m_webViewHelper.reset();
}
示例9: setupTest
WebView* TouchActionTest::setupTest(std::string file,
TouchActionTrackingWebViewClient& client) {
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file));
// Note that JavaScript must be enabled for shadow DOM tests.
WebView* webView =
m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client);
// Set size to enable hit testing, and avoid line wrapping for consistency
// with browser.
webView->resize(WebSize(800, 1200));
// Scroll to verify the code properly transforms windows to client co-ords.
const int kScrollOffset = 100;
Document* document = static_cast<Document*>(webView->mainFrame()->document());
document->frame()->view()->layoutViewportScrollableArea()->setScrollOffset(
ScrollOffset(0, kScrollOffset), ProgrammaticScroll);
return webView;
}
示例10: runTouchActionTest
void TouchActionTest::runTouchActionTest(std::string file) {
TouchActionTrackingWebViewClient client;
// runTouchActionTest() loads a document in a frame, setting up a
// nested message loop. Should any Oilpan GC happen while it is in
// effect, the implicit assumption that we're outside any event
// loop (=> there being no pointers on the stack needing scanning)
// when that GC strikes will no longer hold.
//
// To ensure that the references on the stack are also traced, we
// turn them into persistent, stack allocated references. This
// workaround is sufficient to handle this artificial test
// scenario.
WebView* webView = setupTest(file, client);
Persistent<Document> document =
static_cast<Document*>(webView->mainFrame()->document());
runTestOnTree(document.get(), webView, client);
// Explicitly reset to break dependency on locally scoped client.
m_webViewHelper.reset();
}