| Index: chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
|
| diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
|
| index 5613be78f7f0d066e1ec5896a57a1b040e614247..feef4cf77e75227e9c0301aba7dda6870003f405 100644
|
| --- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
|
| +++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
|
| @@ -16,6 +16,7 @@
|
| #include "content/common/notification_registrar.h"
|
| #include "content/common/notification_service.h"
|
|
|
| +
|
| class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
|
| public:
|
| virtual ~FakeDelegate() { }
|
| @@ -141,6 +142,13 @@ TEST_F(ProtocolHandlerRegistryTest,
|
| ASSERT_FALSE(registry()->CanSchemeBeOverridden("test"));
|
| }
|
|
|
| +TEST_F(ProtocolHandlerRegistryTest, RemovingHandlerMeansItCanBeAddedAgain) {
|
| + registry()->OnAcceptRegisterProtocolHandler(test_protocol_handler());
|
| + ASSERT_TRUE(registry()->CanSchemeBeOverridden("test"));
|
| + registry()->RemoveHandler(test_protocol_handler());
|
| + ASSERT_TRUE(registry()->CanSchemeBeOverridden("test"));
|
| +}
|
| +
|
| TEST_F(ProtocolHandlerRegistryTest, TestStartsAsDefault) {
|
| registry()->OnAcceptRegisterProtocolHandler(test_protocol_handler());
|
| ASSERT_TRUE(registry()->IsDefault(test_protocol_handler()));
|
| @@ -159,9 +167,10 @@ TEST_F(ProtocolHandlerRegistryTest, TestClearDefault) {
|
| registry()->OnAcceptRegisterProtocolHandler(ph1);
|
| registry()->OnAcceptRegisterProtocolHandler(ph2);
|
|
|
| - registry()->SetDefault(ph2);
|
| + registry()->SetDefault(ph1);
|
| registry()->ClearDefault("test");
|
| - ASSERT_FALSE(registry()->IsDefault(ph2));
|
| + ASSERT_FALSE(registry()->IsDefault(ph1));
|
| + ASSERT_TRUE(registry()->IsDefault(ph2));
|
| }
|
|
|
| TEST_F(ProtocolHandlerRegistryTest, TestGetHandlerFor) {
|
| @@ -175,13 +184,13 @@ TEST_F(ProtocolHandlerRegistryTest, TestGetHandlerFor) {
|
| ASSERT_TRUE(registry()->HasDefault("test"));
|
| }
|
|
|
| -TEST_F(ProtocolHandlerRegistryTest, TestMultipleHandlersClearsDefault) {
|
| +TEST_F(ProtocolHandlerRegistryTest, TestMostRecentHandlerIsDefault) {
|
| ProtocolHandler ph1 = CreateProtocolHandler("test", "test1");
|
| ProtocolHandler ph2 = CreateProtocolHandler("test", "test2");
|
| registry()->OnAcceptRegisterProtocolHandler(ph1);
|
| registry()->OnAcceptRegisterProtocolHandler(ph2);
|
| ASSERT_FALSE(registry()->IsDefault(ph1));
|
| - ASSERT_FALSE(registry()->IsDefault(ph2));
|
| + ASSERT_TRUE(registry()->IsDefault(ph2));
|
| }
|
|
|
| TEST_F(ProtocolHandlerRegistryTest, TestSetDefault) {
|
| @@ -220,7 +229,7 @@ TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandler) {
|
|
|
| registry()->RemoveHandler(ph1);
|
| ASSERT_FALSE(registry()->IsRegistered(ph1));
|
| - ASSERT_FALSE(registry()->HasHandler("test"));
|
| + ASSERT_FALSE(registry()->IsHandledProtocol("test"));
|
| }
|
|
|
| TEST_F(ProtocolHandlerRegistryTest, TestIsRegistered) {
|
| @@ -236,6 +245,7 @@ TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandlerRemovesDefault) {
|
| ProtocolHandler ph1 = CreateProtocolHandler("test", "test1");
|
| ProtocolHandler ph2 = CreateProtocolHandler("test", "test2");
|
| ProtocolHandler ph3 = CreateProtocolHandler("test", "test3");
|
| +
|
| registry()->OnAcceptRegisterProtocolHandler(ph1);
|
| registry()->OnAcceptRegisterProtocolHandler(ph2);
|
| registry()->OnAcceptRegisterProtocolHandler(ph3);
|
| @@ -244,3 +254,35 @@ TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandlerRemovesDefault) {
|
| registry()->RemoveHandler(ph1);
|
| ASSERT_FALSE(registry()->IsDefault(ph1));
|
| }
|
| +
|
| +TEST_F(ProtocolHandlerRegistryTest, TestGetHandlersFor) {
|
| + ProtocolHandler ph1 = CreateProtocolHandler("test", "test1");
|
| + ProtocolHandler ph2 = CreateProtocolHandler("test", "test2");
|
| + ProtocolHandler ph3 = CreateProtocolHandler("test", "test3");
|
| + registry()->OnAcceptRegisterProtocolHandler(ph1);
|
| + registry()->OnAcceptRegisterProtocolHandler(ph2);
|
| + registry()->OnAcceptRegisterProtocolHandler(ph3);
|
| +
|
| + const ProtocolHandlerList* handlers = registry()->GetHandlersFor("test");
|
| + ASSERT_TRUE(handlers != NULL);
|
| + ASSERT_EQ(ph1, (*handlers)[0]);
|
| + ASSERT_EQ(ph2, (*handlers)[1]);
|
| + ASSERT_EQ(ph3, (*handlers)[2]);
|
| +}
|
| +
|
| +TEST_F(ProtocolHandlerRegistryTest, TestGetHandledProtocols) {
|
| + std::vector<std::string> protocols;
|
| + registry()->GetHandledProtocols(&protocols);
|
| + ASSERT_EQ((size_t) 0, protocols.size());
|
| +
|
| + registry()->GetHandlersFor("test");
|
| +
|
| + protocols.clear();
|
| + registry()->GetHandledProtocols(&protocols);
|
| + ASSERT_EQ((size_t) 0, protocols.size());
|
| +}
|
| +
|
| +TEST_F(ProtocolHandlerRegistryTest, TestIsHandledProtocol) {
|
| + registry()->GetHandlersFor("test");
|
| + ASSERT_FALSE(registry()->IsHandledProtocol("test"));
|
| +}
|
|
|