Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 #include "core/frame/FrameView.h" | 50 #include "core/frame/FrameView.h" |
| 51 #include "core/frame/LocalFrame.h" | 51 #include "core/frame/LocalFrame.h" |
| 52 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
| 53 #include "core/html/HTMLFormElement.h" | 53 #include "core/html/HTMLFormElement.h" |
| 54 #include "core/loader/FrameLoadRequest.h" | 54 #include "core/loader/FrameLoadRequest.h" |
| 55 #include "core/page/EventHandler.h" | 55 #include "core/page/EventHandler.h" |
| 56 #include "core/rendering/HitTestResult.h" | 56 #include "core/rendering/HitTestResult.h" |
| 57 #include "core/rendering/RenderView.h" | 57 #include "core/rendering/RenderView.h" |
| 58 #include "core/rendering/TextAutosizer.h" | 58 #include "core/rendering/TextAutosizer.h" |
| 59 #include "core/rendering/compositing/RenderLayerCompositor.h" | 59 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 60 #include "platform/DragImage.h" | |
| 60 #include "platform/UserGestureIndicator.h" | 61 #include "platform/UserGestureIndicator.h" |
| 61 #include "platform/geometry/FloatRect.h" | 62 #include "platform/geometry/FloatRect.h" |
| 62 #include "platform/network/ResourceError.h" | 63 #include "platform/network/ResourceError.h" |
| 63 #include "platform/scroll/ScrollbarTheme.h" | 64 #include "platform/scroll/ScrollbarTheme.h" |
| 64 #include "public/platform/Platform.h" | 65 #include "public/platform/Platform.h" |
| 65 #include "public/platform/WebFloatRect.h" | 66 #include "public/platform/WebFloatRect.h" |
| 66 #include "public/platform/WebThread.h" | 67 #include "public/platform/WebThread.h" |
| 67 #include "public/platform/WebURL.h" | 68 #include "public/platform/WebURL.h" |
| 68 #include "public/platform/WebURLResponse.h" | 69 #include "public/platform/WebURLResponse.h" |
| 69 #include "public/platform/WebUnitTestSupport.h" | 70 #include "public/platform/WebUnitTestSupport.h" |
| (...skipping 5356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5426 TEST_F(WebFrameTest, HasVisibleContentOnHiddenFrames) | 5427 TEST_F(WebFrameTest, HasVisibleContentOnHiddenFrames) |
| 5427 { | 5428 { |
| 5428 registerMockedHttpURLLoad("hidden_frames.html"); | 5429 registerMockedHttpURLLoad("hidden_frames.html"); |
| 5429 FrameTestHelpers::WebViewHelper webViewHelper; | 5430 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5430 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "hidd en_frames.html"); | 5431 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "hidd en_frames.html"); |
| 5431 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr ame; frame = frame->traverseNext(false)) { | 5432 for (WebFrame* frame = webViewImpl->mainFrameImpl()->traverseNext(false); fr ame; frame = frame->traverseNext(false)) { |
| 5432 EXPECT_FALSE(frame->hasVisibleContent()); | 5433 EXPECT_FALSE(frame->hasVisibleContent()); |
| 5433 } | 5434 } |
| 5434 } | 5435 } |
| 5435 | 5436 |
| 5437 TEST_F(WebFrameTest, NodeImageTest) | |
| 5438 { | |
| 5439 registerMockedHttpURLLoad("nodeimage.html"); | |
| 5440 | |
| 5441 FixedLayoutTestWebViewClient client; | |
| 5442 client.m_screenInfo.deviceScaleFactor = 1; | |
| 5443 int viewportWidth = 100; | |
| 5444 int viewportHeight = 100; | |
| 5445 | |
| 5446 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 5447 webViewHelper.initializeAndLoad(m_baseURL + "nodeimage.html", true, 0, &clie nt); | |
| 5448 webViewHelper.webView()->settings()->setViewportEnabled(true); | |
| 5449 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | |
| 5450 webViewHelper.webView()->layout(); | |
| 5451 | |
| 5452 SkBitmap bitmap; | |
| 5453 ASSERT_TRUE(bitmap.allocN32Pixels(40, 40)); | |
| 5454 SkCanvas canvas(bitmap); | |
| 5455 canvas.drawColor(SK_ColorGREEN); | |
| 5456 | |
| 5457 RefPtr<WebCore::LocalFrame> frame = webViewHelper.webViewImpl()->page()->mai nFrame(); | |
| 5458 | |
| 5459 // Sub Test 1 | |
| 5460 { | |
| 5461 WebCore::Element* element = frame->document()->getElementById("case-css- transform"); | |
| 5462 OwnPtr<WebCore::DragImage> dragImage = frame->nodeImage(*element); | |
| 5463 EXPECT_TRUE(dragImage); | |
| 5464 EXPECT_EQ(40, dragImage->size().width()); | |
| 5465 EXPECT_EQ(40, dragImage->size().height()); | |
| 5466 const SkBitmap& dragBitmap = dragImage->bitmap(); | |
| 5467 SkAutoLockPixels lockPixel(dragBitmap); | |
| 5468 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.r owBytes() * 40)); | |
|
dcheng
2014/05/28 21:02:59
You can replace bitmap.rowBytes() * 40 with bitmap
spartha
2014/05/29 05:55:00
Done.
| |
| 5469 } | |
| 5470 | |
| 5471 } | |
| 5472 | |
| 5436 } // namespace | 5473 } // namespace |
| OLD | NEW |