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

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

Issue 1565893004: Sets a transparent background for out-of-process subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split cc changes Created 4 years, 10 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
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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 const Color transparentRed(100, 0, 0, 0); 528 const Color transparentRed(100, 0, 0, 0);
529 frame->createView(IntSize(1024, 768), transparentRed, true); 529 frame->createView(IntSize(1024, 768), transparentRed, true);
530 EXPECT_EQ(transparentRed, frame->view()->baseBackgroundColor()); 530 EXPECT_EQ(transparentRed, frame->view()->baseBackgroundColor());
531 frame->view()->dispose(); 531 frame->view()->dispose();
532 } 532 }
533 533
534 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) 534 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame)
535 { 535 {
536 const WebColor kBlue = 0xFF0000FF; 536 const WebColor kBlue = 0xFF0000FF;
537 FrameTestHelpers::TestWebViewClient webViewClient; 537 FrameTestHelpers::TestWebViewClient webViewClient;
538 WebView* webView = WebViewImpl::create(&webViewClient); 538 WebViewImpl* webView = WebViewImpl::create(&webViewClient);
539 EXPECT_NE(kBlue, webView->backgroundColor()); 539 EXPECT_NE(kBlue, webView->backgroundColor());
540 // webView does not have a frame yet, but we should still be able to set the background color. 540 // webView does not have a frame yet, but we should still be able to set the background color.
541 webView->setBaseBackgroundColor(kBlue); 541 webView->setBaseBackgroundColor(kBlue);
542 EXPECT_EQ(kBlue, webView->backgroundColor()); 542 EXPECT_EQ(kBlue, webView->backgroundColor());
543 WebLocalFrameImpl* frame = WebLocalFrameImpl::create(WebTreeScopeType::Docum ent, nullptr); 543 WebLocalFrameImpl* frame = WebLocalFrameImpl::create(WebTreeScopeType::Docum ent, nullptr);
544 webView->setMainFrame(frame); 544 webView->setMainFrame(frame);
545 webView->close(); 545 webView->close();
546 frame->close(); 546 frame->close();
547 } 547 }
548 548
549 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) 549 TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent)
550 { 550 {
551 const WebColor kAlphaRed = 0x80FF0000; 551 const WebColor kAlphaRed = 0x80FF0000;
552 const WebColor kAlphaGreen = 0x8000FF00; 552 const WebColor kAlphaGreen = 0x8000FF00;
553 const int kWidth = 100; 553 const int kWidth = 100;
554 const int kHeight = 100; 554 const int kHeight = 100;
555 555
556 WebView* webView = m_webViewHelper.initialize(); 556 WebViewImpl* webView = m_webViewHelper.initialize();
557 557
558 // Set WebView background to green with alpha. 558 // Set WebView background to green with alpha.
559 webView->setBaseBackgroundColor(kAlphaGreen); 559 webView->setBaseBackgroundColor(kAlphaGreen);
560 webView->settings()->setShouldClearDocumentBackground(false); 560 webView->settings()->setShouldClearDocumentBackground(false);
561 webView->resize(WebSize(kWidth, kHeight)); 561 webView->resize(WebSize(kWidth, kHeight));
562 webView->updateAllLifecyclePhases(); 562 webView->updateAllLifecyclePhases();
563 563
564 // Set canvas background to red with alpha. 564 // Set canvas background to red with alpha.
565 SkBitmap bitmap; 565 SkBitmap bitmap;
566 bitmap.allocN32Pixels(kWidth, kHeight); 566 bitmap.allocN32Pixels(kWidth, kHeight);
(...skipping 2643 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline Point); 3210 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline Point);
3211 ASSERT_TRUE(!!result); 3211 ASSERT_TRUE(!!result);
3212 3212
3213 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); 3213 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y);
3214 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt); 3214 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt);
3215 ASSERT_TRUE(!!result); 3215 ASSERT_TRUE(!!result);
3216 } 3216 }
3217 #endif 3217 #endif
3218 3218
3219 } // namespace blink 3219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698