| OLD | NEW |
| 1 // Copyright 2008, Google Inc. | 1 // Copyright 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 #include "base/message_loop.h" | 30 #include "base/message_loop.h" |
| 31 #include "base/ref_counted.h" | 31 #include "base/ref_counted.h" |
| 32 #include "base/test_suite.h" | 32 #include "base/test_suite.h" |
| 33 #include "net/base/host_resolver_unittest.h" | 33 #include "net/base/mock_host_resolver.h" |
| 34 | 34 |
| 35 class NetTestSuite : public TestSuite { | 35 class NetTestSuite : public TestSuite { |
| 36 public: | 36 public: |
| 37 NetTestSuite(int argc, char** argv) : TestSuite(argc, argv) { | 37 NetTestSuite(int argc, char** argv) : TestSuite(argc, argv) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual void Initialize() { | 40 virtual void Initialize() { |
| 41 TestSuite::Initialize(); | 41 TestSuite::Initialize(); |
| 42 | 42 |
| 43 host_mapper_ = new net::RuleBasedHostMapper(); | 43 host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL); |
| 44 scoped_host_mapper_.Init(host_mapper_.get()); | 44 scoped_host_resolver_proc_.Init(host_resolver_proc_.get()); |
| 45 // In case any attempts are made to resolve host names, force them all to | 45 // In case any attempts are made to resolve host names, force them all to |
| 46 // be mapped to localhost. This prevents DNS queries from being sent in | 46 // be mapped to localhost. This prevents DNS queries from being sent in |
| 47 // the process of running these unit tests. | 47 // the process of running these unit tests. |
| 48 host_mapper_->AddRule("*", "127.0.0.1"); | 48 host_resolver_proc_->AddRule("*", "127.0.0.1"); |
| 49 | 49 |
| 50 message_loop_.reset(new MessageLoopForIO()); | 50 message_loop_.reset(new MessageLoopForIO()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual void Shutdown() { | 53 virtual void Shutdown() { |
| 54 // We want to destroy this here before the TestSuite continues to tear down | 54 // We want to destroy this here before the TestSuite continues to tear down |
| 55 // the environment. | 55 // the environment. |
| 56 message_loop_.reset(); | 56 message_loop_.reset(); |
| 57 | 57 |
| 58 TestSuite::Shutdown(); | 58 TestSuite::Shutdown(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 scoped_ptr<MessageLoop> message_loop_; | 62 scoped_ptr<MessageLoop> message_loop_; |
| 63 scoped_refptr<net::RuleBasedHostMapper> host_mapper_; | 63 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; |
| 64 net::ScopedHostMapper scoped_host_mapper_; | 64 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 int main(int argc, char** argv) { | 67 int main(int argc, char** argv) { |
| 68 return NetTestSuite(argc, argv).Run(); | 68 return NetTestSuite(argc, argv).Run(); |
| 69 } | 69 } |
| OLD | NEW |