Remove usage of base::StringPrintf in unit tests (issue #1632)
This commit is contained in:
parent
03f3900d75
commit
9ed17519a9
|
@ -4,10 +4,9 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/stringprintf.h"
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_weak_ptr.h"
|
||||
#include "include/cef_v8.h"
|
||||
|
@ -94,11 +93,10 @@ class MRRenderDelegate : public ClientAppRenderer::Delegate {
|
|||
}
|
||||
|
||||
if (expected_count != actual_count) {
|
||||
const std::string& exceptionStr =
|
||||
base::StringPrintf("%s failed; expected %d, got %d",
|
||||
message_name.c_str(), expected_count,
|
||||
actual_count);
|
||||
exception = exceptionStr;
|
||||
std::stringstream ss;
|
||||
ss << message_name << " failed; expected " << expected_count <<
|
||||
", got " << actual_count;
|
||||
exception = ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,8 +437,9 @@ class SingleQueryTestHandler : public SingleLoadTestHandler {
|
|||
std::string GetMainHTML() override {
|
||||
std::string html;
|
||||
|
||||
const std::string& errorCodeStr =
|
||||
base::StringPrintf("%d", kSingleQueryErrorCode);
|
||||
std::stringstream ss;
|
||||
ss << kSingleQueryErrorCode;
|
||||
const std::string& errorCodeStr = ss.str();
|
||||
|
||||
html = "<html><body><script>\n"
|
||||
// No requests should exist.
|
||||
|
@ -668,10 +667,12 @@ class SinglePersistentQueryTestHandler : public SingleLoadTestHandler {
|
|||
std::string GetMainHTML() override {
|
||||
std::string html;
|
||||
|
||||
const std::string& responseCountStr =
|
||||
base::StringPrintf("%d", kSinglePersistentQueryResponseCount);
|
||||
const std::string& errorCodeStr =
|
||||
base::StringPrintf("%d", kSingleQueryErrorCode);
|
||||
std::stringstream ss;
|
||||
ss << kSinglePersistentQueryResponseCount;
|
||||
const std::string& responseCountStr = ss.str();
|
||||
ss.str("");
|
||||
ss << kSingleQueryErrorCode;
|
||||
const std::string& errorCodeStr = ss.str();
|
||||
|
||||
html = "<html><body><script>\n"
|
||||
// No requests should exist.
|
||||
|
@ -1674,7 +1675,9 @@ class MultiQueryManager : public CefMessageRouterBrowserSide::Handler {
|
|||
|
||||
std::string GetIDString(const std::string& prefix, int index) const {
|
||||
EXPECT_TRUE(!prefix.empty());
|
||||
return base::StringPrintf("%s%d", prefix.c_str(), GetIDFromIndex(index));
|
||||
std::stringstream ss;
|
||||
ss << prefix << GetIDFromIndex(index);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool SplitIDString(const std::string& str,
|
||||
|
@ -1691,7 +1694,9 @@ class MultiQueryManager : public CefMessageRouterBrowserSide::Handler {
|
|||
}
|
||||
|
||||
std::string GetIntString(int val) const {
|
||||
return base::StringPrintf("%d", val);
|
||||
std::stringstream ss;
|
||||
ss << val;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
int GetIDFromIndex(int index) const { return id_offset_ + index; }
|
||||
|
@ -2010,8 +2015,9 @@ class MultiQueryMultiHandlerTestHandler :
|
|||
bool persistent,
|
||||
CefRefPtr<Callback> callback) override {
|
||||
// Each handler only handles a single request.
|
||||
const std::string& handled_request =
|
||||
base::StringPrintf("%s:%d", kMultiQueryRequest, index_);
|
||||
std::stringstream ss;
|
||||
ss << kMultiQueryRequest << ":" << index_;
|
||||
const std::string& handled_request = ss.str();
|
||||
if (request != handled_request)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
// can be found in the LICENSE file.
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/stringprintf.h"
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
|
@ -99,10 +98,13 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
same_origin_(same_origin) {}
|
||||
|
||||
void SetupTest() override {
|
||||
url1_ = base::StringPrintf("%snav1.html?t=%d",
|
||||
kNetNotifyOrigin1, test_type_);
|
||||
url2_ = base::StringPrintf("%snav2.html?t=%d",
|
||||
same_origin_ ? kNetNotifyOrigin1 : kNetNotifyOrigin2, test_type_);
|
||||
std::stringstream ss;
|
||||
ss << kNetNotifyOrigin1 << "nav1.html?t=" << test_type_;
|
||||
url1_ = ss.str();
|
||||
ss.str("");
|
||||
ss << (same_origin_ ? kNetNotifyOrigin1 : kNetNotifyOrigin2) <<
|
||||
"nav2.html?t=" << test_type_;
|
||||
url2_ = ss.str();
|
||||
|
||||
cookie_manager_ = CefCookieManager::CreateManager(CefString(), true, NULL);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
|
@ -289,9 +288,9 @@ class RequestSchemeHandler : public CefResourceHandler {
|
|||
settings_.response->GetHeaderMap(headerMap);
|
||||
|
||||
if (settings_.expect_save_cookie) {
|
||||
std::string cookie = base::StringPrintf("%s=%s", kRequestSaveCookieName,
|
||||
"save-cookie-value");
|
||||
headerMap.insert(std::make_pair("Set-Cookie", cookie));
|
||||
std::stringstream ss;
|
||||
ss << kRequestSaveCookieName << "=" << "save-cookie-value";
|
||||
headerMap.insert(std::make_pair("Set-Cookie", ss.str()));
|
||||
}
|
||||
|
||||
response->SetHeaderMap(headerMap);
|
||||
|
@ -868,7 +867,9 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
|||
|
||||
// Return an appropriate scheme URL for the specified |path|.
|
||||
std::string MakeSchemeURL(const std::string& path) {
|
||||
return base::StringPrintf("%s/%s", kRequestOrigin, path.c_str());
|
||||
std::stringstream ss;
|
||||
ss << kRequestOrigin << "/" << path;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// Add a scheme handler for the current test. Called during test setup.
|
||||
|
|
Loading…
Reference in New Issue