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/WebFrameTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge. 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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
3440 { 3442 {
3441 reset(); 3443 reset();
3442 } 3444 }
3443 3445
3444 void reset() 3446 void reset()
3445 { 3447 {
3446 createNotifications.clear(); 3448 createNotifications.clear();
3447 releaseNotifications.clear(); 3449 releaseNotifications.clear();
3448 } 3450 }
3449 3451
3450 Vector<OwnPtr<Notification>> createNotifications; 3452 Vector<std::unique_ptr<Notification>> createNotifications;
3451 Vector<OwnPtr<Notification>> releaseNotifications; 3453 Vector<std::unique_ptr<Notification>> releaseNotifications;
3452 3454
3453 private: 3455 private:
3454 void didCreateScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> con text, int extensionGroup, int worldId) override 3456 void didCreateScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> con text, int extensionGroup, int worldId) override
3455 { 3457 {
3456 createNotifications.append(adoptPtr(new Notification(frame, context, wor ldId))); 3458 createNotifications.append(wrapUnique(new Notification(frame, context, w orldId)));
3457 } 3459 }
3458 3460
3459 void willReleaseScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> c ontext, int worldId) override 3461 void willReleaseScriptContext(WebLocalFrame* frame, v8::Local<v8::Context> c ontext, int worldId) override
3460 { 3462 {
3461 releaseNotifications.append(adoptPtr(new Notification(frame, context, wo rldId))); 3463 releaseNotifications.append(wrapUnique(new Notification(frame, context, worldId)));
3462 } 3464 }
3463 }; 3465 };
3464 3466
3465 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload) 3467 TEST_P(ParameterizedWebFrameTest, ContextNotificationsLoadUnload)
3466 { 3468 {
3467 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); 3469 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
3468 3470
3469 registerMockedHttpURLLoad("context_notifications_test.html"); 3471 registerMockedHttpURLLoad("context_notifications_test.html");
3470 registerMockedHttpURLLoad("context_notifications_test_frame.html"); 3472 registerMockedHttpURLLoad("context_notifications_test_frame.html");
3471 3473
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
4559 } 4561 }
4560 #endif 4562 #endif
4561 4563
4562 class CompositedSelectionBoundsTestLayerTreeView : public WebLayerTreeView { 4564 class CompositedSelectionBoundsTestLayerTreeView : public WebLayerTreeView {
4563 public: 4565 public:
4564 CompositedSelectionBoundsTestLayerTreeView() : m_selectionCleared(false) { } 4566 CompositedSelectionBoundsTestLayerTreeView() : m_selectionCleared(false) { }
4565 ~CompositedSelectionBoundsTestLayerTreeView() override { } 4567 ~CompositedSelectionBoundsTestLayerTreeView() override { }
4566 4568
4567 void registerSelection(const WebSelection& selection) override 4569 void registerSelection(const WebSelection& selection) override
4568 { 4570 {
4569 m_selection = adoptPtr(new WebSelection(selection)); 4571 m_selection = wrapUnique(new WebSelection(selection));
4570 } 4572 }
4571 4573
4572 void clearSelection() override 4574 void clearSelection() override
4573 { 4575 {
4574 m_selectionCleared = true; 4576 m_selectionCleared = true;
4575 m_selection.reset(); 4577 m_selection.reset();
4576 } 4578 }
4577 4579
4578 bool getAndResetSelectionCleared() 4580 bool getAndResetSelectionCleared()
4579 { 4581 {
4580 bool selectionCleared = m_selectionCleared; 4582 bool selectionCleared = m_selectionCleared;
4581 m_selectionCleared = false; 4583 m_selectionCleared = false;
4582 return selectionCleared; 4584 return selectionCleared;
4583 } 4585 }
4584 4586
4585 const WebSelection* selection() const { return m_selection.get(); } 4587 const WebSelection* selection() const { return m_selection.get(); }
4586 const WebSelectionBound* start() const { return m_selection ? &m_selection-> start() : nullptr; } 4588 const WebSelectionBound* start() const { return m_selection ? &m_selection-> start() : nullptr; }
4587 const WebSelectionBound* end() const { return m_selection ? &m_selection->en d() : nullptr; } 4589 const WebSelectionBound* end() const { return m_selection ? &m_selection->en d() : nullptr; }
4588 4590
4589 private: 4591 private:
4590 bool m_selectionCleared; 4592 bool m_selectionCleared;
4591 OwnPtr<WebSelection> m_selection; 4593 std::unique_ptr<WebSelection> m_selection;
4592 }; 4594 };
4593 4595
4594 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test WebViewClient { 4596 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test WebViewClient {
4595 public: 4597 public:
4596 ~CompositedSelectionBoundsTestWebViewClient() override {} 4598 ~CompositedSelectionBoundsTestWebViewClient() override {}
4597 WebLayerTreeView* layerTreeView() override { return &m_testLayerTreeView; } 4599 WebLayerTreeView* layerTreeView() override { return &m_testLayerTreeView; }
4598 4600
4599 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur n m_testLayerTreeView; } 4601 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur n m_testLayerTreeView; }
4600 4602
4601 private: 4603 private:
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
6270 FrameTestHelpers::loadFrame(iframe, url2); 6272 FrameTestHelpers::loadFrame(iframe, url2);
6271 EXPECT_EQ(iframe, client.frame()); 6273 EXPECT_EQ(iframe, client.frame());
6272 EXPECT_EQ(url2, iframe->document().url().string().utf8()); 6274 EXPECT_EQ(url2, iframe->document().url().string().utf8());
6273 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 6275 EXPECT_FALSE(client.replacesCurrentHistoryItem());
6274 } 6276 }
6275 6277
6276 // Test verifies that layout will change a layer's scrollable attibutes 6278 // Test verifies that layout will change a layer's scrollable attibutes
6277 TEST_F(WebFrameTest, overflowHiddenRewrite) 6279 TEST_F(WebFrameTest, overflowHiddenRewrite)
6278 { 6280 {
6279 registerMockedHttpURLLoad("non-scrollable.html"); 6281 registerMockedHttpURLLoad("non-scrollable.html");
6280 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr (new FakeCompositingWebViewClient()); 6282 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = wrapUnique(new FakeCompositingWebViewClient());
6281 FrameTestHelpers::WebViewHelper webViewHelper; 6283 FrameTestHelpers::WebViewHelper webViewHelper;
6282 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView); 6284 webViewHelper.initialize(true, nullptr, fakeCompositingWebViewClient.get(), nullptr, &configueCompositingWebView);
6283 6285
6284 webViewHelper.resize(WebSize(100, 100)); 6286 webViewHelper.resize(WebSize(100, 100));
6285 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html"); 6287 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html");
6286 6288
6287 PaintLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor( ); 6289 PaintLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor( );
6288 ASSERT_TRUE(compositor->scrollLayer()); 6290 ASSERT_TRUE(compositor->scrollLayer());
6289 6291
6290 // Verify that the WebLayer is not scrollable initially. 6292 // Verify that the WebLayer is not scrollable initially.
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
6986 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); 6988 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width());
6987 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); 6989 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height());
6988 const SkBitmap& dragBitmap = dragImage->bitmap(); 6990 const SkBitmap& dragBitmap = dragImage->bitmap();
6989 SkAutoLockPixels lockPixel(dragBitmap); 6991 SkAutoLockPixels lockPixel(dragBitmap);
6990 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze())); 6992 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze()));
6991 } 6993 }
6992 6994
6993 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant) 6995 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant)
6994 { 6996 {
6995 FrameTestHelpers::WebViewHelper webViewHelper(this); 6997 FrameTestHelpers::WebViewHelper webViewHelper(this);
6996 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-css-3dtransform-descendant")); 6998 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-3dtransform-descendant"));
6997 EXPECT_TRUE(dragImage); 6999 EXPECT_TRUE(dragImage);
6998 7000
6999 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7001 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7000 } 7002 }
7001 7003
7002 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransform) 7004 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransform)
7003 { 7005 {
7004 FrameTestHelpers::WebViewHelper webViewHelper(this); 7006 FrameTestHelpers::WebViewHelper webViewHelper(this);
7005 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-css-transform")); 7007 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-transform"));
7006 EXPECT_TRUE(dragImage); 7008 EXPECT_TRUE(dragImage);
7007 7009
7008 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7010 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7009 } 7011 }
7010 7012
7011 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSS3DTransform) 7013 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSS3DTransform)
7012 { 7014 {
7013 FrameTestHelpers::WebViewHelper webViewHelper(this); 7015 FrameTestHelpers::WebViewHelper webViewHelper(this);
7014 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-css-3dtransform")); 7016 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-css-3dtransform"));
7015 EXPECT_TRUE(dragImage); 7017 EXPECT_TRUE(dragImage);
7016 7018
7017 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7019 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7018 } 7020 }
7019 7021
7020 TEST_P(ParameterizedWebFrameTest, NodeImageTestInlineBlock) 7022 TEST_P(ParameterizedWebFrameTest, NodeImageTestInlineBlock)
7021 { 7023 {
7022 FrameTestHelpers::WebViewHelper webViewHelper(this); 7024 FrameTestHelpers::WebViewHelper webViewHelper(this);
7023 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-inlineblock")); 7025 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-inlineblock"));
7024 EXPECT_TRUE(dragImage); 7026 EXPECT_TRUE(dragImage);
7025 7027
7026 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7028 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7027 } 7029 }
7028 7030
7029 TEST_P(ParameterizedWebFrameTest, NodeImageTestFloatLeft) 7031 TEST_P(ParameterizedWebFrameTest, NodeImageTestFloatLeft)
7030 { 7032 {
7031 FrameTestHelpers::WebViewHelper webViewHelper(this); 7033 FrameTestHelpers::WebViewHelper webViewHelper(this);
7032 OwnPtr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string ("case-float-left-overflow-hidden")); 7034 std::unique_ptr<DragImage> dragImage = nodeImageTestSetup(&webViewHelper, st d::string("case-float-left-overflow-hidden"));
7033 EXPECT_TRUE(dragImage); 7035 EXPECT_TRUE(dragImage);
7034 7036
7035 nodeImageTestValidation(IntSize(40, 40), dragImage.get()); 7037 nodeImageTestValidation(IntSize(40, 40), dragImage.get());
7036 } 7038 }
7037 7039
7038 // Crashes on Android: http://crbug.com/403804 7040 // Crashes on Android: http://crbug.com/403804
7039 #if OS(ANDROID) 7041 #if OS(ANDROID)
7040 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic) 7042 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic)
7041 #else 7043 #else
7042 TEST_P(ParameterizedWebFrameTest, PrintingBasic) 7044 TEST_P(ParameterizedWebFrameTest, PrintingBasic)
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
8663 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8665 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame();
8664 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8666 v8::HandleScope scope(v8::Isolate::GetCurrent());
8665 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8667 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8666 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8668 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8667 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8669 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8668 ASSERT_TRUE(result->IsString()); 8670 ASSERT_TRUE(result->IsString());
8669 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); 8671 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked()));
8670 } 8672 }
8671 8673
8672 } // namespace blink 8674 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698