OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/memory/ref_counted.h" | |
6 #include "chrome/browser/extensions/extension_apitest.h" | |
7 #include "extensions/browser/api/dns/host_resolver_wrapper.h" | |
8 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" | |
9 #include "net/dns/mock_host_resolver.h" | |
10 | |
11 class DnsApiTest : public ExtensionApiTest { | |
12 public: | |
13 DnsApiTest() : resolver_creator_(new extensions::MockHostResolverCreator()) {} | |
14 | |
15 private: | |
16 virtual void SetUpOnMainThread() OVERRIDE { | |
17 ExtensionApiTest::SetUpOnMainThread(); | |
18 extensions::HostResolverWrapper::GetInstance()->SetHostResolverForTesting( | |
19 resolver_creator_->CreateMockHostResolver()); | |
20 } | |
21 | |
22 virtual void TearDownOnMainThread() OVERRIDE { | |
23 extensions::HostResolverWrapper::GetInstance()-> | |
24 SetHostResolverForTesting(NULL); | |
25 resolver_creator_->DeleteMockHostResolver(); | |
26 ExtensionApiTest::TearDownOnMainThread(); | |
27 } | |
28 | |
29 // The MockHostResolver asserts that it's used on the same thread on which | |
30 // it's created, which is actually a stronger rule than its real counterpart. | |
31 // But that's fine; it's good practice. | |
32 scoped_refptr<extensions::MockHostResolverCreator> resolver_creator_; | |
33 }; | |
34 | |
35 IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsExtension) { | |
36 ASSERT_TRUE(RunExtensionTest("dns/api")) << message_; | |
37 } | |
OLD | NEW |