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

Side by Side Diff: chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc

Issue 8371023: Calls to rph updating existing handlers are ignored. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s"), 458 ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s"),
459 "test1"); 459 "test1");
460 ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s"), 460 ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s"),
461 "test2"); 461 "test2");
462 registry()->OnAcceptRegisterProtocolHandler(ph1); 462 registry()->OnAcceptRegisterProtocolHandler(ph1);
463 463
464 ASSERT_TRUE(registry()->IsRegistered(ph1)); 464 ASSERT_TRUE(registry()->IsRegistered(ph1));
465 ASSERT_TRUE(registry()->HasRegisteredEquivalent(ph2)); 465 ASSERT_TRUE(registry()->HasRegisteredEquivalent(ph2));
466 } 466 }
467 467
468 TEST_F(ProtocolHandlerRegistryTest, TestSilentlyRegisterHandler) {
469 ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s"),
470 "test1");
471 ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s"),
472 "test2");
473 ProtocolHandler ph3 = CreateProtocolHandler("ignore", GURL("http://test/%s"),
474 "ignore1");
475 ProtocolHandler ph4 = CreateProtocolHandler("ignore", GURL("http://test/%s"),
476 "ignore2");
477
478 ASSERT_FALSE(registry()->SilentlyHandleRegisterHandlerRequest(ph1));
479 ASSERT_FALSE(registry()->IsRegistered(ph1));
480
481 registry()->OnAcceptRegisterProtocolHandler(ph1);
482 ASSERT_TRUE(registry()->IsRegistered(ph1));
483
484 ASSERT_TRUE(registry()->SilentlyHandleRegisterHandlerRequest(ph2));
485 ASSERT_FALSE(registry()->IsRegistered(ph1));
486 ASSERT_TRUE(registry()->IsRegistered(ph2));
487
488 ASSERT_FALSE(registry()->SilentlyHandleRegisterHandlerRequest(ph3));
489 ASSERT_FALSE(registry()->IsRegistered(ph3));
490
491 registry()->OnIgnoreRegisterProtocolHandler(ph3);
492 ASSERT_FALSE(registry()->IsRegistered(ph3));
493 ASSERT_TRUE(registry()->IsIgnored(ph3));
494
495 ASSERT_TRUE(registry()->SilentlyHandleRegisterHandlerRequest(ph4));
496 ASSERT_FALSE(registry()->IsRegistered(ph4));
497 ASSERT_TRUE(registry()->HasIgnoredEquivalent(ph4));
498 }
499
468 TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandlerRemovesDefault) { 500 TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandlerRemovesDefault) {
469 ProtocolHandler ph1 = CreateProtocolHandler("test", "test1"); 501 ProtocolHandler ph1 = CreateProtocolHandler("test", "test1");
470 ProtocolHandler ph2 = CreateProtocolHandler("test", "test2"); 502 ProtocolHandler ph2 = CreateProtocolHandler("test", "test2");
471 ProtocolHandler ph3 = CreateProtocolHandler("test", "test3"); 503 ProtocolHandler ph3 = CreateProtocolHandler("test", "test3");
472 504
473 registry()->OnAcceptRegisterProtocolHandler(ph1); 505 registry()->OnAcceptRegisterProtocolHandler(ph1);
474 registry()->OnAcceptRegisterProtocolHandler(ph2); 506 registry()->OnAcceptRegisterProtocolHandler(ph2);
475 registry()->OnAcceptRegisterProtocolHandler(ph3); 507 registry()->OnAcceptRegisterProtocolHandler(ph3);
476 508
477 registry()->OnAcceptRegisterProtocolHandler(ph1); 509 registry()->OnAcceptRegisterProtocolHandler(ph1);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 GURL("http://other.com/%s"), "test"); 788 GURL("http://other.com/%s"), "test");
757 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(), 789 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(),
758 ph1.IsSameOrigin(ph2)); 790 ph1.IsSameOrigin(ph2));
759 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(), 791 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(),
760 ph2.IsSameOrigin(ph1)); 792 ph2.IsSameOrigin(ph1));
761 ASSERT_EQ(ph2.url().GetOrigin() == ph3.url().GetOrigin(), 793 ASSERT_EQ(ph2.url().GetOrigin() == ph3.url().GetOrigin(),
762 ph2.IsSameOrigin(ph3)); 794 ph2.IsSameOrigin(ph3));
763 ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(), 795 ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(),
764 ph3.IsSameOrigin(ph2)); 796 ph3.IsSameOrigin(ph2));
765 } 797 }
OLDNEW
« no previous file with comments | « chrome/browser/custom_handlers/protocol_handler_registry.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698