Commit 1968073e authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Make RenderViewTest not be dependent on RenderWidget.

The WebFrameWidget can be retrieved via the WebView. Move
one test that was accessing the LayerTreeHost to blink.

BUG=1097816

Change-Id: I373d6ed7ff97a3669a7d303b86944c001f5e9eac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464027
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816753}
parent 47c81eeb
......@@ -10,11 +10,11 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_input_element.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/public/web/web_widget.h"
#include "ui/events/keycodes/keyboard_codes.h"
namespace autofill {
......@@ -35,8 +35,8 @@ class FormControlClickDetectionTest : public ChromeRenderViewTest {
" <input type='button' id='button'></input><br>"
" <input type='button' id='button_2' disabled></input><br>"
"</form>");
GetWebWidget()->Resize(blink::WebSize(500, 500));
GetWebWidget()->SetFocus(true);
GetWebFrameWidget()->Resize(blink::WebSize(500, 500));
GetWebFrameWidget()->SetFocus(true);
blink::WebDocument document = GetMainFrame()->GetDocument();
text_ = document.GetElementById("text_1");
textarea_ = document.GetElementById("textarea_1");
......
......@@ -45,7 +45,7 @@
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_form_element.h"
#include "third_party/blink/public/web/web_widget.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "ui/events/keycodes/keyboard_codes.h"
#if defined(OS_ANDROID)
......@@ -388,8 +388,8 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
LoadHTML(kFormHTML);
// Necessary for SimulateElementClick() to work correctly.
GetWebWidget()->Resize(blink::WebSize(500, 500));
GetWebWidget()->SetFocus(true);
GetWebFrameWidget()->Resize(blink::WebSize(500, 500));
GetWebFrameWidget()->SetFocus(true);
// Now retrieve the input elements so the test can access them.
UpdateUsernameAndPasswordElements();
......
......@@ -33,8 +33,8 @@
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_widget.h"
#include "ui/events/keycodes/keyboard_codes.h"
using autofill::mojom::FocusedFieldType;
......@@ -225,7 +225,7 @@ void PasswordGenerationAgentTest::SetUp() {
// Necessary for focus changes to work correctly and dispatch blur events
// when a field was previously focused.
GetWebWidget()->SetFocus(true);
GetWebFrameWidget()->SetFocus(true);
}
void PasswordGenerationAgentTest::TearDown() {
......
......@@ -605,9 +605,7 @@ void RenderViewTest::SendNativeKeyEvent(
}
void RenderViewTest::SendInputEvent(const blink::WebInputEvent& input_event) {
RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
RenderWidget* widget = view->GetMainRenderFrame()->GetLocalRootRenderWidget();
widget->GetWebWidget()->ProcessInputEventSynchronouslyForTesting(
GetWebFrameWidget()->ProcessInputEventSynchronouslyForTesting(
blink::WebCoalescedInputEvent(input_event, ui::LatencyInfo()),
base::DoNothing());
}
......@@ -690,13 +688,11 @@ void RenderViewTest::SimulatePointClick(const gfx::Point& point) {
mouse_event.button = WebMouseEvent::Button::kLeft;
mouse_event.SetPositionInWidget(point.x(), point.y());
mouse_event.click_count = 1;
RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
RenderWidget* widget = view->GetMainRenderFrame()->GetLocalRootRenderWidget();
widget->GetWebWidget()->ProcessInputEventSynchronouslyForTesting(
GetWebFrameWidget()->ProcessInputEventSynchronouslyForTesting(
blink::WebCoalescedInputEvent(mouse_event, ui::LatencyInfo()),
base::DoNothing());
mouse_event.SetType(WebInputEvent::Type::kMouseUp);
widget->GetWebWidget()->ProcessInputEventSynchronouslyForTesting(
GetWebFrameWidget()->ProcessInputEventSynchronouslyForTesting(
blink::WebCoalescedInputEvent(mouse_event, ui::LatencyInfo()),
base::DoNothing());
}
......@@ -716,13 +712,11 @@ void RenderViewTest::SimulatePointRightClick(const gfx::Point& point) {
mouse_event.button = WebMouseEvent::Button::kRight;
mouse_event.SetPositionInWidget(point.x(), point.y());
mouse_event.click_count = 1;
RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
RenderWidget* widget = view->GetMainRenderFrame()->GetLocalRootRenderWidget();
widget->GetWebWidget()->ProcessInputEventSynchronouslyForTesting(
GetWebFrameWidget()->ProcessInputEventSynchronouslyForTesting(
blink::WebCoalescedInputEvent(mouse_event, ui::LatencyInfo()),
base::DoNothing());
mouse_event.SetType(WebInputEvent::Type::kMouseUp);
widget->GetWebWidget()->ProcessInputEventSynchronouslyForTesting(
GetWebFrameWidget()->ProcessInputEventSynchronouslyForTesting(
blink::WebCoalescedInputEvent(mouse_event, ui::LatencyInfo()),
base::DoNothing());
}
......@@ -735,9 +729,7 @@ void RenderViewTest::SimulateRectTap(const gfx::Rect& rect) {
gesture_event.data.tap.tap_count = 1;
gesture_event.data.tap.width = rect.width();
gesture_event.data.tap.height = rect.height();
RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
RenderWidget* widget = view->GetMainRenderFrame()->GetLocalRootRenderWidget();
widget->GetWebWidget()->ProcessInputEventSynchronouslyForTesting(
GetWebFrameWidget()->ProcessInputEventSynchronouslyForTesting(
blink::WebCoalescedInputEvent(gesture_event, ui::LatencyInfo()),
base::DoNothing());
}
......@@ -772,10 +764,6 @@ void RenderViewTest::Reload(const GURL& url) {
void RenderViewTest::Resize(gfx::Size new_size,
bool is_fullscreen_granted) {
RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
RenderWidget* render_widget =
view->GetMainRenderFrame()->GetLocalRootRenderWidget();
blink::VisualProperties visual_properties;
visual_properties.screen_info = blink::ScreenInfo();
visual_properties.new_size = new_size;
......@@ -783,7 +771,7 @@ void RenderViewTest::Resize(gfx::Size new_size,
visual_properties.is_fullscreen_granted = is_fullscreen_granted;
visual_properties.display_mode = blink::mojom::DisplayMode::kBrowser;
render_widget->GetWebWidget()->ApplyVisualProperties(visual_properties);
GetWebFrameWidget()->ApplyVisualProperties(visual_properties);
}
void RenderViewTest::SimulateUserTypingASCIICharacter(char ascii_character,
......@@ -859,9 +847,8 @@ void RenderViewTest::SetUseZoomForDSFEnabled(bool enabled) {
render_thread_->SetUseZoomForDSFEnabled(enabled);
}
blink::WebWidget* RenderViewTest::GetWebWidget() {
RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
return view->GetMainRenderFrame()->GetLocalRootRenderWidget()->GetWebWidget();
blink::WebFrameWidget* RenderViewTest::GetWebFrameWidget() {
return view_->GetWebView()->MainFrameWidget();
}
ContentClient* RenderViewTest::CreateContentClient() {
......
......@@ -31,10 +31,10 @@ namespace scheduler {
class WebThreadScheduler;
}
struct VisualProperties;
class WebFrameWidget;
class WebGestureEvent;
class WebInputElement;
class WebMouseEvent;
class WebWidget;
}
namespace gfx {
......@@ -187,7 +187,7 @@ class RenderViewTest : public testing::Test {
// Enables to use zoom for device scale.
void SetUseZoomForDSFEnabled(bool zoom_for_dsf);
blink::WebWidget* GetWebWidget();
blink::WebFrameWidget* GetWebFrameWidget();
// Allows a subclass to override the various content client implementations.
virtual ContentClient* CreateContentClient();
......
......@@ -717,14 +717,6 @@ void RenderWidget::DidNavigate(ukm::SourceId source_id, const GURL& url) {
}
}
blink::WebInputMethodController* RenderWidget::GetInputMethodController()
const {
if (auto* frame_widget = GetFrameWidget())
return frame_widget->GetActiveWebInputMethodController();
return nullptr;
}
#if BUILDFLAG(ENABLE_PLUGINS)
PepperPluginInstanceImpl* RenderWidget::GetFocusedPepperPluginInsideWidget() {
blink::WebFrameWidget* frame_widget = GetFrameWidget();
......
......@@ -64,7 +64,6 @@
namespace blink {
class WebFrameWidget;
class WebInputMethodController;
class WebLocalFrame;
class WebMouseEvent;
class WebPagePopup;
......@@ -187,11 +186,6 @@ class CONTENT_EXPORT RenderWidget
// is true, the widget returned is a blink::WebFrameWidget.
blink::WebWidget* GetWebWidget() const { return webwidget_; }
// Returns the current instance of WebInputMethodController which is to be
// used for IME related tasks. This instance corresponds to the one from
// focused frame and can be nullptr.
blink::WebInputMethodController* GetInputMethodController() const;
// A main frame RenderWidget is destroyed and recreated using the same routing
// id. So messages en route to a destroyed RenderWidget may end up being
// received by a provisional RenderWidget, even though we don't normally
......
......@@ -12,7 +12,6 @@
#include "content/renderer/render_frame_proxy.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
#include "content/renderer/render_widget.h"
#include "third_party/blink/public/common/widget/visual_properties.h"
#include "third_party/blink/public/platform/web_runtime_features.h"
#include "third_party/blink/public/web/web_frame_widget.h"
......@@ -26,11 +25,6 @@ namespace content {
class RenderWidgetTest : public RenderViewTest {
protected:
RenderWidget* widget() {
auto* view_impl = static_cast<RenderViewImpl*>(view_);
return view_impl->GetMainRenderFrame()->GetLocalRootRenderWidget();
}
gfx::Range LastCompositionRange() {
render_widget_host_->GetWidgetInputHandler()->RequestCompositionUpdates(
true, false);
......@@ -39,7 +33,7 @@ class RenderWidgetTest : public RenderViewTest {
}
blink::WebInputMethodController* GetInputMethodController() {
return widget()->GetInputMethodController();
return GetWebFrameWidget()->GetActiveWebInputMethodController();
}
void CommitText(std::string text) {
......@@ -49,7 +43,7 @@ class RenderWidgetTest : public RenderViewTest {
base::RunLoop().RunUntilIdle();
}
void SetFocus(bool focused) { GetWebWidget()->SetFocus(focused); }
void SetFocus(bool focused) { GetWebFrameWidget()->SetFocus(focused); }
gfx::PointF GetCenterPointOfElement(const blink::WebString& id) {
auto rect =
......@@ -123,43 +117,37 @@ TEST_F(RenderWidgetTest, CompositorIdHitTestAPI) {
// Hit the root
EXPECT_EQ(GetCompositorElementId(),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(gfx::PointF(10, 10))
.GetScrollableContainerId());
// Hit non-scrollable div
EXPECT_EQ(GetCompositorElementId(),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(GetCenterPointOfElement("green"))
.GetScrollableContainerId());
// Hit scrollable div
EXPECT_EQ(GetCompositorElementId("red"),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(GetCenterPointOfElement("red"))
.GetScrollableContainerId());
// Hit overflow:hidden div
EXPECT_EQ(GetCompositorElementId(),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(GetCenterPointOfElement("blue"))
.GetScrollableContainerId());
// Hit position fixed div
EXPECT_EQ(GetCompositorElementId(),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(GetCenterPointOfElement("yellow"))
.GetScrollableContainerId());
// Hit inner scroller inside another scroller
EXPECT_EQ(GetCompositorElementId("cyan"),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(GetCenterPointOfElement("cyan-parent"))
.GetScrollableContainerId());
}
......@@ -194,8 +182,7 @@ TEST_F(RenderWidgetTest, CompositorIdHitTestAPIWithImplicitRootScroller) {
EXPECT_EQ(GetMainFrame()
->GetDocument()
.GetVisualViewportScrollingElementIdForTesting(),
widget()
->GetWebWidget()
GetWebFrameWidget()
->HitTestResultAt(GetCenterPointOfElement("white"))
.GetScrollableContainerId());
}
......@@ -207,9 +194,9 @@ TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) {
gfx::Range range = LastCompositionRange();
EXPECT_FALSE(range.IsValid());
blink::WebVector<ui::ImeTextSpan> empty_ime_text_spans;
DCHECK(widget()->GetInputMethodController());
widget()->GetInputMethodController()->SetComposition(
"hello", empty_ime_text_spans, blink::WebRange(), 3, 3);
DCHECK(GetInputMethodController());
GetInputMethodController()->SetComposition("hello", empty_ime_text_spans,
blink::WebRange(), 3, 3);
range = LastCompositionRange();
EXPECT_TRUE(range.IsValid());
EXPECT_EQ(0U, range.start());
......@@ -283,23 +270,4 @@ TEST_F(RenderWidgetTest, PageFocusIme) {
GetInputMethodController()->TextInputInfo().value.Utf8());
}
// Tests that the value of VisualProperties::is_pinch_gesture_active is
// not propagated to the LayerTreeHost when properties are synced for main
// frame.
TEST_F(RenderWidgetTest, ActivePinchGestureUpdatesLayerTreeHost) {
auto* layer_tree_host = widget()->layer_tree_host();
EXPECT_FALSE(layer_tree_host->is_external_pinch_gesture_active_for_testing());
blink::VisualProperties visual_properties;
// Sync visual properties on a mainframe RenderWidget.
visual_properties.is_pinch_gesture_active = true;
widget()->GetWebWidget()->ApplyVisualProperties(visual_properties);
// We do not expect the |is_pinch_gesture_active| value to propagate to the
// LayerTreeHost for the main-frame. Since GesturePinch events are handled
// directly by the layer tree for the main frame, it already knows whether or
// not a pinch gesture is active, and so we shouldn't propagate this
// information to the layer tree for a main-frame's widget.
EXPECT_FALSE(layer_tree_host->is_external_pinch_gesture_active_for_testing());
}
} // namespace content
......@@ -502,4 +502,23 @@ TEST_F(NotifySwapTimesWebFrameWidgetTest,
testing::IsEmpty());
}
// Tests that the value of VisualProperties::is_pinch_gesture_active is
// not propagated to the LayerTreeHost when properties are synced for main
// frame.
TEST_F(WebFrameWidgetSimTest, ActivePinchGestureUpdatesLayerTreeHost) {
auto* layer_tree_host = WebView().MainFrameViewWidget()->LayerTreeHost();
EXPECT_FALSE(layer_tree_host->is_external_pinch_gesture_active_for_testing());
blink::VisualProperties visual_properties;
// Sync visual properties on a mainframe RenderWidget.
visual_properties.is_pinch_gesture_active = true;
WebView().MainFrameViewWidget()->ApplyVisualProperties(visual_properties);
// We do not expect the |is_pinch_gesture_active| value to propagate to the
// LayerTreeHost for the main-frame. Since GesturePinch events are handled
// directly by the layer tree for the main frame, it already knows whether or
// not a pinch gesture is active, and so we shouldn't propagate this
// information to the layer tree for a main-frame's widget.
EXPECT_FALSE(layer_tree_host->is_external_pinch_gesture_active_for_testing());
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment