diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 17:38:31 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 17:38:31 +0000 |
commit | 61899d3915693df7dbc8c5bdaa6e8ae4ba3931d0 (patch) | |
tree | fead65e8733d8eff08cccb9ca2d45079fd632691 /chrome/browser/visitedlink_unittest.cc | |
parent | b8e58b6d17f0ceb74f5ec6b6bcfc0b3e863599cc (diff) | |
download | chromium_src-61899d3915693df7dbc8c5bdaa6e8ae4ba3931d0.zip chromium_src-61899d3915693df7dbc8c5bdaa6e8ae4ba3931d0.tar.gz chromium_src-61899d3915693df7dbc8c5bdaa6e8ae4ba3931d0.tar.bz2 |
Reverting 8722,8721.
Review URL: http://codereview.chromium.org/19024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/visitedlink_unittest.cc')
-rw-r--r-- | chrome/browser/visitedlink_unittest.cc | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc index 2dac97f..86c2a24 100644 --- a/chrome/browser/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink_unittest.cc @@ -9,7 +9,6 @@ #include "base/message_loop.h" #include "base/file_util.h" #include "base/path_service.h" -#include "base/process_util.h" #include "base/shared_memory.h" #include "base/string_util.h" #include "chrome/browser/visitedlink_master.h" @@ -29,28 +28,28 @@ GURL TestURL(int i) { return GURL(StringPrintf("%s%d", g_test_prefix, i)); } +// when testing in single-threaded mode +VisitedLinkMaster* g_master = NULL; std::vector<VisitedLinkSlave*> g_slaves; VisitedLinkMaster::PostNewTableEvent SynchronousBroadcastNewTableEvent; void SynchronousBroadcastNewTableEvent(base::SharedMemory* table) { if (table) { for (std::vector<VisitedLinkSlave>::size_type i = 0; - i < g_slaves.size(); i++) { + i < (int)g_slaves.size(); i++) { base::SharedMemoryHandle new_handle = NULL; - table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); + table->ShareToProcess(GetCurrentProcess(), &new_handle); g_slaves[i]->Init(new_handle); } } } -} // namespace - class VisitedLinkTest : public testing::Test { protected: // Initialize the history system. This should be called before InitVisited(). bool InitHistory() { history_service_ = new HistoryService; - return history_service_->Init(history_dir_.ToWStringHack(), NULL); + return history_service_->Init(history_dir_, NULL); } // Initializes the visited link objects. Pass in the size that you want a @@ -104,7 +103,7 @@ class VisitedLinkTest : public testing::Test { // Create a slave database. VisitedLinkSlave slave; base::SharedMemoryHandle new_handle = NULL; - master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); + master_->ShareToProcess(GetCurrentProcess(), &new_handle); bool success = slave.Init(new_handle); ASSERT_TRUE(success); g_slaves.push_back(&slave); @@ -133,11 +132,12 @@ class VisitedLinkTest : public testing::Test { // testing::Test virtual void SetUp() { PathService::Get(base::DIR_TEMP, &history_dir_); - history_dir_ = history_dir_.Append(FILE_PATH_LITERAL("VisitedLinkTest")); + file_util::AppendToPath(&history_dir_, L"VisitedLinkTest"); file_util::Delete(history_dir_, true); file_util::CreateDirectory(history_dir_); - visited_file_ = history_dir_.Append(FILE_PATH_LITERAL("VisitedLinks")); + visited_file_ = history_dir_; + file_util::AppendToPath(&visited_file_, L"VisitedLinks"); } virtual void TearDown() { @@ -148,13 +148,15 @@ class VisitedLinkTest : public testing::Test { MessageLoop message_loop_; // Filenames for the services; - FilePath history_dir_; - FilePath visited_file_; + std::wstring history_dir_; + std::wstring visited_file_; scoped_ptr<VisitedLinkMaster> master_; scoped_refptr<HistoryService> history_service_; }; +} // namespace + // This test creates and reads some databases to make sure the data is // preserved throughout those operations. TEST_F(VisitedLinkTest, DatabaseIO) { @@ -176,11 +178,11 @@ TEST_F(VisitedLinkTest, Delete) { // Add a cluster from 14-17 wrapping around to 0. These will all hash to the // same value. - const VisitedLinkCommon::Fingerprint kFingerprint0 = kInitialSize * 0 + 14; - const VisitedLinkCommon::Fingerprint kFingerprint1 = kInitialSize * 1 + 14; - const VisitedLinkCommon::Fingerprint kFingerprint2 = kInitialSize * 2 + 14; - const VisitedLinkCommon::Fingerprint kFingerprint3 = kInitialSize * 3 + 14; - const VisitedLinkCommon::Fingerprint kFingerprint4 = kInitialSize * 4 + 14; + const int kFingerprint0 = kInitialSize * 0 + 14; + const int kFingerprint1 = kInitialSize * 1 + 14; + const int kFingerprint2 = kInitialSize * 2 + 14; + const int kFingerprint3 = kInitialSize * 3 + 14; + const int kFingerprint4 = kInitialSize * 4 + 14; master_->AddFingerprint(kFingerprint0); // @14 master_->AddFingerprint(kFingerprint1); // @15 master_->AddFingerprint(kFingerprint2); // @16 @@ -191,9 +193,8 @@ TEST_F(VisitedLinkTest, Delete) { // order). EXPECT_EQ(kFingerprint3, master_->hash_table_[0]); master_->DeleteFingerprint(kFingerprint3, false); - VisitedLinkCommon::Fingerprint zero_fingerprint = 0; - EXPECT_EQ(zero_fingerprint, master_->hash_table_[1]); - EXPECT_NE(zero_fingerprint, master_->hash_table_[0]); + EXPECT_EQ(0, master_->hash_table_[1]); + EXPECT_NE(0, master_->hash_table_[0]); // Deleting the other four should leave the table empty. master_->DeleteFingerprint(kFingerprint0, false); @@ -203,8 +204,7 @@ TEST_F(VisitedLinkTest, Delete) { EXPECT_EQ(0, master_->used_items_); for (int i = 0; i < kInitialSize; i++) - EXPECT_EQ(zero_fingerprint, master_->hash_table_[i]) << - "Hash table has values in it."; + EXPECT_EQ(0, master_->hash_table_[i]) << "Hash table has values in it."; } // When we delete more than kBigDeleteThreshold we trigger different behavior @@ -240,7 +240,7 @@ TEST_F(VisitedLinkTest, DeleteAll) { { VisitedLinkSlave slave; base::SharedMemoryHandle new_handle = NULL; - master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); + master_->ShareToProcess(GetCurrentProcess(), &new_handle); ASSERT_TRUE(slave.Init(new_handle)); g_slaves.push_back(&slave); @@ -288,7 +288,7 @@ TEST_F(VisitedLinkTest, Resizing) { // ...and a slave VisitedLinkSlave slave; base::SharedMemoryHandle new_handle = NULL; - master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); + master_->ShareToProcess(GetCurrentProcess(), &new_handle); bool success = slave.Init(new_handle); ASSERT_TRUE(success); g_slaves.push_back(&slave); |