Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(989)

Side by Side Diff: chrome/browser/visitedlink_unittest.cc

Issue 48005: Port visitedlink tests to Linux. Also make them pass on Linux, which (Closed)
Patch Set: GetInvalidHandle -> NULLHandle Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/visitedlink_master.cc ('k') | chrome/test/unit/unit_tests.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 return GURL(StringPrintf("%s%d", g_test_prefix, i)); 29 return GURL(StringPrintf("%s%d", g_test_prefix, i));
30 } 30 }
31 31
32 std::vector<VisitedLinkSlave*> g_slaves; 32 std::vector<VisitedLinkSlave*> g_slaves;
33 33
34 VisitedLinkMaster::PostNewTableEvent SynchronousBroadcastNewTableEvent; 34 VisitedLinkMaster::PostNewTableEvent SynchronousBroadcastNewTableEvent;
35 void SynchronousBroadcastNewTableEvent(base::SharedMemory* table) { 35 void SynchronousBroadcastNewTableEvent(base::SharedMemory* table) {
36 if (table) { 36 if (table) {
37 for (std::vector<VisitedLinkSlave>::size_type i = 0; 37 for (std::vector<VisitedLinkSlave>::size_type i = 0;
38 i < g_slaves.size(); i++) { 38 i < g_slaves.size(); i++) {
39 base::SharedMemoryHandle new_handle = NULL; 39 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
40 table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); 40 table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
41 g_slaves[i]->Init(new_handle); 41 g_slaves[i]->Init(new_handle);
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46 } // namespace 46 } // namespace
47 47
48 class VisitedLinkTest : public testing::Test { 48 class VisitedLinkTest : public testing::Test {
49 protected: 49 protected:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ASSERT_TRUE(InitHistory()); 96 ASSERT_TRUE(InitHistory());
97 ASSERT_TRUE(InitVisited(0, true)); 97 ASSERT_TRUE(InitVisited(0, true));
98 master_->DebugValidate(); 98 master_->DebugValidate();
99 99
100 // check that the table has the proper number of entries 100 // check that the table has the proper number of entries
101 int used_count = master_->GetUsedCount(); 101 int used_count = master_->GetUsedCount();
102 ASSERT_EQ(used_count, g_test_count); 102 ASSERT_EQ(used_count, g_test_count);
103 103
104 // Create a slave database. 104 // Create a slave database.
105 VisitedLinkSlave slave; 105 VisitedLinkSlave slave;
106 base::SharedMemoryHandle new_handle = NULL; 106 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
107 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); 107 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
108 bool success = slave.Init(new_handle); 108 bool success = slave.Init(new_handle);
109 ASSERT_TRUE(success); 109 ASSERT_TRUE(success);
110 g_slaves.push_back(&slave); 110 g_slaves.push_back(&slave);
111 111
112 bool found; 112 bool found;
113 for (int i = 0; i < g_test_count; i++) { 113 for (int i = 0; i < g_test_count; i++) {
114 GURL cur = TestURL(i); 114 GURL cur = TestURL(i);
115 found = master_->IsVisited(cur); 115 found = master_->IsVisited(cur);
116 EXPECT_TRUE(found) << "URL " << i << "not found in master."; 116 EXPECT_TRUE(found) << "URL " << i << "not found in master.";
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 Reload(); 233 Reload();
234 } 234 }
235 235
236 TEST_F(VisitedLinkTest, DeleteAll) { 236 TEST_F(VisitedLinkTest, DeleteAll) {
237 ASSERT_TRUE(InitHistory()); 237 ASSERT_TRUE(InitHistory());
238 ASSERT_TRUE(InitVisited(0, true)); 238 ASSERT_TRUE(InitVisited(0, true));
239 239
240 { 240 {
241 VisitedLinkSlave slave; 241 VisitedLinkSlave slave;
242 base::SharedMemoryHandle new_handle = NULL; 242 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
243 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); 243 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
244 ASSERT_TRUE(slave.Init(new_handle)); 244 ASSERT_TRUE(slave.Init(new_handle));
245 g_slaves.push_back(&slave); 245 g_slaves.push_back(&slave);
246 246
247 // Add the test URLs. 247 // Add the test URLs.
248 for (int i = 0; i < g_test_count; i++) { 248 for (int i = 0; i < g_test_count; i++) {
249 master_->AddURL(TestURL(i)); 249 master_->AddURL(TestURL(i));
250 ASSERT_EQ(i + 1, master_->GetUsedCount()); 250 ASSERT_EQ(i + 1, master_->GetUsedCount());
251 } 251 }
252 master_->DebugValidate(); 252 master_->DebugValidate();
(...skipping 27 matching lines...) Expand all
280 // This tests that the master correctly resizes its tables when it gets too 280 // This tests that the master correctly resizes its tables when it gets too
281 // full, notifies its slaves of the change, and updates the disk. 281 // full, notifies its slaves of the change, and updates the disk.
282 TEST_F(VisitedLinkTest, Resizing) { 282 TEST_F(VisitedLinkTest, Resizing) {
283 // Create a very small database. 283 // Create a very small database.
284 const int32 initial_size = 17; 284 const int32 initial_size = 17;
285 ASSERT_TRUE(InitHistory()); 285 ASSERT_TRUE(InitHistory());
286 ASSERT_TRUE(InitVisited(initial_size, true)); 286 ASSERT_TRUE(InitVisited(initial_size, true));
287 287
288 // ...and a slave 288 // ...and a slave
289 VisitedLinkSlave slave; 289 VisitedLinkSlave slave;
290 base::SharedMemoryHandle new_handle = NULL; 290 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
291 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); 291 master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
292 bool success = slave.Init(new_handle); 292 bool success = slave.Init(new_handle);
293 ASSERT_TRUE(success); 293 ASSERT_TRUE(success);
294 g_slaves.push_back(&slave); 294 g_slaves.push_back(&slave);
295 295
296 int32 used_count = master_->GetUsedCount(); 296 int32 used_count = master_->GetUsedCount();
297 ASSERT_EQ(used_count, 0); 297 ASSERT_EQ(used_count, 0);
298 298
299 for (int i = 0; i < g_test_count; i++) { 299 for (int i = 0; i < g_test_count; i++) {
300 master_->AddURL(TestURL(i)); 300 master_->AddURL(TestURL(i));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // complete. 366 // complete.
367 master_->set_rebuild_complete_task(new MessageLoop::QuitTask); 367 master_->set_rebuild_complete_task(new MessageLoop::QuitTask);
368 MessageLoop::current()->Run(); 368 MessageLoop::current()->Run();
369 369
370 // Test that all URLs were written to the database properly. 370 // Test that all URLs were written to the database properly.
371 Reload(); 371 Reload();
372 372
373 // Make sure the extra one was *not* written (Reload won't test this). 373 // Make sure the extra one was *not* written (Reload won't test this).
374 EXPECT_FALSE(master_->IsVisited(TestURL(g_test_count))); 374 EXPECT_FALSE(master_->IsVisited(TestURL(g_test_count)));
375 } 375 }
OLDNEW
« no previous file with comments | « chrome/browser/visitedlink_master.cc ('k') | chrome/test/unit/unit_tests.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698