Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4024)

Unified Diff: chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc

Issue 7033018: Handler settings page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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"
willchan no longer on Chromium 2011/05/20 22:48:50 spurious?
koz (OOO until 15th September) 2011/05/20 23:18:57 Done.
+
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"));
+}

Powered by Google App Engine
This is Rietveld 408576698