summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_resolver_v8_unittest.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-02 21:07:12 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-02 21:07:12 +0000
commit90ae1fb15d69378587f608f1bce437956b845a12 (patch)
tree7db5220f440e7b425cc67c2304b860494c1da72a /net/proxy/proxy_resolver_v8_unittest.cc
parentd5726c5273e71ae842c1d7136821210f2f691592 (diff)
downloadchromium_src-90ae1fb15d69378587f608f1bce437956b845a12.zip
chromium_src-90ae1fb15d69378587f608f1bce437956b845a12.tar.gz
chromium_src-90ae1fb15d69378587f608f1bce437956b845a12.tar.bz2
Rename ProxyResolverV8::JSBindings --> ProxyResolverJSBindings.
(Since it isn't really V8-specific, and could be re-used for impelmentations using a different JS engine). Review URL: http://codereview.chromium.org/159773 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_resolver_v8_unittest.cc')
-rw-r--r--net/proxy/proxy_resolver_v8_unittest.cc70
1 files changed, 3 insertions, 67 deletions
diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc
index db359a4..20d878b 100644
--- a/net/proxy/proxy_resolver_v8_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_unittest.cc
@@ -6,10 +6,10 @@
#include "base/string_util.h"
#include "base/path_service.h"
#include "googleurl/src/gurl.h"
-#include "net/base/mock_host_resolver.h"
#include "net/base/net_errors.h"
-#include "net/proxy/proxy_resolver_v8.h"
#include "net/proxy/proxy_info.h"
+#include "net/proxy/proxy_resolver_js_bindings.h"
+#include "net/proxy/proxy_resolver_v8.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -17,7 +17,7 @@ namespace {
// Javascript bindings for ProxyResolverV8, which returns mock values.
// Each time one of the bindings is called into, we push the input into a
// list, for later verification.
-class MockJSBindings : public net::ProxyResolverV8::JSBindings {
+class MockJSBindings : public net::ProxyResolverJSBindings {
public:
MockJSBindings() : my_ip_address_count(0) {}
@@ -376,67 +376,3 @@ TEST(ProxyResolverV8Test, V8Bindings) {
EXPECT_EQ(2, bindings->my_ip_address_count);
}
-TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
- // Get a hold of a DefaultJSBindings* (it is a hidden impl class).
- scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
- net::ProxyResolverV8::CreateDefaultBindings(
- new net::MockHostResolver, NULL));
-
- // Considered an error.
- EXPECT_EQ("", bindings->DnsResolve(""));
-
- const struct {
- const char* input;
- const char* expected;
- } tests[] = {
- {"www.google.com", "127.0.0.1"},
- {".", ""},
- {"foo@google.com", ""},
- {"@google.com", ""},
- {"foo:pass@google.com", ""},
- {"%", ""},
- {"www.google.com:80", ""},
- {"www.google.com:", ""},
- {"www.google.com.", ""},
- {"#", ""},
- {"127.0.0.1", ""},
- {"this has spaces", ""},
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- std::string actual = bindings->DnsResolve(tests[i].input);
-
- // ########################################################################
- // TODO(eroman)
- // ########################################################################
- // THIS TEST IS CURRENTLY FLAWED.
- //
- // Since we are running in unit-test mode, the HostResolve is using a
- // mock HostResolverProc, which will always return 127.0.0.1, without going
- // through the real codepaths.
- //
- // It is important that these tests be run with the real thing, since we
- // need to verify that HostResolver doesn't blow up when you send it
- // weird inputs. This is necessary since the data reach it is UNSANITIZED.
- // It comes directly from the PAC javascript.
- //
- // For now we just check that it maps to 127.0.0.1.
- std::string expected = tests[i].expected;
- if (expected == "")
- expected = "127.0.0.1";
- EXPECT_EQ(expected, actual);
- }
-}
-
-TEST(ProxyResolverV8DefaultBindingsTest, MyIpAddress) {
- // Get a hold of a DefaultJSBindings* (it is a hidden impl class).
- scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
- net::ProxyResolverV8::CreateDefaultBindings(
- new net::MockHostResolver, NULL));
-
- // Our IP address is always going to be 127.0.0.1, since we are using a
- // mock host resolver.
- std::string my_ip_address = bindings->MyIpAddress();
-
- EXPECT_EQ("127.0.0.1", my_ip_address);
-}