OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 5 #include <vector> |
6 #include <string> | 6 #include <string> |
7 #include <cstdio> | 7 #include <cstdio> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 ASSERT_TRUE(InitVisited(0, true)); | 124 ASSERT_TRUE(InitVisited(0, true)); |
125 master_->DebugValidate(); | 125 master_->DebugValidate(); |
126 | 126 |
127 // check that the table has the proper number of entries | 127 // check that the table has the proper number of entries |
128 int used_count = master_->GetUsedCount(); | 128 int used_count = master_->GetUsedCount(); |
129 ASSERT_EQ(used_count, g_test_count); | 129 ASSERT_EQ(used_count, g_test_count); |
130 | 130 |
131 // Create a slave database. | 131 // Create a slave database. |
132 VisitedLinkSlave slave; | 132 VisitedLinkSlave slave; |
133 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); | 133 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); |
134 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); | 134 master_->shared_memory()->ShareToProcess( |
| 135 base::GetCurrentProcessHandle(), &new_handle); |
135 bool success = slave.Init(new_handle); | 136 bool success = slave.Init(new_handle); |
136 ASSERT_TRUE(success); | 137 ASSERT_TRUE(success); |
137 g_slaves.push_back(&slave); | 138 g_slaves.push_back(&slave); |
138 | 139 |
139 bool found; | 140 bool found; |
140 for (int i = 0; i < g_test_count; i++) { | 141 for (int i = 0; i < g_test_count; i++) { |
141 GURL cur = TestURL(i); | 142 GURL cur = TestURL(i); |
142 found = master_->IsVisited(cur); | 143 found = master_->IsVisited(cur); |
143 EXPECT_TRUE(found) << "URL " << i << "not found in master."; | 144 EXPECT_TRUE(found) << "URL " << i << "not found in master."; |
144 | 145 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 Reload(); | 265 Reload(); |
265 } | 266 } |
266 | 267 |
267 TEST_F(VisitedLinkTest, DeleteAll) { | 268 TEST_F(VisitedLinkTest, DeleteAll) { |
268 ASSERT_TRUE(InitHistory()); | 269 ASSERT_TRUE(InitHistory()); |
269 ASSERT_TRUE(InitVisited(0, true)); | 270 ASSERT_TRUE(InitVisited(0, true)); |
270 | 271 |
271 { | 272 { |
272 VisitedLinkSlave slave; | 273 VisitedLinkSlave slave; |
273 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); | 274 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); |
274 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); | 275 master_->shared_memory()->ShareToProcess( |
| 276 base::GetCurrentProcessHandle(), &new_handle); |
275 ASSERT_TRUE(slave.Init(new_handle)); | 277 ASSERT_TRUE(slave.Init(new_handle)); |
276 g_slaves.push_back(&slave); | 278 g_slaves.push_back(&slave); |
277 | 279 |
278 // Add the test URLs. | 280 // Add the test URLs. |
279 for (int i = 0; i < g_test_count; i++) { | 281 for (int i = 0; i < g_test_count; i++) { |
280 master_->AddURL(TestURL(i)); | 282 master_->AddURL(TestURL(i)); |
281 ASSERT_EQ(i + 1, master_->GetUsedCount()); | 283 ASSERT_EQ(i + 1, master_->GetUsedCount()); |
282 } | 284 } |
283 master_->DebugValidate(); | 285 master_->DebugValidate(); |
284 | 286 |
(...skipping 27 matching lines...) Expand all Loading... |
312 // full, notifies its slaves of the change, and updates the disk. | 314 // full, notifies its slaves of the change, and updates the disk. |
313 TEST_F(VisitedLinkTest, Resizing) { | 315 TEST_F(VisitedLinkTest, Resizing) { |
314 // Create a very small database. | 316 // Create a very small database. |
315 const int32 initial_size = 17; | 317 const int32 initial_size = 17; |
316 ASSERT_TRUE(InitHistory()); | 318 ASSERT_TRUE(InitHistory()); |
317 ASSERT_TRUE(InitVisited(initial_size, true)); | 319 ASSERT_TRUE(InitVisited(initial_size, true)); |
318 | 320 |
319 // ...and a slave | 321 // ...and a slave |
320 VisitedLinkSlave slave; | 322 VisitedLinkSlave slave; |
321 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); | 323 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); |
322 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); | 324 master_->shared_memory()->ShareToProcess( |
| 325 base::GetCurrentProcessHandle(), &new_handle); |
323 bool success = slave.Init(new_handle); | 326 bool success = slave.Init(new_handle); |
324 ASSERT_TRUE(success); | 327 ASSERT_TRUE(success); |
325 g_slaves.push_back(&slave); | 328 g_slaves.push_back(&slave); |
326 | 329 |
327 int32 used_count = master_->GetUsedCount(); | 330 int32 used_count = master_->GetUsedCount(); |
328 ASSERT_EQ(used_count, 0); | 331 ASSERT_EQ(used_count, 0); |
329 | 332 |
330 for (int i = 0; i < g_test_count; i++) { | 333 for (int i = 0; i < g_test_count; i++) { |
331 master_->AddURL(TestURL(i)); | 334 master_->AddURL(TestURL(i)); |
332 used_count = master_->GetUsedCount(); | 335 used_count = master_->GetUsedCount(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 EXPECT_EQ(0, profile()->add_event_count()); | 763 EXPECT_EQ(0, profile()->add_event_count()); |
761 EXPECT_EQ(0, profile()->reset_event_count()); | 764 EXPECT_EQ(0, profile()->reset_event_count()); |
762 | 765 |
763 rvh()->CreateRenderView(profile_->GetRequestContext()); | 766 rvh()->CreateRenderView(profile_->GetRequestContext()); |
764 | 767 |
765 // We should now have just a reset event: adds are eaten up by a reset | 768 // We should now have just a reset event: adds are eaten up by a reset |
766 // that followed. | 769 // that followed. |
767 EXPECT_EQ(0, profile()->add_event_count()); | 770 EXPECT_EQ(0, profile()->add_event_count()); |
768 EXPECT_EQ(1, profile()->reset_event_count()); | 771 EXPECT_EQ(1, profile()->reset_event_count()); |
769 } | 772 } |
OLD | NEW |