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

Side by Side Diff: webkit/tools/test_shell/test_webview_delegate.cc

Issue 255024: Make dumpResourceLoadCallbacks() show relative paths which match the results ... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « webkit/tools/layout_tests/test_expectations.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This file contains the implementation of TestWebViewDelegate, which serves 5 // This file contains the implementation of TestWebViewDelegate, which serves
6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to
7 // have initialized a MessageLoop before these methods are called. 7 // have initialized a MessageLoop before these methods are called.
8 8
9 #include "config.h" 9 #include "config.h"
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (url.empty() || std::string::npos == url.find("file://")) 115 if (url.empty() || std::string::npos == url.find("file://"))
116 return url; 116 return url;
117 117
118 std::string filename = 118 std::string filename =
119 WideToUTF8(file_util::GetFilenameFromPath(UTF8ToWide(url))); 119 WideToUTF8(file_util::GetFilenameFromPath(UTF8ToWide(url)));
120 if (filename.empty()) 120 if (filename.empty())
121 return "file:"; // A WebKit test has this in its expected output. 121 return "file:"; // A WebKit test has this in its expected output.
122 return filename; 122 return filename;
123 } 123 }
124 124
125 // Used to write a platform neutral file:/// URL by taking the
126 // filename and its directory. (e.g., converts
127 // "file:///tmp/foo/bar.txt" to just "bar.txt").
128 std::string DescriptionSuitableForTestResult(const std::string& url) {
129 if (url.empty() || std::string::npos == url.find("file://"))
130 return url;
131
132 size_t pos = url.rfind('/');
133 if (pos == std::string::npos || pos == 0)
134 return "ERROR:" + url;
135 pos = url.rfind('/', pos - 1);
136 if (pos == std::string::npos)
137 return "ERROR:" + url;
138
139 return url.substr(pos + 1);
140 }
141
125 // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake 142 // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake
126 // dragging a file. 143 // dragging a file.
127 void AddDRTFakeFileToDataObject(WebDragData* drag_data) { 144 void AddDRTFakeFileToDataObject(WebDragData* drag_data) {
128 drag_data->appendToFileNames(WebString::fromUTF8("DRTFakeFile")); 145 drag_data->appendToFileNames(WebString::fromUTF8("DRTFakeFile"));
129 } 146 }
130 147
131 // Get a debugging string from a WebNavigationType. 148 // Get a debugging string from a WebNavigationType.
132 const char* WebNavigationTypeToString(WebNavigationType type) { 149 const char* WebNavigationTypeToString(WebNavigationType type) {
133 switch (type) { 150 switch (type) {
134 case WebKit::WebNavigationTypeLinkClicked: 151 case WebKit::WebNavigationTypeLinkClicked:
(...skipping 16 matching lines...) Expand all
151 if (url.SchemeIs("file")) 168 if (url.SchemeIs("file"))
152 return url.ExtractFileName(); 169 return url.ExtractFileName();
153 170
154 return url.possibly_invalid_spec(); 171 return url.possibly_invalid_spec();
155 } 172 }
156 173
157 std::string GetResponseDescription(const WebURLResponse& response) { 174 std::string GetResponseDescription(const WebURLResponse& response) {
158 if (response.isNull()) 175 if (response.isNull())
159 return "(null)"; 176 return "(null)";
160 177
178 const std::string url = GURL(response.url()).possibly_invalid_spec();
161 return StringPrintf("<NSURLResponse %s, http status code %d>", 179 return StringPrintf("<NSURLResponse %s, http status code %d>",
162 GURL(response.url()).possibly_invalid_spec().c_str(), 180 DescriptionSuitableForTestResult(url).c_str(),
163 response.httpStatusCode()); 181 response.httpStatusCode());
164 } 182 }
165 183
166 std::string GetErrorDescription(const WebURLError& error) { 184 std::string GetErrorDescription(const WebURLError& error) {
167 std::string domain = UTF16ToASCII(error.domain); 185 std::string domain = UTF16ToASCII(error.domain);
168 int code = error.reason; 186 int code = error.reason;
169 187
170 if (domain == net::kErrorDomain) { 188 if (domain == net::kErrorDomain) {
171 domain = "NSURLErrorDomain"; 189 domain = "NSURLErrorDomain";
172 switch (error.reason) { 190 switch (error.reason) {
173 case net::ERR_ABORTED: 191 case net::ERR_ABORTED:
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (shell_->ShouldDumpFrameLoadCallbacks()) { 812 if (shell_->ShouldDumpFrameLoadCallbacks()) {
795 printf("%S - didChangeLocationWithinPageForFrame\n", 813 printf("%S - didChangeLocationWithinPageForFrame\n",
796 GetFrameDescription(frame).c_str()); 814 GetFrameDescription(frame).c_str());
797 } 815 }
798 816
799 UpdateForCommittedLoad(frame, is_new_navigation); 817 UpdateForCommittedLoad(frame, is_new_navigation);
800 } 818 }
801 819
802 void TestWebViewDelegate::assignIdentifierToRequest( 820 void TestWebViewDelegate::assignIdentifierToRequest(
803 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { 821 WebFrame* frame, unsigned identifier, const WebURLRequest& request) {
804 if (shell_->ShouldDumpResourceLoadCallbacks()) 822 if (shell_->ShouldDumpResourceLoadCallbacks()) {
805 resource_identifier_map_[identifier] = request.url().spec(); 823 resource_identifier_map_[identifier] =
824 DescriptionSuitableForTestResult(request.url().spec());
825 }
806 } 826 }
807 827
808 void TestWebViewDelegate::willSendRequest( 828 void TestWebViewDelegate::willSendRequest(
809 WebFrame* frame, unsigned identifier, WebURLRequest& request, 829 WebFrame* frame, unsigned identifier, WebURLRequest& request,
810 const WebURLResponse& redirect_response) { 830 const WebURLResponse& redirect_response) {
811 GURL url = request.url(); 831 GURL url = request.url();
812 std::string request_url = url.possibly_invalid_spec(); 832 std::string request_url = url.possibly_invalid_spec();
813 833
814 if (shell_->ShouldDumpResourceLoadCallbacks()) { 834 if (shell_->ShouldDumpResourceLoadCallbacks()) {
815 GURL main_document_url = request.firstPartyForCookies(); 835 GURL main_document_url = request.firstPartyForCookies();
816 printf("%s - willSendRequest <NSURLRequest URL %s, main document URL %s," 836 printf("%s - willSendRequest <NSURLRequest URL %s, main document URL %s,"
817 " http method %s> redirectResponse %s\n", 837 " http method %s> redirectResponse %s\n",
818 GetResourceDescription(identifier).c_str(), 838 GetResourceDescription(identifier).c_str(),
819 request_url.c_str(), 839 DescriptionSuitableForTestResult(request_url).c_str(),
820 GetURLDescription(main_document_url).c_str(), 840 GetURLDescription(main_document_url).c_str(),
821 request.httpMethod().utf8().data(), 841 request.httpMethod().utf8().data(),
822 GetResponseDescription(redirect_response).c_str()); 842 GetResponseDescription(redirect_response).c_str());
823 } 843 }
824 844
825 if (!redirect_response.isNull() && block_redirects_) { 845 if (!redirect_response.isNull() && block_redirects_) {
826 printf("Returning null for this redirect\n"); 846 printf("Returning null for this redirect\n");
827 847
828 // To block the request, we set its URL to an empty one. 848 // To block the request, we set its URL to an empty one.
829 request.setURL(WebURL()); 849 request.setURL(WebURL());
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 } 1102 }
1083 1103
1084 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { 1104 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) {
1085 fake_rect_ = rect; 1105 fake_rect_ = rect;
1086 using_fake_rect_ = true; 1106 using_fake_rect_ = true;
1087 } 1107 }
1088 1108
1089 WebRect TestWebViewDelegate::fake_window_rect() { 1109 WebRect TestWebViewDelegate::fake_window_rect() {
1090 return fake_rect_; 1110 return fake_rect_;
1091 } 1111 }
OLDNEW
« no previous file with comments | « webkit/tools/layout_tests/test_expectations.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698