Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: net/proxy/proxy_resolver_v8_unittest.cc

Issue 38001: Implement the PAC js-binding for "myIpAddress()". (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: update unittest for DnsResolve based on new empty string Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/proxy/proxy_resolver_v8.h" 10 #include "net/proxy/proxy_resolver_v8.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 // MyIpAddress was called two times. 374 // MyIpAddress was called two times.
375 EXPECT_EQ(2, bindings->my_ip_address_count); 375 EXPECT_EQ(2, bindings->my_ip_address_count);
376 } 376 }
377 377
378 TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) { 378 TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
379 // Get a hold of a DefaultJSBindings* (it is a hidden impl class). 379 // Get a hold of a DefaultJSBindings* (it is a hidden impl class).
380 net::ProxyResolverV8 resolver; 380 net::ProxyResolverV8 resolver;
381 net::ProxyResolverV8::JSBindings* bindings = resolver.js_bindings(); 381 net::ProxyResolverV8::JSBindings* bindings = resolver.js_bindings();
382 382
383 // Considered an error.
384 EXPECT_EQ("", bindings->DnsResolve(""));
385
383 const struct { 386 const struct {
384 const char* input; 387 const char* input;
385 const char* expected; 388 const char* expected;
386 } tests[] = { 389 } tests[] = {
387 {"www.google.com", "127.0.0.1"}, 390 {"www.google.com", "127.0.0.1"},
388 {"", ""},
389 {".", ""}, 391 {".", ""},
390 {"foo@google.com", ""}, 392 {"foo@google.com", ""},
391 {"@google.com", ""}, 393 {"@google.com", ""},
392 {"foo:pass@google.com", ""}, 394 {"foo:pass@google.com", ""},
393 {"%", ""}, 395 {"%", ""},
394 {"www.google.com:80", ""}, 396 {"www.google.com:80", ""},
395 {"www.google.com:", ""}, 397 {"www.google.com:", ""},
396 {"www.google.com.", ""}, 398 {"www.google.com.", ""},
397 {"#", ""}, 399 {"#", ""},
398 {"127.0.0.1", ""}, 400 {"127.0.0.1", ""},
(...skipping 18 matching lines...) Expand all
417 // It comes directly from the PAC javascript. 419 // It comes directly from the PAC javascript.
418 // 420 //
419 // For now we just check that it maps to 127.0.0.1. 421 // For now we just check that it maps to 127.0.0.1.
420 std::string expected = tests[i].expected; 422 std::string expected = tests[i].expected;
421 if (expected == "") 423 if (expected == "")
422 expected = "127.0.0.1"; 424 expected = "127.0.0.1";
423 EXPECT_EQ(expected, actual); 425 EXPECT_EQ(expected, actual);
424 } 426 }
425 } 427 }
426 428
429 TEST(ProxyResolverV8DefaultBindingsTest, MyIpAddress) {
430 // Get a hold of a DefaultJSBindings* (it is a hidden impl class).
431 net::ProxyResolverV8 resolver;
432 net::ProxyResolverV8::JSBindings* bindings = resolver.js_bindings();
433
434 // Our ip address is always going to be 127.0.0.1, since we are using a
435 // mock host mapper when running in unit-test mode.
436 std::string my_ip_address = bindings->MyIpAddress();
437
438 EXPECT_EQ("127.0.0.1", my_ip_address);
439 }
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698