OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const std::string kHostname = "127.0.0.1"; | 35 const std::string kHostname = "127.0.0.1"; |
36 const int kPort = 8888; | 36 const int kPort = 8888; |
37 | 37 |
38 class SocketsUdpApiTest : public ExtensionApiTest { | 38 class SocketsUdpApiTest : public ExtensionApiTest { |
39 public: | 39 public: |
40 SocketsUdpApiTest() : resolver_event_(true, false), | 40 SocketsUdpApiTest() : resolver_event_(true, false), |
41 resolver_creator_( | 41 resolver_creator_( |
42 new extensions::MockHostResolverCreator()) { | 42 new extensions::MockHostResolverCreator()) { |
43 } | 43 } |
44 | 44 |
45 virtual void SetUpOnMainThread() OVERRIDE { | 45 virtual void SetUpOnMainThread() override { |
46 extensions::HostResolverWrapper::GetInstance()->SetHostResolverForTesting( | 46 extensions::HostResolverWrapper::GetInstance()->SetHostResolverForTesting( |
47 resolver_creator_->CreateMockHostResolver()); | 47 resolver_creator_->CreateMockHostResolver()); |
48 } | 48 } |
49 | 49 |
50 virtual void TearDownOnMainThread() OVERRIDE { | 50 virtual void TearDownOnMainThread() override { |
51 extensions::HostResolverWrapper::GetInstance()-> | 51 extensions::HostResolverWrapper::GetInstance()-> |
52 SetHostResolverForTesting(NULL); | 52 SetHostResolverForTesting(NULL); |
53 resolver_creator_->DeleteMockHostResolver(); | 53 resolver_creator_->DeleteMockHostResolver(); |
54 } | 54 } |
55 | 55 |
56 private: | 56 private: |
57 base::WaitableEvent resolver_event_; | 57 base::WaitableEvent resolver_event_; |
58 | 58 |
59 // The MockHostResolver asserts that it's used on the same thread on which | 59 // The MockHostResolver asserts that it's used on the same thread on which |
60 // it's created, which is actually a stronger rule than its real counterpart. | 60 // it's created, which is actually a stronger rule than its real counterpart. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 extensions::ResultCatcher catcher; | 96 extensions::ResultCatcher catcher; |
97 catcher.RestrictToBrowserContext(browser()->profile()); | 97 catcher.RestrictToBrowserContext(browser()->profile()); |
98 ExtensionTestMessageListener listener("info_please", true); | 98 ExtensionTestMessageListener listener("info_please", true); |
99 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); | 99 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); |
100 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 100 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
101 listener.Reply( | 101 listener.Reply( |
102 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); | 102 base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort)); |
103 | 103 |
104 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 104 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
105 } | 105 } |
OLD | NEW |