コード例 #1
0
TEST_F(EventHandlerTest, draggedSVGImagePositionTest)
{
    setHtmlInnerHTML(
        "<style>"
        "body { margin: 0px; }"
        "[draggable] {"
        "-webkit-user-select: none; user-select: none; -webkit-user-drag: element; }"
        "</style>"
        "<div style='width: 300px; height: 100px;'>"
        "<svg width='500' height='500'>"
        "<rect x='100' y='100' width='100px' height='100px' fill='blue' draggable='true'/>"
        "</svg>"
        "</div>");
    PlatformMouseEvent mouseDownEvent(
        IntPoint(145, 144),
        IntPoint(212, 282),
        LeftButton,
        PlatformEvent::MousePressed,
        1,
        PlatformEvent::Modifiers::LeftButtonDown,
        WTF::monotonicallyIncreasingTime());
    document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent);

    PlatformMouseEvent mouseMoveEvent(
        IntPoint(618, 298),
        IntPoint(685, 436),
        LeftButton,
        PlatformEvent::MouseMoved,
        1,
        PlatformEvent::Modifiers::LeftButtonDown,
        WTF::monotonicallyIncreasingTime());
    document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);

    EXPECT_EQ(IntPoint(45, 44), document().frame()->eventHandler().dragDataTransferLocationForTesting());
}
コード例 #2
0
TEST_F(EventHandlerTest, draggedInlinePositionTest)
{
    setHtmlInnerHTML(
        "<style>"
        "body { margin: 0px; }"
        ".line { font-family: sans-serif; background: blue; width: 300px; height: 30px; font-size: 40px; margin-left: 250px; }"
        "</style>"
        "<div style='width: 300px; height: 100px;'>"
        "<span class='line' draggable='true'>abcd</span>"
        "</div>");
    PlatformMouseEvent mouseDownEvent(
        IntPoint(262, 29),
        IntPoint(329, 67),
        LeftButton,
        PlatformEvent::MousePressed,
        1,
        PlatformEvent::Modifiers::LeftButtonDown,
        WTF::monotonicallyIncreasingTime());
    document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent);

    PlatformMouseEvent mouseMoveEvent(
        IntPoint(618, 298),
        IntPoint(685, 436),
        LeftButton,
        PlatformEvent::MouseMoved,
        1,
        PlatformEvent::Modifiers::LeftButtonDown,
        WTF::monotonicallyIncreasingTime());
    document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);

    EXPECT_EQ(IntPoint(12, 29), document().frame()->eventHandler().dragDataTransferLocationForTesting());
}
コード例 #3
0
// Helpers
void Ut_MStatusBarView::mouseDownWorker(QPointF downAt)
{
    mouseDownPos = downAt;
    mouseEvent = MouseEvent::MouseDown;
    QGraphicsSceneMouseEvent mouseDownEvent(QEvent::GraphicsSceneMousePress);
    m_subject->mousePressEvent(&mouseDownEvent);
}
コード例 #4
0
TEST_F(EventHandlerTest, dragSelectionAfterScroll)
{
    setHtmlInnerHTML("<style> body { margin: 0px; } .upper { width: 300px; height: 400px; }"
        ".lower { margin: 0px; width: 300px; height: 400px; } .line { display: block; width: 300px; height: 30px; } </style>"
        "<div class='upper'></div>"
        "<div class='lower'>"
        "<span class='line'>Line 1</span><span class='line'>Line 2</span><span class='line'>Line 3</span><span class='line'>Line 4</span><span class='line'>Line 5</span>"
        "<span class='line'>Line 6</span><span class='line'>Line 7</span><span class='line'>Line 8</span><span class='line'>Line 9</span><span class='line'>Line 10</span>"
        "</div>");

    FrameView* frameView = document().view();
    frameView->scrollTo(DoublePoint(0, 400));

    PlatformMouseEvent mouseDownEvent(
        IntPoint(0, 0),
        IntPoint(100, 200),
        LeftButton,
        PlatformEvent::MousePressed,
        1,
        static_cast<PlatformEvent::Modifiers>(0),
        WTF::currentTime());
    document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent);

    PlatformMouseEvent mouseMoveEvent(
        IntPoint(100, 50),
        IntPoint(200, 250),
        LeftButton,
        PlatformEvent::MouseMoved,
        1,
        static_cast<PlatformEvent::Modifiers>(0),
        WTF::currentTime());
    document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);

    page().autoscrollController().animate(WTF::currentTime());
    page().animator().serviceScriptedAnimations(WTF::currentTime());

    PlatformMouseEvent mouseUpEvent(
        IntPoint(100, 50),
        IntPoint(200, 250),
        LeftButton,
        PlatformEvent::MouseReleased,
        1,
        static_cast<PlatformEvent::Modifiers>(0),
        WTF::currentTime());
    document().frame()->eventHandler().handleMouseReleaseEvent(mouseUpEvent);

    FrameSelection& selection = document().frame()->selection();
    ASSERT_TRUE(selection.isRange());
    RefPtrWillBeRawPtr<Range> range = createRange(selection.selection().toNormalizedEphemeralRange());
    ASSERT_TRUE(range.get());
    EXPECT_EQ("Line 1\nLine 2", range->text());
}
コード例 #5
0
TEST_F(EventHandlerTest, dragSelectionAfterScroll) {
  setHtmlInnerHTML(
      "<style> body { margin: 0px; } .upper { width: 300px; height: 400px; }"
      ".lower { margin: 0px; width: 300px; height: 400px; } .line { display: "
      "block; width: 300px; height: 30px; } </style>"
      "<div class='upper'></div>"
      "<div class='lower'>"
      "<span class='line'>Line 1</span><span class='line'>Line 2</span><span "
      "class='line'>Line 3</span><span class='line'>Line 4</span><span "
      "class='line'>Line 5</span>"
      "<span class='line'>Line 6</span><span class='line'>Line 7</span><span "
      "class='line'>Line 8</span><span class='line'>Line 9</span><span "
      "class='line'>Line 10</span>"
      "</div>");

  FrameView* frameView = document().view();
  frameView->layoutViewportScrollableArea()->setScrollOffset(
      ScrollOffset(0, 400), ProgrammaticScroll);

  PlatformMouseEvent mouseDownEvent(
      IntPoint(0, 0), IntPoint(100, 200), WebPointerProperties::Button::Left,
      PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::LeftButtonDown,
      WTF::monotonicallyIncreasingTime());
  document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent);

  PlatformMouseEvent mouseMoveEvent(
      IntPoint(100, 50), IntPoint(200, 250), WebPointerProperties::Button::Left,
      PlatformEvent::MouseMoved, 1, PlatformEvent::Modifiers::LeftButtonDown,
      WTF::monotonicallyIncreasingTime());
  document().frame()->eventHandler().handleMouseMoveEvent(
      mouseMoveEvent, Vector<PlatformMouseEvent>());

  page().autoscrollController().animate(WTF::monotonicallyIncreasingTime());
  page().animator().serviceScriptedAnimations(
      WTF::monotonicallyIncreasingTime());

  PlatformMouseEvent mouseUpEvent(
      IntPoint(100, 50), IntPoint(200, 250), WebPointerProperties::Button::Left,
      PlatformEvent::MouseReleased, 1, static_cast<PlatformEvent::Modifiers>(0),
      WTF::monotonicallyIncreasingTime());
  document().frame()->eventHandler().handleMouseReleaseEvent(mouseUpEvent);

  FrameSelection& selection = document().frame()->selection();
  ASSERT_TRUE(selection.isRange());
  Range* range =
      createRange(selection.selection().toNormalizedEphemeralRange());
  ASSERT_TRUE(range);
  EXPECT_EQ("Line 1\nLine 2", range->text());
}
コード例 #6
0
// Regression test for http://crbug.com/641403 to verify we use up-to-date
// layout tree for dispatching "contextmenu" event.
TEST_F(EventHandlerTest, sendContextMenuEventWithHover) {
  setHtmlInnerHTML(
      "<style>*:hover { color: red; }</style>"
      "<div>foo</div>");
  document().settings()->setScriptEnabled(true);
  Element* script = document().createElement("script");
  script->setInnerHTML(
      "document.addEventListener('contextmenu', event => "
      "event.preventDefault());");
  document().body()->appendChild(script);
  document().updateStyleAndLayout();
  document().frame()->selection().setSelection(
      SelectionInDOMTree::Builder()
          .collapse(Position(document().body(), 0))
          .build());
  PlatformMouseEvent mouseDownEvent(
      IntPoint(0, 0), IntPoint(100, 200), WebPointerProperties::Button::Right,
      PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::RightButtonDown,
      WTF::monotonicallyIncreasingTime());
  EXPECT_EQ(
      WebInputEventResult::HandledApplication,
      document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent));
}