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

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: small nits 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..16acfb51308d38815fcadfb96bb826a1c40aaa02 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
@@ -141,6 +141,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 +166,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 +183,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 +228,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 +244,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 +253,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"));
+}
tony 2011/05/23 21:42:00 Can we add some notification tests?
koz (OOO until 15th September) 2011/05/24 08:47:49 Done.

Powered by Google App Engine
This is Rietveld 408576698