| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/custom_handlers/protocol_handler_registry.h" | 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/custom_handlers/protocol_handler.h" | 14 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "chrome/test/base/testing_browser_process_test.h" | |
| 17 #include "chrome/test/base/testing_pref_service.h" | 16 #include "chrome/test/base/testing_pref_service.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 20 #include "content/browser/renderer_host/test_render_view_host.h" | 19 #include "content/browser/renderer_host/test_render_view_host.h" |
| 21 #include "content/common/notification_observer.h" | 20 #include "content/common/notification_observer.h" |
| 22 #include "content/common/notification_registrar.h" | 21 #include "content/common/notification_registrar.h" |
| 23 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 24 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 25 | 24 |
| 26 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { | 25 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 std::vector<std::string> output; | 179 std::vector<std::string> output; |
| 181 registry_->GetRegisteredProtocols(&output); | 180 registry_->GetRegisteredProtocols(&output); |
| 182 called_ = true; | 181 called_ = true; |
| 183 } | 182 } |
| 184 | 183 |
| 185 ProtocolHandlerRegistry* registry_; | 184 ProtocolHandlerRegistry* registry_; |
| 186 bool called_; | 185 bool called_; |
| 187 NotificationRegistrar notification_registrar_; | 186 NotificationRegistrar notification_registrar_; |
| 188 }; | 187 }; |
| 189 | 188 |
| 190 class ProtocolHandlerRegistryTest : public TestingBrowserProcessTest { | 189 class ProtocolHandlerRegistryTest : public testing::Test { |
| 191 protected: | 190 protected: |
| 192 ProtocolHandlerRegistryTest() | 191 ProtocolHandlerRegistryTest() |
| 193 : test_protocol_handler_(CreateProtocolHandler("test", "test")) {} | 192 : test_protocol_handler_(CreateProtocolHandler("test", "test")) {} |
| 194 | 193 |
| 195 FakeDelegate* delegate() const { return delegate_; } | 194 FakeDelegate* delegate() const { return delegate_; } |
| 196 TestingProfile* profile() const { return profile_.get(); } | 195 TestingProfile* profile() const { return profile_.get(); } |
| 197 PrefService* pref_service() const { return profile_->GetPrefs(); } | 196 PrefService* pref_service() const { return profile_->GetPrefs(); } |
| 198 ProtocolHandlerRegistry* registry() const { return registry_.get(); } | 197 ProtocolHandlerRegistry* registry() const { return registry_.get(); } |
| 199 const ProtocolHandler& test_protocol_handler() const { | 198 const ProtocolHandler& test_protocol_handler() const { |
| 200 return test_protocol_handler_; | 199 return test_protocol_handler_; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 } | 664 } |
| 666 | 665 |
| 667 TEST_F(ProtocolHandlerRegistryTest, TestLoadEnabledGetsPropogatedToIO) { | 666 TEST_F(ProtocolHandlerRegistryTest, TestLoadEnabledGetsPropogatedToIO) { |
| 668 registry()->Disable(); | 667 registry()->Disable(); |
| 669 ReloadProtocolHandlerRegistry(); | 668 ReloadProtocolHandlerRegistry(); |
| 670 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 669 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 671 NewRunnableFunction(QuitUILoop)); | 670 NewRunnableFunction(QuitUILoop)); |
| 672 MessageLoop::current()->Run(); | 671 MessageLoop::current()->Run(); |
| 673 ASSERT_FALSE(enabled_io()); | 672 ASSERT_FALSE(enabled_io()); |
| 674 } | 673 } |
| OLD | NEW |