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

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

Issue 1291343008: Fix crash in WebViewImpl::contentsPreferredMinimumSize (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 url = m_baseURL + "specify_size.html?1.5px:1.5px"; 2615 url = m_baseURL + "specify_size.html?1.5px:1.5px";
2616 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 2616 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html");
2617 webView = m_webViewHelper.initializeAndLoad(url, true); 2617 webView = m_webViewHelper.initializeAndLoad(url, true);
2618 2618
2619 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1)); 2619 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1));
2620 size = webView->contentsPreferredMinimumSize(); 2620 size = webView->contentsPreferredMinimumSize();
2621 EXPECT_EQ(2, size.width); 2621 EXPECT_EQ(2, size.width);
2622 EXPECT_EQ(2, size.height); 2622 EXPECT_EQ(2, size.height);
2623 } 2623 }
2624 2624
2625 TEST_F(WebViewTest, PreferredSizeDirtyLayout)
2626 {
2627 std::string url = m_baseURL + "specify_size.html?100px:100px";
2628 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html");
2629 WebView* webView = m_webViewHelper.initializeAndLoad(url, true);
2630 WebElement documentElement = webView->mainFrame()->document().documentElemen t();
2631
2632 WebSize size = webView->contentsPreferredMinimumSize();
2633 EXPECT_EQ(100, size.width);
2634 EXPECT_EQ(100, size.height);
2635
2636 bool setStyle = documentElement.setAttribute("style", "display: none");
2637 EXPECT_TRUE(setStyle);
2638
2639 size = webView->contentsPreferredMinimumSize();
2640 EXPECT_EQ(0, size.width);
2641 EXPECT_EQ(0, size.height);
2642 }
2643
2625 class UnhandledTapWebViewClient : public FrameTestHelpers::TestWebViewClient { 2644 class UnhandledTapWebViewClient : public FrameTestHelpers::TestWebViewClient {
2626 public: 2645 public:
2627 void showUnhandledTapUIIfNeeded(const WebPoint& tappedPosition, const WebNod e& tappedNode, bool pageChanged) override 2646 void showUnhandledTapUIIfNeeded(const WebPoint& tappedPosition, const WebNod e& tappedNode, bool pageChanged) override
2628 { 2647 {
2629 m_wasCalled = true; 2648 m_wasCalled = true;
2630 m_tappedPosition = tappedPosition; 2649 m_tappedPosition = tappedPosition;
2631 m_tappedNode = tappedNode; 2650 m_tappedNode = tappedNode;
2632 m_pageChanged = pageChanged; 2651 m_pageChanged = pageChanged;
2633 } 2652 }
2634 bool getWasCalled() const { return m_wasCalled; } 2653 bool getWasCalled() const { return m_wasCalled; }
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); 3359 webViewImpl->advanceFocusInForm(WebFocusTypeBackward);
3341 } 3360 }
3342 // Now focus will stay on previous focus itself, because it has no previous 3361 // Now focus will stay on previous focus itself, because it has no previous
3343 // element. 3362 // element.
3344 EXPECT_EQ(currentFocus, document->focusedElement()); 3363 EXPECT_EQ(currentFocus, document->focusedElement());
3345 3364
3346 m_webViewHelper.reset(); 3365 m_webViewHelper.reset();
3347 } 3366 }
3348 3367
3349 } // namespace blink 3368 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698