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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <cstdio> | 8 #include <cstdio> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "base/timer/mock_timer.h" | 24 #include "base/timer/mock_timer.h" |
25 #include "components/visitedlink/browser/visitedlink_delegate.h" | 25 #include "components/visitedlink/browser/visitedlink_delegate.h" |
26 #include "components/visitedlink/browser/visitedlink_event_listener.h" | 26 #include "components/visitedlink/browser/visitedlink_event_listener.h" |
27 #include "components/visitedlink/browser/visitedlink_master.h" | 27 #include "components/visitedlink/browser/visitedlink_master.h" |
28 #include "components/visitedlink/common/visitedlink.mojom.h" | 28 #include "components/visitedlink/common/visitedlink.mojom.h" |
29 #include "components/visitedlink/renderer/visitedlink_slave.h" | 29 #include "components/visitedlink/renderer/visitedlink_slave.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
32 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
33 #include "content/public/browser/render_widget_host_view.h" | |
34 #include "content/public/browser/web_contents.h" | |
35 #include "content/public/test/mock_render_process_host.h" | 33 #include "content/public/test/mock_render_process_host.h" |
36 #include "content/public/test/test_browser_context.h" | 34 #include "content/public/test/test_browser_context.h" |
37 #include "content/public/test/test_browser_thread_bundle.h" | 35 #include "content/public/test/test_browser_thread_bundle.h" |
38 #include "content/public/test/test_renderer_host.h" | 36 #include "content/public/test/test_renderer_host.h" |
39 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
40 #include "services/service_manager/public/cpp/interface_provider.h" | 38 #include "services/service_manager/public/cpp/interface_provider.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "url/gurl.h" | 40 #include "url/gurl.h" |
43 | 41 |
44 using content::BrowserThread; | 42 using content::BrowserThread; |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 RenderViewHostTester::For(rvh())->CreateTestRenderView( | 780 RenderViewHostTester::For(rvh())->CreateTestRenderView( |
783 base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, false); | 781 base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, false); |
784 | 782 |
785 // Waiting complete rebuild the table. | 783 // Waiting complete rebuild the table. |
786 content::RunAllBlockingPoolTasksUntilIdle(); | 784 content::RunAllBlockingPoolTasksUntilIdle(); |
787 | 785 |
788 // After rebuild table expect reset event. | 786 // After rebuild table expect reset event. |
789 EXPECT_EQ(1, context()->reset_event_count()); | 787 EXPECT_EQ(1, context()->reset_event_count()); |
790 | 788 |
791 // Simulate tab becoming inactive. | 789 // Simulate tab becoming inactive. |
792 web_contents()->GetRenderWidgetHostView()->Hide(); | 790 RenderViewHostTester::For(rvh())->SimulateWasHidden(); |
793 | 791 |
794 // Add a few URLs. | 792 // Add a few URLs. |
795 master()->AddURL(GURL("http://acidtests.org/")); | 793 master()->AddURL(GURL("http://acidtests.org/")); |
796 master()->AddURL(GURL("http://google.com/")); | 794 master()->AddURL(GURL("http://google.com/")); |
797 master()->AddURL(GURL("http://chromium.org/")); | 795 master()->AddURL(GURL("http://chromium.org/")); |
798 ASSERT_TRUE(timer_->IsRunning()); | 796 ASSERT_TRUE(timer_->IsRunning()); |
799 timer_->Fire(); | 797 timer_->Fire(); |
800 context()->WaitForNoUpdate(); | 798 context()->WaitForNoUpdate(); |
801 | 799 |
802 // We shouldn't have any events. | 800 // We shouldn't have any events. |
803 EXPECT_EQ(0, context()->add_event_count()); | 801 EXPECT_EQ(0, context()->add_event_count()); |
804 EXPECT_EQ(1, context()->reset_event_count()); | 802 EXPECT_EQ(1, context()->reset_event_count()); |
805 | 803 |
806 // Simulate the tab becoming active. | 804 // Simulate the tab becoming active. |
807 web_contents()->GetRenderWidgetHostView()->Show(); | 805 RenderViewHostTester::For(rvh())->SimulateWasShown(); |
808 context()->WaitForUpdate(); | 806 context()->WaitForUpdate(); |
809 | 807 |
810 // We should now have 3 add events, still no reset events. | 808 // We should now have 3 add events, still no reset events. |
811 EXPECT_EQ(1, context()->add_event_count()); | 809 EXPECT_EQ(1, context()->add_event_count()); |
812 EXPECT_EQ(1, context()->reset_event_count()); | 810 EXPECT_EQ(1, context()->reset_event_count()); |
813 | 811 |
814 // Deactivate the tab again. | 812 // Deactivate the tab again. |
815 web_contents()->GetRenderWidgetHostView()->Hide(); | 813 RenderViewHostTester::For(rvh())->SimulateWasHidden(); |
816 | 814 |
817 // Add a bunch of URLs (over 50) to exhaust the link event buffer. | 815 // Add a bunch of URLs (over 50) to exhaust the link event buffer. |
818 for (int i = 0; i < 100; i++) | 816 for (int i = 0; i < 100; i++) |
819 master()->AddURL(TestURL(i)); | 817 master()->AddURL(TestURL(i)); |
820 | 818 |
821 ASSERT_TRUE(timer_->IsRunning()); | 819 ASSERT_TRUE(timer_->IsRunning()); |
822 timer_->Fire(); | 820 timer_->Fire(); |
823 context()->WaitForNoUpdate(); | 821 context()->WaitForNoUpdate(); |
824 | 822 |
825 // Again, no change in events until tab is active. | 823 // Again, no change in events until tab is active. |
826 EXPECT_EQ(1, context()->add_event_count()); | 824 EXPECT_EQ(1, context()->add_event_count()); |
827 EXPECT_EQ(1, context()->reset_event_count()); | 825 EXPECT_EQ(1, context()->reset_event_count()); |
828 | 826 |
829 // Activate the tab. | 827 // Activate the tab. |
830 web_contents()->GetRenderWidgetHostView()->Show(); | 828 RenderViewHostTester::For(rvh())->SimulateWasShown(); |
831 EXPECT_FALSE(timer_->IsRunning()); | 829 EXPECT_FALSE(timer_->IsRunning()); |
832 context()->WaitForUpdate(); | 830 context()->WaitForUpdate(); |
833 | 831 |
834 // We should have only one more reset event. | 832 // We should have only one more reset event. |
835 EXPECT_EQ(1, context()->add_event_count()); | 833 EXPECT_EQ(1, context()->add_event_count()); |
836 EXPECT_EQ(2, context()->reset_event_count()); | 834 EXPECT_EQ(2, context()->reset_event_count()); |
837 } | 835 } |
838 | 836 |
839 // Tests that VisitedLink ignores renderer process creation notification for a | 837 // Tests that VisitedLink ignores renderer process creation notification for a |
840 // different context. | 838 // different context. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 // Waiting complete loading the table. | 878 // Waiting complete loading the table. |
881 content::RunAllBlockingPoolTasksUntilIdle(); | 879 content::RunAllBlockingPoolTasksUntilIdle(); |
882 | 880 |
883 context()->binding().FlushForTesting(); | 881 context()->binding().FlushForTesting(); |
884 | 882 |
885 // After load table expect completely reset event. | 883 // After load table expect completely reset event. |
886 EXPECT_EQ(1, context()->completely_reset_event_count()); | 884 EXPECT_EQ(1, context()->completely_reset_event_count()); |
887 } | 885 } |
888 | 886 |
889 } // namespace visitedlink | 887 } // namespace visitedlink |
OLD | NEW |