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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #include "public/web/WebTextCheckingResult.h" 121 #include "public/web/WebTextCheckingResult.h"
122 #include "public/web/WebViewClient.h" 122 #include "public/web/WebViewClient.h"
123 #include "testing/gmock/include/gmock/gmock.h" 123 #include "testing/gmock/include/gmock/gmock.h"
124 #include "testing/gtest/include/gtest/gtest.h" 124 #include "testing/gtest/include/gtest/gtest.h"
125 #include "web/TextFinder.h" 125 #include "web/TextFinder.h"
126 #include "web/WebLocalFrameImpl.h" 126 #include "web/WebLocalFrameImpl.h"
127 #include "web/WebRemoteFrameImpl.h" 127 #include "web/WebRemoteFrameImpl.h"
128 #include "web/WebViewImpl.h" 128 #include "web/WebViewImpl.h"
129 #include "web/tests/FrameTestHelpers.h" 129 #include "web/tests/FrameTestHelpers.h"
130 #include "wtf/Forward.h" 130 #include "wtf/Forward.h"
131 #include "wtf/PtrUtil.h"
131 #include "wtf/dtoa/utils.h" 132 #include "wtf/dtoa/utils.h"
132 #include <map> 133 #include <map>
134 #include <memory>
133 #include <stdarg.h> 135 #include <stdarg.h>
134 #include <v8.h> 136 #include <v8.h>
135 137
136 using blink::URLTestHelpers::toKURL; 138 using blink::URLTestHelpers::toKURL;
137 using blink::testing::runPendingTasks; 139 using blink::testing::runPendingTasks;
138 using testing::ElementsAre; 140 using testing::ElementsAre;
139 using testing::Mock; 141 using testing::Mock;
140 using testing::_; 142 using testing::_;
141 143
142 namespace blink { 144 namespace blink {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 settings->setLoadsImagesAutomatically(true); 249 settings->setLoadsImagesAutomatically(true);
248 } 250 }
249 251
250 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers ::WebViewHelper* webViewHelper) 252 void initializeTextSelectionWebView(const std::string& url, FrameTestHelpers ::WebViewHelper* webViewHelper)
251 { 253 {
252 webViewHelper->initializeAndLoad(url, true); 254 webViewHelper->initializeAndLoad(url, true);
253 webViewHelper->webView()->settings()->setDefaultFontSize(12); 255 webViewHelper->webView()->settings()->setDefaultFontSize(12);
254 webViewHelper->resize(WebSize(640, 480)); 256 webViewHelper->resize(WebSize(640, 480));
255 } 257 }
256 258
257 PassOwnPtr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelper* we bViewHelper, const std::string& testcase) 259 std::unique_ptr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelpe r* webViewHelper, const std::string& testcase)
258 { 260 {
259 registerMockedHttpURLLoad("nodeimage.html"); 261 registerMockedHttpURLLoad("nodeimage.html");
260 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); 262 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html");
261 webViewHelper->resize(WebSize(640, 480)); 263 webViewHelper->resize(WebSize(640, 480));
262 LocalFrame* frame = toLocalFrame(webViewHelper->webViewImpl()->page()->m ainFrame()); 264 LocalFrame* frame = toLocalFrame(webViewHelper->webViewImpl()->page()->m ainFrame());
263 DCHECK(frame); 265 DCHECK(frame);
264 Element* element = frame->document()->getElementById(testcase.c_str()); 266 Element* element = frame->document()->getElementById(testcase.c_str());
265 return frame->nodeImage(*element); 267 return frame->nodeImage(*element);
266 } 268 }
267 269
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2440 TEST_F(WebFrameTest, DISABLED_updateOverlayScrollbarLayers) 2442 TEST_F(WebFrameTest, DISABLED_updateOverlayScrollbarLayers)
2441 #else 2443 #else
2442 TEST_F(WebFrameTest, updateOverlayScrollbarLayers) 2444 TEST_F(WebFrameTest, updateOverlayScrollbarLayers)
2443 #endif 2445 #endif
2444 { 2446 {
2445 registerMockedHttpURLLoad("large-div.html"); 2447 registerMockedHttpURLLoad("large-div.html");
2446 2448
2447 int viewWidth = 500; 2449 int viewWidth = 500;
2448 int viewHeight = 500; 2450 int viewHeight = 500;
2449 2451
2450 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr (new FakeCompositingWebViewClient()); 2452 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient());
2451 FrameTestHelpers::WebViewHelper webViewHelper; 2453 FrameTestHelpers::WebViewHelper webViewHelper;
2452 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView); 2454 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView);
2453 2455
2454 webViewHelper.resize(WebSize(viewWidth, viewHeight)); 2456 webViewHelper.resize(WebSize(viewWidth, viewHeight));
2455 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html"); 2457 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html");
2456 2458
2457 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); 2459 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
2458 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForHorizontalScrollbar ()); 2460 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForHorizontalScrollbar ());
2459 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForVerticalScrollbar() ); 2461 EXPECT_TRUE(view->layoutViewItem().compositor()->layerForVerticalScrollbar() );
2460 2462
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
3415 { 3417 {
3416 reset(); 3418 reset();
3417 } 3419 }
3418 3420
3419 void reset() 3421 void reset()
3420 { 3422 {
3421 createNotifications.clear(); 3423 createNotifications.clear();
3422 releaseNotifications.clear(); 3424 releaseNotifications.clear();
3423 } 3425 }
3424 3426
3425 Vector<OwnPtr<Notification>> createNotifications; 3427 Vector<std::unique_ptr<Notification>> createNotifications;
3426 Vector<OwnPtr<Notification>> releaseNotifications; 3428 Vector<std::unique_ptr<Notification>> releaseNotifications;
3427 3429
3428 private: 3430 private:
3429 void didCreateScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> con text, int extensionGroup, int worldId) override 3431 void didCreateScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> con text, int extensionGroup, int worldId) override
3430 { 3432 {
3431 createNotifications.append(adoptPtr(new Notification(frame, context, wor ldId))); 3433 createNotifications.append(wrapUnique(new Notification(frame, context, w orldId)));
3432 } 3434 }
3433 3435
3434 void willReleaseScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> c ontext, int worldId) override 3436 void willReleaseScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> c ontext, int worldId) override
3435 { 3437 {
3436 releaseNotifications.append(adoptPtr(new Notification(frame, context, wo rldId))); 3438 releaseNotifications.append(wrapUnique(new Notification(frame, context, worldId)));
3437 } 3439 }
3438 }; 3440 };
3439 3441
3440 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload) 3442 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload)
3441 { 3443 {
3442 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); 3444 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
3443 3445
3444 registerMockedHttpURLLoad("context_notifications_test.html"); 3446 registerMockedHttpURLLoad("context_notifications_test.html");
3445 registerMockedHttpURLLoad("context_notifications_test_frame.html"); 3447 registerMockedHttpURLLoad("context_notifications_test_frame.html");
3446 3448
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
4534 } 4536 }
4535 #endif 4537 #endif
4536 4538
4537 class CompositedSelectionBoundsTestLayerTreeView : public WebLayerTreeView { 4539 class CompositedSelectionBoundsTestLayerTreeView : public WebLayerTreeView {
4538 public: 4540 public:
4539 CompositedSelectionBoundsTestLayerTreeView() : m_selectionCleared(false) { } 4541 CompositedSelectionBoundsTestLayerTreeView() : m_selectionCleared(false) { }
4540 ~CompositedSelectionBoundsTestLayerTreeView() override { } 4542 ~CompositedSelectionBoundsTestLayerTreeView() override { }
4541 4543
4542 void registerSelection(const WebSelection& selection) override 4544 void registerSelection(const WebSelection& selection) override
4543 { 4545 {
4544 m_selection = adoptPtr(new WebSelection(selection)); 4546 m_selection = wrapUnique(new WebSelection(selection));
4545 } 4547 }
4546 4548
4547 void clearSelection() override 4549 void clearSelection() override
4548 { 4550 {
4549 m_selectionCleared = true; 4551 m_selectionCleared = true;
4550 m_selection.reset(); 4552 m_selection.reset();
4551 } 4553 }
4552 4554
4553 bool getAndResetSelectionCleared() 4555 bool getAndResetSelectionCleared()
4554 { 4556 {
4555 bool selectionCleared = m_selectionCleared; 4557 bool selectionCleared = m_selectionCleared;
4556 m_selectionCleared = false; 4558 m_selectionCleared = false;
4557 return selectionCleared; 4559 return selectionCleared;
4558 } 4560 }
4559 4561
4560 const WebSelection* selection() const { return m_selection.get(); } 4562 const WebSelection* selection() const { return m_selection.get(); }
4561 const WebSelectionBound* start() const { return m_selection ? &m_selection-> start() : nullptr; } 4563 const WebSelectionBound* start() const { return m_selection ? &m_selection-> start() : nullptr; }
4562 const WebSelectionBound* end() const { return m_selection ? &m_selection->en d() : nullptr; } 4564 const WebSelectionBound* end() const { return m_selection ? &m_selection->en d() : nullptr; }
4563 4565
4564 private: 4566 private:
4565 bool m_selectionCleared; 4567 bool m_selectionCleared;
4566 OwnPtr<WebSelection> m_selection; 4568 std::unique_ptr<WebSelection> m_selection;
4567 }; 4569 };
4568 4570
4569 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test WebViewClient { 4571 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test WebViewClient {
4570 public: 4572 public:
4571 ~CompositedSelectionBoundsTestWebViewClient() override {} 4573 ~CompositedSelectionBoundsTestWebViewClient() override {}
4572 WebLayerTreeView* layerTreeView() override { return &m_testLayerTreeView; } 4574 WebLayerTreeView* layerTreeView() override { return &m_testLayerTreeView; }
4573 4575
4574 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur n m_testLayerTreeView; } 4576 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur n m_testLayerTreeView; }
4575 4577
4576 private: 4578 private:
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 FrameTestHelpers::loadFrame(iframe, url2); 6247 FrameTestHelpers::loadFrame(iframe, url2);
6246 EXPECT_EQ(iframe, client.frame()); 6248 EXPECT_EQ(iframe, client.frame());
6247 EXPECT_EQ(url2, iframe->document().url().string().utf8()); 6249 EXPECT_EQ(url2, iframe->document().url().string().utf8());
6248 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 6250 EXPECT_FALSE(client.replacesCurrentHistoryItem());
6249 } 6251 }
6250 6252
6251 // Test verifies that layout will change a layer's scrollable attibutes 6253 // Test verifies that layout will change a layer's scrollable attibutes
6252 TEST_F(WebFrameTest, overflowHiddenRewrite) 6254 TEST_F(WebFrameTest, overflowHiddenRewrite)
6253 { 6255 {
6254 registerMockedHttpURLLoad("non-scrollable.html"); 6256 registerMockedHttpURLLoad("non-scrollable.html");
6255 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr (new FakeCompositingWebViewClient()); 6257 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient());
6256 FrameTestHelpers::WebViewHelper webViewHelper; 6258 FrameTestHelpers::WebViewHelper webViewHelper;
6257 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView); 6259 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView);
6258 6260
6259 webViewHelper.resize(WebSize(100, 100)); 6261 webViewHelper.resize(WebSize(100, 100));
6260 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html"); 6262 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html");
6261 6263
6262 PaintLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor( ); 6264 PaintLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor( );
6263 ASSERT_TRUE(compositor->scrollLayer()); 6265 ASSERT_TRUE(compositor->scrollLayer());
6264 6266
6265 // Verify that the WebLayer is not scrollable initially. 6267 // Verify that the WebLayer is not scrollable initially.
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
6961 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); 6963 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width());
6962 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); 6964 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height());
6963 const SkBitmap& dragBitmap = dragImage->bitmap(); 6965 const SkBitmap& dragBitmap = dragImage->bitmap();
6964 SkAutoLockPixels lockPixel(dragBitmap); 6966 SkAutoLockPixels lockPixel(dragBitmap);
6965 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze())); 6967 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze()));
6966 } 6968 }
6967 6969
6968 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant) 6970 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant)
6969 { 6971 {
6970 FrameTestHelpers::WebViewHelper webViewHelper(this); 6972 FrameTestHelpers::WebViewHelper webViewHelper(this);
6971 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-css-3dtransform-descendant")); 6973 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-3dtransform-descendant"));
6972 EXPECT_TRUE(dragImage); 6974 EXPECT_TRUE(dragImage);
6973 6975
6974 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 6976 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
6975 } 6977 }
6976 6978
6977 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransform) 6979 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransform)
6978 { 6980 {
6979 FrameTestHelpers::WebViewHelper webViewHelper(this); 6981 FrameTestHelpers::WebViewHelper webViewHelper(this);
6980 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-css-transform")); 6982 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-transform"));
6981 EXPECT_TRUE(dragImage); 6983 EXPECT_TRUE(dragImage);
6982 6984
6983 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 6985 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
6984 } 6986 }
6985 6987
6986 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSS3DTransform) 6988 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSS3DTransform)
6987 { 6989 {
6988 FrameTestHelpers::WebViewHelper webViewHelper(this); 6990 FrameTestHelpers::WebViewHelper webViewHelper(this);
6989 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-css-3dtransform")); 6991 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-3dtransform"));
6990 EXPECT_TRUE(dragImage); 6992 EXPECT_TRUE(dragImage);
6991 6993
6992 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 6994 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
6993 } 6995 }
6994 6996
6995 TEST_P(ParameterizedWebFrameTest, NodeImageTestInlineBlock) 6997 TEST_P(ParameterizedWebFrameTest, NodeImageTestInlineBlock)
6996 { 6998 {
6997 FrameTestHelpers::WebViewHelper webViewHelper(this); 6999 FrameTestHelpers::WebViewHelper webViewHelper(this);
6998 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-inlineblock")); 7000 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-inlineblock"));
6999 EXPECT_TRUE(dragImage); 7001 EXPECT_TRUE(dragImage);
7000 7002
7001 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7003 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7002 } 7004 }
7003 7005
7004 TEST_P(ParameterizedWebFrameTest, NodeImageTestFloatLeft) 7006 TEST_P(ParameterizedWebFrameTest, NodeImageTestFloatLeft)
7005 { 7007 {
7006 FrameTestHelpers::WebViewHelper webViewHelper(this); 7008 FrameTestHelpers::WebViewHelper webViewHelper(this);
7007 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-float-left-overflow-hidden")); 7009 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-float-left-overflow-hidden"));
7008 EXPECT_TRUE(dragImage); 7010 EXPECT_TRUE(dragImage);
7009 7011
7010 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7012 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7011 } 7013 }
7012 7014
7013 // Crashes on Android: http://crbug.com/403804 7015 // Crashes on Android: http://crbug.com/403804
7014 #if OS(ANDROID) 7016 #if OS(ANDROID)
7015 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic) 7017 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic)
7016 #else 7018 #else
7017 TEST_P(ParameterizedWebFrameTest, PrintingBasic) 7019 TEST_P(ParameterizedWebFrameTest, PrintingBasic)
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
8696 ASSERT_FALSE(grandchildFrame->canHaveSecureChild()); 8698 ASSERT_FALSE(grandchildFrame->canHaveSecureChild());
8697 Document* mainDocument = mainFrame->document(); 8699 Document* mainDocument = mainFrame->document();
8698 Document* childDocument = childFrame->document(); 8700 Document* childDocument = childFrame->document();
8699 Document* grandchildDocument = grandchildFrame->document(); 8701 Document* grandchildDocument = grandchildFrame->document();
8700 ASSERT_FALSE(mainDocument->isSecureContext()); 8702 ASSERT_FALSE(mainDocument->isSecureContext());
8701 ASSERT_TRUE(childDocument->isSecureContext()); 8703 ASSERT_TRUE(childDocument->isSecureContext());
8702 ASSERT_FALSE(grandchildDocument->isSecureContext()); 8704 ASSERT_FALSE(grandchildDocument->isSecureContext());
8703 } 8705 }
8704 8706
8705 } // namespace blink 8707 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/TextFinderTest.cpp ('k') | third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698