| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
| 9 #include "content/public/test/test_utils.h" | 9 #include "content/public/test/test_utils.h" |
| 10 #include "extensions/browser/api/dns/dns_api.h" | 10 #include "extensions/browser/api/dns/dns_api.h" |
| 11 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | 11 #include "extensions/browser/api/dns/host_resolver_wrapper.h" |
| 12 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" | 12 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" |
| 13 #include "extensions/browser/api_test_utils.h" | 13 #include "extensions/browser/api_test_utils.h" |
| 14 #include "extensions/browser/notification_types.h" | 14 #include "extensions/browser/notification_types.h" |
| 15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/test_util.h" | 16 #include "extensions/common/test_util.h" |
| 17 #include "extensions/shell/test/shell_apitest.h" | 17 #include "extensions/shell/test/shell_apitest.h" |
| 18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 | 19 |
| 20 using extensions::api_test_utils::RunFunctionAndReturnSingleResult; | 20 using extensions::api_test_utils::RunFunctionAndReturnSingleResult; |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 class DnsApiTest : public ShellApiTest { | 24 class DnsApiTest : public ShellApiTest { |
| 25 public: | 25 public: |
| 26 DnsApiTest() : resolver_creator_(new MockHostResolverCreator()) {} | 26 DnsApiTest() : resolver_creator_(new MockHostResolverCreator()) {} |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 virtual void SetUpOnMainThread() OVERRIDE { | 29 virtual void SetUpOnMainThread() override { |
| 30 ShellApiTest::SetUpOnMainThread(); | 30 ShellApiTest::SetUpOnMainThread(); |
| 31 HostResolverWrapper::GetInstance()->SetHostResolverForTesting( | 31 HostResolverWrapper::GetInstance()->SetHostResolverForTesting( |
| 32 resolver_creator_->CreateMockHostResolver()); | 32 resolver_creator_->CreateMockHostResolver()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void TearDownOnMainThread() OVERRIDE { | 35 virtual void TearDownOnMainThread() override { |
| 36 HostResolverWrapper::GetInstance()->SetHostResolverForTesting(NULL); | 36 HostResolverWrapper::GetInstance()->SetHostResolverForTesting(NULL); |
| 37 resolver_creator_->DeleteMockHostResolver(); | 37 resolver_creator_->DeleteMockHostResolver(); |
| 38 ShellApiTest::TearDownOnMainThread(); | 38 ShellApiTest::TearDownOnMainThread(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // The MockHostResolver asserts that it's used on the same thread on which | 41 // The MockHostResolver asserts that it's used on the same thread on which |
| 42 // it's created, which is actually a stronger rule than its real counterpart. | 42 // it's created, which is actually a stronger rule than its real counterpart. |
| 43 // But that's fine; it's good practice. | 43 // But that's fine; it's good practice. |
| 44 scoped_refptr<MockHostResolverCreator> resolver_creator_; | 44 scoped_refptr<MockHostResolverCreator> resolver_creator_; |
| 45 }; | 45 }; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 std::string address; | 87 std::string address; |
| 88 EXPECT_TRUE(dict->GetString("address", &address)); | 88 EXPECT_TRUE(dict->GetString("address", &address)); |
| 89 EXPECT_EQ(MockHostResolverCreator::kAddress, address); | 89 EXPECT_EQ(MockHostResolverCreator::kAddress, address); |
| 90 } | 90 } |
| 91 | 91 |
| 92 IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsExtension) { | 92 IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsExtension) { |
| 93 ASSERT_TRUE(RunAppTest("api_test/dns/api")) << message_; | 93 ASSERT_TRUE(RunAppTest("api_test/dns/api")) << message_; |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace extensions | 96 } // namespace extensions |
| OLD | NEW |