| 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 10 matching lines...) Expand all Loading... |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 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/test_suite.h" | 32 #include "base/test_suite.h" |
| 32 #include "net/base/scoped_host_mapper.h" | 33 #include "net/base/host_resolver_unittest.h" |
| 33 | 34 |
| 34 class NetTestSuite : public TestSuite { | 35 class NetTestSuite : public TestSuite { |
| 35 public: | 36 public: |
| 36 NetTestSuite(int argc, char** argv) : TestSuite(argc, argv) { | 37 NetTestSuite(int argc, char** argv) |
| 38 : TestSuite(argc, argv), |
| 39 host_mapper_(new net::RuleBasedHostMapper()), |
| 40 scoped_host_mapper_(host_mapper_.get()) { |
| 37 // In case any attempts are made to resolve host names, force them all to | 41 // In case any attempts are made to resolve host names, force them all to |
| 38 // be mapped to localhost. This prevents DNS queries from being sent in | 42 // be mapped to localhost. This prevents DNS queries from being sent in |
| 39 // the process of running these unit tests. | 43 // the process of running these unit tests. |
| 40 host_mapper_.AddRule("*", "127.0.0.1"); | 44 host_mapper_->AddRule("*", "127.0.0.1"); |
| 41 } | 45 } |
| 42 | 46 |
| 43 virtual void Initialize() { | 47 virtual void Initialize() { |
| 44 TestSuite::Initialize(); | 48 TestSuite::Initialize(); |
| 45 | 49 |
| 46 message_loop_.reset(new MessageLoopForIO()); | 50 message_loop_.reset(new MessageLoopForIO()); |
| 47 } | 51 } |
| 48 | 52 |
| 49 virtual void Shutdown() { | 53 virtual void Shutdown() { |
| 50 // 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 |
| 51 // the environment. | 55 // the environment. |
| 52 message_loop_.reset(); | 56 message_loop_.reset(); |
| 53 | 57 |
| 54 TestSuite::Shutdown(); | 58 TestSuite::Shutdown(); |
| 55 } | 59 } |
| 56 | 60 |
| 57 private: | 61 private: |
| 58 scoped_ptr<MessageLoop> message_loop_; | 62 scoped_ptr<MessageLoop> message_loop_; |
| 59 net::ScopedHostMapper host_mapper_; | 63 scoped_refptr<net::RuleBasedHostMapper> host_mapper_; |
| 64 net::ScopedHostMapper scoped_host_mapper_; |
| 60 }; | 65 }; |
| 61 | 66 |
| 62 int main(int argc, char** argv) { | 67 int main(int argc, char** argv) { |
| 63 return NetTestSuite(argc, argv).Run(); | 68 return NetTestSuite(argc, argv).Run(); |
| 64 } | 69 } |
| OLD | NEW |