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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <tuple>
7 8
8 #include "base/bind.h" 9 #include "base/bind.h"
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
13 #include "base/location.h" 14 #include "base/location.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; 532 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
532 533
533 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url)); 534 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
534 ProcessPendingMessages(); 535 ProcessPendingMessages();
535 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( 536 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
536 ViewHostMsg_SaveImageFromDataURL::ID); 537 ViewHostMsg_SaveImageFromDataURL::ID);
537 EXPECT_TRUE(msg2); 538 EXPECT_TRUE(msg2);
538 539
539 ViewHostMsg_SaveImageFromDataURL::Param param1; 540 ViewHostMsg_SaveImageFromDataURL::Param param1;
540 ViewHostMsg_SaveImageFromDataURL::Read(msg2, &param1); 541 ViewHostMsg_SaveImageFromDataURL::Read(msg2, &param1);
541 EXPECT_EQ(base::get<2>(param1).length(), image_data_url.length()); 542 EXPECT_EQ(std::get<2>(param1).length(), image_data_url.length());
542 EXPECT_EQ(base::get<2>(param1), image_data_url); 543 EXPECT_EQ(std::get<2>(param1), image_data_url);
543 544
544 ProcessPendingMessages(); 545 ProcessPendingMessages();
545 render_thread_->sink().ClearMessages(); 546 render_thread_->sink().ClearMessages();
546 547
547 const std::string large_data_url(1024 * 1024 * 20 - 1, 'd'); 548 const std::string large_data_url(1024 * 1024 * 20 - 1, 'd');
548 549
549 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url)); 550 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url));
550 ProcessPendingMessages(); 551 ProcessPendingMessages();
551 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( 552 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
552 ViewHostMsg_SaveImageFromDataURL::ID); 553 ViewHostMsg_SaveImageFromDataURL::ID);
553 EXPECT_TRUE(msg3); 554 EXPECT_TRUE(msg3);
554 555
555 ViewHostMsg_SaveImageFromDataURL::Param param2; 556 ViewHostMsg_SaveImageFromDataURL::Param param2;
556 ViewHostMsg_SaveImageFromDataURL::Read(msg3, &param2); 557 ViewHostMsg_SaveImageFromDataURL::Read(msg3, &param2);
557 EXPECT_EQ(base::get<2>(param2).length(), large_data_url.length()); 558 EXPECT_EQ(std::get<2>(param2).length(), large_data_url.length());
558 EXPECT_EQ(base::get<2>(param2), large_data_url); 559 EXPECT_EQ(std::get<2>(param2), large_data_url);
559 560
560 ProcessPendingMessages(); 561 ProcessPendingMessages();
561 render_thread_->sink().ClearMessages(); 562 render_thread_->sink().ClearMessages();
562 563
563 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd'); 564 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd');
564 565
565 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); 566 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
566 ProcessPendingMessages(); 567 ProcessPendingMessages();
567 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( 568 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
568 ViewHostMsg_SaveImageFromDataURL::ID); 569 ViewHostMsg_SaveImageFromDataURL::ID);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 ProcessPendingMessages(); 619 ProcessPendingMessages();
619 620
620 const IPC::Message* frame_navigate_msg = 621 const IPC::Message* frame_navigate_msg =
621 render_thread_->sink().GetUniqueMessageMatching( 622 render_thread_->sink().GetUniqueMessageMatching(
622 FrameHostMsg_DidCommitProvisionalLoad::ID); 623 FrameHostMsg_DidCommitProvisionalLoad::ID);
623 EXPECT_TRUE(frame_navigate_msg); 624 EXPECT_TRUE(frame_navigate_msg);
624 625
625 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; 626 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params;
626 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, 627 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
627 &host_nav_params); 628 &host_nav_params);
628 EXPECT_EQ("POST", base::get<0>(host_nav_params).method); 629 EXPECT_EQ("POST", std::get<0>(host_nav_params).method);
629 630
630 // Check post data sent to browser matches 631 // Check post data sent to browser matches
631 EXPECT_TRUE(base::get<0>(host_nav_params).page_state.IsValid()); 632 EXPECT_TRUE(std::get<0>(host_nav_params).page_state.IsValid());
632 std::unique_ptr<HistoryEntry> entry = 633 std::unique_ptr<HistoryEntry> entry =
633 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state); 634 PageStateToHistoryEntry(std::get<0>(host_nav_params).page_state);
634 blink::WebHTTPBody body = entry->root().httpBody(); 635 blink::WebHTTPBody body = entry->root().httpBody();
635 blink::WebHTTPBody::Element element; 636 blink::WebHTTPBody::Element element;
636 bool successful = body.elementAt(0, element); 637 bool successful = body.elementAt(0, element);
637 EXPECT_TRUE(successful); 638 EXPECT_TRUE(successful);
638 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); 639 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type);
639 EXPECT_EQ(length, element.data.size()); 640 EXPECT_EQ(length, element.data.size());
640 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); 641 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length));
641 } 642 }
642 643
643 // Check that page ID will be initialized in case of navigation 644 // Check that page ID will be initialized in case of navigation
(...skipping 21 matching lines...) Expand all
665 EXPECT_NE(view_page_id(), -1); 666 EXPECT_NE(view_page_id(), -1);
666 667
667 const IPC::Message* frame_navigate_msg = 668 const IPC::Message* frame_navigate_msg =
668 render_thread_->sink().GetUniqueMessageMatching( 669 render_thread_->sink().GetUniqueMessageMatching(
669 FrameHostMsg_DidCommitProvisionalLoad::ID); 670 FrameHostMsg_DidCommitProvisionalLoad::ID);
670 EXPECT_TRUE(frame_navigate_msg); 671 EXPECT_TRUE(frame_navigate_msg);
671 672
672 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; 673 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params;
673 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, 674 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
674 &host_nav_params); 675 &host_nav_params);
675 EXPECT_TRUE(base::get<0>(host_nav_params).page_state.IsValid()); 676 EXPECT_TRUE(std::get<0>(host_nav_params).page_state.IsValid());
676 677
677 const IPC::Message* frame_page_id_msg = 678 const IPC::Message* frame_page_id_msg =
678 render_thread_->sink().GetUniqueMessageMatching( 679 render_thread_->sink().GetUniqueMessageMatching(
679 FrameHostMsg_DidAssignPageId::ID); 680 FrameHostMsg_DidAssignPageId::ID);
680 EXPECT_TRUE(frame_page_id_msg); 681 EXPECT_TRUE(frame_page_id_msg);
681 682
682 FrameHostMsg_DidAssignPageId::Param host_page_id_params; 683 FrameHostMsg_DidAssignPageId::Param host_page_id_params;
683 FrameHostMsg_DidAssignPageId::Read(frame_page_id_msg, &host_page_id_params); 684 FrameHostMsg_DidAssignPageId::Read(frame_page_id_msg, &host_page_id_params);
684 685
685 EXPECT_EQ(base::get<0>(host_page_id_params), view_page_id()); 686 EXPECT_EQ(std::get<0>(host_page_id_params), view_page_id());
686 } 687 }
687 688
688 #if defined(OS_ANDROID) 689 #if defined(OS_ANDROID)
689 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { 690 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) {
690 CommonNavigationParams common_params; 691 CommonNavigationParams common_params;
691 common_params.url = GURL("data:text/html,"); 692 common_params.url = GURL("data:text/html,");
692 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 693 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
693 common_params.transition = ui::PAGE_TRANSITION_TYPED; 694 common_params.transition = ui::PAGE_TRANSITION_TYPED;
694 common_params.base_url_for_data_url = GURL("about:blank"); 695 common_params.base_url_for_data_url = GURL("about:blank");
695 common_params.history_url_for_data_url = GURL("about:blank"); 696 common_params.history_url_for_data_url = GURL("about:blank");
696 RequestNavigationParams request_params; 697 RequestNavigationParams request_params;
697 request_params.data_url_as_string = 698 request_params.data_url_as_string =
698 "data:text/html,<html><head><title>Data page</title></head></html>"; 699 "data:text/html,<html><head><title>Data page</title></head></html>";
699 700
700 frame()->Navigate(common_params, StartNavigationParams(), 701 frame()->Navigate(common_params, StartNavigationParams(),
701 request_params); 702 request_params);
702 const IPC::Message* frame_title_msg = nullptr; 703 const IPC::Message* frame_title_msg = nullptr;
703 do { 704 do {
704 ProcessPendingMessages(); 705 ProcessPendingMessages();
705 frame_title_msg = render_thread_->sink().GetUniqueMessageMatching( 706 frame_title_msg = render_thread_->sink().GetUniqueMessageMatching(
706 FrameHostMsg_UpdateTitle::ID); 707 FrameHostMsg_UpdateTitle::ID);
707 } while (!frame_title_msg); 708 } while (!frame_title_msg);
708 709
709 // Check post data sent to browser matches. 710 // Check post data sent to browser matches.
710 FrameHostMsg_UpdateTitle::Param title_params; 711 FrameHostMsg_UpdateTitle::Param title_params;
711 EXPECT_TRUE(FrameHostMsg_UpdateTitle::Read(frame_title_msg, &title_params)); 712 EXPECT_TRUE(FrameHostMsg_UpdateTitle::Read(frame_title_msg, &title_params));
712 EXPECT_EQ(base::ASCIIToUTF16("Data page"), base::get<0>(title_params)); 713 EXPECT_EQ(base::ASCIIToUTF16("Data page"), std::get<0>(title_params));
713 } 714 }
714 #endif 715 #endif
715 716
716 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { 717 TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
717 WebUITestWebUIControllerFactory factory; 718 WebUITestWebUIControllerFactory factory;
718 WebUIControllerFactory::RegisterFactory(&factory); 719 WebUIControllerFactory::RegisterFactory(&factory);
719 720
720 DocumentState state; 721 DocumentState state;
721 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); 722 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated());
722 723
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // Load page B, which will trigger an UpdateState message for page A. 1013 // Load page B, which will trigger an UpdateState message for page A.
1013 LoadHTML("<div>Page B</div>"); 1014 LoadHTML("<div>Page B</div>");
1014 1015
1015 // Check for a valid UpdateState message for page A. 1016 // Check for a valid UpdateState message for page A.
1016 ProcessPendingMessages(); 1017 ProcessPendingMessages();
1017 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( 1018 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
1018 ViewHostMsg_UpdateState::ID); 1019 ViewHostMsg_UpdateState::ID);
1019 ASSERT_TRUE(msg_A); 1020 ASSERT_TRUE(msg_A);
1020 ViewHostMsg_UpdateState::Param param; 1021 ViewHostMsg_UpdateState::Param param;
1021 ViewHostMsg_UpdateState::Read(msg_A, &param); 1022 ViewHostMsg_UpdateState::Read(msg_A, &param);
1022 int page_id_A = base::get<0>(param); 1023 int page_id_A = std::get<0>(param);
1023 PageState state_A = base::get<1>(param); 1024 PageState state_A = std::get<1>(param);
1024 EXPECT_EQ(1, page_id_A); 1025 EXPECT_EQ(1, page_id_A);
1025 render_thread_->sink().ClearMessages(); 1026 render_thread_->sink().ClearMessages();
1026 1027
1027 // Load page C, which will trigger an UpdateState message for page B. 1028 // Load page C, which will trigger an UpdateState message for page B.
1028 LoadHTML("<div>Page C</div>"); 1029 LoadHTML("<div>Page C</div>");
1029 1030
1030 // Check for a valid UpdateState for page B. 1031 // Check for a valid UpdateState for page B.
1031 ProcessPendingMessages(); 1032 ProcessPendingMessages();
1032 const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching( 1033 const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching(
1033 ViewHostMsg_UpdateState::ID); 1034 ViewHostMsg_UpdateState::ID);
1034 ASSERT_TRUE(msg_B); 1035 ASSERT_TRUE(msg_B);
1035 ViewHostMsg_UpdateState::Read(msg_B, &param); 1036 ViewHostMsg_UpdateState::Read(msg_B, &param);
1036 int page_id_B = base::get<0>(param); 1037 int page_id_B = std::get<0>(param);
1037 PageState state_B = base::get<1>(param); 1038 PageState state_B = std::get<1>(param);
1038 EXPECT_EQ(2, page_id_B); 1039 EXPECT_EQ(2, page_id_B);
1039 EXPECT_NE(state_A, state_B); 1040 EXPECT_NE(state_A, state_B);
1040 render_thread_->sink().ClearMessages(); 1041 render_thread_->sink().ClearMessages();
1041 1042
1042 // Load page D, which will trigger an UpdateState message for page C. 1043 // Load page D, which will trigger an UpdateState message for page C.
1043 LoadHTML("<div>Page D</div>"); 1044 LoadHTML("<div>Page D</div>");
1044 1045
1045 // Check for a valid UpdateState for page C. 1046 // Check for a valid UpdateState for page C.
1046 ProcessPendingMessages(); 1047 ProcessPendingMessages();
1047 const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching( 1048 const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching(
1048 ViewHostMsg_UpdateState::ID); 1049 ViewHostMsg_UpdateState::ID);
1049 ASSERT_TRUE(msg_C); 1050 ASSERT_TRUE(msg_C);
1050 ViewHostMsg_UpdateState::Read(msg_C, &param); 1051 ViewHostMsg_UpdateState::Read(msg_C, &param);
1051 int page_id_C = base::get<0>(param); 1052 int page_id_C = std::get<0>(param);
1052 PageState state_C = base::get<1>(param); 1053 PageState state_C = std::get<1>(param);
1053 EXPECT_EQ(3, page_id_C); 1054 EXPECT_EQ(3, page_id_C);
1054 EXPECT_NE(state_B, state_C); 1055 EXPECT_NE(state_B, state_C);
1055 render_thread_->sink().ClearMessages(); 1056 render_thread_->sink().ClearMessages();
1056 1057
1057 // Go back to C and commit, preparing for our real test. 1058 // Go back to C and commit, preparing for our real test.
1058 CommonNavigationParams common_params_C; 1059 CommonNavigationParams common_params_C;
1059 RequestNavigationParams request_params_C; 1060 RequestNavigationParams request_params_C;
1060 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1061 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1061 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 1062 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
1062 request_params_C.current_history_list_length = 4; 1063 request_params_C.current_history_list_length = 4;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 request_params.page_state = state_A; 1097 request_params.page_state = state_A;
1097 frame()->Navigate(common_params, StartNavigationParams(), request_params); 1098 frame()->Navigate(common_params, StartNavigationParams(), request_params);
1098 ProcessPendingMessages(); 1099 ProcessPendingMessages();
1099 1100
1100 // Now ensure that the UpdateState message we receive is consistent 1101 // Now ensure that the UpdateState message we receive is consistent
1101 // and represents page C in both page_id and state. 1102 // and represents page C in both page_id and state.
1102 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 1103 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
1103 ViewHostMsg_UpdateState::ID); 1104 ViewHostMsg_UpdateState::ID);
1104 ASSERT_TRUE(msg); 1105 ASSERT_TRUE(msg);
1105 ViewHostMsg_UpdateState::Read(msg, &param); 1106 ViewHostMsg_UpdateState::Read(msg, &param);
1106 int page_id = base::get<0>(param); 1107 int page_id = std::get<0>(param);
1107 PageState state = base::get<1>(param); 1108 PageState state = std::get<1>(param);
1108 EXPECT_EQ(page_id_C, page_id); 1109 EXPECT_EQ(page_id_C, page_id);
1109 EXPECT_NE(state_A, state); 1110 EXPECT_NE(state_A, state);
1110 EXPECT_NE(state_B, state); 1111 EXPECT_NE(state_B, state);
1111 EXPECT_EQ(state_C, state); 1112 EXPECT_EQ(state_C, state);
1112 } 1113 }
1113 1114
1114 // Test that our IME backend sends a notification message when the input focus 1115 // Test that our IME backend sends a notification message when the input focus
1115 // changes. 1116 // changes.
1116 TEST_F(RenderViewImplTest, OnImeTypeChanged) { 1117 TEST_F(RenderViewImplTest, OnImeTypeChanged) {
1117 // Load an HTML page consisting of two input fields. 1118 // Load an HTML page consisting of two input fields.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 render_thread_->sink().ClearMessages(); 1171 render_thread_->sink().ClearMessages();
1171 1172
1172 // Update the IME status and verify if our IME backend sends an IPC message 1173 // Update the IME status and verify if our IME backend sends an IPC message
1173 // to activate IMEs. 1174 // to activate IMEs.
1174 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 1175 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
1175 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); 1176 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
1176 EXPECT_TRUE(msg != NULL); 1177 EXPECT_TRUE(msg != NULL);
1177 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); 1178 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
1178 ViewHostMsg_TextInputStateChanged::Param params; 1179 ViewHostMsg_TextInputStateChanged::Param params;
1179 ViewHostMsg_TextInputStateChanged::Read(msg, &params); 1180 ViewHostMsg_TextInputStateChanged::Read(msg, &params);
1180 TextInputState p = base::get<0>(params); 1181 TextInputState p = std::get<0>(params);
1181 ui::TextInputType type = p.type; 1182 ui::TextInputType type = p.type;
1182 ui::TextInputMode input_mode = p.mode; 1183 ui::TextInputMode input_mode = p.mode;
1183 bool can_compose_inline = p.can_compose_inline; 1184 bool can_compose_inline = p.can_compose_inline;
1184 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); 1185 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type);
1185 EXPECT_EQ(true, can_compose_inline); 1186 EXPECT_EQ(true, can_compose_inline);
1186 1187
1187 // Move the input focus to the second <input> element, where we should 1188 // Move the input focus to the second <input> element, where we should
1188 // de-activate IMEs. 1189 // de-activate IMEs.
1189 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); 1190 ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
1190 ProcessPendingMessages(); 1191 ProcessPendingMessages();
1191 render_thread_->sink().ClearMessages(); 1192 render_thread_->sink().ClearMessages();
1192 1193
1193 // Update the IME status and verify if our IME backend sends an IPC message 1194 // Update the IME status and verify if our IME backend sends an IPC message
1194 // to de-activate IMEs. 1195 // to de-activate IMEs.
1195 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 1196 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
1196 msg = render_thread_->sink().GetMessageAt(0); 1197 msg = render_thread_->sink().GetMessageAt(0);
1197 EXPECT_TRUE(msg != NULL); 1198 EXPECT_TRUE(msg != NULL);
1198 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); 1199 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
1199 ViewHostMsg_TextInputStateChanged::Read(msg, &params); 1200 ViewHostMsg_TextInputStateChanged::Read(msg, &params);
1200 p = base::get<0>(params); 1201 p = std::get<0>(params);
1201 type = p.type; 1202 type = p.type;
1202 input_mode = p.mode; 1203 input_mode = p.mode;
1203 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); 1204 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type);
1204 1205
1205 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { 1206 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) {
1206 const InputModeTestCase* test_case = &kInputModeTestCases[i]; 1207 const InputModeTestCase* test_case = &kInputModeTestCases[i];
1207 std::string javascript = 1208 std::string javascript =
1208 base::StringPrintf("document.getElementById('%s').focus();", 1209 base::StringPrintf("document.getElementById('%s').focus();",
1209 test_case->input_id); 1210 test_case->input_id);
1210 // Move the input focus to the target <input> element, where we should 1211 // Move the input focus to the target <input> element, where we should
1211 // activate IMEs. 1212 // activate IMEs.
1212 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); 1213 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL);
1213 ProcessPendingMessages(); 1214 ProcessPendingMessages();
1214 render_thread_->sink().ClearMessages(); 1215 render_thread_->sink().ClearMessages();
1215 1216
1216 // Update the IME status and verify if our IME backend sends an IPC 1217 // Update the IME status and verify if our IME backend sends an IPC
1217 // message to activate IMEs. 1218 // message to activate IMEs.
1218 view()->UpdateTextInputState(ShowIme::HIDE_IME, 1219 view()->UpdateTextInputState(ShowIme::HIDE_IME,
1219 ChangeSource::FROM_NON_IME); 1220 ChangeSource::FROM_NON_IME);
1220 ProcessPendingMessages(); 1221 ProcessPendingMessages();
1221 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); 1222 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
1222 EXPECT_TRUE(msg != NULL); 1223 EXPECT_TRUE(msg != NULL);
1223 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); 1224 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
1224 ViewHostMsg_TextInputStateChanged::Read(msg, &params); 1225 ViewHostMsg_TextInputStateChanged::Read(msg, &params);
1225 p = base::get<0>(params); 1226 p = std::get<0>(params);
1226 type = p.type; 1227 type = p.type;
1227 input_mode = p.mode; 1228 input_mode = p.mode;
1228 EXPECT_EQ(test_case->expected_mode, input_mode); 1229 EXPECT_EQ(test_case->expected_mode, input_mode);
1229 } 1230 }
1230 } 1231 }
1231 } 1232 }
1232 1233
1233 // Test that our IME backend can compose CJK words. 1234 // Test that our IME backend can compose CJK words.
1234 // Our IME front-end sends many platform-independent messages to the IME backend 1235 // Our IME front-end sends many platform-independent messages to the IME backend
1235 // while it composes CJK words. This test sends the minimal messages captured 1236 // while it composes CJK words. This test sends the minimal messages captured
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 LoadHTML("<input id='test1' value='hello1'></input>" 1976 LoadHTML("<input id='test1' value='hello1'></input>"
1976 "<input id='test2' value='hello2'></input>"); 1977 "<input id='test2' value='hello2'></input>");
1977 1978
1978 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); 1979 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1979 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( 1980 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
1980 ViewHostMsg_FocusedNodeChanged::ID); 1981 ViewHostMsg_FocusedNodeChanged::ID);
1981 EXPECT_TRUE(msg1); 1982 EXPECT_TRUE(msg1);
1982 1983
1983 ViewHostMsg_FocusedNodeChanged::Param params; 1984 ViewHostMsg_FocusedNodeChanged::Param params;
1984 ViewHostMsg_FocusedNodeChanged::Read(msg1, &params); 1985 ViewHostMsg_FocusedNodeChanged::Read(msg1, &params);
1985 EXPECT_TRUE(base::get<0>(params)); 1986 EXPECT_TRUE(std::get<0>(params));
1986 render_thread_->sink().ClearMessages(); 1987 render_thread_->sink().ClearMessages();
1987 1988
1988 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); 1989 ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
1989 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( 1990 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
1990 ViewHostMsg_FocusedNodeChanged::ID); 1991 ViewHostMsg_FocusedNodeChanged::ID);
1991 EXPECT_TRUE(msg2); 1992 EXPECT_TRUE(msg2);
1992 ViewHostMsg_FocusedNodeChanged::Read(msg2, &params); 1993 ViewHostMsg_FocusedNodeChanged::Read(msg2, &params);
1993 EXPECT_TRUE(base::get<0>(params)); 1994 EXPECT_TRUE(std::get<0>(params));
1994 render_thread_->sink().ClearMessages(); 1995 render_thread_->sink().ClearMessages();
1995 1996
1996 view()->webview()->clearFocusedElement(); 1997 view()->webview()->clearFocusedElement();
1997 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( 1998 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
1998 ViewHostMsg_FocusedNodeChanged::ID); 1999 ViewHostMsg_FocusedNodeChanged::ID);
1999 EXPECT_TRUE(msg3); 2000 EXPECT_TRUE(msg3);
2000 ViewHostMsg_FocusedNodeChanged::Read(msg3, &params); 2001 ViewHostMsg_FocusedNodeChanged::Read(msg3, &params);
2001 EXPECT_FALSE(base::get<0>(params)); 2002 EXPECT_FALSE(std::get<0>(params));
2002 render_thread_->sink().ClearMessages(); 2003 render_thread_->sink().ClearMessages();
2003 } 2004 }
2004 2005
2005 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) { 2006 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) {
2006 ServiceWorkerNetworkProvider* provider = NULL; 2007 ServiceWorkerNetworkProvider* provider = NULL;
2007 RequestExtraData* extra_data = NULL; 2008 RequestExtraData* extra_data = NULL;
2008 2009
2009 // Make sure each new document has a new provider and 2010 // Make sure each new document has a new provider and
2010 // that the main request is tagged with the provider's id. 2011 // that the main request is tagged with the provider's id.
2011 LoadHTML("<b>A Document</b>"); 2012 LoadHTML("<b>A Document</b>");
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 base::TimeTicks lower_bound_navigation_start; 2092 base::TimeTicks lower_bound_navigation_start;
2092 frame()->GetWebFrame()->loadHTMLString( 2093 frame()->GetWebFrame()->loadHTMLString(
2093 "hello world", blink::WebURL(GURL("data:text/html,"))); 2094 "hello world", blink::WebURL(GURL("data:text/html,")));
2094 ProcessPendingMessages(); 2095 ProcessPendingMessages();
2095 const IPC::Message* frame_navigate_msg = 2096 const IPC::Message* frame_navigate_msg =
2096 render_thread_->sink().GetUniqueMessageMatching( 2097 render_thread_->sink().GetUniqueMessageMatching(
2097 FrameHostMsg_DidStartProvisionalLoad::ID); 2098 FrameHostMsg_DidStartProvisionalLoad::ID);
2098 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params; 2099 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params;
2099 FrameHostMsg_DidStartProvisionalLoad::Read(frame_navigate_msg, 2100 FrameHostMsg_DidStartProvisionalLoad::Read(frame_navigate_msg,
2100 &host_nav_params); 2101 &host_nav_params);
2101 base::TimeTicks transmitted_start = base::get<1>(host_nav_params); 2102 base::TimeTicks transmitted_start = std::get<1>(host_nav_params);
2102 EXPECT_FALSE(transmitted_start.is_null()); 2103 EXPECT_FALSE(transmitted_start.is_null());
2103 EXPECT_LT(lower_bound_navigation_start, transmitted_start); 2104 EXPECT_LT(lower_bound_navigation_start, transmitted_start);
2104 } 2105 }
2105 2106
2106 TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForReload) { 2107 TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForReload) {
2107 const char url_string[] = "data:text/html,<div>Page</div>"; 2108 const char url_string[] = "data:text/html,<div>Page</div>";
2108 // Navigate once, then reload. 2109 // Navigate once, then reload.
2109 LoadHTML(url_string); 2110 LoadHTML(url_string);
2110 ProcessPendingMessages(); 2111 ProcessPendingMessages();
2111 render_thread_->sink().ClearMessages(); 2112 render_thread_->sink().ClearMessages();
2112 2113
2113 CommonNavigationParams common_params; 2114 CommonNavigationParams common_params;
2114 common_params.url = GURL(url_string); 2115 common_params.url = GURL(url_string);
2115 common_params.navigation_type = 2116 common_params.navigation_type =
2116 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; 2117 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
2117 common_params.transition = ui::PAGE_TRANSITION_RELOAD; 2118 common_params.transition = ui::PAGE_TRANSITION_RELOAD;
2118 2119
2119 frame()->Navigate(common_params, StartNavigationParams(), 2120 frame()->Navigate(common_params, StartNavigationParams(),
2120 RequestNavigationParams()); 2121 RequestNavigationParams());
2121 2122
2122 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = 2123 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params =
2123 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); 2124 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>();
2124 // The true timestamp is later than the browser initiated one. 2125 // The true timestamp is later than the browser initiated one.
2125 EXPECT_PRED2(TimeTicksGT, base::get<1>(host_nav_params), 2126 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params),
2126 common_params.navigation_start); 2127 common_params.navigation_start);
2127 } 2128 }
2128 2129
2129 TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForHistoryNavigation) { 2130 TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForHistoryNavigation) {
2130 LoadHTML("<div id=pagename>Page A</div>"); 2131 LoadHTML("<div id=pagename>Page A</div>");
2131 LoadHTML("<div id=pagename>Page B</div>"); 2132 LoadHTML("<div id=pagename>Page B</div>");
2132 PageState back_state = GetCurrentPageState(); 2133 PageState back_state = GetCurrentPageState();
2133 LoadHTML("<div id=pagename>Page C</div>"); 2134 LoadHTML("<div id=pagename>Page C</div>");
2134 PageState forward_state = GetCurrentPageState(); 2135 PageState forward_state = GetCurrentPageState();
2135 ProcessPendingMessages(); 2136 ProcessPendingMessages();
2136 render_thread_->sink().ClearMessages(); 2137 render_thread_->sink().ClearMessages();
2137 2138
2138 // Go back. 2139 // Go back.
2139 CommonNavigationParams common_params_back; 2140 CommonNavigationParams common_params_back;
2140 common_params_back.url = 2141 common_params_back.url =
2141 GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"); 2142 GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>");
2142 common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 2143 common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
2143 GoToOffsetWithParams(-1, back_state, common_params_back, 2144 GoToOffsetWithParams(-1, back_state, common_params_back,
2144 StartNavigationParams(), RequestNavigationParams()); 2145 StartNavigationParams(), RequestNavigationParams());
2145 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = 2146 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params =
2146 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); 2147 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>();
2147 EXPECT_PRED2(TimeTicksGT, base::get<1>(host_nav_params), 2148 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params),
2148 common_params_back.navigation_start); 2149 common_params_back.navigation_start);
2149 render_thread_->sink().ClearMessages(); 2150 render_thread_->sink().ClearMessages();
2150 2151
2151 // Go forward. 2152 // Go forward.
2152 CommonNavigationParams common_params_forward; 2153 CommonNavigationParams common_params_forward;
2153 common_params_forward.url = 2154 common_params_forward.url =
2154 GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>"); 2155 GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>");
2155 common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK; 2156 common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
2156 GoToOffsetWithParams(1, forward_state, common_params_forward, 2157 GoToOffsetWithParams(1, forward_state, common_params_forward,
2157 StartNavigationParams(), RequestNavigationParams()); 2158 StartNavigationParams(), RequestNavigationParams());
2158 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 = 2159 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 =
2159 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); 2160 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>();
2160 EXPECT_PRED2(TimeTicksGT, base::get<1>(host_nav_params2), 2161 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params2),
2161 common_params_forward.navigation_start); 2162 common_params_forward.navigation_start);
2162 } 2163 }
2163 2164
2164 TEST_F(RenderViewImplTest, BrowserNavigationStartSuccessfullyTransmitted) { 2165 TEST_F(RenderViewImplTest, BrowserNavigationStartSuccessfullyTransmitted) {
2165 CommonNavigationParams common_params; 2166 CommonNavigationParams common_params;
2166 common_params.url = GURL("data:text/html,<div>Page</div>"); 2167 common_params.url = GURL("data:text/html,<div>Page</div>");
2167 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2168 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2168 common_params.transition = ui::PAGE_TRANSITION_TYPED; 2169 common_params.transition = ui::PAGE_TRANSITION_TYPED;
2169 2170
2170 frame()->Navigate(common_params, StartNavigationParams(), 2171 frame()->Navigate(common_params, StartNavigationParams(),
2171 RequestNavigationParams()); 2172 RequestNavigationParams());
2172 2173
2173 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = 2174 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params =
2174 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); 2175 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>();
2175 EXPECT_EQ(base::get<1>(host_nav_params), common_params.navigation_start); 2176 EXPECT_EQ(std::get<1>(host_nav_params), common_params.navigation_start);
2176 } 2177 }
2177 2178
2178 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { 2179 TEST_F(RenderViewImplTest, PreferredSizeZoomed) {
2179 LoadHTML("<body style='margin:0;'><div style='display:inline-block; " 2180 LoadHTML("<body style='margin:0;'><div style='display:inline-block; "
2180 "width:400px; height:400px;'/></body>"); 2181 "width:400px; height:400px;'/></body>");
2181 view()->webview()->mainFrame()->setCanHaveScrollbars(false); 2182 view()->webview()->mainFrame()->setCanHaveScrollbars(false);
2182 EnablePreferredSizeMode(); 2183 EnablePreferredSizeMode();
2183 2184
2184 gfx::Size size = GetPreferredSize(); 2185 gfx::Size size = GetPreferredSize();
2185 EXPECT_EQ(gfx::Size(400, 400), size); 2186 EXPECT_EQ(gfx::Size(400, 400), size);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 "," 2502 ","
2502 "\"functionDeclaration\":\"function foo(){ " 2503 "\"functionDeclaration\":\"function foo(){ "
2503 "Promise.resolve().then(() => " 2504 "Promise.resolve().then(() => "
2504 "console.log(239))}\"" 2505 "console.log(239))}\""
2505 "}" 2506 "}"
2506 "}"); 2507 "}");
2507 EXPECT_EQ(1, CountNotifications("Console.messageAdded")); 2508 EXPECT_EQ(1, CountNotifications("Console.messageAdded"));
2508 } 2509 }
2509 2510
2510 } // namespace content 2511 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/plugin_power_saver_helper_browsertest.cc ('k') | content/renderer/render_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698