| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 7 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
| 8 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" | 8 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" |
| 9 #include "chrome/browser/extensions/api/socket/socket_api.h" | 9 #include "chrome/browser/extensions/api/socket/socket_api.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 // We need this while the socket.{listen,accept} methods require the | 37 // We need this while the socket.{listen,accept} methods require the |
| 38 // enable-experimental-extension-apis flag. After that we should remove it, | 38 // enable-experimental-extension-apis flag. After that we should remove it, |
| 39 // as well as the "experimental" permission in the test apps' manifests. | 39 // as well as the "experimental" permission in the test apps' manifests. |
| 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 41 ExtensionApiTest::SetUpCommandLine(command_line); | 41 ExtensionApiTest::SetUpCommandLine(command_line); |
| 42 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 42 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 43 } | 43 } |
| 44 | 44 |
| 45 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 void CleanUpOnMainThread() OVERRIDE { | 50 virtual void CleanUpOnMainThread() 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 LoadExtension(test_data_dir_.AppendASCII("socket/unload")); | 192 LoadExtension(test_data_dir_.AppendASCII("socket/unload")); |
| 193 ASSERT_TRUE(extension); | 193 ASSERT_TRUE(extension); |
| 194 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 194 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 195 | 195 |
| 196 UnloadExtension(extension->id()); | 196 UnloadExtension(extension->id()); |
| 197 | 197 |
| 198 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/unload"))) | 198 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/unload"))) |
| 199 << message_; | 199 << message_; |
| 200 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 200 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 201 } | 201 } |
| OLD | NEW |