| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "core/timing/PerformanceCompositeTiming.h" | 57 #include "core/timing/PerformanceCompositeTiming.h" |
| 58 #include "platform/KeyboardCodes.h" | 58 #include "platform/KeyboardCodes.h" |
| 59 #include "platform/UserGestureIndicator.h" | 59 #include "platform/UserGestureIndicator.h" |
| 60 #include "platform/geometry/IntSize.h" | 60 #include "platform/geometry/IntSize.h" |
| 61 #include "platform/graphics/Color.h" | 61 #include "platform/graphics/Color.h" |
| 62 #include "platform/graphics/GraphicsContext.h" | 62 #include "platform/graphics/GraphicsContext.h" |
| 63 #include "platform/graphics/paint/SkPictureBuilder.h" | 63 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 64 #include "platform/testing/URLTestHelpers.h" | 64 #include "platform/testing/URLTestHelpers.h" |
| 65 #include "platform/testing/UnitTestHelpers.h" | 65 #include "platform/testing/UnitTestHelpers.h" |
| 66 #include "public/platform/Platform.h" | 66 #include "public/platform/Platform.h" |
| 67 #include "public/platform/WebClipboard.h" | |
| 68 #include "public/platform/WebDisplayMode.h" | 67 #include "public/platform/WebDisplayMode.h" |
| 69 #include "public/platform/WebDragData.h" | 68 #include "public/platform/WebDragData.h" |
| 70 #include "public/platform/WebDragOperation.h" | 69 #include "public/platform/WebDragOperation.h" |
| 70 #include "public/platform/WebMockClipboard.h" |
| 71 #include "public/platform/WebSize.h" | 71 #include "public/platform/WebSize.h" |
| 72 #include "public/platform/WebThread.h" | 72 #include "public/platform/WebThread.h" |
| 73 #include "public/platform/WebURLLoaderMockFactory.h" | 73 #include "public/platform/WebURLLoaderMockFactory.h" |
| 74 #include "public/web/WebAutofillClient.h" | 74 #include "public/web/WebAutofillClient.h" |
| 75 #include "public/web/WebCache.h" | 75 #include "public/web/WebCache.h" |
| 76 #include "public/web/WebContentDetectionResult.h" | 76 #include "public/web/WebContentDetectionResult.h" |
| 77 #include "public/web/WebDateTimeChooserCompletion.h" | 77 #include "public/web/WebDateTimeChooserCompletion.h" |
| 78 #include "public/web/WebDeviceEmulationParams.h" | 78 #include "public/web/WebDeviceEmulationParams.h" |
| 79 #include "public/web/WebDocument.h" | 79 #include "public/web/WebDocument.h" |
| 80 #include "public/web/WebElement.h" | 80 #include "public/web/WebElement.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html")
; | 317 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html")
; |
| 318 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); | 318 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); |
| 319 webView->resize(WebSize(400, 400)); | 319 webView->resize(WebSize(400, 400)); |
| 320 | 320 |
| 321 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard); | 321 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard); |
| 322 | 322 |
| 323 webView->copyImageAt(WebPoint(50, 50)); | 323 webView->copyImageAt(WebPoint(50, 50)); |
| 324 | 324 |
| 325 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard)); | 325 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard)); |
| 326 | 326 |
| 327 WebData data = Platform::current()->clipboard()->readImage(WebClipboard::Buf
fer()); | 327 WebImage image = static_cast<WebMockClipboard*>(Platform::current()->clipboa
rd())->readRawImage(WebClipboard::Buffer()); |
| 328 WebImage image = WebImage::fromData(data, WebSize()); | |
| 329 | 328 |
| 330 SkAutoLockPixels autoLock(image.getSkBitmap()); | 329 SkAutoLockPixels autoLock(image.getSkBitmap()); |
| 331 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)
); | 330 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)
); |
| 332 }; | 331 }; |
| 333 | 332 |
| 334 TEST_F(WebViewTest, CopyImageAtWithPinchZoom) | 333 TEST_F(WebViewTest, CopyImageAtWithPinchZoom) |
| 335 { | 334 { |
| 336 std::string url = m_baseURL + "canvas-copy-image.html"; | 335 std::string url = m_baseURL + "canvas-copy-image.html"; |
| 337 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html")
; | 336 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html")
; |
| 338 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(url, true, 0); | 337 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(url, true, 0); |
| 339 webView->resize(WebSize(400, 400)); | 338 webView->resize(WebSize(400, 400)); |
| 340 webView->updateAllLifecyclePhases(); | 339 webView->updateAllLifecyclePhases(); |
| 341 webView->setPageScaleFactor(2); | 340 webView->setPageScaleFactor(2); |
| 342 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); | 341 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); |
| 343 | 342 |
| 344 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard); | 343 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard); |
| 345 | 344 |
| 346 webView->copyImageAt(WebPoint(0, 0)); | 345 webView->copyImageAt(WebPoint(0, 0)); |
| 347 | 346 |
| 348 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard)); | 347 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber(WebClip
board::BufferStandard)); |
| 349 | 348 |
| 350 WebData data = Platform::current()->clipboard()->readImage(WebClipboard::Buf
fer()); | 349 WebImage image = static_cast<WebMockClipboard*>(Platform::current()->clipboa
rd())->readRawImage(WebClipboard::Buffer()); |
| 351 WebImage image = WebImage::fromData(data, WebSize()); | |
| 352 | 350 |
| 353 SkAutoLockPixels autoLock(image.getSkBitmap()); | 351 SkAutoLockPixels autoLock(image.getSkBitmap()); |
| 354 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)
); | 352 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)
); |
| 355 }; | 353 }; |
| 356 | 354 |
| 357 TEST_F(WebViewTest, CopyImageWithImageMap) | 355 TEST_F(WebViewTest, CopyImageWithImageMap) |
| 358 { | 356 { |
| 359 SaveImageFromDataURLWebViewClient client; | 357 SaveImageFromDataURLWebViewClient client; |
| 360 | 358 |
| 361 std::string url = m_baseURL + "image-map.html"; | 359 std::string url = m_baseURL + "image-map.html"; |
| (...skipping 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3291 frame->setAutofillClient(&client); | 3289 frame->setAutofillClient(&client); |
| 3292 webView->setInitialFocus(false); | 3290 webView->setInitialFocus(false); |
| 3293 | 3291 |
| 3294 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3292 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); |
| 3295 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3293 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3296 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3294 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3297 frame->setAutofillClient(0); | 3295 frame->setAutofillClient(0); |
| 3298 } | 3296 } |
| 3299 | 3297 |
| 3300 } // namespace blink | 3298 } // namespace blink |
| OLD | NEW |