summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/SConscript35
-rw-r--r--net/base/data_url_unittest.cc16
-rw-r--r--net/base/escape_unittest.cc68
3 files changed, 66 insertions, 53 deletions
diff --git a/net/SConscript b/net/SConscript
index 4f8a739..b2dbea4 100644
--- a/net/SConscript
+++ b/net/SConscript
@@ -52,13 +52,20 @@ env.Append(
# These net files work on *all* platforms; files that don't work
# cross-platforom live below.
input_files = [
+ 'base/address_list.cc',
'base/auth_cache.cc',
'base/base64.cc',
'base/bzip2_filter.cc',
+ 'base/client_socket_handle.cc',
+ 'base/client_socket_pool.cc',
+ 'base/cookie_policy.cc',
+ 'base/data_url.cc',
+ 'base/escape.cc',
'base/filter.cc',
'base/gzip_filter.cc',
'base/gzip_header.cc',
'base/net_errors.cc',
+ 'base/net_module.cc',
'disk_cache/backend_impl.cc',
'disk_cache/block_files.cc',
'disk_cache/entry_impl.cc',
@@ -70,26 +77,24 @@ input_files = [
'disk_cache/rankings.cc',
'disk_cache/stats.cc',
'disk_cache/trace.cc',
+ 'http/http_chunked_decoder.cc',
+ 'http/http_util.cc',
+ 'url_request/url_request_error_job.cc',
+ 'url_request/url_request_job_metrics.cc',
+ 'url_request/url_request_job_tracker.cc',
]
if env['PLATFORM'] == 'win32':
input_files.extend([
- 'base/address_list.cc',
'base/client_socket_factory.cc',
- 'base/client_socket_handle.cc',
- 'base/client_socket_pool.cc',
'base/cookie_monster.cc',
- 'base/cookie_policy.cc',
- 'base/data_url.cc',
'base/directory_lister.cc',
'base/dns_resolution_observer.cc',
- 'base/escape.cc',
'base/ev_root_ca_metadata.cc',
'base/host_resolver.cc',
'base/listen_socket.cc',
'base/mime_sniffer.cc',
'base/mime_util.cc',
- 'base/net_module.cc',
'base/net_util.cc',
'base/platform_mime_util_win.cc',
'base/registry_controlled_domain.cc',
@@ -103,13 +108,11 @@ if env['PLATFORM'] == 'win32':
'base/winsock_init.cc',
'base/x509_certificate.cc',
'http/cert_status_cache.cc',
- 'http/http_chunked_decoder.cc',
'http/http_cache.cc',
'http/http_network_layer.cc',
'http/http_network_transaction.cc',
'http/http_response_headers.cc',
'http/http_transaction_winhttp.cc',
- 'http/http_util.cc',
'http/http_vary_data.cc',
'http/winhttp_request_throttle.cc',
'proxy/proxy_resolver_fixed.cc',
@@ -118,7 +121,6 @@ if env['PLATFORM'] == 'win32':
'url_request/mime_sniffer_proxy.cc',
'url_request/url_request.cc',
'url_request/url_request_about_job.cc',
- 'url_request/url_request_error_job.cc',
'url_request/url_request_file_dir_job.cc',
'url_request/url_request_file_job.cc',
'url_request/url_request_filter.cc',
@@ -127,8 +129,6 @@ if env['PLATFORM'] == 'win32':
'url_request/url_request_inet_job.cc',
'url_request/url_request_job.cc',
'url_request/url_request_job_manager.cc',
- 'url_request/url_request_job_metrics.cc',
- 'url_request/url_request_job_tracker.cc',
'url_request/url_request_simple_job.cc',
'url_request/url_request_test_job.cc',
'url_request/url_request_view_cache_job.cc',
@@ -147,6 +147,11 @@ if env['PLATFORM'] == 'win32':
'disk_cache/os_file_win.cc',
])
+if env['PLATFORM'] == 'darwin':
+ input_files.extend([
+ 'base/platform_mime_util_mac.cc',
+ ])
+
if env['PLATFORM'] in ('darwin', 'posix'):
input_files.extend([
'disk_cache/cache_util_posix.cc',
@@ -223,6 +228,9 @@ unittest_files = [
'base/auth_cache_unittest.cc',
'base/base64_unittest.cc',
'base/bzip2_filter_unittest.cc',
+ 'base/client_socket_pool_unittest.cc',
+ 'base/data_url_unittest.cc',
+ 'base/escape_unittest.cc',
'base/gzip_filter_unittest.cc',
'disk_cache/addr_unittest.cc',
'$BASE_DIR/run_all_unittests$OBJSUFFIX',
@@ -230,12 +238,9 @@ unittest_files = [
if env['PLATFORM'] == 'win32':
unittest_files.extend([
- 'base/client_socket_pool_unittest.cc',
'base/cookie_monster_unittest.cc',
'base/cookie_policy_unittest.cc',
- 'base/data_url_unittest.cc',
'base/directory_lister_unittest.cc',
- 'base/escape_unittest.cc',
'base/mime_sniffer_unittest.cc',
'base/mime_util_unittest.cc',
'base/net_util_unittest.cc',
diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc
index 3eae2d5..719fd83 100644
--- a/net/base/data_url_unittest.cc
+++ b/net/base/data_url_unittest.cc
@@ -34,19 +34,21 @@
namespace {
+ struct ParseTestData {
+ const char* url;
+ bool is_valid;
+ const char* mime_type;
+ const char* charset;
+ const char* data;
+ };
+
class DataURLTest : public testing::Test {
};
}
TEST(DataURLTest, Parse) {
- const struct {
- const char* url;
- bool is_valid;
- const char* mime_type;
- const char* charset;
- const char* data;
- } tests[] = {
+ const ParseTestData tests[] = {
{ "data:",
false,
"",
diff --git a/net/base/escape_unittest.cc b/net/base/escape_unittest.cc
index 53100a91..6a201d4 100644
--- a/net/base/escape_unittest.cc
+++ b/net/base/escape_unittest.cc
@@ -36,22 +36,48 @@
#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-struct unescape_case {
+namespace {
+
+struct EscapeCase {
+ const wchar_t* input;
+ const wchar_t* output;
+};
+
+struct UnescapeURLCase {
const char* input;
+ UnescapeRule::Type rules;
const char* output;
};
+struct UnescapeAndDecodeURLCase {
+ const char* encoding;
+ const char* input;
+
+ // The expected output when run through UnescapeURL.
+ const char* url_unescaped;
+
+ // The expected output when run through UnescapeQuery.
+ const char* query_unescaped;
+
+ // The expected output when run through UnescapeAndDecodeURLComponent.
+ const wchar_t* decoded;
+};
+
+struct EscapeForHTMLCase {
+ const char* input;
+ const char* expected_output;
+};
+
+}
+
TEST(Escape, EscapeTextForFormSubmission) {
- struct escape_case {
- const wchar_t* input;
- const wchar_t* output;
- } escape_cases[] = {
+ const EscapeCase escape_cases[] = {
{L"foo", L"foo"},
{L"foo bar", L"foo+bar"},
{L"foo++", L"foo%2B%2B"}
};
for (int i = 0; i < arraysize(escape_cases); ++i) {
- escape_case value = escape_cases[i];
+ EscapeCase value = escape_cases[i];
EXPECT_EQ(value.output, EscapeQueryParamValueUTF8(value.input));
}
@@ -72,9 +98,8 @@ TEST(Escape, EscapeTextForFormSubmission) {
EXPECT_EQ(out, std::string("+"));
} else if (no_escape.find(in) == std::string::npos) {
// Check %hex escaping
- char buf[4];
- sprintf_s(buf, 4, "%%%02X", i);
- EXPECT_EQ(std::string(buf), out);
+ std::string expected = StringPrintf("%%%02X", i);
+ EXPECT_EQ(expected, out);
} else {
// No change for things in the no_escape list.
EXPECT_EQ(out, in);
@@ -109,11 +134,7 @@ TEST(Escape, EscapePath) {
}
TEST(Escape, UnescapeURLComponent) {
- struct UnescapeCase {
- const char* input;
- UnescapeRule::Type rules;
- const char* output;
- } unescape_cases[] = {
+ const UnescapeURLCase unescape_cases[] = {
{"", UnescapeRule::NORMAL, ""},
{"%2", UnescapeRule::NORMAL, "%2"},
{"%%%%%%", UnescapeRule::NORMAL, "%%%%%%"},
@@ -162,19 +183,7 @@ TEST(Escape, UnescapeURLComponent) {
}
TEST(Escape, UnescapeAndDecodeURLComponent) {
- struct UnescapeCase {
- const char* encoding;
- const char* input;
-
- // The expected output when run through UnescapeURL.
- const char* url_unescaped;
-
- // The expected output when run through UnescapeQuery.
- const char* query_unescaped;
-
- // The expected output when run through UnescapeAndDecodeURLComponent.
- const wchar_t* decoded;
- } unescape_cases[] = {
+ const UnescapeAndDecodeURLCase unescape_cases[] = {
{"UTF8", "+", "+", " ", L"+"},
{"UTF8", "%2+", "%2+", "%2 ", L"%2+"},
{"UTF8", "+%%%+%%%", "+%%%+%%%", " %%% %%%", L"+%%%+%%%"},
@@ -226,10 +235,7 @@ TEST(Escape, UnescapeAndDecodeURLComponent) {
}
TEST(Escape, EscapeForHTML) {
- static const struct {
- const char* input;
- const char* expected_output;
- } tests[] = {
+ const EscapeForHTMLCase tests[] = {
{ "hello", "hello" },
{ "<hello>", "&lt;hello&gt;" },
{ "don\'t mess with me", "don&#39;t mess with me" },