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

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

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add WebViewHelper for unittests. Created 7 years, 3 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 protected: 217 protected:
218 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi ze, 218 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi ze,
219 const std::string& pageWidth, const std::string& pageHei ght, 219 const std::string& pageWidth, const std::string& pageHei ght,
220 int expectedWidth, int expectedHeight, 220 int expectedWidth, int expectedHeight,
221 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState); 221 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState);
222 222
223 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile); 223 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile);
224 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile); 224 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile);
225 225
226 std::string m_baseURL; 226 std::string m_baseURL;
227 FrameTestHelpers::WebViewHelper m_webViewHelper;
227 }; 228 };
228 229
229 TEST_F(WebViewTest, SetBaseBackgroundColor) 230 TEST_F(WebViewTest, SetBaseBackgroundColor)
230 { 231 {
231 const WebColor kWhite = 0xFFFFFFFF; 232 const WebColor kWhite = 0xFFFFFFFF;
232 const WebColor kBlue = 0xFF0000FF; 233 const WebColor kBlue = 0xFF0000FF;
233 const WebColor kDarkCyan = 0xFF227788; 234 const WebColor kDarkCyan = 0xFF227788;
234 const WebColor kTranslucentPutty = 0x80BFB196; 235 const WebColor kTranslucentPutty = 0x80BFB196;
235 236
236 WebView* webView = FrameTestHelpers::createWebView(); 237 WebView* webView = m_webViewHelper.initialize();
237 EXPECT_EQ(kWhite, webView->backgroundColor()); 238 EXPECT_EQ(kWhite, webView->backgroundColor());
238 239
239 webView->setBaseBackgroundColor(kBlue); 240 webView->setBaseBackgroundColor(kBlue);
240 EXPECT_EQ(kBlue, webView->backgroundColor()); 241 EXPECT_EQ(kBlue, webView->backgroundColor());
241 242
242 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 243 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
243 webView->mainFrame()->loadHTMLString( 244 webView->mainFrame()->loadHTMLString(
244 "<html><head><style>body {background-color:#227788}</style></head></html >", baseURL); 245 "<html><head><style>body {background-color:#227788}</style></head></html >", baseURL);
245 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); 246 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
246 EXPECT_EQ(kDarkCyan, webView->backgroundColor()); 247 EXPECT_EQ(kDarkCyan, webView->backgroundColor());
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 testInputMode(WebString("verbatim"), "input_mode_default_verbatim.html"); 472 testInputMode(WebString("verbatim"), "input_mode_default_verbatim.html");
472 testInputMode(WebString("verbatim"), "input_mode_type_text_verbatim.html"); 473 testInputMode(WebString("verbatim"), "input_mode_type_text_verbatim.html");
473 testInputMode(WebString("verbatim"), "input_mode_type_search_verbatim.html") ; 474 testInputMode(WebString("verbatim"), "input_mode_type_search_verbatim.html") ;
474 testInputMode(WebString(), "input_mode_type_url_verbatim.html"); 475 testInputMode(WebString(), "input_mode_type_url_verbatim.html");
475 testInputMode(WebString("verbatim"), "input_mode_textarea_verbatim.html"); 476 testInputMode(WebString("verbatim"), "input_mode_textarea_verbatim.html");
476 } 477 }
477 478
478 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) 479 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo)
479 { 480 {
480 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 481 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
481 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 482 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
482 webView->setInitialFocus(false); 483 webView->setInitialFocus(false);
483 webView->setEditableSelectionOffsets(5, 13); 484 webView->setEditableSelectionOffsets(5, 13);
484 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); 485 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame());
485 EXPECT_EQ("56789abc", frame->selectionAsText()); 486 EXPECT_EQ("56789abc", frame->selectionAsText());
486 WebTextInputInfo info = webView->textInputInfo(); 487 WebTextInputInfo info = webView->textInputInfo();
487 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); 488 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value);
488 EXPECT_EQ(5, info.selectionStart); 489 EXPECT_EQ(5, info.selectionStart);
489 EXPECT_EQ(13, info.selectionEnd); 490 EXPECT_EQ(13, info.selectionEnd);
490 EXPECT_EQ(-1, info.compositionStart); 491 EXPECT_EQ(-1, info.compositionStart);
491 EXPECT_EQ(-1, info.compositionEnd); 492 EXPECT_EQ(-1, info.compositionEnd);
492 webView->close(); 493 webView->close();
493 494
494 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_editable_populated.html")); 495 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_editable_populated.html"));
495 webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "content_editab le_populated.html"); 496 m_webViewHelper.reset();
497 webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_po pulated.html");
496 webView->setInitialFocus(false); 498 webView->setInitialFocus(false);
497 webView->setEditableSelectionOffsets(8, 19); 499 webView->setEditableSelectionOffsets(8, 19);
498 frame = toWebFrameImpl(webView->mainFrame()); 500 frame = toWebFrameImpl(webView->mainFrame());
499 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); 501 EXPECT_EQ("89abcdefghi", frame->selectionAsText());
500 info = webView->textInputInfo(); 502 info = webView->textInputInfo();
501 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); 503 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value);
502 EXPECT_EQ(8, info.selectionStart); 504 EXPECT_EQ(8, info.selectionStart);
503 EXPECT_EQ(19, info.selectionEnd); 505 EXPECT_EQ(19, info.selectionEnd);
504 EXPECT_EQ(-1, info.compositionStart); 506 EXPECT_EQ(-1, info.compositionStart);
505 EXPECT_EQ(-1, info.compositionEnd); 507 EXPECT_EQ(-1, info.compositionEnd);
506 webView->close(); 508 webView->close();
507 } 509 }
508 510
509 TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange) 511 TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange)
510 { 512 {
511 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 513 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
512 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 514 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
513 webView->setInitialFocus(false); 515 webView->setInitialFocus(false);
514 516
515 // Set up a composition that needs to be committed. 517 // Set up a composition that needs to be committed.
516 std::string compositionText("hello"); 518 std::string compositionText("hello");
517 519
518 WebVector<WebCompositionUnderline> emptyUnderlines; 520 WebVector<WebCompositionUnderline> emptyUnderlines;
519 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 3, 3); 521 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 3, 3);
520 522
521 WebTextInputInfo info = webView->textInputInfo(); 523 WebTextInputInfo info = webView->textInputInfo();
522 EXPECT_EQ("hello", std::string(info.value.utf8().data())); 524 EXPECT_EQ("hello", std::string(info.value.utf8().data()));
(...skipping 23 matching lines...) Expand all
546 EXPECT_EQ(8, info.selectionEnd); 548 EXPECT_EQ(8, info.selectionEnd);
547 EXPECT_EQ(-1, info.compositionStart); 549 EXPECT_EQ(-1, info.compositionStart);
548 EXPECT_EQ(-1, info.compositionEnd); 550 EXPECT_EQ(-1, info.compositionEnd);
549 551
550 webView->close(); 552 webView->close();
551 } 553 }
552 554
553 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) 555 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition)
554 { 556 {
555 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); 557 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html"));
556 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "text_ area_populated.html"); 558 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_ populated.html");
557 webView->setInitialFocus(false); 559 webView->setInitialFocus(false);
558 560
559 WebVector<WebCompositionUnderline> emptyUnderlines; 561 WebVector<WebCompositionUnderline> emptyUnderlines;
560 562
561 webView->setEditableSelectionOffsets(4, 4); 563 webView->setEditableSelectionOffsets(4, 4);
562 webView->setCompositionFromExistingText(8, 12, emptyUnderlines); 564 webView->setCompositionFromExistingText(8, 12, emptyUnderlines);
563 565
564 WebTextInputInfo info = webView->textInputInfo(); 566 WebTextInputInfo info = webView->textInputInfo();
565 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf 8().data())); 567 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf 8().data()));
566 EXPECT_EQ(4, info.selectionStart); 568 EXPECT_EQ(4, info.selectionStart);
(...skipping 18 matching lines...) Expand all
585 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u tf8().data())); 587 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u tf8().data()));
586 588
587 webView->close(); 589 webView->close();
588 } 590 }
589 591
590 TEST_F(WebViewTest, FormChange) 592 TEST_F(WebViewTest, FormChange)
591 { 593 {
592 FormChangeWebViewClient client; 594 FormChangeWebViewClient client;
593 client.reset(); 595 client.reset();
594 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_set_value_while_focused.html")); 596 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_set_value_while_focused.html"));
595 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_set_value_while_focused.html", true, 0, &client); 597 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_set_value_while_focused.html", true, 0, &client);
596 EXPECT_TRUE(client.called()); 598 EXPECT_TRUE(client.called());
597 EXPECT_TRUE(client.focused()); 599 EXPECT_TRUE(client.focused());
598 client.reset(); 600 client.reset();
601 m_webViewHelper.reset();
599 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_set_value_while_not_focused.html")); 602 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_set_value_while_not_focused.html"));
600 webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_se t_value_while_not_focused.html", true, 0, &client); 603 webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_set_val ue_while_not_focused.html", true, 0, &client);
601 EXPECT_TRUE(client.called()); 604 EXPECT_TRUE(client.called());
602 EXPECT_FALSE(client.focused()); 605 EXPECT_FALSE(client.focused());
603 webView->close(); 606 webView->close();
604 } 607 }
605 608
606 TEST_F(WebViewTest, ExtendSelectionAndDelete) 609 TEST_F(WebViewTest, ExtendSelectionAndDelete)
607 { 610 {
608 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 611 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
609 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 612 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
610 webView->setInitialFocus(false); 613 webView->setInitialFocus(false);
611 webView->setEditableSelectionOffsets(10, 10); 614 webView->setEditableSelectionOffsets(10, 10);
612 webView->extendSelectionAndDelete(5, 8); 615 webView->extendSelectionAndDelete(5, 8);
613 WebTextInputInfo info = webView->textInputInfo(); 616 WebTextInputInfo info = webView->textInputInfo();
614 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 617 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
615 EXPECT_EQ(5, info.selectionStart); 618 EXPECT_EQ(5, info.selectionStart);
616 EXPECT_EQ(5, info.selectionEnd); 619 EXPECT_EQ(5, info.selectionEnd);
617 webView->extendSelectionAndDelete(10, 0); 620 webView->extendSelectionAndDelete(10, 0);
618 info = webView->textInputInfo(); 621 info = webView->textInputInfo();
619 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 622 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
620 webView->close(); 623 webView->close();
621 } 624 }
622 625
623 TEST_F(WebViewTest, SetCompositionFromExistingText) 626 TEST_F(WebViewTest, SetCompositionFromExistingText)
624 { 627 {
625 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 628 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
626 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 629 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
627 webView->setInitialFocus(false); 630 webView->setInitialFocus(false);
628 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 631 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
629 underlines[0] = WebKit::WebCompositionUnderline(0, 4, 0, false); 632 underlines[0] = WebKit::WebCompositionUnderline(0, 4, 0, false);
630 webView->setEditableSelectionOffsets(4, 10); 633 webView->setEditableSelectionOffsets(4, 10);
631 webView->setCompositionFromExistingText(8, 12, underlines); 634 webView->setCompositionFromExistingText(8, 12, underlines);
632 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView) ->compositionUnderlines(); 635 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView) ->compositionUnderlines();
633 EXPECT_EQ(8u, underlineResults[0].startOffset); 636 EXPECT_EQ(8u, underlineResults[0].startOffset);
634 EXPECT_EQ(12u, underlineResults[0].endOffset); 637 EXPECT_EQ(12u, underlineResults[0].endOffset);
635 WebTextInputInfo info = webView->textInputInfo(); 638 WebTextInputInfo info = webView->textInputInfo();
636 EXPECT_EQ(4, info.selectionStart); 639 EXPECT_EQ(4, info.selectionStart);
637 EXPECT_EQ(10, info.selectionEnd); 640 EXPECT_EQ(10, info.selectionEnd);
638 EXPECT_EQ(8, info.compositionStart); 641 EXPECT_EQ(8, info.compositionStart);
639 EXPECT_EQ(12, info.compositionEnd); 642 EXPECT_EQ(12, info.compositionEnd);
640 WebVector<WebCompositionUnderline> emptyUnderlines; 643 WebVector<WebCompositionUnderline> emptyUnderlines;
641 webView->setCompositionFromExistingText(0, 0, emptyUnderlines); 644 webView->setCompositionFromExistingText(0, 0, emptyUnderlines);
642 info = webView->textInputInfo(); 645 info = webView->textInputInfo();
643 EXPECT_EQ(4, info.selectionStart); 646 EXPECT_EQ(4, info.selectionStart);
644 EXPECT_EQ(10, info.selectionEnd); 647 EXPECT_EQ(10, info.selectionEnd);
645 EXPECT_EQ(-1, info.compositionStart); 648 EXPECT_EQ(-1, info.compositionStart);
646 EXPECT_EQ(-1, info.compositionEnd); 649 EXPECT_EQ(-1, info.compositionEnd);
647 webView->close(); 650 webView->close();
648 } 651 }
649 652
650 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) 653 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea)
651 { 654 {
652 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); 655 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html"));
653 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "text_ area_populated.html"); 656 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_ populated.html");
654 webView->setInitialFocus(false); 657 webView->setInitialFocus(false);
655 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 658 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
656 underlines[0] = WebKit::WebCompositionUnderline(0, 4, 0, false); 659 underlines[0] = WebKit::WebCompositionUnderline(0, 4, 0, false);
657 webView->setEditableSelectionOffsets(27, 27); 660 webView->setEditableSelectionOffsets(27, 27);
658 std::string newLineText("\n"); 661 std::string newLineText("\n");
659 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); 662 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str()));
660 WebTextInputInfo info = webView->textInputInfo(); 663 WebTextInputInfo info = webView->textInputInfo();
661 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); 664 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data()));
662 665
663 webView->setEditableSelectionOffsets(31, 31); 666 webView->setEditableSelectionOffsets(31, 31);
(...skipping 15 matching lines...) Expand all
679 EXPECT_EQ(34, info.selectionStart); 682 EXPECT_EQ(34, info.selectionStart);
680 EXPECT_EQ(34, info.selectionEnd); 683 EXPECT_EQ(34, info.selectionEnd);
681 EXPECT_EQ(-1, info.compositionStart); 684 EXPECT_EQ(-1, info.compositionStart);
682 EXPECT_EQ(-1, info.compositionEnd); 685 EXPECT_EQ(-1, info.compositionEnd);
683 webView->close(); 686 webView->close();
684 } 687 }
685 688
686 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) 689 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition)
687 { 690 {
688 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 691 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
689 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 692 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
690 webView->setInitialFocus(false); 693 webView->setInitialFocus(false);
691 694
692 std::string compositionTextFirst("hello "); 695 std::string compositionTextFirst("hello ");
693 std::string compositionTextSecond("world"); 696 std::string compositionTextSecond("world");
694 WebVector<WebCompositionUnderline> emptyUnderlines; 697 WebVector<WebCompositionUnderline> emptyUnderlines;
695 698
696 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str() )); 699 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str() ));
697 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 5); 700 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 5);
698 701
699 WebTextInputInfo info = webView->textInputInfo(); 702 WebTextInputInfo info = webView->textInputInfo();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 EXPECT_EQ(2, info.selectionStart); 744 EXPECT_EQ(2, info.selectionStart);
742 EXPECT_EQ(2, info.selectionEnd); 745 EXPECT_EQ(2, info.selectionEnd);
743 EXPECT_EQ(-1, info.compositionStart); 746 EXPECT_EQ(-1, info.compositionStart);
744 EXPECT_EQ(-1, info.compositionEnd); 747 EXPECT_EQ(-1, info.compositionEnd);
745 webView->close(); 748 webView->close();
746 } 749 }
747 750
748 TEST_F(WebViewTest, IsSelectionAnchorFirst) 751 TEST_F(WebViewTest, IsSelectionAnchorFirst)
749 { 752 {
750 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 753 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
751 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 754 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
752 WebFrame* frame = webView->mainFrame(); 755 WebFrame* frame = webView->mainFrame();
753 756
754 webView->setInitialFocus(false); 757 webView->setInitialFocus(false);
755 webView->setEditableSelectionOffsets(4, 10); 758 webView->setEditableSelectionOffsets(4, 10);
756 EXPECT_TRUE(webView->isSelectionAnchorFirst()); 759 EXPECT_TRUE(webView->isSelectionAnchorFirst());
757 WebRect anchor; 760 WebRect anchor;
758 WebRect focus; 761 WebRect focus;
759 webView->selectionBounds(anchor, focus); 762 webView->selectionBounds(anchor, focus);
760 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y)) ; 763 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y)) ;
761 EXPECT_FALSE(webView->isSelectionAnchorFirst()); 764 EXPECT_FALSE(webView->isSelectionAnchorFirst());
762 webView->close(); 765 webView->close();
763 } 766 }
764 767
765 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) 768 TEST_F(WebViewTest, HistoryResetScrollAndScaleState)
766 { 769 {
767 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("hello_world.html")); 770 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("hello_world.html"));
768 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL oad(m_baseURL + "hello_world.html")); 771 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(m _baseURL + "hello_world.html"));
769 webViewImpl->resize(WebSize(640, 480)); 772 webViewImpl->resize(WebSize(640, 480));
770 webViewImpl->layout(); 773 webViewImpl->layout();
771 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 774 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
772 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 775 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
773 776
774 // Make the page scale and scroll with the given paremeters. 777 // Make the page scale and scroll with the given paremeters.
775 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); 778 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84));
776 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 779 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
777 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); 780 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width);
778 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); 781 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // WebViewClient methods 815 // WebViewClient methods
813 virtual bool enterFullScreen() { return true; } 816 virtual bool enterFullScreen() { return true; }
814 virtual void exitFullScreen() { } 817 virtual void exitFullScreen() { }
815 }; 818 };
816 819
817 820
818 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) 821 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState)
819 { 822 {
820 EnterFullscreenWebViewClient client; 823 EnterFullscreenWebViewClient client;
821 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("hello_world.html")); 824 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("hello_world.html"));
822 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL oad(m_baseURL + "hello_world.html", true, 0, &client)); 825 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(m _baseURL + "hello_world.html", true, 0, &client));
823 webViewImpl->settings()->setFullScreenEnabled(true); 826 webViewImpl->settings()->setFullScreenEnabled(true);
824 webViewImpl->resize(WebSize(640, 480)); 827 webViewImpl->resize(WebSize(640, 480));
825 webViewImpl->layout(); 828 webViewImpl->layout();
826 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 829 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
827 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 830 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
828 831
829 // Make the page scale and scroll with the given paremeters. 832 // Make the page scale and scroll with the given paremeters.
830 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); 833 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84));
831 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 834 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
832 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); 835 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 webView->handleInputEvent(event); 916 webView->handleInputEvent(event);
914 runPendingTasks(); 917 runPendingTasks();
915 return true; 918 return true;
916 } 919 }
917 920
918 TEST_F(WebViewTest, DetectContentAroundPosition) 921 TEST_F(WebViewTest, DetectContentAroundPosition)
919 { 922 {
920 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html")); 923 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html"));
921 924
922 ContentDetectorClient client; 925 ContentDetectorClient client;
923 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "conte nt_listeners.html", true, 0, &client); 926 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client);
924 webView->resize(WebSize(500, 300)); 927 webView->resize(WebSize(500, 300));
925 webView->layout(); 928 webView->layout();
926 runPendingTasks(); 929 runPendingTasks();
927 930
928 WebString clickListener = WebString::fromUTF8("clickListener"); 931 WebString clickListener = WebString::fromUTF8("clickListener");
929 WebString touchstartListener = WebString::fromUTF8("touchstartListener"); 932 WebString touchstartListener = WebString::fromUTF8("touchstartListener");
930 WebString mousedownListener = WebString::fromUTF8("mousedownListener"); 933 WebString mousedownListener = WebString::fromUTF8("mousedownListener");
931 WebString noListener = WebString::fromUTF8("noListener"); 934 WebString noListener = WebString::fromUTF8("noListener");
932 WebString link = WebString::fromUTF8("link"); 935 WebString link = WebString::fromUTF8("link");
933 936
(...skipping 28 matching lines...) Expand all
962 webView->handleInputEvent(event); 965 webView->handleInputEvent(event);
963 runPendingTasks(); 966 runPendingTasks();
964 EXPECT_TRUE(client.pendingIntentsCancelled()); 967 EXPECT_TRUE(client.pendingIntentsCancelled());
965 webView->close(); 968 webView->close();
966 } 969 }
967 970
968 TEST_F(WebViewTest, ClientTapHandling) 971 TEST_F(WebViewTest, ClientTapHandling)
969 { 972 {
970 TapHandlingWebViewClient client; 973 TapHandlingWebViewClient client;
971 client.reset(); 974 client.reset();
972 WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", tru e, 0, &client); 975 WebView* webView = m_webViewHelper.initializeAndLoad("about:blank", true, 0, &client);
973 WebGestureEvent event; 976 WebGestureEvent event;
974 event.type = WebInputEvent::GestureTap; 977 event.type = WebInputEvent::GestureTap;
975 event.x = 3; 978 event.x = 3;
976 event.y = 8; 979 event.y = 8;
977 webView->handleInputEvent(event); 980 webView->handleInputEvent(event);
978 runPendingTasks(); 981 runPendingTasks();
979 EXPECT_EQ(3, client.tapX()); 982 EXPECT_EQ(3, client.tapX());
980 EXPECT_EQ(8, client.tapY()); 983 EXPECT_EQ(8, client.tapY());
981 client.reset(); 984 client.reset();
982 event.type = WebInputEvent::GestureLongPress; 985 event.type = WebInputEvent::GestureLongPress;
983 event.x = 25; 986 event.x = 25;
984 event.y = 7; 987 event.y = 7;
985 webView->handleInputEvent(event); 988 webView->handleInputEvent(event);
986 runPendingTasks(); 989 runPendingTasks();
987 EXPECT_EQ(25, client.longpressX()); 990 EXPECT_EQ(25, client.longpressX());
988 EXPECT_EQ(7, client.longpressY()); 991 EXPECT_EQ(7, client.longpressY());
989 webView->close(); 992 webView->close();
990 } 993 }
991 994
992 #if OS(ANDROID) 995 #if OS(ANDROID)
993 TEST_F(WebViewTest, LongPressSelection) 996 TEST_F(WebViewTest, LongPressSelection)
994 { 997 {
995 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html")); 998 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html"));
996 999
997 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "longp ress_selection.html", true); 1000 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ selection.html", true);
998 webView->resize(WebSize(500, 300)); 1001 webView->resize(WebSize(500, 300));
999 webView->layout(); 1002 webView->layout();
1000 runPendingTasks(); 1003 runPendingTasks();
1001 1004
1002 WebString target = WebString::fromUTF8("target"); 1005 WebString target = WebString::fromUTF8("target");
1003 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); 1006 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse");
1004 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); 1007 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame());
1005 1008
1006 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, onselec tstartfalse)); 1009 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, onselec tstartfalse));
1007 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 1010 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
1008 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, target) ); 1011 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, target) );
1009 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); 1012 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data()));
1010 webView->close(); 1013 webView->close();
1011 } 1014 }
1012 #endif 1015 #endif
1013 1016
1014 TEST_F(WebViewTest, SelectionOnDisabledInput) 1017 TEST_F(WebViewTest, SelectionOnDisabledInput)
1015 { 1018 {
1016 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("selection_disabled.html")); 1019 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("selection_disabled.html"));
1017 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "selec tion_disabled.html", true); 1020 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "selection_ disabled.html", true);
1018 webView->resize(WebSize(640, 480)); 1021 webView->resize(WebSize(640, 480));
1019 webView->layout(); 1022 webView->layout();
1020 runPendingTasks(); 1023 runPendingTasks();
1021 1024
1022 std::string testWord = "This text should be selected."; 1025 std::string testWord = "This text should be selected.";
1023 1026
1024 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); 1027 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame());
1025 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data())); 1028 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data()));
1026 1029
1027 size_t location; 1030 size_t location;
1028 size_t length; 1031 size_t length;
1029 EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length )); 1032 EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length ));
1030 EXPECT_EQ(location, 0UL); 1033 EXPECT_EQ(location, 0UL);
1031 EXPECT_EQ(length, testWord.length()); 1034 EXPECT_EQ(length, testWord.length());
1032 1035
1033 webView->close(); 1036 webView->close();
1034 } 1037 }
1035 1038
1036 TEST_F(WebViewTest, SelectionOnReadOnlyInput) 1039 TEST_F(WebViewTest, SelectionOnReadOnlyInput)
1037 { 1040 {
1038 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("selection_readonly.html")); 1041 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("selection_readonly.html"));
1039 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "selec tion_readonly.html", true); 1042 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "selection_ readonly.html", true);
1040 webView->resize(WebSize(640, 480)); 1043 webView->resize(WebSize(640, 480));
1041 webView->layout(); 1044 webView->layout();
1042 runPendingTasks(); 1045 runPendingTasks();
1043 1046
1044 std::string testWord = "This text should be selected."; 1047 std::string testWord = "This text should be selected.";
1045 1048
1046 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); 1049 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame());
1047 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data())); 1050 EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data()));
1048 1051
1049 size_t location; 1052 size_t location;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 bool m_ignoreTextChanges; 1089 bool m_ignoreTextChanges;
1087 int m_textChangesWhileIgnored; 1090 int m_textChangesWhileIgnored;
1088 int m_textChangesWhileNotIgnored; 1091 int m_textChangesWhileNotIgnored;
1089 }; 1092 };
1090 1093
1091 1094
1092 TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) 1095 TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange)
1093 { 1096 {
1094 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 1097 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1095 MockAutofillClient client; 1098 MockAutofillClient client;
1096 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 1099 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
1097 webView->setAutofillClient(&client); 1100 webView->setAutofillClient(&client);
1098 webView->setInitialFocus(false); 1101 webView->setInitialFocus(false);
1099 1102
1100 // Set up a composition that needs to be committed. 1103 // Set up a composition that needs to be committed.
1101 WebVector<WebCompositionUnderline> emptyUnderlines; 1104 WebVector<WebCompositionUnderline> emptyUnderlines;
1102 webView->setEditableSelectionOffsets(4, 10); 1105 webView->setEditableSelectionOffsets(4, 10);
1103 webView->setCompositionFromExistingText(8, 12, emptyUnderlines); 1106 webView->setCompositionFromExistingText(8, 12, emptyUnderlines);
1104 WebTextInputInfo info = webView->textInputInfo(); 1107 WebTextInputInfo info = webView->textInputInfo();
1105 EXPECT_EQ(4, info.selectionStart); 1108 EXPECT_EQ(4, info.selectionStart);
1106 EXPECT_EQ(10, info.selectionEnd); 1109 EXPECT_EQ(10, info.selectionEnd);
1107 EXPECT_EQ(8, info.compositionStart); 1110 EXPECT_EQ(8, info.compositionStart);
1108 EXPECT_EQ(12, info.compositionEnd); 1111 EXPECT_EQ(12, info.compositionEnd);
1109 1112
1110 // Clear the focus and track that the subsequent composition commit does not trigger a 1113 // Clear the focus and track that the subsequent composition commit does not trigger a
1111 // text changed notification for autofill. 1114 // text changed notification for autofill.
1112 client.clearChangeCounts(); 1115 client.clearChangeCounts();
1113 webView->setFocus(false); 1116 webView->setFocus(false);
1114 EXPECT_EQ(1, client.textChangesWhileIgnored()); 1117 EXPECT_EQ(1, client.textChangesWhileIgnored());
1115 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); 1118 EXPECT_EQ(0, client.textChangesWhileNotIgnored());
1116 1119
1117 webView->setAutofillClient(0); 1120 webView->setAutofillClient(0);
1118 webView->close(); 1121 webView->close();
1119 } 1122 }
1120 1123
1121 TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange) 1124 TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange)
1122 { 1125 {
1123 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 1126 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1124 MockAutofillClient client; 1127 MockAutofillClient client;
1125 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html"); 1128 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
1126 webView->setAutofillClient(&client); 1129 webView->setAutofillClient(&client);
1127 webView->setInitialFocus(false); 1130 webView->setInitialFocus(false);
1128 1131
1129 // Set up a composition that needs to be committed. 1132 // Set up a composition that needs to be committed.
1130 std::string compositionText("testingtext"); 1133 std::string compositionText("testingtext");
1131 1134
1132 WebVector<WebCompositionUnderline> emptyUnderlines; 1135 WebVector<WebCompositionUnderline> emptyUnderlines;
1133 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 0, compositionText.length()); 1136 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 0, compositionText.length());
1134 1137
1135 WebTextInputInfo info = webView->textInputInfo(); 1138 WebTextInputInfo info = webView->textInputInfo();
1136 EXPECT_EQ(0, info.selectionStart); 1139 EXPECT_EQ(0, info.selectionStart);
1137 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); 1140 EXPECT_EQ((int) compositionText.length(), info.selectionEnd);
1138 EXPECT_EQ(0, info.compositionStart); 1141 EXPECT_EQ(0, info.compositionStart);
1139 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); 1142 EXPECT_EQ((int) compositionText.length(), info.compositionEnd);
1140 1143
1141 client.clearChangeCounts(); 1144 client.clearChangeCounts();
1142 webView->confirmComposition(); 1145 webView->confirmComposition();
1143 EXPECT_EQ(0, client.textChangesWhileIgnored()); 1146 EXPECT_EQ(0, client.textChangesWhileIgnored());
1144 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); 1147 EXPECT_EQ(1, client.textChangesWhileNotIgnored());
1145 1148
1146 webView->setAutofillClient(0); 1149 webView->setAutofillClient(0);
1147 webView->close(); 1150 webView->close();
1148 } 1151 }
1149 1152
1150 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) 1153 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange)
1151 { 1154 {
1152 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 1155 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1153 MockAutofillClient client; 1156 MockAutofillClient client;
1154 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input _field_populated.html", true); 1157 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html", true);
1155 webView->setAutofillClient(&client); 1158 webView->setAutofillClient(&client);
1156 webView->setInitialFocus(false); 1159 webView->setInitialFocus(false);
1157 1160
1158 WebVector<WebCompositionUnderline> emptyUnderlines; 1161 WebVector<WebCompositionUnderline> emptyUnderlines;
1159 1162
1160 client.clearChangeCounts(); 1163 client.clearChangeCounts();
1161 webView->setCompositionFromExistingText(8, 12, emptyUnderlines); 1164 webView->setCompositionFromExistingText(8, 12, emptyUnderlines);
1162 1165
1163 WebTextInputInfo info = webView->textInputInfo(); 1166 WebTextInputInfo info = webView->textInputInfo();
1164 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf 8().data())); 1167 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf 8().data()));
1165 EXPECT_EQ(8, info.compositionStart); 1168 EXPECT_EQ(8, info.compositionStart);
1166 EXPECT_EQ(12, info.compositionEnd); 1169 EXPECT_EQ(12, info.compositionEnd);
1167 1170
1168 EXPECT_EQ(0, client.textChangesWhileIgnored()); 1171 EXPECT_EQ(0, client.textChangesWhileIgnored());
1169 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); 1172 EXPECT_EQ(0, client.textChangesWhileNotIgnored());
1170 1173
1171 WebDocument document = webView->mainFrame()->document(); 1174 WebDocument document = webView->mainFrame()->document();
1172 EXPECT_EQ(WebString::fromUTF8("none"), document.getElementById("inputEvent" ).firstChild().nodeValue()); 1175 EXPECT_EQ(WebString::fromUTF8("none"), document.getElementById("inputEvent" ).firstChild().nodeValue());
1173 1176
1174 webView->setAutofillClient(0); 1177 webView->setAutofillClient(0);
1175 webView->close(); 1178 webView->close();
1176 } 1179 }
1177 1180
1178 TEST_F(WebViewTest, ShadowRoot) 1181 TEST_F(WebViewTest, ShadowRoot)
1179 { 1182 {
1180 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("shadow_dom_test.html")); 1183 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("shadow_dom_test.html"));
1181 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL oad(m_baseURL + "shadow_dom_test.html", true)); 1184 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initializeAndLoad(m _baseURL + "shadow_dom_test.html", true));
1182 1185
1183 WebDocument document = webViewImpl->mainFrame()->document(); 1186 WebDocument document = webViewImpl->mainFrame()->document();
1184 { 1187 {
1185 WebElement elementWithShadowRoot = document.getElementById("shadowroot") ; 1188 WebElement elementWithShadowRoot = document.getElementById("shadowroot") ;
1186 EXPECT_FALSE(elementWithShadowRoot.isNull()); 1189 EXPECT_FALSE(elementWithShadowRoot.isNull());
1187 WebNode shadowRoot = elementWithShadowRoot.shadowRoot(); 1190 WebNode shadowRoot = elementWithShadowRoot.shadowRoot();
1188 EXPECT_FALSE(shadowRoot.isNull()); 1191 EXPECT_FALSE(shadowRoot.isNull());
1189 } 1192 }
1190 { 1193 {
1191 WebElement elementWithoutShadowRoot = document.getElementById("noshadowr oot"); 1194 WebElement elementWithoutShadowRoot = document.getElementById("noshadowr oot");
1192 EXPECT_FALSE(elementWithoutShadowRoot.isNull()); 1195 EXPECT_FALSE(elementWithoutShadowRoot.isNull());
1193 WebNode shadowRoot = elementWithoutShadowRoot.shadowRoot(); 1196 WebNode shadowRoot = elementWithoutShadowRoot.shadowRoot();
1194 EXPECT_TRUE(shadowRoot.isNull()); 1197 EXPECT_TRUE(shadowRoot.isNull());
1195 } 1198 }
1196 webViewImpl->close(); 1199 webViewImpl->close();
1197 } 1200 }
1198 1201
1199 TEST_F(WebViewTest, HelperPlugin) 1202 TEST_F(WebViewTest, HelperPlugin)
1200 { 1203 {
1201 HelperPluginCreatingWebViewClient client; 1204 HelperPluginCreatingWebViewClient client;
1202 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebView(tru e, 0, &client)); 1205 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initialize(true, 0, &client));
1203 1206
1204 WebFrameImpl* frame = toWebFrameImpl(webViewImpl->mainFrame()); 1207 WebFrameImpl* frame = toWebFrameImpl(webViewImpl->mainFrame());
1205 client.setWebFrameClient(frame->client()); 1208 client.setWebFrameClient(frame->client());
1206 1209
1207 WebHelperPluginImpl* helperPlugin = webViewImpl->createHelperPlugin("dummy-p lugin-type", frame->document()); 1210 WebHelperPluginImpl* helperPlugin = webViewImpl->createHelperPlugin("dummy-p lugin-type", frame->document());
1208 EXPECT_TRUE(helperPlugin); 1211 EXPECT_TRUE(helperPlugin);
1209 EXPECT_EQ(0, helperPlugin->getPlugin()); // Invalid plugin type means no plu gin. 1212 EXPECT_EQ(0, helperPlugin->getPlugin()); // Invalid plugin type means no plu gin.
1210 1213
1211 webViewImpl->closeHelperPluginSoon(helperPlugin); 1214 webViewImpl->closeHelperPluginSoon(helperPlugin);
1212 1215
1213 webViewImpl->close(); 1216 webViewImpl->close();
1214 } 1217 }
1215 1218
1216 } 1219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698