Commit 5ecf7cb2 authored by mmenke@chromium.org's avatar mmenke@chromium.org

Make it possible to build cronet without icu.

BUG=362608

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269687 0039d316-1c4b-4281-b951-d872f2087c98
parent b1a64b4d
......@@ -89,7 +89,17 @@
'-landroid',
'-Wl,--gc-sections',
'-Wl,--exclude-libs,ALL'
]
],
'conditions': [
[ 'use_icu_alternatives_on_android == 1', {
'dependencies!': [
'../base/base.gyp:base_i18n',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
]
},
],
],
},
{
'target_name': 'cronet',
......
......@@ -6,12 +6,15 @@
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
#include "components/cronet/android/org_chromium_net_UrlRequest.h"
#include "components/cronet/android/org_chromium_net_UrlRequestContext.h"
#include "net/android/net_jni_registrar.h"
#include "url/android/url_jni_registrar.h"
#if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
#include "base/i18n/icu_util.h"
#endif
namespace {
const base::android::RegistrationMethod kCronetRegisteredMethods[] = {
......@@ -42,7 +45,9 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
g_at_exit_manager = new base::AtExitManager();
#if !defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
base::i18n::InitializeICU();
#endif
return JNI_VERSION_1_6;
}
......
......@@ -15,7 +15,7 @@
#include "net/cert/x509_util_android.h"
#include "net/proxy/proxy_config_service_android.h"
#if defined(USE_ICU_ALTERNATIVES)
#if defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
#include "net/base/net_string_util_icu_alternatives_android.h"
#endif
......@@ -32,7 +32,7 @@ static base::android::RegistrationMethod kNetRegisteredMethods[] = {
net::NetworkChangeNotifierAndroid::Register },
{ "ProxyConfigService", net::ProxyConfigServiceAndroid::Register },
{ "X509Util", net::RegisterX509Util },
#if defined(USE_ICU_ALTERNATIVES)
#if defined(USE_ICU_ALTERNATIVES_ON_ANDROID)
{ "NetStringUtils", net::RegisterNetStringUtils }
#endif
};
......
This diff is collapsed.
This diff is collapsed.
......@@ -439,8 +439,15 @@
},
],
[ 'use_icu_alternatives_on_android == 1', {
'dependencies!': [
'../base/base.gyp:base_i18n',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
],
'sources!': [
'base/filename_util_icu.cc',
'base/net_string_util_icu.cc',
'base/net_util_icu.cc',
],
'sources': [
'base/net_string_util_icu_alternatives_android.cc',
......@@ -641,7 +648,10 @@
],
},
],
[ 'use_v8_in_net==1', {
# Always need use_v8_in_net to be 1 to run gyp on Android, so just
# remove net_unittest's dependency on v8 when using icu alternatives
# instead of setting use_v8_in_net to 0.
[ 'use_v8_in_net==1 and use_icu_alternatives_on_android==0', {
'dependencies': [
'net_with_v8',
],
......@@ -749,10 +759,22 @@
},
],
['OS == "android" and gtest_target_type == "shared_library"', {
# TODO(mmenke): This depends on test_support_base, which depends on
# icu. Figure out a way to remove that dependency.
'dependencies': [
'../testing/android/native_test.gyp:native_test_native_code',
]
}],
[ 'use_icu_alternatives_on_android == 1', {
'dependencies!': [
'../base/base.gyp:base_i18n',
],
'sources!': [
'base/filename_util_unittest.cc',
'base/net_util_icu_unittest.cc',
],
},
],
],
'target_conditions': [
# These source files are excluded by default platform rules, but they
......@@ -823,6 +845,8 @@
],
'export_dependent_settings': [
'../base/base.gyp:base',
# TODO(mmenke): This depends on icu, figure out a way to build tests
# without icu.
'../base/base.gyp:test_support_base',
'../testing/gtest.gyp:gtest',
'../testing/gmock.gyp:gmock',
......
......@@ -1250,6 +1250,7 @@
'base/net_log_unittest.cc',
'base/net_log_unittest.h',
'base/net_util_unittest.cc',
'base/net_util_icu_unittest.cc',
'base/network_change_notifier_win_unittest.cc',
'base/prioritized_dispatcher_unittest.cc',
'base/priority_queue_unittest.cc',
......
......@@ -91,6 +91,7 @@ class RequestContext : public URLRequestContext {
URLRequestContextStorage storage_;
};
#if !defined(DISABLE_FILE_SUPPORT)
// Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest.
GURL GetTestFileUrl(const std::string& relpath) {
base::FilePath path;
......@@ -101,6 +102,7 @@ GURL GetTestFileUrl(const std::string& relpath) {
GURL base_url = FilePathToFileURL(path);
return GURL(base_url.spec() + "/" + relpath);
}
#endif // !defined(DISABLE_FILE_SUPPORT)
// Really simple NetworkDelegate so we can allow local file access on ChromeOS
// without introducing layering violations. Also causes a test failure if a
......@@ -352,7 +354,9 @@ TEST_F(ProxyScriptFetcherImplTest, TooLarge) {
// These two URLs are the same file, but are http:// vs file://
GURL urls[] = {
test_server_.GetURL("files/large-pac.nsproxy"),
#if !defined(DISABLE_FILE_SUPPORT)
GetTestFileUrl("large-pac.nsproxy")
#endif
};
// Try fetching URLs that are 101 bytes large. We should abort the request
......
......@@ -30,7 +30,6 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/capturing_net_log.h"
#include "net/base/filename_util.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
#include "net/base/load_timing_info_test_util.h"
......@@ -77,6 +76,7 @@
#include "testing/platform_test.h"
#if !defined(DISABLE_FILE_SUPPORT)
#include "net/base/filename_util.h"
#include "net/url_request/file_protocol_handler.h"
#include "net/url_request/url_request_file_dir_job.h"
#endif
......@@ -697,6 +697,7 @@ TEST_F(URLRequestTest, DataURLImageTest) {
}
}
#if !defined(DISABLE_FILE_SUPPORT)
TEST_F(URLRequestTest, FileTest) {
base::FilePath app_path;
PathService::Get(base::FILE_EXE, &app_path);
......@@ -895,80 +896,6 @@ TEST_F(URLRequestTest, AllowFileURLs) {
}
}
TEST_F(URLRequestTest, InvalidUrlTest) {
TestDelegate d;
{
URLRequest r(GURL("invalid url"), DEFAULT_PRIORITY, &d, &default_context_);
r.Start();
EXPECT_TRUE(r.is_pending());
base::RunLoop().Run();
EXPECT_TRUE(d.request_failed());
}
}
#if defined(OS_WIN)
TEST_F(URLRequestTest, ResolveShortcutTest) {
base::FilePath app_path;
PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
app_path = app_path.AppendASCII("net");
app_path = app_path.AppendASCII("data");
app_path = app_path.AppendASCII("url_request_unittest");
app_path = app_path.AppendASCII("with-headers.html");
std::wstring lnk_path = app_path.value() + L".lnk";
base::win::ScopedCOMInitializer com_initializer;
// Temporarily create a shortcut for test
{
base::win::ScopedComPtr<IShellLink> shell;
ASSERT_TRUE(SUCCEEDED(shell.CreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER)));
base::win::ScopedComPtr<IPersistFile> persist;
ASSERT_TRUE(SUCCEEDED(shell.QueryInterface(persist.Receive())));
EXPECT_TRUE(SUCCEEDED(shell->SetPath(app_path.value().c_str())));
EXPECT_TRUE(SUCCEEDED(shell->SetDescription(L"ResolveShortcutTest")));
EXPECT_TRUE(SUCCEEDED(persist->Save(lnk_path.c_str(), TRUE)));
}
TestDelegate d;
{
URLRequest r(FilePathToFileURL(base::FilePath(lnk_path)),
DEFAULT_PRIORITY,
&d,
&default_context_);
r.Start();
EXPECT_TRUE(r.is_pending());
base::RunLoop().Run();
WIN32_FILE_ATTRIBUTE_DATA data;
GetFileAttributesEx(app_path.value().c_str(),
GetFileExInfoStandard, &data);
HANDLE file = CreateFile(app_path.value().c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
EXPECT_NE(INVALID_HANDLE_VALUE, file);
scoped_ptr<char[]> buffer(new char[data.nFileSizeLow]);
DWORD read_size;
BOOL result;
result = ReadFile(file, buffer.get(), data.nFileSizeLow,
&read_size, NULL);
std::string content(buffer.get(), read_size);
CloseHandle(file);
EXPECT_TRUE(!r.is_pending());
EXPECT_EQ(1, d.received_redirect_count());
EXPECT_EQ(content, d.data_received());
}
// Clean the shortcut
DeleteFile(lnk_path.c_str());
}
#endif // defined(OS_WIN)
TEST_F(URLRequestTest, FileDirCancelTest) {
// Put in mock resource provider.
......@@ -1067,7 +994,84 @@ TEST_F(URLRequestTest, FileDirRedirectSingleSlash) {
ASSERT_EQ(1, d.received_redirect_count());
ASSERT_FALSE(req.status().is_success());
}
#endif
#endif // defined(OS_WIN)
#endif // !defined(DISABLE_FILE_SUPPORT)
TEST_F(URLRequestTest, InvalidUrlTest) {
TestDelegate d;
{
URLRequest r(GURL("invalid url"), DEFAULT_PRIORITY, &d, &default_context_);
r.Start();
EXPECT_TRUE(r.is_pending());
base::RunLoop().Run();
EXPECT_TRUE(d.request_failed());
}
}
#if defined(OS_WIN)
TEST_F(URLRequestTest, ResolveShortcutTest) {
base::FilePath app_path;
PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
app_path = app_path.AppendASCII("net");
app_path = app_path.AppendASCII("data");
app_path = app_path.AppendASCII("url_request_unittest");
app_path = app_path.AppendASCII("with-headers.html");
std::wstring lnk_path = app_path.value() + L".lnk";
base::win::ScopedCOMInitializer com_initializer;
// Temporarily create a shortcut for test
{
base::win::ScopedComPtr<IShellLink> shell;
ASSERT_TRUE(SUCCEEDED(shell.CreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER)));
base::win::ScopedComPtr<IPersistFile> persist;
ASSERT_TRUE(SUCCEEDED(shell.QueryInterface(persist.Receive())));
EXPECT_TRUE(SUCCEEDED(shell->SetPath(app_path.value().c_str())));
EXPECT_TRUE(SUCCEEDED(shell->SetDescription(L"ResolveShortcutTest")));
EXPECT_TRUE(SUCCEEDED(persist->Save(lnk_path.c_str(), TRUE)));
}
TestDelegate d;
{
URLRequest r(FilePathToFileURL(base::FilePath(lnk_path)),
DEFAULT_PRIORITY,
&d,
&default_context_);
r.Start();
EXPECT_TRUE(r.is_pending());
base::RunLoop().Run();
WIN32_FILE_ATTRIBUTE_DATA data;
GetFileAttributesEx(app_path.value().c_str(),
GetFileExInfoStandard, &data);
HANDLE file = CreateFile(app_path.value().c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
EXPECT_NE(INVALID_HANDLE_VALUE, file);
scoped_ptr<char[]> buffer(new char[data.nFileSizeLow]);
DWORD read_size;
BOOL result;
result = ReadFile(file, buffer.get(), data.nFileSizeLow,
&read_size, NULL);
std::string content(buffer.get(), read_size);
CloseHandle(file);
EXPECT_TRUE(!r.is_pending());
EXPECT_EQ(1, d.received_redirect_count());
EXPECT_EQ(content, d.data_received());
}
// Clean the shortcut
DeleteFile(lnk_path.c_str());
}
#endif // defined(OS_WIN)
// Custom URLRequestJobs for use with interceptor tests
class RestartTestJob : public URLRequestTestJob {
......
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