| Index: Source/core/input/EventHandlerTest.cpp
|
| diff --git a/Source/core/layout/LayoutThemeTest.cpp b/Source/core/input/EventHandlerTest.cpp
|
| similarity index 19%
|
| copy from Source/core/layout/LayoutThemeTest.cpp
|
| copy to Source/core/input/EventHandlerTest.cpp
|
| index 8ca5c0c44fc2cf78a40465cd8a0a50baee57274b..a3511adc26e30e245d2199a39e6b227ab20a293d 100644
|
| --- a/Source/core/layout/LayoutThemeTest.cpp
|
| +++ b/Source/core/input/EventHandlerTest.cpp
|
| @@ -1,89 +1,100 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| #include "config.h"
|
| -#include "core/layout/LayoutTheme.h"
|
| +#include "core/input/EventHandler.h"
|
|
|
| -#include "core/dom/NodeComputedStyle.h"
|
| +#include "core/dom/Document.h"
|
| +#include "core/dom/Range.h"
|
| +#include "core/editing/FrameSelection.h"
|
| #include "core/frame/FrameView.h"
|
| +#include "core/frame/LocalFrame.h"
|
| #include "core/html/HTMLDocument.h"
|
| -#include "core/html/HTMLElement.h"
|
| -#include "core/page/FocusController.h"
|
| +#include "core/page/AutoscrollController.h"
|
| #include "core/page/Page.h"
|
| -#include "core/style/ComputedStyle.h"
|
| +#include "core/testing/CoreTestHelpers.h"
|
| #include "core/testing/DummyPageHolder.h"
|
| -#include "platform/graphics/Color.h"
|
| +#include "platform/PlatformMouseEvent.h"
|
| #include <gtest/gtest.h>
|
|
|
| namespace blink {
|
|
|
| -class LayoutThemeTest : public ::testing::Test {
|
| +class EventHandlerTest : public ::testing::Test {
|
| protected:
|
| void SetUp() override;
|
| - HTMLDocument& document() const { return *m_document; }
|
| +
|
| + Page& page() const { return m_dummyPageHolder->page(); }
|
| + Document& document() const { return m_dummyPageHolder->document(); }
|
| +
|
| void setHtmlInnerHTML(const char* htmlContent);
|
|
|
| private:
|
| OwnPtr<DummyPageHolder> m_dummyPageHolder;
|
| - HTMLDocument* m_document;
|
| };
|
|
|
| -void LayoutThemeTest::SetUp()
|
| +void EventHandlerTest::SetUp()
|
| {
|
| - m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
|
| - m_document = toHTMLDocument(&m_dummyPageHolder->document());
|
| - ASSERT(m_document);
|
| + m_dummyPageHolder = DummyPageHolder::create(IntSize(300, 400));
|
| }
|
|
|
| -void LayoutThemeTest::setHtmlInnerHTML(const char* htmlContent)
|
| +void EventHandlerTest::setHtmlInnerHTML(const char* htmlContent)
|
| {
|
| document().documentElement()->setInnerHTML(String::fromUTF8(htmlContent), ASSERT_NO_EXCEPTION);
|
| document().view()->updateLayoutAndStyleForPainting();
|
| }
|
|
|
| -inline Color outlineColor(Element* element)
|
| -{
|
| - return element->computedStyle()->visitedDependentColor(CSSPropertyOutlineColor);
|
| -}
|
| -
|
| -inline EBorderStyle outlineStyle(Element* element)
|
| +TEST_F(EventHandlerTest, dragSelectionAfterScroll)
|
| {
|
| - return element->computedStyle()->outlineStyle();
|
| -}
|
| -
|
| -TEST_F(LayoutThemeTest, ChangeFocusRingColor)
|
| -{
|
| - setHtmlInnerHTML("<span id=span tabIndex=0>Span</span>");
|
| -
|
| - Element* span = document().getElementById(AtomicString("span"));
|
| - EXPECT_NE(nullptr, span);
|
| - EXPECT_NE(nullptr, span->layoutObject());
|
| -
|
| - Color customColor = makeRGB(123, 145, 167);
|
| -
|
| - // Checking unfocused style.
|
| - EXPECT_EQ(BNONE, outlineStyle(span));
|
| - EXPECT_NE(customColor, outlineColor(span));
|
| -
|
| - // Do focus.
|
| - document().page()->focusController().setActive(true);
|
| - document().page()->focusController().setFocused(true);
|
| - span->focus();
|
| - document().view()->updateLayoutAndStyleForPainting();
|
| -
|
| - // Checking focused style.
|
| - EXPECT_NE(BNONE, outlineStyle(span));
|
| - EXPECT_NE(customColor, outlineColor(span));
|
| -
|
| - // Change focus ring color.
|
| - LayoutTheme::theme().setCustomFocusRingColor(customColor);
|
| - Page::platformColorsChanged();
|
| - document().view()->updateLayoutAndStyleForPainting();
|
| -
|
| - // Check that the focus ring color is updated.
|
| - EXPECT_NE(BNONE, outlineStyle(span));
|
| - EXPECT_EQ(customColor, outlineColor(span));
|
| + 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 = selection.toNormalizedRange();
|
| + ASSERT_TRUE(range.get());
|
| + EXPECT_EQ("Line 1\nLine 2", range->text());
|
| }
|
|
|
| } // namespace blink
|
|
|