OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 631 } |
632 | 632 |
633 TEST_F(ProtocolHandlerRegistryTest, TestDisablePreventsHandling) { | 633 TEST_F(ProtocolHandlerRegistryTest, TestDisablePreventsHandling) { |
634 ProtocolHandler ph1 = CreateProtocolHandler("test", "test1"); | 634 ProtocolHandler ph1 = CreateProtocolHandler("test", "test1"); |
635 registry()->OnAcceptRegisterProtocolHandler(ph1); | 635 registry()->OnAcceptRegisterProtocolHandler(ph1); |
636 ASSERT_TRUE(registry()->IsHandledProtocol("test")); | 636 ASSERT_TRUE(registry()->IsHandledProtocol("test")); |
637 registry()->Disable(); | 637 registry()->Disable(); |
638 ASSERT_FALSE(registry()->IsHandledProtocol("test")); | 638 ASSERT_FALSE(registry()->IsHandledProtocol("test")); |
639 } | 639 } |
640 | 640 |
641 // TODO(smckay): This is much more appropriately an integration | |
642 // test. Make that so, then update the | |
643 // ShellIntegretion{Delegate,Callback,Worker} test classes we use to fully | |
644 // isolate this test from the FILE thread. | |
645 TEST_F(ProtocolHandlerRegistryTest, TestOSRegistration) { | 641 TEST_F(ProtocolHandlerRegistryTest, TestOSRegistration) { |
646 ProtocolHandler ph_do1 = CreateProtocolHandler("do", "test1"); | 642 ProtocolHandler ph_do1 = CreateProtocolHandler("do", "test1"); |
647 ProtocolHandler ph_do2 = CreateProtocolHandler("do", "test2"); | 643 ProtocolHandler ph_do2 = CreateProtocolHandler("do", "test2"); |
648 ProtocolHandler ph_dont = CreateProtocolHandler("dont", "test"); | 644 ProtocolHandler ph_dont = CreateProtocolHandler("dont", "test"); |
649 | 645 |
650 ASSERT_FALSE(delegate()->IsFakeRegisteredWithOS("do")); | 646 ASSERT_FALSE(delegate()->IsFakeRegisteredWithOS("do")); |
651 ASSERT_FALSE(delegate()->IsFakeRegisteredWithOS("dont")); | 647 ASSERT_FALSE(delegate()->IsFakeRegisteredWithOS("dont")); |
652 | 648 |
653 registry()->OnAcceptRegisterProtocolHandler(ph_do1); | 649 registry()->OnAcceptRegisterProtocolHandler(ph_do1); |
654 registry()->OnDenyRegisterProtocolHandler(ph_dont); | 650 registry()->OnDenyRegisterProtocolHandler(ph_dont); |
655 base::RunLoop().RunUntilIdle(); | 651 base::RunLoop().RunUntilIdle(); |
656 | 652 |
657 ASSERT_TRUE(delegate()->IsFakeRegisteredWithOS("do")); | 653 ASSERT_TRUE(delegate()->IsFakeRegisteredWithOS("do")); |
658 ASSERT_FALSE(delegate()->IsFakeRegisteredWithOS("dont")); | 654 ASSERT_FALSE(delegate()->IsFakeRegisteredWithOS("dont")); |
659 | 655 |
660 // This should not register with the OS, if it does the delegate | 656 // This should not register with the OS, if it does the delegate |
661 // will assert for us. We don't need to wait for the message loop | 657 // will assert for us. We don't need to wait for the message loop |
662 // as it should not go through to the shell worker. | 658 // as it should not go through to the shell worker. |
663 registry()->OnAcceptRegisterProtocolHandler(ph_do2); | 659 registry()->OnAcceptRegisterProtocolHandler(ph_do2); |
664 } | 660 } |
665 | 661 |
666 #if defined(OS_LINUX) | 662 #if defined(OS_LINUX) |
667 // TODO(benwells): When Linux support is more reliable and | 663 // TODO(benwells): When Linux support is more reliable and |
668 // http://crbug.com/88255 is fixed this test will pass. | 664 // http://crbug.com/88255 is fixed this test will pass. |
669 #define MAYBE_TestOSRegistrationFailure DISABLED_TestOSRegistrationFailure | 665 #define MAYBE_TestOSRegistrationFailure DISABLED_TestOSRegistrationFailure |
670 #else | 666 #else |
671 #define MAYBE_TestOSRegistrationFailure TestOSRegistrationFailure | 667 #define MAYBE_TestOSRegistrationFailure TestOSRegistrationFailure |
672 #endif | 668 #endif |
673 | 669 |
674 // TODO(smckay): This is much more appropriately an integration | |
675 // test. Make that so, then update the | |
676 // ShellIntegretion{Delegate,Callback,Worker} test classes we use to fully | |
677 // isolate this test from the FILE thread. | |
678 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestOSRegistrationFailure) { | 670 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestOSRegistrationFailure) { |
679 ProtocolHandler ph_do = CreateProtocolHandler("do", "test1"); | 671 ProtocolHandler ph_do = CreateProtocolHandler("do", "test1"); |
680 ProtocolHandler ph_dont = CreateProtocolHandler("dont", "test"); | 672 ProtocolHandler ph_dont = CreateProtocolHandler("dont", "test"); |
681 | 673 |
682 ASSERT_FALSE(registry()->IsHandledProtocol("do")); | 674 ASSERT_FALSE(registry()->IsHandledProtocol("do")); |
683 ASSERT_FALSE(registry()->IsHandledProtocol("dont")); | 675 ASSERT_FALSE(registry()->IsHandledProtocol("dont")); |
684 | 676 |
685 registry()->OnAcceptRegisterProtocolHandler(ph_do); | 677 registry()->OnAcceptRegisterProtocolHandler(ph_do); |
686 base::RunLoop().RunUntilIdle(); | 678 base::RunLoop().RunUntilIdle(); |
687 | 679 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 // added to pref. | 988 // added to pref. |
997 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); | 989 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); |
998 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 990 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
999 | 991 |
1000 registry()->RemoveIgnoredHandler(p2u1); | 992 registry()->RemoveIgnoredHandler(p2u1); |
1001 | 993 |
1002 // p2u1 installed by user and policy, so it is removed from pref alone. | 994 // p2u1 installed by user and policy, so it is removed from pref alone. |
1003 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); | 995 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); |
1004 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 996 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
1005 } | 997 } |
OLD | NEW |