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

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

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops 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 WebLocalFrame* frame = WebLocalFrame::create(WebTreeScopeType::Document, nul lptr); 416 FrameTestHelpers::TestWebFrameClient webFrameClient;
417 WebLocalFrame* frame = WebLocalFrame::create(WebTreeScopeType::Document, &we bFrameClient);
417 webView->setMainFrame(frame); 418 webView->setMainFrame(frame);
418 webView->close(); 419 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 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , nullptr); 1830 FrameTestHelpers::TestWebFrameClient webFrameClient;
1831 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &webFrameClient);
1831 webView->setMainFrame(localFrame); 1832 webView->setMainFrame(localFrame);
1832 WebGestureEvent event; 1833 WebGestureEvent event;
1833 event.type = WebInputEvent::GestureTap; 1834 event.type = WebInputEvent::GestureTap;
1834 event.sourceDevice = WebGestureDeviceTouchscreen; 1835 event.sourceDevice = WebGestureDeviceTouchscreen;
1835 event.x = 3; 1836 event.x = 3;
1836 event.y = 8; 1837 event.y = 8;
1837 EXPECT_EQ(WebInputEventResult::NotHandled, webView->handleInputEvent(event)) ; 1838 EXPECT_EQ(WebInputEventResult::NotHandled, webView->handleInputEvent(event)) ;
1838 webView->close(); 1839 webView->close();
1839 // Explicitly close as the frame as no frame client to do so on frameDetache d().
1840 localFrame->close();
1841 } 1840 }
1842 1841
1843 TEST_F(WebViewTest, LongPressEmptyDiv) 1842 TEST_F(WebViewTest, LongPressEmptyDiv)
1844 { 1843 {
1845 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), 1844 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()),
1846 WebString::fromUTF8("long_press_empty_div.html")); 1845 WebString::fromUTF8("long_press_empty_div.html"));
1847 1846
1848 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "long_p ress_empty_div.html", true); 1847 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "long_p ress_empty_div.html", true);
1849 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false); 1848 webView->settingsImpl()->setAlwaysShowContextMenuOnTouch(false);
1850 webView->resize(WebSize(500, 300)); 1849 webView->resize(WebSize(500, 300));
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 webView->updateAllLifecyclePhases(); 2714 webView->updateAllLifecyclePhases();
2716 // Left upper corner of the rect will be end position in the DOM hierarchy. 2715 // Left upper corner of the rect will be end position in the DOM hierarchy.
2717 WebRect cropRect(30, 110, 400, 250); 2716 WebRect cropRect(30, 110, 400, 250);
2718 // This should not still crash. See crbug.com/589082 for more details. 2717 // This should not still crash. See crbug.com/589082 for more details.
2719 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 2718 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
2720 } 2719 }
2721 2720
2722 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien t { 2721 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien t {
2723 public: 2722 public:
2724 CreateChildCounterFrameClient() : m_count(0) { } 2723 CreateChildCounterFrameClient() : m_count(0) { }
2725 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We bString& name, const WebString& uniqueName, WebSandboxFlags, const WebFrameOwner Properties&) override; 2724 WebLocalFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, con st WebString& name, const WebString& uniqueName, WebSandboxFlags, const WebFrame OwnerProperties&) override;
2726 2725
2727 int count() const { return m_count; } 2726 int count() const { return m_count; }
2728 2727
2729 private: 2728 private:
2730 int m_count; 2729 int m_count;
2731 }; 2730 };
2732 2731
2733 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, const WebString& name, const WebString& uniqueName, Web SandboxFlags sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties) 2732 WebLocalFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* pa rent, WebTreeScopeType scope, const WebString& name, const WebString& uniqueName , WebSandboxFlags sandboxFlags, const WebFrameOwnerProperties& frameOwnerPropert ies)
2734 { 2733 {
2735 ++m_count; 2734 ++m_count;
2736 return TestWebFrameClient::createChildFrame(parent, scope, name, uniqueName, sandboxFlags, frameOwnerProperties); 2735 return TestWebFrameClient::createChildFrame(parent, scope, name, uniqueName, sandboxFlags, frameOwnerProperties);
2737 } 2736 }
2738 2737
2739 TEST_F(WebViewTest, ChangeDisplayMode) 2738 TEST_F(WebViewTest, ChangeDisplayMode)
2740 { 2739 {
2741 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("display_mode.html")); 2740 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("display_mode.html"));
2742 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "display_mo de.html", true); 2741 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "display_mo de.html", true);
2743 2742
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
3716 3715
3717 // Transform adapts to page scale changes. 3716 // Transform adapts to page scale changes.
3718 webViewImpl->setPageScaleFactor(2.f); 3717 webViewImpl->setPageScaleFactor(2.f);
3719 expectedMatrix.makeIdentity().scale(2.f).translate(-50, -55).translate(50, 5 5).scale(1. / 2.f); 3718 expectedMatrix.makeIdentity().scale(2.f).translate(-50, -55).translate(50, 5 5).scale(1. / 2.f);
3720 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting()); 3719 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting());
3721 // visibleContentRect doesn't change. 3720 // visibleContentRect doesn't change.
3722 EXPECT_EQ(IntRect(50, 55, 50, 75), *devToolsEmulator->visibleContentRectForP ainting()); 3721 EXPECT_EQ(IntRect(50, 55, 50, 75), *devToolsEmulator->visibleContentRectForP ainting());
3723 } 3722 }
3724 3723
3725 } // namespace blink 3724 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698