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

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

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