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

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

Issue 454643002: Route selection bounds updates through WebLayerTreeView (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revised Created 6 years, 3 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
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "public/web/WebFrame.h" 33 #include "public/web/WebFrame.h"
34 34
35 #include "SkBitmap.h" 35 #include "SkBitmap.h"
36 #include "SkCanvas.h" 36 #include "SkCanvas.h"
37 #include "bindings/core/v8/V8Node.h"
37 #include "core/UserAgentStyleSheets.h" 38 #include "core/UserAgentStyleSheets.h"
38 #include "core/clipboard/DataTransfer.h" 39 #include "core/clipboard/DataTransfer.h"
39 #include "core/css/StyleSheetContents.h" 40 #include "core/css/StyleSheetContents.h"
40 #include "core/css/resolver/StyleResolver.h" 41 #include "core/css/resolver/StyleResolver.h"
41 #include "core/css/resolver/ViewportStyleResolver.h" 42 #include "core/css/resolver/ViewportStyleResolver.h"
42 #include "core/dom/DocumentMarkerController.h" 43 #include "core/dom/DocumentMarkerController.h"
43 #include "core/dom/Fullscreen.h" 44 #include "core/dom/Fullscreen.h"
44 #include "core/dom/NodeRenderStyle.h" 45 #include "core/dom/NodeRenderStyle.h"
45 #include "core/dom/Range.h" 46 #include "core/dom/Range.h"
46 #include "core/editing/Editor.h" 47 #include "core/editing/Editor.h"
(...skipping 4001 matching lines...) Expand 10 before | Expand all | Expand 10 after
4048 } 4049 }
4049 4050
4050 bool getAndResetSelectionCleared() 4051 bool getAndResetSelectionCleared()
4051 { 4052 {
4052 bool selectionCleared = m_selectionCleared; 4053 bool selectionCleared = m_selectionCleared;
4053 m_selectionCleared = false; 4054 m_selectionCleared = false;
4054 return selectionCleared; 4055 return selectionCleared;
4055 } 4056 }
4056 4057
4057 const WebSelectionBound* start() const { return m_start.get(); } 4058 const WebSelectionBound* start() const { return m_start.get(); }
4058 const WebSelectionBound* end() const { return m_start.get(); } 4059 const WebSelectionBound* end() const { return m_end.get(); }
4059 4060
4060 private: 4061 private:
4061 bool m_selectionCleared; 4062 bool m_selectionCleared;
4062 OwnPtr<WebSelectionBound> m_start; 4063 OwnPtr<WebSelectionBound> m_start;
4063 OwnPtr<WebSelectionBound> m_end; 4064 OwnPtr<WebSelectionBound> m_end;
4064 }; 4065 };
4065 4066
4066 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test WebViewClient { 4067 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test WebViewClient {
4067 public: 4068 public:
4068 virtual ~CompositedSelectionBoundsTestWebViewClient() { } 4069 virtual ~CompositedSelectionBoundsTestWebViewClient() { }
4069 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree View; } 4070 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree View; }
4070 4071
4071 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur n m_testLayerTreeView; } 4072 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur n m_testLayerTreeView; }
4072 4073
4073 private: 4074 private:
4074 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; 4075 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView;
4075 }; 4076 };
4076 4077
4078 class CompositedSelectionBoundsTest : public WebFrameTest {
4079 protected:
4080 CompositedSelectionBoundsTest()
4081 : m_fakeSelectionLayerTreeView(m_fakeSelectionWebViewClient.selectionLay erTreeView())
4082 {
4083 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true );
4084 registerMockedHttpURLLoad("Ahem.ttf");
4085
4086 m_webViewHelper.initialize(true, 0, &m_fakeSelectionWebViewClient);
4087 m_webViewHelper.webView()->settings()->setDefaultFontSize(12);
4088 m_webViewHelper.webView()->setPageScaleFactorLimits(1, 1);
4089 m_webViewHelper.webView()->resize(WebSize(640, 480));
4090 }
4091
4092 void runTest(const char* testFile)
4093 {
4094 registerMockedHttpURLLoad(testFile);
4095 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba seURL + testFile);
4096 m_webViewHelper.webView()->layout();
4097
4098 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star t();
4099 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end();
4100
4101 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
4102 v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->e xecuteScriptAndReturnValueForTests(WebScriptSource("expectedResult"));
4103 if (result.IsEmpty() || (*result)->IsUndefined()) {
4104 EXPECT_FALSE(selectStart);
4105 EXPECT_FALSE(selectEnd);
4106 return;
4107 }
4108
4109 ASSERT_TRUE(selectStart);
4110 ASSERT_TRUE(selectEnd);
4111
4112 ASSERT_TRUE((*result)->IsArray());
4113 v8::Array& expectedResult = *v8::Array::Cast(*result);
4114 ASSERT_EQ(10u, expectedResult.Length());
4115
4116 blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck (v8::Isolate::GetCurrent(), expectedResult.Get(0));
4117 ASSERT_TRUE(layerOwnerNodeForStart);
4118 EXPECT_EQ(layerOwnerNodeForStart->renderer()->enclosingLayer()->enclosin gLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), sel ectStart->layerId);
4119 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay er.x);
4120 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay er.y);
4121 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn Layer.x);
4122 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn Layer.y);
4123
4124 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v 8::Isolate::GetCurrent(), expectedResult.Get(5));
4125 ASSERT_TRUE(layerOwnerNodeForEnd);
4126 EXPECT_EQ(layerOwnerNodeForEnd->renderer()->enclosingLayer()->enclosingL ayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), selec tEnd->layerId);
4127 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer .x);
4128 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer .y);
4129 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa yer.x);
4130 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa yer.y);
4131 }
4132
4133 void runTestWithMultipleFiles(const char* testFile, ...)
4134 {
4135 va_list auxFiles;
4136 va_start(auxFiles, testFile);
4137 while (const char* auxFile = va_arg(auxFiles, const char*))
4138 registerMockedHttpURLLoad(auxFile);
4139 va_end(auxFiles);
4140
4141 runTest(testFile);
4142 }
4143
4144 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient;
4145 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView;
4146 FrameTestHelpers::WebViewHelper m_webViewHelper;
4147 };
4148
4149 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun ds_none.html"); }
4150 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou nds_basic.html"); }
4151 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti on_bounds_transformed.html"); }
4152 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio n_bounds_split_layer.html"); }
4153 TEST_F(CompositedSelectionBoundsTest, Iframe) { runTestWithMultipleFiles("compos ited_selection_bounds_iframe.html", "composited_selection_bounds_basic.html", nu llptr); }
4154
4077 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) 4155 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared)
4078 { 4156 {
4079 RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); 4157 RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true);
4080 4158
4081 registerMockedHttpURLLoad("select_range_basic.html"); 4159 registerMockedHttpURLLoad("select_range_basic.html");
4082 registerMockedHttpURLLoad("select_range_scroll.html"); 4160 registerMockedHttpURLLoad("select_range_scroll.html");
4083 4161
4084 int viewWidth = 500; 4162 int viewWidth = 500;
4085 int viewHeight = 500; 4163 int viewHeight = 500;
4086 4164
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
6272 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6350 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6273 6351
6274 // Neither should a page reload. 6352 // Neither should a page reload.
6275 localFrame->reload(); 6353 localFrame->reload();
6276 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6354 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6277 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6355 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6278 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6356 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6279 } 6357 }
6280 6358
6281 } // namespace 6359 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698