| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "WebWidget.h" | 51 #include "WebWidget.h" |
| 52 #include "core/dom/Document.h" | 52 #include "core/dom/Document.h" |
| 53 #include "core/dom/Element.h" | 53 #include "core/dom/Element.h" |
| 54 #include "core/html/HTMLDocument.h" | 54 #include "core/html/HTMLDocument.h" |
| 55 #include "core/html/HTMLInputElement.h" | 55 #include "core/html/HTMLInputElement.h" |
| 56 #include "core/loader/FrameLoadRequest.h" | 56 #include "core/loader/FrameLoadRequest.h" |
| 57 #include "core/frame/FrameView.h" | 57 #include "core/frame/FrameView.h" |
| 58 #include "core/page/Chrome.h" | 58 #include "core/page/Chrome.h" |
| 59 #include "core/page/Settings.h" | 59 #include "core/page/Settings.h" |
| 60 #include "core/platform/chromium/KeyboardCodes.h" | 60 #include "core/platform/chromium/KeyboardCodes.h" |
| 61 #include "platform/graphics/Color.h" | |
| 62 #include "public/platform/Platform.h" | 61 #include "public/platform/Platform.h" |
| 63 #include "public/platform/WebSize.h" | 62 #include "public/platform/WebSize.h" |
| 64 #include "public/platform/WebThread.h" | 63 #include "public/platform/WebThread.h" |
| 65 #include "public/platform/WebUnitTestSupport.h" | 64 #include "public/platform/WebUnitTestSupport.h" |
| 66 #include "public/web/WebWidgetClient.h" | 65 #include "public/web/WebWidgetClient.h" |
| 67 #include "third_party/skia/include/core/SkBitmap.h" | |
| 68 #include "third_party/skia/include/core/SkBitmapDevice.h" | |
| 69 #include "third_party/skia/include/core/SkCanvas.h" | |
| 70 | 66 |
| 71 using namespace blink; | 67 using namespace blink; |
| 72 using blink::FrameTestHelpers::runPendingTasks; | 68 using blink::FrameTestHelpers::runPendingTasks; |
| 73 using blink::URLTestHelpers::toKURL; | 69 using blink::URLTestHelpers::toKURL; |
| 74 | 70 |
| 75 namespace { | 71 namespace { |
| 76 | 72 |
| 77 enum HorizontalScrollbarState { | 73 enum HorizontalScrollbarState { |
| 78 NoHorizontalScrollbar, | 74 NoHorizontalScrollbar, |
| 79 VisibleHorizontalScrollbar, | 75 VisibleHorizontalScrollbar, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) | 267 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
| 272 { | 268 { |
| 273 const WebColor kBlue = 0xFF0000FF; | 269 const WebColor kBlue = 0xFF0000FF; |
| 274 WebView* webView = WebViewImpl::create(0); | 270 WebView* webView = WebViewImpl::create(0); |
| 275 EXPECT_NE(kBlue, webView->backgroundColor()); | 271 EXPECT_NE(kBlue, webView->backgroundColor()); |
| 276 // webView does not have a frame yet, but we should still be able to set the
background color. | 272 // webView does not have a frame yet, but we should still be able to set the
background color. |
| 277 webView->setBaseBackgroundColor(kBlue); | 273 webView->setBaseBackgroundColor(kBlue); |
| 278 EXPECT_EQ(kBlue, webView->backgroundColor()); | 274 EXPECT_EQ(kBlue, webView->backgroundColor()); |
| 279 } | 275 } |
| 280 | 276 |
| 281 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) | |
| 282 { | |
| 283 const WebColor kAlphaRed = 0x80FF0000; | |
| 284 const WebColor kAlphaGreen = 0x8000FF00; | |
| 285 const int kWidth = 100; | |
| 286 const int kHeight = 100; | |
| 287 | |
| 288 // Set WebView background to green with alpha. | |
| 289 WebView* webView = m_webViewHelper.initialize(); | |
| 290 webView->setBaseBackgroundColor(kAlphaGreen); | |
| 291 webView->settings()->setShouldClearDocumentBackground(false); | |
| 292 webView->resize(WebSize(kWidth, kHeight)); | |
| 293 webView->layout(); | |
| 294 | |
| 295 // Set canvas background to red with alpha. | |
| 296 SkBitmap bitmap; | |
| 297 bitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight); | |
| 298 bitmap.allocPixels(); | |
| 299 SkBitmapDevice device(bitmap); | |
| 300 SkCanvas canvas(&device); | |
| 301 canvas.clear(kAlphaRed); | |
| 302 webView->paint(&canvas, WebRect(0, 0, kWidth, kHeight)); | |
| 303 | |
| 304 // The result should be a blend of red and green. | |
| 305 uint32_t color = *bitmap.getAddr32(50, 50); | |
| 306 EXPECT_TRUE(WebCore::redChannel(color)); | |
| 307 EXPECT_TRUE(WebCore::greenChannel(color)); | |
| 308 } | |
| 309 | |
| 310 TEST_F(WebViewTest, FocusIsInactive) | 277 TEST_F(WebViewTest, FocusIsInactive) |
| 311 { | 278 { |
| 312 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "visible_iframe.html"); | 279 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "visible_iframe.html"); |
| 313 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if
rame.html"); | 280 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "visible_if
rame.html"); |
| 314 | 281 |
| 315 webView->setFocus(true); | 282 webView->setFocus(true); |
| 316 webView->setIsActive(true); | 283 webView->setIsActive(true); |
| 317 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); | 284 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 318 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 285 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
| 319 | 286 |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 EXPECT_STREQ("1970-W01", inputElement->value().utf8().data()); | 1343 EXPECT_STREQ("1970-W01", inputElement->value().utf8().data()); |
| 1377 | 1344 |
| 1378 openDateTimeChooser(webViewImpl, inputElement); | 1345 openDateTimeChooser(webViewImpl, inputElement); |
| 1379 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie
t_NaN()); | 1346 client.chooserCompletion()->didChooseValue(std::numeric_limits<double>::quie
t_NaN()); |
| 1380 client.clearChooserCompletion(); | 1347 client.clearChooserCompletion(); |
| 1381 EXPECT_STREQ("", inputElement->value().utf8().data()); | 1348 EXPECT_STREQ("", inputElement->value().utf8().data()); |
| 1382 } | 1349 } |
| 1383 #endif | 1350 #endif |
| 1384 | 1351 |
| 1385 } | 1352 } |
| OLD | NEW |