| 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 17 matching lines...) Expand all Loading... |
| 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/test/mock_render_process_host.h" | 33 #include "content/public/test/mock_render_process_host.h" |
| 34 #include "content/public/test/test_browser_context.h" | 34 #include "content/public/test/test_browser_context.h" |
| 35 #include "content/public/test/test_browser_thread_bundle.h" | 35 #include "content/public/test/test_browser_thread_bundle.h" |
| 36 #include "content/public/test/test_renderer_host.h" | 36 #include "content/public/test/test_renderer_host.h" |
| 37 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
| 38 #include "services/service_manager/public/cpp/interface_provider.h" | |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "url/gurl.h" | 39 #include "url/gurl.h" |
| 41 | 40 |
| 42 using content::BrowserThread; | 41 using content::BrowserThread; |
| 43 using content::MockRenderProcessHost; | 42 using content::MockRenderProcessHost; |
| 44 using content::RenderViewHostTester; | 43 using content::RenderViewHostTester; |
| 45 | 44 |
| 46 namespace visitedlink { | 45 namespace visitedlink { |
| 47 | 46 |
| 48 namespace { | 47 namespace { |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 mojo::Binding<mojom::VisitedLinkNotificationSink> binding_; | 589 mojo::Binding<mojom::VisitedLinkNotificationSink> binding_; |
| 591 }; | 590 }; |
| 592 | 591 |
| 593 // Stub out as little as possible, borrowing from RenderProcessHost. | 592 // Stub out as little as possible, borrowing from RenderProcessHost. |
| 594 class VisitRelayingRenderProcessHost : public MockRenderProcessHost { | 593 class VisitRelayingRenderProcessHost : public MockRenderProcessHost { |
| 595 public: | 594 public: |
| 596 explicit VisitRelayingRenderProcessHost( | 595 explicit VisitRelayingRenderProcessHost( |
| 597 content::BrowserContext* browser_context, | 596 content::BrowserContext* browser_context, |
| 598 VisitCountingContext* context) | 597 VisitCountingContext* context) |
| 599 : MockRenderProcessHost(browser_context), widgets_(0) { | 598 : MockRenderProcessHost(browser_context), widgets_(0) { |
| 600 SetRemoteInterfaces(base::MakeUnique<service_manager::InterfaceProvider>()); | 599 OverrideBinderForTesting( |
| 601 service_manager::InterfaceProvider::TestApi test_api(GetRemoteInterfaces()); | |
| 602 test_api.SetBinderForName( | |
| 603 mojom::VisitedLinkNotificationSink::Name_, | 600 mojom::VisitedLinkNotificationSink::Name_, |
| 604 base::Bind(&VisitCountingContext::Bind, base::Unretained(context))); | 601 base::Bind(&VisitCountingContext::Bind, base::Unretained(context))); |
| 605 content::NotificationService::current()->Notify( | 602 content::NotificationService::current()->Notify( |
| 606 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 603 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 607 content::Source<RenderProcessHost>(this), | 604 content::Source<RenderProcessHost>(this), |
| 608 content::NotificationService::NoDetails()); | 605 content::NotificationService::NoDetails()); |
| 609 } | 606 } |
| 610 ~VisitRelayingRenderProcessHost() override { | 607 ~VisitRelayingRenderProcessHost() override { |
| 611 content::NotificationService::current()->Notify( | 608 content::NotificationService::current()->Notify( |
| 612 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 609 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 // Waiting complete loading the table. | 875 // Waiting complete loading the table. |
| 879 content::RunAllBlockingPoolTasksUntilIdle(); | 876 content::RunAllBlockingPoolTasksUntilIdle(); |
| 880 | 877 |
| 881 context()->binding().FlushForTesting(); | 878 context()->binding().FlushForTesting(); |
| 882 | 879 |
| 883 // After load table expect completely reset event. | 880 // After load table expect completely reset event. |
| 884 EXPECT_EQ(1, context()->completely_reset_event_count()); | 881 EXPECT_EQ(1, context()->completely_reset_event_count()); |
| 885 } | 882 } |
| 886 | 883 |
| 887 } // namespace visitedlink | 884 } // namespace visitedlink |
| OLD | NEW |