Commit 75bdfb9c authored by dcheng@chromium.org's avatar dcheng@chromium.org

Cleanup: use base::StringPrintf instead of snprintf in WebTestProxy.

BUG=none

Review URL: https://codereview.chromium.org/408163002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284810 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a4aef47
......@@ -9,6 +9,7 @@
#include "base/callback_helpers.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h"
#include "content/shell/renderer/test_runner/SpellCheckClient.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
......@@ -114,12 +115,10 @@ void PrintResponseDescription(WebTestDelegate* delegate,
delegate->printMessage("(null)");
return;
}
std::string url = response.url().spec();
char data[100];
snprintf(data, sizeof(data), "%d", response.httpStatusCode());
delegate->printMessage(std::string("<NSURLResponse ") +
DescriptionSuitableForTestResult(url) +
", http status code " + data + ">");
delegate->printMessage(base::StringPrintf(
"<NSURLResponse %s, http status code %d>",
DescriptionSuitableForTestResult(response.url().spec()).c_str(),
response.httpStatusCode()));
}
std::string URLDescription(const GURL& url) {
......@@ -286,10 +285,8 @@ std::string DumpFrameScrollPosition(blink::WebFrame* frame, bool recursive) {
result =
std::string("frame '") + frame->uniqueName().utf8().data() + "' ";
}
char data[100];
snprintf(
data, sizeof(data), "scrolled to %d,%d\n", offset.width, offset.height);
result += data;
base::StringAppendF(
&result, "scrolled to %d,%d\n", offset.width, offset.height);
}
if (!recursive)
......@@ -964,12 +961,8 @@ void WebTestProxyBase::DidFinishDocumentLoad(blink::WebLocalFrame* frame) {
unsigned pendingUnloadEvents = frame->unloadListenerCount();
if (pendingUnloadEvents) {
PrintFrameDescription(delegate_, frame);
char buffer[100];
snprintf(buffer,
sizeof(buffer),
" - has %u onunload handler(s)\n",
pendingUnloadEvents);
delegate_->printMessage(buffer);
delegate_->printMessage(base::StringPrintf(
" - has %u onunload handler(s)\n", pendingUnloadEvents));
}
}
}
......@@ -1136,13 +1129,10 @@ void WebTestProxyBase::DidChangeResourcePriority(
delegate_->printMessage("<unknown>");
else
delegate_->printMessage(resource_identifier_map_[identifier]);
delegate_->printMessage(" changed priority to ");
delegate_->printMessage(PriorityDescription(priority));
char buffer[64];
snprintf(
buffer, sizeof(buffer), ", intra_priority %d", intra_priority_value);
delegate_->printMessage(buffer);
delegate_->printMessage("\n");
delegate_->printMessage(
base::StringPrintf(" changed priority to %s, intra_priority %d\n",
PriorityDescription(priority).c_str(),
intra_priority_value));
}
}
......@@ -1186,9 +1176,7 @@ void WebTestProxyBase::DidAddMessageToConsole(
}
delegate_->printMessage(std::string("CONSOLE ") + level + ": ");
if (source_line) {
char buffer[40];
snprintf(buffer, sizeof(buffer), "line %d: ", source_line);
delegate_->printMessage(buffer);
delegate_->printMessage(base::StringPrintf("line %d: ", source_line));
}
if (!message.text.isEmpty()) {
std::string new_message;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment