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

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

Issue 270613004: Implement "Copy image" for canvas (blink side). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed nits Created 6 years, 5 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
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/tests/data/canvas-copy-image.html » ('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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/html/HTMLTextAreaElement.h" 42 #include "core/html/HTMLTextAreaElement.h"
43 #include "core/loader/FrameLoadRequest.h" 43 #include "core/loader/FrameLoadRequest.h"
44 #include "core/page/Chrome.h" 44 #include "core/page/Chrome.h"
45 #include "core/page/Page.h" 45 #include "core/page/Page.h"
46 #include "core/rendering/RenderLayer.h" 46 #include "core/rendering/RenderLayer.h"
47 #include "core/rendering/RenderView.h" 47 #include "core/rendering/RenderView.h"
48 #include "platform/KeyboardCodes.h" 48 #include "platform/KeyboardCodes.h"
49 #include "platform/geometry/IntSize.h" 49 #include "platform/geometry/IntSize.h"
50 #include "platform/graphics/Color.h" 50 #include "platform/graphics/Color.h"
51 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
52 #include "public/platform/WebClipboard.h"
52 #include "public/platform/WebDragData.h" 53 #include "public/platform/WebDragData.h"
53 #include "public/platform/WebSize.h" 54 #include "public/platform/WebSize.h"
54 #include "public/platform/WebThread.h" 55 #include "public/platform/WebThread.h"
55 #include "public/platform/WebUnitTestSupport.h" 56 #include "public/platform/WebUnitTestSupport.h"
56 #include "public/web/WebAutofillClient.h" 57 #include "public/web/WebAutofillClient.h"
57 #include "public/web/WebContentDetectionResult.h" 58 #include "public/web/WebContentDetectionResult.h"
58 #include "public/web/WebDateTimeChooserCompletion.h" 59 #include "public/web/WebDateTimeChooserCompletion.h"
59 #include "public/web/WebDocument.h" 60 #include "public/web/WebDocument.h"
60 #include "public/web/WebDragOperation.h" 61 #include "public/web/WebDragOperation.h"
61 #include "public/web/WebElement.h" 62 #include "public/web/WebElement.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState); 208 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState);
208 209
209 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile); 210 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile);
210 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile); 211 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile);
211 void testSelectionRootBounds(const char* htmlFile, float pageScaleFactor); 212 void testSelectionRootBounds(const char* htmlFile, float pageScaleFactor);
212 213
213 std::string m_baseURL; 214 std::string m_baseURL;
214 FrameTestHelpers::WebViewHelper m_webViewHelper; 215 FrameTestHelpers::WebViewHelper m_webViewHelper;
215 }; 216 };
216 217
218 TEST_F(WebViewTest, CopyImageAt)
219 {
220 std::string url = m_baseURL + "canvas-copy-image.html";
221 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html") ;
222 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0);
223 webView->resize(WebSize(400, 400));
224 webView->copyImageAt(WebPoint(50, 50));
225
226 blink::WebData data = blink::Platform::current()->clipboard()->readImage(bli nk::WebClipboard::Buffer());
227 blink::WebImage image = blink::WebImage::fromData(data, WebSize());
228
229 SkAutoLockPixels autoLock(image.getSkBitmap());
230 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0) );
231 };
232
217 TEST_F(WebViewTest, SetBaseBackgroundColor) 233 TEST_F(WebViewTest, SetBaseBackgroundColor)
218 { 234 {
219 const WebColor kWhite = 0xFFFFFFFF; 235 const WebColor kWhite = 0xFFFFFFFF;
220 const WebColor kBlue = 0xFF0000FF; 236 const WebColor kBlue = 0xFF0000FF;
221 const WebColor kDarkCyan = 0xFF227788; 237 const WebColor kDarkCyan = 0xFF227788;
222 const WebColor kTranslucentPutty = 0x80BFB196; 238 const WebColor kTranslucentPutty = 0x80BFB196;
223 const WebColor kTransparent = 0x00000000; 239 const WebColor kTransparent = 0x00000000;
224 240
225 WebViewImpl* webView = m_webViewHelper.initialize(); 241 WebViewImpl* webView = m_webViewHelper.initialize();
226 EXPECT_EQ(kWhite, webView->backgroundColor()); 242 EXPECT_EQ(kWhite, webView->backgroundColor());
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 2046
2031 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 2047 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
2032 2048
2033 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 2049 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
2034 2050
2035 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 2051 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
2036 webView->setAutofillClient(0); 2052 webView->setAutofillClient(0);
2037 } 2053 }
2038 2054
2039 } // namespace 2055 } // namespace
OLDNEW
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/tests/data/canvas-copy-image.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698