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

Side by Side Diff: chrome/test/automation/automation_proxy_uitest.cc

Issue 5783004: Keep deinlining stuff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Well, it all compiles locally? Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 6
7 #include "app/app_switches.h" 7 #include "app/app_switches.h"
8 #include "app/message_box_flags.h" 8 #include "app/message_box_flags.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 "data:text/html,<html><head><title>External tab test</title></head>" 630 "data:text/html,<html><head><title>External tab test</title></head>"
631 "<body>A simple page for testing a floating/invisible tab<br></div>" 631 "<body>A simple page for testing a floating/invisible tab<br></div>"
632 "</body></html>"; 632 "</body></html>";
633 633
634 ExternalTabUITestMockClient::ExternalTabUITestMockClient(int execution_timeout) 634 ExternalTabUITestMockClient::ExternalTabUITestMockClient(int execution_timeout)
635 : AutomationProxy(execution_timeout, false), 635 : AutomationProxy(execution_timeout, false),
636 host_window_style_(WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE), 636 host_window_style_(WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE),
637 host_window_(NULL) { 637 host_window_(NULL) {
638 } 638 }
639 639
640 ExternalTabUITestMockClient::~ExternalTabUITestMockClient() {
641 EXPECT_TRUE(host_window_ == NULL);
642 }
643
640 void ExternalTabUITestMockClient::ReplyStarted( 644 void ExternalTabUITestMockClient::ReplyStarted(
641 const IPC::AutomationURLResponse* response, 645 const IPC::AutomationURLResponse* response,
642 int tab_handle, int request_id) { 646 int tab_handle, int request_id) {
643 AutomationProxy::Send(new AutomationMsg_RequestStarted(0, tab_handle, 647 AutomationProxy::Send(new AutomationMsg_RequestStarted(0, tab_handle,
644 request_id, *response)); 648 request_id, *response));
645 } 649 }
646 650
647 void ExternalTabUITestMockClient::ReplyData( 651 void ExternalTabUITestMockClient::ReplyData(
648 const std::string* data, int tab_handle, int request_id) { 652 const std::string* data, int tab_handle, int request_id) {
649 AutomationProxy::Send(new AutomationMsg_RequestData(0, tab_handle, 653 AutomationProxy::Send(new AutomationMsg_RequestData(0, tab_handle,
650 request_id, *data)); 654 request_id, *data));
651 } 655 }
652 656
653 void ExternalTabUITestMockClient::ReplyEOF(int tab_handle, int request_id) { 657 void ExternalTabUITestMockClient::ReplyEOF(int tab_handle, int request_id) {
654 ReplyEnd(URLRequestStatus(), tab_handle, request_id); 658 ReplyEnd(URLRequestStatus(), tab_handle, request_id);
655 } 659 }
656 660
657 void ExternalTabUITestMockClient::ReplyEnd(const URLRequestStatus& status, 661 void ExternalTabUITestMockClient::ReplyEnd(const URLRequestStatus& status,
658 int tab_handle, int request_id) { 662 int tab_handle, int request_id) {
659 AutomationProxy::Send(new AutomationMsg_RequestEnd(0, tab_handle, 663 AutomationProxy::Send(new AutomationMsg_RequestEnd(0, tab_handle,
660 request_id, status)); 664 request_id, status));
661 } 665 }
662 666
663 void ExternalTabUITestMockClient::Reply404(int tab_handle, int request_id) { 667 void ExternalTabUITestMockClient::Reply404(int tab_handle, int request_id) {
664 const IPC::AutomationURLResponse notfound = {"", "HTTP/1.1 404\r\n\r\n"}; 668 const IPC::AutomationURLResponse notfound("", "HTTP/1.1 404\r\n\r\n", 0,
669 base::Time(), "", 0);
665 ReplyStarted(&notfound, tab_handle, request_id); 670 ReplyStarted(&notfound, tab_handle, request_id);
666 ReplyEOF(tab_handle, request_id); 671 ReplyEOF(tab_handle, request_id);
667 } 672 }
668 673
669 void ExternalTabUITestMockClient::ServeHTMLData(int tab_handle, 674 void ExternalTabUITestMockClient::ServeHTMLData(int tab_handle,
670 const GURL& url, 675 const GURL& url,
671 const std::string& data) { 676 const std::string& data) {
672 EXPECT_CALL(*this, OnRequestStart(tab_handle, _, testing::AllOf( 677 EXPECT_CALL(*this, OnRequestStart(tab_handle, _, testing::AllOf(
673 testing::Field(&IPC::AutomationURLRequest::url, url.spec()), 678 testing::Field(&IPC::AutomationURLRequest::url, url.spec()),
674 testing::Field(&IPC::AutomationURLRequest::method, StrEq("GET"))))) 679 testing::Field(&IPC::AutomationURLRequest::method, StrEq("GET")))))
(...skipping 26 matching lines...) Expand all
701 void* iter = NULL; 706 void* iter = NULL;
702 int handle; 707 int handle;
703 ASSERT_TRUE(message.ReadInt(&iter, &handle)); 708 ASSERT_TRUE(message.ReadInt(&iter, &handle));
704 709
705 // Call base class 710 // Call base class
706 AutomationProxy::InvalidateHandle(message); 711 AutomationProxy::InvalidateHandle(message);
707 HandleClosed(handle); 712 HandleClosed(handle);
708 } 713 }
709 714
710 // Most of the time we need external tab with these settings. 715 // Most of the time we need external tab with these settings.
711 const IPC::ExternalTabSettings ExternalTabUITestMockClient::default_settings = { 716 const IPC::ExternalTabSettings ExternalTabUITestMockClient::default_settings(
712 NULL, gfx::Rect(), // will be replaced by CreateHostWindowAndTab 717 NULL, gfx::Rect(), // will be replaced by CreateHostWindowAndTab
713 WS_CHILD | WS_VISIBLE, 718 WS_CHILD | WS_VISIBLE,
714 false, // is_off_the_record 719 false, // is_off_the_record
715 true, // load_requests_via_automation 720 true, // load_requests_via_automation
716 true, // handle_top_level_requests 721 true, // handle_top_level_requests
717 GURL() // initial_url 722 GURL(), // initial_url
718 }; 723 GURL(), // referrer
724 false, // infobars_enabled
725 false); // route_all_top_level_navigations
719 726
720 // static 727 // static
721 const IPC::AutomationURLResponse ExternalTabUITestMockClient::http_200 = 728 const IPC::AutomationURLResponse ExternalTabUITestMockClient::http_200(
722 {"", "HTTP/0.9 200\r\n\r\n", }; 729 "",
730 "HTTP/0.9 200\r\n\r\n",
731 0,
732 base::Time(),
733 "",
734 0);
723 735
724 void ExternalTabUITestMockClient::OnMessageReceived(const IPC::Message& msg) { 736 void ExternalTabUITestMockClient::OnMessageReceived(const IPC::Message& msg) {
725 IPC_BEGIN_MESSAGE_MAP(ExternalTabUITestMockClient, msg) 737 IPC_BEGIN_MESSAGE_MAP(ExternalTabUITestMockClient, msg)
726 IPC_MESSAGE_HANDLER(AutomationMsg_DidNavigate, OnDidNavigate) 738 IPC_MESSAGE_HANDLER(AutomationMsg_DidNavigate, OnDidNavigate)
727 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardMessageToExternalHost, 739 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardMessageToExternalHost,
728 OnForwardMessageToExternalHost) 740 OnForwardMessageToExternalHost)
729 IPC_MESSAGE_HANDLER(AutomationMsg_RequestStart, OnRequestStart) 741 IPC_MESSAGE_HANDLER(AutomationMsg_RequestStart, OnRequestStart)
730 IPC_MESSAGE_HANDLER(AutomationMsg_RequestRead, OnRequestRead) 742 IPC_MESSAGE_HANDLER(AutomationMsg_RequestRead, OnRequestRead)
731 IPC_MESSAGE_HANDLER(AutomationMsg_RequestEnd, OnRequestEnd) 743 IPC_MESSAGE_HANDLER(AutomationMsg_RequestEnd, OnRequestEnd)
732 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookieAsync, OnSetCookieAsync) 744 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookieAsync, OnSetCookieAsync)
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1107
1096 // Flaky, http://crbug.com/61023. 1108 // Flaky, http://crbug.com/61023.
1097 TEST_F(ExternalTabUITest, FLAKY_HostNetworkStackAbortRequest) { 1109 TEST_F(ExternalTabUITest, FLAKY_HostNetworkStackAbortRequest) {
1098 scoped_refptr<TabProxy> tab; 1110 scoped_refptr<TabProxy> tab;
1099 TimedMessageLoopRunner loop(MessageLoop::current()); 1111 TimedMessageLoopRunner loop(MessageLoop::current());
1100 ASSERT_THAT(mock_, testing::NotNull()); 1112 ASSERT_THAT(mock_, testing::NotNull());
1101 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) 1113 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _))
1102 .Times(testing::AnyNumber()); 1114 .Times(testing::AnyNumber());
1103 1115
1104 std::string url = "http://placetogo.org"; 1116 std::string url = "http://placetogo.org";
1105 const IPC::AutomationURLResponse http_200 = {"", "HTTP/0.9 200\r\n\r\n", };
1106 1117
1107 testing::InSequence sequence; 1118 testing::InSequence sequence;
1108 EXPECT_CALL(*mock_, OnRequestStart(1, 2, testing::AllOf( 1119 EXPECT_CALL(*mock_, OnRequestStart(1, 2, testing::AllOf(
1109 testing::Field(&IPC::AutomationURLRequest::url, StrEq(url + "/")), 1120 testing::Field(&IPC::AutomationURLRequest::url, StrEq(url + "/")),
1110 testing::Field(&IPC::AutomationURLRequest::method, StrEq("GET"))))) 1121 testing::Field(&IPC::AutomationURLRequest::method, StrEq("GET")))))
1111 .Times(1) 1122 .Times(1)
1112 // We can simply do CreateFunctor(1, 2, &http_200) since we know the 1123 // We can simply do CreateFunctor(1, 2, &http_200) since we know the
1113 // tab handle and request id, but using WithArgs<> is much more fancy :) 1124 // tab handle and request id, but using WithArgs<> is much more fancy :)
1114 .WillOnce(testing::WithArgs<0, 1>(testing::Invoke(CreateFunctor(mock_, 1125 .WillOnce(testing::WithArgs<0, 1>(testing::Invoke(CreateFunctor(mock_,
1115 &ExternalTabUITestMockClient::ReplyStarted, &http_200)))); 1126 &ExternalTabUITestMockClient::ReplyStarted,
1127 &ExternalTabUITestMockClient::http_200))));
1116 1128
1117 // Return some trivial page, that have a link to a "logo.gif" image 1129 // Return some trivial page, that have a link to a "logo.gif" image
1118 const std::string data = "<!DOCTYPE html><title>Hello"; 1130 const std::string data = "<!DOCTYPE html><title>Hello";
1119 1131
1120 EXPECT_CALL(*mock_, OnRequestRead(1, 2, testing::Gt(0))) 1132 EXPECT_CALL(*mock_, OnRequestRead(1, 2, testing::Gt(0)))
1121 .Times(2) 1133 .Times(2)
1122 .WillOnce(testing::InvokeWithoutArgs(CreateFunctor(mock_, 1134 .WillOnce(testing::InvokeWithoutArgs(CreateFunctor(mock_,
1123 &ExternalTabUITestMockClient::ReplyData, &data, 1, 2))) 1135 &ExternalTabUITestMockClient::ReplyData, &data, 1, 2)))
1124 .WillOnce(testing::WithArgs<0, 1>( 1136 .WillOnce(testing::WithArgs<0, 1>(
1125 testing::InvokeWithoutArgs(CreateFunctor(mock_, 1137 testing::InvokeWithoutArgs(CreateFunctor(mock_,
(...skipping 12 matching lines...) Expand all
1138 // Flaky, http://crbug.com/61023. 1150 // Flaky, http://crbug.com/61023.
1139 TEST_F(ExternalTabUITest, FLAKY_HostNetworkStackUnresponsiveRenderer) { 1151 TEST_F(ExternalTabUITest, FLAKY_HostNetworkStackUnresponsiveRenderer) {
1140 scoped_refptr<TabProxy> tab; 1152 scoped_refptr<TabProxy> tab;
1141 TimedMessageLoopRunner loop(MessageLoop::current()); 1153 TimedMessageLoopRunner loop(MessageLoop::current());
1142 ASSERT_THAT(mock_, testing::NotNull()); 1154 ASSERT_THAT(mock_, testing::NotNull());
1143 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) 1155 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _))
1144 .Times(testing::AnyNumber()); 1156 .Times(testing::AnyNumber());
1145 EXPECT_CALL(*mock_, OnLoad(_, _)).Times(testing::AnyNumber()); 1157 EXPECT_CALL(*mock_, OnLoad(_, _)).Times(testing::AnyNumber());
1146 1158
1147 std::string url = "http://placetogo.org"; 1159 std::string url = "http://placetogo.org";
1148 const IPC::AutomationURLResponse http_200 = {"", "HTTP/0.9 200\r\n\r\n", };
1149 1160
1150 EXPECT_CALL(*mock_, OnRequestStart(1, 3, testing::_)) 1161 EXPECT_CALL(*mock_, OnRequestStart(1, 3, testing::_))
1151 .Times(testing::AnyNumber()); 1162 .Times(testing::AnyNumber());
1152 EXPECT_CALL(*mock_, OnDidNavigate(_, _)).Times(testing::AnyNumber()); 1163 EXPECT_CALL(*mock_, OnDidNavigate(_, _)).Times(testing::AnyNumber());
1153 1164
1154 testing::InSequence sequence; 1165 testing::InSequence sequence;
1155 EXPECT_CALL(*mock_, OnRequestStart(1, 2, testing::AllOf( 1166 EXPECT_CALL(*mock_, OnRequestStart(1, 2, testing::AllOf(
1156 testing::Field(&IPC::AutomationURLRequest::url, StrEq(url + "/")), 1167 testing::Field(&IPC::AutomationURLRequest::url, StrEq(url + "/")),
1157 testing::Field(&IPC::AutomationURLRequest::method, StrEq("GET"))))) 1168 testing::Field(&IPC::AutomationURLRequest::method, StrEq("GET")))))
1158 .Times(1) 1169 .Times(1)
1159 // We can simply do CreateFunctor(1, 2, &http_200) since we know the 1170 // We can simply do CreateFunctor(1, 2, &http_200) since we know the
1160 // tab handle and request id, but using WithArgs<> is much more fancy :) 1171 // tab handle and request id, but using WithArgs<> is much more fancy :)
1161 .WillOnce(testing::WithArgs<0, 1>(testing::Invoke(CreateFunctor(mock_, 1172 .WillOnce(testing::WithArgs<0, 1>(testing::Invoke(CreateFunctor(mock_,
1162 &ExternalTabUITestMockClient::ReplyStarted, &http_200)))); 1173 &ExternalTabUITestMockClient::ReplyStarted,
1174 &ExternalTabUITestMockClient::http_200))));
1163 1175
1164 const std::string head = "<html><title>Hello</title><body>"; 1176 const std::string head = "<html><title>Hello</title><body>";
1165 1177
1166 const std::string data = "<table border=\"1\"><tr><th>Month</th>" 1178 const std::string data = "<table border=\"1\"><tr><th>Month</th>"
1167 "<th>Savings</th></tr><tr><td>January</td>" 1179 "<th>Savings</th></tr><tr><td>January</td>"
1168 "<td>$100</td></tr><tr><td>February</td>" 1180 "<td>$100</td></tr><tr><td>February</td>"
1169 "<td>$100</td></tr><tr><td>March</td>" 1181 "<td>$100</td></tr><tr><td>March</td>"
1170 "<td>$100</td></tr><tr><td>April</td>" 1182 "<td>$100</td></tr><tr><td>April</td>"
1171 "<td>$100</td></tr><tr><td>May</td>" 1183 "<td>$100</td></tr><tr><td>May</td>"
1172 "<td>$100</td></tr><tr><td>June</td>" 1184 "<td>$100</td></tr><tr><td>June</td>"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 int diff_pixels_count = 0; 1709 int diff_pixels_count = 0;
1698 for (int x = 0; x < img_size.width(); ++x) { 1710 for (int x = 0; x < img_size.width(); ++x) {
1699 for (int y = 0; y < img_size.height(); ++y) { 1711 for (int y = 0; y < img_size.height(); ++y) {
1700 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) { 1712 if (*snapshot_bmp.getAddr32(x, y) != *reference_bmp.getAddr32(x, y)) {
1701 ++diff_pixels_count; 1713 ++diff_pixels_count;
1702 } 1714 }
1703 } 1715 }
1704 } 1716 }
1705 ASSERT_EQ(diff_pixels_count, 0); 1717 ASSERT_EQ(diff_pixels_count, 0);
1706 } 1718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698