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 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 3459 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
3460 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(static_ca
st<WebViewImpl*>(m_webView)->page()->mainFrame()->document()->url())); | 3460 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(static_ca
st<WebViewImpl*>(m_webView)->page()->mainFrame()->document()->url())); |
3461 webViewImpl->page()->mainFrame()->loader()->load(frameRequest); | 3461 webViewImpl->page()->mainFrame()->loader()->load(frameRequest); |
3462 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 3462 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
3463 | 3463 |
3464 EXPECT_TRUE(client.frameLoadTypeSameSeen()); | 3464 EXPECT_TRUE(client.frameLoadTypeSameSeen()); |
3465 m_webView->close(); | 3465 m_webView->close(); |
3466 m_webView = 0; | 3466 m_webView = 0; |
3467 } | 3467 } |
3468 | 3468 |
| 3469 TEST_F(WebFrameTest, WebNodeImageContents) |
| 3470 { |
| 3471 m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true); |
| 3472 WebFrame* frame = m_webView->mainFrame(); |
| 3473 |
| 3474 static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoA
AAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90I
AAAAAElFTkSuQmCC\">"; |
| 3475 |
| 3476 // Load up the image and test that we can extract the contents. |
| 3477 WebCore::KURL testURL = toKURL("about:blank"); |
| 3478 frame->loadHTMLString(bluePNG, testURL); |
| 3479 runPendingTasks(); |
| 3480 |
| 3481 WebNode node = frame->document().body().firstChild(); |
| 3482 EXPECT_TRUE(node.isElementNode()); |
| 3483 WebElement element = node.to<WebElement>(); |
| 3484 WebImage image = element.imageContents(); |
| 3485 ASSERT_FALSE(image.isNull()); |
| 3486 EXPECT_EQ(image.size().width, 10); |
| 3487 EXPECT_EQ(image.size().height, 10); |
| 3488 SkBitmap bitmap = image.getSkBitmap(); |
| 3489 SkAutoLockPixels locker(bitmap); |
| 3490 EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); |
| 3491 } |
3469 | 3492 |
3470 } // namespace | 3493 } // namespace |
OLD | NEW |