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