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

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

Issue 2389493002: Revert of Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: Created 4 years, 2 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) 407 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame)
408 { 408 {
409 const WebColor kBlue = 0xFF0000FF; 409 const WebColor kBlue = 0xFF0000FF;
410 FrameTestHelpers::TestWebViewClient webViewClient; 410 FrameTestHelpers::TestWebViewClient webViewClient;
411 WebViewImpl* webView = WebViewImpl::create(&webViewClient, WebPageVisibility StateVisible); 411 WebViewImpl* webView = WebViewImpl::create(&webViewClient, WebPageVisibility StateVisible);
412 EXPECT_NE(kBlue, webView->backgroundColor()); 412 EXPECT_NE(kBlue, webView->backgroundColor());
413 // webView does not have a frame yet, but we should still be able to set the background color. 413 // webView does not have a frame yet, but we should still be able to set the background color.
414 webView->setBaseBackgroundColor(kBlue); 414 webView->setBaseBackgroundColor(kBlue);
415 EXPECT_EQ(kBlue, webView->backgroundColor()); 415 EXPECT_EQ(kBlue, webView->backgroundColor());
416 FrameTestHelpers::TestWebFrameClient webFrameClient; 416 WebLocalFrame* frame = WebLocalFrame::create(WebTreeScopeType::Document, nul lptr);
417 WebLocalFrame* frame = WebLocalFrame::create(WebTreeScopeType::Document, &we bFrameClient);
418 webView->setMainFrame(frame); 417 webView->setMainFrame(frame);
419 webView->close(); 418 webView->close();
419 frame->close();
420 } 420 }
421 421
422 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) 422 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent)
423 { 423 {
424 const WebColor kAlphaRed = 0x80FF0000; 424 const WebColor kAlphaRed = 0x80FF0000;
425 const WebColor kAlphaGreen = 0x8000FF00; 425 const WebColor kAlphaGreen = 0x8000FF00;
426 const int kWidth = 100; 426 const int kWidth = 100;
427 const int kHeight = 100; 427 const int kHeight = 100;
428 428
429 WebViewImpl* webView = m_webViewHelper.initialize(); 429 WebViewImpl* webView = m_webViewHelper.initialize();
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 runPendingTasks(); 1820 runPendingTasks();
1821 EXPECT_EQ(25, client.longpressX()); 1821 EXPECT_EQ(25, client.longpressX());
1822 EXPECT_EQ(7, client.longpressY()); 1822 EXPECT_EQ(7, client.longpressY());
1823 1823
1824 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 1824 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
1825 } 1825 }
1826 1826
1827 TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient) 1827 TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient)
1828 { 1828 {
1829 WebViewImpl* webView = WebViewImpl::create(nullptr, WebPageVisibilityStateVi sible); 1829 WebViewImpl* webView = WebViewImpl::create(nullptr, WebPageVisibilityStateVi sible);
1830 FrameTestHelpers::TestWebFrameClient webFrameClient; 1830 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , nullptr);
1831 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &webFrameClient);
1832 webView->setMainFrame(localFrame); 1831 webView->setMainFrame(localFrame);
1833 WebGestureEvent event; 1832 WebGestureEvent event;
1834 event.type = WebInputEvent::GestureTap; 1833 event.type = WebInputEvent::GestureTap;
1835 event.sourceDevice = WebGestureDeviceTouchscreen; 1834 event.sourceDevice = WebGestureDeviceTouchscreen;
1836 event.x = 3; 1835 event.x = 3;
1837 event.y = 8; 1836 event.y = 8;
1838 EXPECT_EQ(WebInputEventResult::NotHandled, webView->handleInputEvent(event)) ; 1837 EXPECT_EQ(WebInputEventResult::NotHandled, webView->handleInputEvent(event)) ;
1839 webView->close(); 1838 webView->close();
1839 // Explicitly close as the frame as no frame client to do so on frameDetache d().
1840 localFrame->close();
1840 } 1841 }
1841 1842
1842 TEST_F(WebViewTest, LongPressEmptyDiv) 1843 TEST_F(WebViewTest, LongPressEmptyDiv)
1843 { 1844 {
1844 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), 1845 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()),
1845 WebString::fromUTF8("long_press_empty_div.html")); 1846 WebString::fromUTF8("long_press_empty_div.html"));
1846 1847
1847 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "long_p ress_empty_div.html", true); 1848 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "long_p ress_empty_div.html", true);
1848 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 1849 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
1849 webView->resize(WebSize(500, 300)); 1850 webView->resize(WebSize(500, 300));
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 webView->updateAllLifecyclePhases(); 2715 webView->updateAllLifecyclePhases();
2715 // Left upper corner of the rect will be end position in the DOM hierarchy. 2716 // Left upper corner of the rect will be end position in the DOM hierarchy.
2716 WebRect cropRect(30, 110, 400, 250); 2717 WebRect cropRect(30, 110, 400, 250);
2717 // This should not still crash. See crbug.com/589082 for more details. 2718 // This should not still crash. See crbug.com/589082 for more details.
2718 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 2719 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
2719 } 2720 }
2720 2721
2721 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien t { 2722 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien t {
2722 public: 2723 public:
2723 CreateChildCounterFrameClient() : m_count(0) { } 2724 CreateChildCounterFrameClient() : m_count(0) { }
2724 WebLocalFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, con st WebString& name, const WebString& uniqueName, WebSandboxFlags, const WebFrame OwnerProperties&) override; 2725 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We bString& name, const WebString& uniqueName, WebSandboxFlags, const WebFrameOwner Properties&) override;
2725 2726
2726 int count() const { return m_count; } 2727 int count() const { return m_count; }
2727 2728
2728 private: 2729 private:
2729 int m_count; 2730 int m_count;
2730 }; 2731 };
2731 2732
2732 WebLocalFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* pa rent, WebTreeScopeType scope, const WebString& name, const WebString& uniqueName , WebSandboxFlags sandboxFlags, const WebFrameOwnerProperties& frameOwnerPropert ies) 2733 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, const WebString& name, const WebString& uniqueName, Web SandboxFlags sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties)
2733 { 2734 {
2734 ++m_count; 2735 ++m_count;
2735 return TestWebFrameClient::createChildFrame(parent, scope, name, uniqueName, sandboxFlags, frameOwnerProperties); 2736 return TestWebFrameClient::createChildFrame(parent, scope, name, uniqueName, sandboxFlags, frameOwnerProperties);
2736 } 2737 }
2737 2738
2738 TEST_F(WebViewTest, ChangeDisplayMode) 2739 TEST_F(WebViewTest, ChangeDisplayMode)
2739 { 2740 {
2740 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("display_mode.html")); 2741 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("display_mode.html"));
2741 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "display_mo de.html", true); 2742 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "display_mo de.html", true);
2742 2743
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 3716
3716 // Transform adapts to page scale changes. 3717 // Transform adapts to page scale changes.
3717 webViewImpl->setPageScaleFactor(2.f); 3718 webViewImpl->setPageScaleFactor(2.f);
3718 expectedMatrix.makeIdentity().scale(2.f).translate(-50, -55).translate(50, 5 5).scale(1. / 2.f); 3719 expectedMatrix.makeIdentity().scale(2.f).translate(-50, -55).translate(50, 5 5).scale(1. / 2.f);
3719 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting()); 3720 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting());
3720 // visibleContentRect doesn't change. 3721 // visibleContentRect doesn't change.
3721 EXPECT_EQ(IntRect(50, 55, 50, 75), *devToolsEmulator->visibleContentRectForP ainting()); 3722 EXPECT_EQ(IntRect(50, 55, 50, 75), *devToolsEmulator->visibleContentRectForP ainting());
3722 } 3723 }
3723 3724
3724 } // namespace blink 3725 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.cpp ('k') | third_party/WebKit/public/web/WebFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698