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 <cstdio> | 5 #include <cstdio> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/visitedlink/visitedlink_delegate.h" | |
17 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" | |
18 #include "chrome/browser/visitedlink/visitedlink_master.h" | |
19 #include "chrome/common/render_messages.h" | |
20 #include "chrome/renderer/visitedlink_slave.h" | |
21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
22 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "components/visitedlink/browser/visitedlink_delegate.h" | |
19 #include "components/visitedlink/browser/visitedlink_event_listener.h" | |
20 #include "components/visitedlink/browser/visitedlink_master.h" | |
21 #include "components/visitedlink/common/visitedlink_messages.h" | |
22 #include "components/visitedlink/renderer/visitedlink_slave.h" | |
23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
25 #include "content/public/test/mock_render_process_host.h" | 25 #include "content/public/test/mock_render_process_host.h" |
26 #include "content/public/test/test_browser_context.h" | 26 #include "content/public/test/test_browser_context.h" |
27 #include "content/public/test/test_browser_thread.h" | 27 #include "content/public/test/test_browser_thread.h" |
28 #include "content/public/test/test_renderer_host.h" | 28 #include "content/public/test/test_renderer_host.h" |
29 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 using components::VisitedLinkCommon; | |
brettw
2013/01/18 21:58:47
Ditto.
boliu
2013/01/18 22:42:15
Done.
| |
33 using components::VisitedLinkDelegate; | |
34 using components::VisitedLinkMaster; | |
35 using components::VisitedLinkSlave; | |
32 using content::BrowserThread; | 36 using content::BrowserThread; |
33 using content::MockRenderProcessHost; | 37 using content::MockRenderProcessHost; |
34 using content::RenderViewHostTester; | 38 using content::RenderViewHostTester; |
35 | 39 |
36 namespace { | 40 namespace { |
37 | 41 |
38 typedef std::vector<GURL> URLs; | 42 typedef std::vector<GURL> URLs; |
39 | 43 |
40 // a nice long URL that we can append numbers to to get new URLs | 44 // a nice long URL that we can append numbers to to get new URLs |
41 const char g_test_prefix[] = | 45 const char g_test_prefix[] = |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 const GURL& TestURLIterator::NextURL() { | 107 const GURL& TestURLIterator::NextURL() { |
104 return *(iterator_++); | 108 return *(iterator_++); |
105 } | 109 } |
106 | 110 |
107 bool TestURLIterator::HasNextURL() const { | 111 bool TestURLIterator::HasNextURL() const { |
108 return iterator_ != end_; | 112 return iterator_ != end_; |
109 } | 113 } |
110 | 114 |
111 } // namespace | 115 } // namespace |
112 | 116 |
117 namespace components { | |
118 | |
113 class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener { | 119 class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener { |
114 public: | 120 public: |
115 TrackingVisitedLinkEventListener() | 121 TrackingVisitedLinkEventListener() |
116 : reset_count_(0), | 122 : reset_count_(0), |
117 add_count_(0) {} | 123 add_count_(0) {} |
118 | 124 |
119 virtual void NewTable(base::SharedMemory* table) { | 125 virtual void NewTable(base::SharedMemory* table) { |
120 if (table) { | 126 if (table) { |
121 for (std::vector<VisitedLinkSlave>::size_type i = 0; | 127 for (std::vector<VisitedLinkSlave>::size_type i = 0; |
122 i < g_slaves.size(); i++) { | 128 i < g_slaves.size(); i++) { |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
750 EXPECT_EQ(1, profile()->add_event_count()); | 756 EXPECT_EQ(1, profile()->add_event_count()); |
751 EXPECT_EQ(0, profile()->reset_event_count()); | 757 EXPECT_EQ(0, profile()->reset_event_count()); |
752 | 758 |
753 // Activate the tab. | 759 // Activate the tab. |
754 RenderViewHostTester::For(rvh())->SimulateWasShown(); | 760 RenderViewHostTester::For(rvh())->SimulateWasShown(); |
755 | 761 |
756 // We should have only one more reset event. | 762 // We should have only one more reset event. |
757 EXPECT_EQ(1, profile()->add_event_count()); | 763 EXPECT_EQ(1, profile()->add_event_count()); |
758 EXPECT_EQ(1, profile()->reset_event_count()); | 764 EXPECT_EQ(1, profile()->reset_event_count()); |
759 } | 765 } |
766 | |
767 } // namespace components | |
OLD | NEW |