Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Rebasing... Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().height); 1334 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().height);
1335 1335
1336 // Set up a composition from existing text that needs to be committed. 1336 // Set up a composition from existing text that needs to be committed.
1337 Vector<CompositionUnderline> empty_underlines; 1337 Vector<CompositionUnderline> empty_underlines;
1338 WebLocalFrameBase* frame = web_view->MainFrameImpl(); 1338 WebLocalFrameBase* frame = web_view->MainFrameImpl();
1339 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( 1339 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText(
1340 empty_underlines, 0, 3); 1340 empty_underlines, 0, 3);
1341 1341
1342 // Scroll the input field out of the viewport. 1342 // Scroll the input field out of the viewport.
1343 Element* element = static_cast<Element*>( 1343 Element* element = static_cast<Element*>(
1344 web_view->MainFrame()->GetDocument().GetElementById("btn")); 1344 web_view->MainFrameImpl()->GetDocument().GetElementById("btn"));
1345 element->scrollIntoView(); 1345 element->scrollIntoView();
1346 float offset_height = web_view->MainFrame()->GetScrollOffset().height; 1346 float offset_height = web_view->MainFrame()->GetScrollOffset().height;
1347 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); 1347 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width);
1348 EXPECT_LT(0, offset_height); 1348 EXPECT_LT(0, offset_height);
1349 1349
1350 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); 1350 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo();
1351 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); 1351 EXPECT_EQ("hello", std::string(info.value.Utf8().data()));
1352 1352
1353 // Verify that the input field is not scrolled back into the viewport. 1353 // Verify that the input field is not scrolled back into the viewport.
1354 frame->FrameWidget() 1354 frame->FrameWidget()
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 1534
1535 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { 1535 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) {
1536 RegisterMockedHttpURLLoad("content_editable_rich_text.html"); 1536 RegisterMockedHttpURLLoad("content_editable_rich_text.html");
1537 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( 1537 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
1538 base_url_ + "content_editable_rich_text.html"); 1538 base_url_ + "content_editable_rich_text.html");
1539 web_view->SetInitialFocus(false); 1539 web_view->SetInitialFocus(false);
1540 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1540 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1541 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1541 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1542 WebLocalFrameBase* frame = web_view->MainFrameImpl(); 1542 WebLocalFrameBase* frame = web_view->MainFrameImpl();
1543 frame->SetEditableSelectionOffsets(1, 1); 1543 frame->SetEditableSelectionOffsets(1, 1);
1544 WebDocument document = web_view->MainFrame()->GetDocument(); 1544 WebDocument document = web_view->MainFrameImpl()->GetDocument();
1545 EXPECT_FALSE(document.GetElementById("bold").IsNull()); 1545 EXPECT_FALSE(document.GetElementById("bold").IsNull());
1546 frame->SetCompositionFromExistingText(0, 4, underlines); 1546 frame->SetCompositionFromExistingText(0, 4, underlines);
1547 EXPECT_FALSE(document.GetElementById("bold").IsNull()); 1547 EXPECT_FALSE(document.GetElementById("bold").IsNull());
1548 } 1548 }
1549 1549
1550 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { 1550 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) {
1551 RegisterMockedHttpURLLoad("input_field_populated.html"); 1551 RegisterMockedHttpURLLoad("input_field_populated.html");
1552 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( 1552 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
1553 base_url_ + "input_field_populated.html"); 1553 base_url_ + "input_field_populated.html");
1554 web_view->SetInitialFocus(false); 1554 web_view->SetInitialFocus(false);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 const std::string foo_url = base_url_ + "foo.html"; 1955 const std::string foo_url = base_url_ + "foo.html";
1956 const std::string bar_url = base_url_ + "bar.html"; 1956 const std::string bar_url = base_url_ + "bar.html";
1957 1957
1958 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(foo_url); 1958 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(foo_url);
1959 1959
1960 ASSERT_TRUE(web_view); 1960 ASSERT_TRUE(web_view);
1961 1961
1962 // Drag and drop barUrl and verify that we've navigated to it. 1962 // Drag and drop barUrl and verify that we've navigated to it.
1963 DragAndDropURL(web_view, bar_url); 1963 DragAndDropURL(web_view, bar_url);
1964 EXPECT_EQ(bar_url, 1964 EXPECT_EQ(bar_url,
1965 web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); 1965 web_view->MainFrameImpl()->GetDocument().Url().GetString().Utf8());
1966 1966
1967 // Drag and drop fooUrl and verify that we've navigated back to it. 1967 // Drag and drop fooUrl and verify that we've navigated back to it.
1968 DragAndDropURL(web_view, foo_url); 1968 DragAndDropURL(web_view, foo_url);
1969 EXPECT_EQ(foo_url, 1969 EXPECT_EQ(foo_url,
1970 web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); 1970 web_view->MainFrameImpl()->GetDocument().Url().GetString().Utf8());
1971 1971
1972 // Disable navigation on drag-and-drop. 1972 // Disable navigation on drag-and-drop.
1973 web_view->SettingsImpl()->SetNavigateOnDragDrop(false); 1973 web_view->SettingsImpl()->SetNavigateOnDragDrop(false);
1974 1974
1975 // Attempt to drag and drop to barUrl and verify that no navigation has 1975 // Attempt to drag and drop to barUrl and verify that no navigation has
1976 // occurred. 1976 // occurred.
1977 DragAndDropURL(web_view, bar_url); 1977 DragAndDropURL(web_view, bar_url);
1978 EXPECT_EQ(foo_url, 1978 EXPECT_EQ(foo_url,
1979 web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); 1979 web_view->MainFrameImpl()->GetDocument().Url().GetString().Utf8());
1980 } 1980 }
1981 1981
1982 bool WebViewTest::TapElement(WebInputEvent::Type type, Element* element) { 1982 bool WebViewTest::TapElement(WebInputEvent::Type type, Element* element) {
1983 if (!element || !element->GetLayoutObject()) 1983 if (!element || !element->GetLayoutObject())
1984 return false; 1984 return false;
1985 1985
1986 DCHECK(web_view_helper_.WebView()); 1986 DCHECK(web_view_helper_.WebView());
1987 element->scrollIntoViewIfNeeded(); 1987 element->scrollIntoViewIfNeeded();
1988 1988
1989 // TODO(bokan): Technically incorrect, event positions should be in viewport 1989 // TODO(bokan): Technically incorrect, event positions should be in viewport
(...skipping 15 matching lines...) Expand all
2005 2005
2006 web_view_helper_.WebView()->HandleInputEvent(WebCoalescedInputEvent(event)); 2006 web_view_helper_.WebView()->HandleInputEvent(WebCoalescedInputEvent(event));
2007 RunPendingTasks(); 2007 RunPendingTasks();
2008 return true; 2008 return true;
2009 } 2009 }
2010 2010
2011 bool WebViewTest::TapElementById(WebInputEvent::Type type, 2011 bool WebViewTest::TapElementById(WebInputEvent::Type type,
2012 const WebString& id) { 2012 const WebString& id) {
2013 DCHECK(web_view_helper_.WebView()); 2013 DCHECK(web_view_helper_.WebView());
2014 Element* element = static_cast<Element*>( 2014 Element* element = static_cast<Element*>(
2015 web_view_helper_.WebView()->MainFrame()->GetDocument().GetElementById( 2015 web_view_helper_.WebView()->MainFrameImpl()->GetDocument().GetElementById(
2016 id)); 2016 id));
2017 return TapElement(type, element); 2017 return TapElement(type, element);
2018 } 2018 }
2019 2019
2020 IntSize WebViewTest::PrintICBSizeFromPageSize(const FloatSize& page_size) { 2020 IntSize WebViewTest::PrintICBSizeFromPageSize(const FloatSize& page_size) {
2021 // The expected layout size comes from the calculation done in 2021 // The expected layout size comes from the calculation done in
2022 // ResizePageRectsKeepingRatio() which is used from PrintContext::begin() to 2022 // ResizePageRectsKeepingRatio() which is used from PrintContext::begin() to
2023 // scale the page size. 2023 // scale the page size.
2024 const float ratio = page_size.Height() / (float)page_size.Width(); 2024 const float ratio = page_size.Height() / (float)page_size.Width();
2025 const int icb_width = 2025 const int icb_width =
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 WebGestureEvent event(WebInputEvent::kGestureLongPress, 2136 WebGestureEvent event(WebInputEvent::kGestureLongPress,
2137 WebInputEvent::kNoModifiers, 2137 WebInputEvent::kNoModifiers,
2138 WebInputEvent::kTimeStampForTesting); 2138 WebInputEvent::kTimeStampForTesting);
2139 event.source_device = kWebGestureDeviceTouchscreen; 2139 event.source_device = kWebGestureDeviceTouchscreen;
2140 event.x = 10; 2140 event.x = 10;
2141 event.y = 10; 2141 event.y = 10;
2142 2142
2143 EXPECT_NE(WebInputEventResult::kHandledSystem, 2143 EXPECT_NE(WebInputEventResult::kHandledSystem,
2144 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); 2144 web_view->HandleInputEvent(WebCoalescedInputEvent(event)));
2145 2145
2146 HTMLElement* element = 2146 HTMLElement* element = ToHTMLElement(
2147 ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); 2147 web_view->MainFrameImpl()->GetDocument().GetElementById("obj"));
2148 EXPECT_FALSE(element->CanStartSelection()); 2148 EXPECT_FALSE(element->CanStartSelection());
2149 } 2149 }
2150 2150
2151 TEST_P(WebViewTest, LongPressObjectFallback) { 2151 TEST_P(WebViewTest, LongPressObjectFallback) {
2152 RegisterMockedHttpURLLoad("long_press_object_fallback.html"); 2152 RegisterMockedHttpURLLoad("long_press_object_fallback.html");
2153 2153
2154 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( 2154 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2155 base_url_ + "long_press_object_fallback.html", true); 2155 base_url_ + "long_press_object_fallback.html", true);
2156 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); 2156 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true);
2157 web_view->Resize(WebSize(500, 300)); 2157 web_view->Resize(WebSize(500, 300));
2158 web_view->UpdateAllLifecyclePhases(); 2158 web_view->UpdateAllLifecyclePhases();
2159 RunPendingTasks(); 2159 RunPendingTasks();
2160 2160
2161 WebGestureEvent event(WebInputEvent::kGestureLongPress, 2161 WebGestureEvent event(WebInputEvent::kGestureLongPress,
2162 WebInputEvent::kNoModifiers, 2162 WebInputEvent::kNoModifiers,
2163 WebInputEvent::kTimeStampForTesting); 2163 WebInputEvent::kTimeStampForTesting);
2164 event.source_device = kWebGestureDeviceTouchscreen; 2164 event.source_device = kWebGestureDeviceTouchscreen;
2165 event.x = 10; 2165 event.x = 10;
2166 event.y = 10; 2166 event.y = 10;
2167 2167
2168 EXPECT_EQ(WebInputEventResult::kHandledSystem, 2168 EXPECT_EQ(WebInputEventResult::kHandledSystem,
2169 web_view->HandleInputEvent(WebCoalescedInputEvent(event))); 2169 web_view->HandleInputEvent(WebCoalescedInputEvent(event)));
2170 2170
2171 HTMLElement* element = 2171 HTMLElement* element = ToHTMLElement(
2172 ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); 2172 web_view->MainFrameImpl()->GetDocument().GetElementById("obj"));
2173 EXPECT_TRUE(element->CanStartSelection()); 2173 EXPECT_TRUE(element->CanStartSelection());
2174 } 2174 }
2175 2175
2176 TEST_P(WebViewTest, LongPressImage) { 2176 TEST_P(WebViewTest, LongPressImage) {
2177 RegisterMockedHttpURLLoad("long_press_image.html"); 2177 RegisterMockedHttpURLLoad("long_press_image.html");
2178 2178
2179 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( 2179 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2180 base_url_ + "long_press_image.html", true); 2180 base_url_ + "long_press_image.html", true);
2181 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); 2181 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false);
2182 web_view->Resize(WebSize(500, 300)); 2182 web_view->Resize(WebSize(500, 300));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 web_view->SettingsImpl()->SetTouchDragDropEnabled(true); 2248 web_view->SettingsImpl()->SetTouchDragDropEnabled(true);
2249 web_view->Resize(WebSize(500, 300)); 2249 web_view->Resize(WebSize(500, 300));
2250 web_view->UpdateAllLifecyclePhases(); 2250 web_view->UpdateAllLifecyclePhases();
2251 RunPendingTasks(); 2251 RunPendingTasks();
2252 2252
2253 WebString anchor_tag_id = WebString::FromUTF8("anchorTag"); 2253 WebString anchor_tag_id = WebString::FromUTF8("anchorTag");
2254 WebString image_tag_id = WebString::FromUTF8("imageTag"); 2254 WebString image_tag_id = WebString::FromUTF8("imageTag");
2255 2255
2256 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, anchor_tag_id)); 2256 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, anchor_tag_id));
2257 EXPECT_STREQ("anchor contextmenu", 2257 EXPECT_STREQ("anchor contextmenu",
2258 web_view->MainFrame()->GetDocument().Title().Utf8().data()); 2258 web_view->MainFrameImpl()->GetDocument().Title().Utf8().data());
2259 2259
2260 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image_tag_id)); 2260 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image_tag_id));
2261 EXPECT_STREQ("image contextmenu", 2261 EXPECT_STREQ("image contextmenu",
2262 web_view->MainFrame()->GetDocument().Title().Utf8().data()); 2262 web_view->MainFrameImpl()->GetDocument().Title().Utf8().data());
2263 } 2263 }
2264 2264
2265 TEST_P(WebViewTest, LongPressEmptyEditableSelection) { 2265 TEST_P(WebViewTest, LongPressEmptyEditableSelection) {
2266 RegisterMockedHttpURLLoad("long_press_empty_editable_selection.html"); 2266 RegisterMockedHttpURLLoad("long_press_empty_editable_selection.html");
2267 2267
2268 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( 2268 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2269 base_url_ + "long_press_empty_editable_selection.html", true); 2269 base_url_ + "long_press_empty_editable_selection.html", true);
2270 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); 2270 web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false);
2271 web_view->Resize(WebSize(500, 300)); 2271 web_view->Resize(WebSize(500, 300));
2272 web_view->UpdateAllLifecyclePhases(); 2272 web_view->UpdateAllLifecyclePhases();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 WebInputEvent::kTimeStampForTesting); 2383 WebInputEvent::kTimeStampForTesting);
2384 event.source_device = kWebGestureDeviceTouchscreen; 2384 event.source_device = kWebGestureDeviceTouchscreen;
2385 event.x = 100; 2385 event.x = 100;
2386 event.y = 25; 2386 event.y = 25;
2387 event.data.tap.tap_count = 2; 2387 event.data.tap.tap_count = 2;
2388 2388
2389 web_view->HandleInputEvent(WebCoalescedInputEvent(event)); 2389 web_view->HandleInputEvent(WebCoalescedInputEvent(event));
2390 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); 2390 EXPECT_TRUE(frame->SelectionAsText().IsEmpty());
2391 2391
2392 HTMLTextAreaElement* text_area_element = toHTMLTextAreaElement( 2392 HTMLTextAreaElement* text_area_element = toHTMLTextAreaElement(
2393 web_view->MainFrame()->GetDocument().GetElementById(blanklinestextbox)); 2393 web_view->MainFrameImpl()->GetDocument().GetElementById(
2394 blanklinestextbox));
2394 text_area_element->setValue("hello"); 2395 text_area_element->setValue("hello");
2395 2396
2396 // Long-press past last word of textbox. 2397 // Long-press past last word of textbox.
2397 EXPECT_TRUE( 2398 EXPECT_TRUE(
2398 TapElementById(WebInputEvent::kGestureLongPress, blanklinestextbox)); 2399 TapElementById(WebInputEvent::kGestureLongPress, blanklinestextbox));
2399 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); 2400 EXPECT_TRUE(frame->SelectionAsText().IsEmpty());
2400 2401
2401 // Double-tap past last word of textbox. 2402 // Double-tap past last word of textbox.
2402 web_view->HandleInputEvent(WebCoalescedInputEvent(event)); 2403 web_view->HandleInputEvent(WebCoalescedInputEvent(event));
2403 EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); 2404 EXPECT_TRUE(frame->SelectionAsText().IsEmpty());
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 2743
2743 TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) { 2744 TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) {
2744 RegisterMockedHttpURLLoad("input_field_populated.html"); 2745 RegisterMockedHttpURLLoad("input_field_populated.html");
2745 MockAutofillClient client; 2746 MockAutofillClient client;
2746 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( 2747 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2747 base_url_ + "input_field_populated.html"); 2748 base_url_ + "input_field_populated.html");
2748 WebLocalFrameBase* frame = web_view->MainFrameImpl(); 2749 WebLocalFrameBase* frame = web_view->MainFrameImpl();
2749 frame->SetAutofillClient(&client); 2750 frame->SetAutofillClient(&client);
2750 web_view->SetInitialFocus(false); 2751 web_view->SetInitialFocus(false);
2751 2752
2752 WebDocument document = web_view->MainFrame()->GetDocument(); 2753 WebDocument document = web_view->MainFrameImpl()->GetDocument();
2753 HTMLFormControlElement* form = 2754 HTMLFormControlElement* form =
2754 ToHTMLFormControlElement(document.GetElementById("sample")); 2755 ToHTMLFormControlElement(document.GetElementById("sample"));
2755 2756
2756 WebInputMethodController* active_input_method_controller = 2757 WebInputMethodController* active_input_method_controller =
2757 frame->FrameWidget()->GetActiveWebInputMethodController(); 2758 frame->FrameWidget()->GetActiveWebInputMethodController();
2758 // Set up a composition that needs to be committed. 2759 // Set up a composition that needs to be committed.
2759 std::string composition_text("testingtext"); 2760 std::string composition_text("testingtext");
2760 2761
2761 WebVector<WebCompositionUnderline> empty_underlines; 2762 WebVector<WebCompositionUnderline> empty_underlines;
2762 active_input_method_controller->SetComposition( 2763 active_input_method_controller->SetComposition(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 frame->SetCompositionFromExistingText(8, 12, empty_underlines); 2798 frame->SetCompositionFromExistingText(8, 12, empty_underlines);
2798 2799
2799 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); 2800 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo();
2800 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", 2801 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz",
2801 std::string(info.value.Utf8().data())); 2802 std::string(info.value.Utf8().data()));
2802 EXPECT_EQ(8, info.composition_start); 2803 EXPECT_EQ(8, info.composition_start);
2803 EXPECT_EQ(12, info.composition_end); 2804 EXPECT_EQ(12, info.composition_end);
2804 2805
2805 EXPECT_EQ(0, client.TextChanges()); 2806 EXPECT_EQ(0, client.TextChanges());
2806 2807
2807 WebDocument document = web_view->MainFrame()->GetDocument(); 2808 WebDocument document = web_view->MainFrameImpl()->GetDocument();
2808 EXPECT_EQ(WebString::FromUTF8("none"), 2809 EXPECT_EQ(WebString::FromUTF8("none"),
2809 document.GetElementById("inputEvent").FirstChild().NodeValue()); 2810 document.GetElementById("inputEvent").FirstChild().NodeValue());
2810 2811
2811 frame->SetAutofillClient(0); 2812 frame->SetAutofillClient(0);
2812 } 2813 }
2813 2814
2814 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { 2815 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient {
2815 public: 2816 public:
2816 ViewCreatingWebViewClient() : did_focus_called_(false) {} 2817 ViewCreatingWebViewClient() : did_focus_called_(false) {}
2817 2818
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 ->MainFrame()) 2885 ->MainFrame())
2885 ->Loader() 2886 ->Loader()
2886 .Load(request_with_target_start); 2887 .Load(request_with_target_start);
2887 EXPECT_TRUE(client.DidFocusCalled()); 2888 EXPECT_TRUE(client.DidFocusCalled());
2888 2889
2889 web_view_helper.Reset(); // Remove dependency on locally scoped client. 2890 web_view_helper.Reset(); // Remove dependency on locally scoped client.
2890 } 2891 }
2891 2892
2892 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) { 2893 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) {
2893 RegisterMockedHttpURLLoad("focusout_focusin_events.html"); 2894 RegisterMockedHttpURLLoad("focusout_focusin_events.html");
2894 WebView* web_view = web_view_helper_.InitializeAndLoad( 2895 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2895 base_url_ + "focusout_focusin_events.html", true, 0); 2896 base_url_ + "focusout_focusin_events.html", true, 0);
2896 2897
2897 web_view->SetFocus(true); 2898 web_view->SetFocus(true);
2898 web_view->SetFocus(false); 2899 web_view->SetFocus(false);
2899 web_view->SetFocus(true); 2900 web_view->SetFocus(true);
2900 2901
2901 WebElement element = 2902 WebElement element =
2902 web_view->MainFrame()->GetDocument().GetElementById("message"); 2903 web_view->MainFrameImpl()->GetDocument().GetElementById("message");
2903 EXPECT_STREQ("focusoutfocusin", element.TextContent().Utf8().data()); 2904 EXPECT_STREQ("focusoutfocusin", element.TextContent().Utf8().data());
2904 } 2905 }
2905 2906
2906 TEST_P(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) { 2907 TEST_P(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) {
2907 RegisterMockedHttpURLLoad("domfocusout_domfocusin_events.html"); 2908 RegisterMockedHttpURLLoad("domfocusout_domfocusin_events.html");
2908 WebView* web_view = web_view_helper_.InitializeAndLoad( 2909 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2909 base_url_ + "domfocusout_domfocusin_events.html", true, 0); 2910 base_url_ + "domfocusout_domfocusin_events.html", true, 0);
2910 2911
2911 web_view->SetFocus(true); 2912 web_view->SetFocus(true);
2912 web_view->SetFocus(false); 2913 web_view->SetFocus(false);
2913 web_view->SetFocus(true); 2914 web_view->SetFocus(true);
2914 2915
2915 WebElement element = 2916 WebElement element =
2916 web_view->MainFrame()->GetDocument().GetElementById("message"); 2917 web_view->MainFrameImpl()->GetDocument().GetElementById("message");
2917 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.TextContent().Utf8().data()); 2918 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.TextContent().Utf8().data());
2918 } 2919 }
2919 2920
2920 static void OpenDateTimeChooser(WebView* web_view, 2921 static void OpenDateTimeChooser(WebView* web_view,
2921 HTMLInputElement* input_element) { 2922 HTMLInputElement* input_element) {
2922 input_element->focus(); 2923 input_element->focus();
2923 2924
2924 WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, 2925 WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown,
2925 WebInputEvent::kNoModifiers, 2926 WebInputEvent::kNoModifiers,
2926 WebInputEvent::kTimeStampForTesting); 2927 WebInputEvent::kTimeStampForTesting);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 3014
3014 // Clear the WebViewClient from the webViewHelper to avoid use-after-free in 3015 // Clear the WebViewClient from the webViewHelper to avoid use-after-free in
3015 // the WebViewHelper destructor. 3016 // the WebViewHelper destructor.
3016 web_view_helper_.Reset(); 3017 web_view_helper_.Reset();
3017 RuntimeEnabledFeatures::SetInputMultipleFieldsUIEnabled( 3018 RuntimeEnabledFeatures::SetInputMultipleFieldsUIEnabled(
3018 original_multiple_fields_flag); 3019 original_multiple_fields_flag);
3019 } 3020 }
3020 3021
3021 TEST_P(WebViewTest, DispatchesFocusBlurOnViewToggle) { 3022 TEST_P(WebViewTest, DispatchesFocusBlurOnViewToggle) {
3022 RegisterMockedHttpURLLoad("focus_blur_events.html"); 3023 RegisterMockedHttpURLLoad("focus_blur_events.html");
3023 WebView* web_view = web_view_helper_.InitializeAndLoad( 3024 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
3024 base_url_ + "focus_blur_events.html", true, 0); 3025 base_url_ + "focus_blur_events.html", true, 0);
3025 3026
3026 web_view->SetFocus(true); 3027 web_view->SetFocus(true);
3027 web_view->SetFocus(false); 3028 web_view->SetFocus(false);
3028 web_view->SetFocus(true); 3029 web_view->SetFocus(true);
3029 3030
3030 WebElement element = 3031 WebElement element =
3031 web_view->MainFrame()->GetDocument().GetElementById("message"); 3032 web_view->MainFrameImpl()->GetDocument().GetElementById("message");
3032 // Expect not to see duplication of events. 3033 // Expect not to see duplication of events.
3033 EXPECT_STREQ("blurfocus", element.TextContent().Utf8().data()); 3034 EXPECT_STREQ("blurfocus", element.TextContent().Utf8().data());
3034 } 3035 }
3035 3036
3036 TEST_P(WebViewTest, SmartClipData) { 3037 TEST_P(WebViewTest, SmartClipData) {
3037 static const char kExpectedClipText[] = "\nPrice 10,000,000won"; 3038 static const char kExpectedClipText[] = "\nPrice 10,000,000won";
3038 static const char kExpectedClipHtml[] = 3039 static const char kExpectedClipHtml[] =
3039 "<div id=\"div4\" style=\"padding: 10px; margin: 10px; border: 2px " 3040 "<div id=\"div4\" style=\"padding: 10px; margin: 10px; border: 2px "
3040 "solid skyblue; float: left; width: 190px; height: 30px; " 3041 "solid skyblue; float: left; width: 190px; height: 30px; "
3041 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " 3042 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: "
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3607 web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(1)); 3608 web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(1));
3608 size = web_view->ContentsPreferredMinimumSize(); 3609 size = web_view->ContentsPreferredMinimumSize();
3609 EXPECT_EQ(2, size.width); 3610 EXPECT_EQ(2, size.width);
3610 EXPECT_EQ(2, size.height); 3611 EXPECT_EQ(2, size.height);
3611 } 3612 }
3612 3613
3613 TEST_P(WebViewTest, PreferredSizeDirtyLayout) { 3614 TEST_P(WebViewTest, PreferredSizeDirtyLayout) {
3614 std::string url = base_url_ + "specify_size.html?100px:100px"; 3615 std::string url = base_url_ + "specify_size.html?100px:100px";
3615 URLTestHelpers::RegisterMockedURLLoad( 3616 URLTestHelpers::RegisterMockedURLLoad(
3616 ToKURL(url), testing::WebTestDataPath("specify_size.html")); 3617 ToKURL(url), testing::WebTestDataPath("specify_size.html"));
3617 WebView* web_view = web_view_helper_.InitializeAndLoad(url, true); 3618 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(url, true);
3618 WebElement document_element = 3619 WebElement document_element =
3619 web_view->MainFrame()->GetDocument().DocumentElement(); 3620 web_view->MainFrameImpl()->GetDocument().DocumentElement();
3620 3621
3621 WebSize size = web_view->ContentsPreferredMinimumSize(); 3622 WebSize size = web_view->ContentsPreferredMinimumSize();
3622 EXPECT_EQ(100, size.width); 3623 EXPECT_EQ(100, size.width);
3623 EXPECT_EQ(100, size.height); 3624 EXPECT_EQ(100, size.height);
3624 3625
3625 document_element.SetAttribute("style", "display: none"); 3626 document_element.SetAttribute("style", "display: none");
3626 3627
3627 size = web_view->ContentsPreferredMinimumSize(); 3628 size = web_view->ContentsPreferredMinimumSize();
3628 EXPECT_EQ(0, size.width); 3629 EXPECT_EQ(0, size.width);
3629 EXPECT_EQ(0, size.height); 3630 EXPECT_EQ(0, size.height);
(...skipping 27 matching lines...) Expand all
3657 IntPoint tapped_position_; 3658 IntPoint tapped_position_;
3658 WebNode tapped_node_; 3659 WebNode tapped_node_;
3659 bool page_changed_ = false; 3660 bool page_changed_ = false;
3660 }; 3661 };
3661 3662
3662 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeeded) { 3663 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeeded) {
3663 std::string test_file = "show_unhandled_tap.html"; 3664 std::string test_file = "show_unhandled_tap.html";
3664 RegisterMockedHttpURLLoad("Ahem.ttf"); 3665 RegisterMockedHttpURLLoad("Ahem.ttf");
3665 RegisterMockedHttpURLLoad(test_file); 3666 RegisterMockedHttpURLLoad(test_file);
3666 UnhandledTapWebViewClient client; 3667 UnhandledTapWebViewClient client;
3667 WebView* web_view = web_view_helper_.InitializeAndLoad(base_url_ + test_file, 3668 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
3668 true, 0, &client); 3669 base_url_ + test_file, true, 0, &client);
3669 web_view->Resize(WebSize(500, 300)); 3670 web_view->Resize(WebSize(500, 300));
3670 web_view->UpdateAllLifecyclePhases(); 3671 web_view->UpdateAllLifecyclePhases();
3671 RunPendingTasks(); 3672 RunPendingTasks();
3672 3673
3673 // Scroll the bottom into view so we can distinguish window coordinates from 3674 // Scroll the bottom into view so we can distinguish window coordinates from
3674 // document coordinates. 3675 // document coordinates.
3675 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, 3676 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap,
3676 WebString::FromUTF8("bottom"))); 3677 WebString::FromUTF8("bottom")));
3677 EXPECT_TRUE(client.GetWasCalled()); 3678 EXPECT_TRUE(client.GetWasCalled());
3678 EXPECT_EQ(64, client.GetTappedXPos()); 3679 EXPECT_EQ(64, client.GetTappedXPos());
3679 EXPECT_EQ(278, client.GetTappedYPos()); 3680 EXPECT_EQ(278, client.GetTappedYPos());
3680 EXPECT_FALSE(client.IsTappedNodeNull()); 3681 EXPECT_FALSE(client.IsTappedNodeNull());
3681 EXPECT_TRUE(client.GetWebNode().IsTextNode()); 3682 EXPECT_TRUE(client.GetWebNode().IsTextNode());
3682 3683
3683 // Test basic tap handling and notification. 3684 // Test basic tap handling and notification.
3684 client.Reset(); 3685 client.Reset();
3685 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, 3686 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap,
3686 WebString::FromUTF8("target"))); 3687 WebString::FromUTF8("target")));
3687 EXPECT_TRUE(client.GetWasCalled()); 3688 EXPECT_TRUE(client.GetWasCalled());
3688 EXPECT_EQ(144, client.GetTappedXPos()); 3689 EXPECT_EQ(144, client.GetTappedXPos());
3689 EXPECT_EQ(82, client.GetTappedYPos()); 3690 EXPECT_EQ(82, client.GetTappedYPos());
3690 EXPECT_FALSE(client.IsTappedNodeNull()); 3691 EXPECT_FALSE(client.IsTappedNodeNull());
3691 EXPECT_TRUE(client.GetWebNode().IsTextNode()); 3692 EXPECT_TRUE(client.GetWebNode().IsTextNode());
3692 // Make sure the returned text node has the parent element that was our 3693 // Make sure the returned text node has the parent element that was our
3693 // target. 3694 // target.
3694 EXPECT_EQ(web_view->MainFrame()->GetDocument().GetElementById("target"), 3695 EXPECT_EQ(web_view->MainFrameImpl()->GetDocument().GetElementById("target"),
3695 client.GetWebNode().ParentNode()); 3696 client.GetWebNode().ParentNode());
3696 3697
3697 // Test correct conversion of coordinates to viewport space under pinch-zoom. 3698 // Test correct conversion of coordinates to viewport space under pinch-zoom.
3698 web_view->SetPageScaleFactor(2); 3699 web_view->SetPageScaleFactor(2);
3699 web_view->SetVisualViewportOffset(WebFloatPoint(50, 20)); 3700 web_view->SetVisualViewportOffset(WebFloatPoint(50, 20));
3700 client.Reset(); 3701 client.Reset();
3701 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, 3702 EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap,
3702 WebString::FromUTF8("target"))); 3703 WebString::FromUTF8("target")));
3703 EXPECT_TRUE(client.GetWasCalled()); 3704 EXPECT_TRUE(client.GetWasCalled());
3704 EXPECT_EQ(188, client.GetTappedXPos()); 3705 EXPECT_EQ(188, client.GetTappedXPos());
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
4346 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); 4347 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars());
4347 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { 4348 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) {
4348 EXPECT_NE(nullptr, 4349 EXPECT_NE(nullptr,
4349 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); 4350 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar());
4350 } else { 4351 } else {
4351 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); 4352 EXPECT_NE(nullptr, frame_view->VerticalScrollbar());
4352 } 4353 }
4353 } 4354 }
4354 4355
4355 } // namespace blink 4356 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698