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

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

Issue 264713014: Remove the composited path from WebViewImpl::paint(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: paint-compositor: rebase Created 6 years, 7 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') | public/web/WebWidget.h » ('j') | 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) 238 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame)
239 { 239 {
240 const WebColor kBlue = 0xFF0000FF; 240 const WebColor kBlue = 0xFF0000FF;
241 WebView* webView = WebViewImpl::create(0); 241 WebView* webView = WebViewImpl::create(0);
242 EXPECT_NE(kBlue, webView->backgroundColor()); 242 EXPECT_NE(kBlue, webView->backgroundColor());
243 // webView does not have a frame yet, but we should still be able to set the background color. 243 // webView does not have a frame yet, but we should still be able to set the background color.
244 webView->setBaseBackgroundColor(kBlue); 244 webView->setBaseBackgroundColor(kBlue);
245 EXPECT_EQ(kBlue, webView->backgroundColor()); 245 EXPECT_EQ(kBlue, webView->backgroundColor());
246 } 246 }
247 247
248 static void disableAccleratedCompositing(WebSettings* webSettings)
249 {
250 webSettings->setAcceleratedCompositingEnabled(false);
251 }
252
248 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) 253 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent)
249 { 254 {
250 const WebColor kAlphaRed = 0x80FF0000; 255 const WebColor kAlphaRed = 0x80FF0000;
251 const WebColor kAlphaGreen = 0x8000FF00; 256 const WebColor kAlphaGreen = 0x8000FF00;
252 const int kWidth = 100; 257 const int kWidth = 100;
253 const int kHeight = 100; 258 const int kHeight = 100;
254 259
260 // Make a WebView that is not composited.
261 bool enableJavascript = false;
262 FrameTestHelpers::TestWebFrameClient* frameClient = 0;
263 WebViewClient* viewClient = 0;
264 WebView* webView = m_webViewHelper.initialize(enableJavascript, frameClient, viewClient, &disableAccleratedCompositing);
265
255 // Set WebView background to green with alpha. 266 // Set WebView background to green with alpha.
256 WebView* webView = m_webViewHelper.initialize();
257 webView->setBaseBackgroundColor(kAlphaGreen); 267 webView->setBaseBackgroundColor(kAlphaGreen);
258 webView->settings()->setShouldClearDocumentBackground(false); 268 webView->settings()->setShouldClearDocumentBackground(false);
259 webView->resize(WebSize(kWidth, kHeight)); 269 webView->resize(WebSize(kWidth, kHeight));
260 webView->layout(); 270 webView->layout();
261 271
262 // Set canvas background to red with alpha. 272 // Set canvas background to red with alpha.
263 SkBitmap bitmap; 273 SkBitmap bitmap;
264 ASSERT_TRUE(bitmap.allocN32Pixels(kWidth, kHeight)); 274 ASSERT_TRUE(bitmap.allocN32Pixels(kWidth, kHeight));
265 SkCanvas canvas(bitmap); 275 SkCanvas canvas(bitmap);
266 canvas.clear(kAlphaRed); 276 canvas.clear(kAlphaRed);
267 webView->paint(&canvas, WebRect(0, 0, kWidth, kHeight)); 277 webView->paint(&canvas, WebRect(0, 0, kWidth, kHeight));
268 278
269 // The result should be a blend of red and green. 279 // The result should be a blend of red and green.
270 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); 280 SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2);
271 EXPECT_TRUE(WebCore::redChannel(color)); 281 EXPECT_TRUE(WebCore::redChannel(color));
272 // FIXME: This should be EXPECT_TRUE. This looks to only work 282 EXPECT_TRUE(WebCore::greenChannel(color));
273 // if compositing is disabled, which is no longer a shipping configuration.
274 // crbug.com/365810
275 EXPECT_FALSE(WebCore::greenChannel(color));
276 } 283 }
277 284
278 TEST_F(WebViewTest, FocusIsInactive) 285 TEST_F(WebViewTest, FocusIsInactive)
279 { 286 {
280 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "visible_iframe.html"); 287 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "visible_iframe.html");
281 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if rame.html"); 288 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if rame.html");
282 289
283 webView->setFocus(true); 290 webView->setFocus(true);
284 webView->setIsActive(true); 291 webView->setIsActive(true);
285 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 292 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 1942
1936 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 1943 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
1937 1944
1938 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 1945 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
1939 1946
1940 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 1947 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
1941 webView->setAutofillClient(0); 1948 webView->setAutofillClient(0);
1942 } 1949 }
1943 1950
1944 } // namespace 1951 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/web/WebWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698