| 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 // History unit tests come in two flavors: | 5 // History unit tests come in two flavors: |
| 6 // | 6 // |
| 7 // 1. The more complicated style is that the unit test creates a full history | 7 // 1. The more complicated style is that the unit test creates a full history |
| 8 // service. This spawns a background thread for the history backend, and | 8 // service. This spawns a background thread for the history backend, and |
| 9 // all communication is asynchronous. This is useful for testing more | 9 // all communication is asynchronous. This is useful for testing more |
| 10 // complicated things or end-to-end behavior. | 10 // complicated things or end-to-end behavior. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 data_path.AppendASCII(base::StringPrintf("history.%d.sql", version)); | 133 data_path.AppendASCII(base::StringPrintf("history.%d.sql", version)); |
| 134 ASSERT_NO_FATAL_FAILURE( | 134 ASSERT_NO_FATAL_FAILURE( |
| 135 ExecuteSQLScript(data_path, history_dir_.Append( | 135 ExecuteSQLScript(data_path, history_dir_.Append( |
| 136 chrome::kHistoryFilename))); | 136 chrome::kHistoryFilename))); |
| 137 } | 137 } |
| 138 | 138 |
| 139 // testing::Test | 139 // testing::Test |
| 140 virtual void SetUp() { | 140 virtual void SetUp() { |
| 141 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 141 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 142 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); | 142 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); |
| 143 ASSERT_TRUE(file_util::CreateDirectory(history_dir_)); | 143 ASSERT_TRUE(base::CreateDirectory(history_dir_)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void DeleteBackend() { | 146 void DeleteBackend() { |
| 147 if (backend_.get()) { | 147 if (backend_.get()) { |
| 148 backend_->Closing(); | 148 backend_->Closing(); |
| 149 backend_ = NULL; | 149 backend_ = NULL; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 virtual void TearDown() { | 153 virtual void TearDown() { |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 base::MessageLoop::current()->Quit(); | 905 base::MessageLoop::current()->Quit(); |
| 906 } | 906 } |
| 907 | 907 |
| 908 protected: | 908 protected: |
| 909 friend class BackendDelegate; | 909 friend class BackendDelegate; |
| 910 | 910 |
| 911 // testing::Test | 911 // testing::Test |
| 912 virtual void SetUp() { | 912 virtual void SetUp() { |
| 913 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 913 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 914 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); | 914 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); |
| 915 ASSERT_TRUE(file_util::CreateDirectory(history_dir_)); | 915 ASSERT_TRUE(base::CreateDirectory(history_dir_)); |
| 916 history_service_.reset(new HistoryService); | 916 history_service_.reset(new HistoryService); |
| 917 if (!history_service_->Init(history_dir_, NULL)) { | 917 if (!history_service_->Init(history_dir_, NULL)) { |
| 918 history_service_.reset(); | 918 history_service_.reset(); |
| 919 ADD_FAILURE(); | 919 ADD_FAILURE(); |
| 920 } | 920 } |
| 921 } | 921 } |
| 922 | 922 |
| 923 virtual void TearDown() { | 923 virtual void TearDown() { |
| 924 if (history_service_) | 924 if (history_service_) |
| 925 CleanupHistoryService(); | 925 CleanupHistoryService(); |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 std::vector<PageUsageData*> results; | 1880 std::vector<PageUsageData*> results; |
| 1881 db_->QuerySegmentUsage(segment_time, 10, &results); | 1881 db_->QuerySegmentUsage(segment_time, 10, &results); |
| 1882 ASSERT_EQ(1u, results.size()); | 1882 ASSERT_EQ(1u, results.size()); |
| 1883 EXPECT_EQ(url, results[0]->GetURL()); | 1883 EXPECT_EQ(url, results[0]->GetURL()); |
| 1884 EXPECT_EQ(segment_id, results[0]->GetID()); | 1884 EXPECT_EQ(segment_id, results[0]->GetID()); |
| 1885 EXPECT_EQ(title, results[0]->GetTitle()); | 1885 EXPECT_EQ(title, results[0]->GetTitle()); |
| 1886 STLDeleteElements(&results); | 1886 STLDeleteElements(&results); |
| 1887 } | 1887 } |
| 1888 | 1888 |
| 1889 } // namespace history | 1889 } // namespace history |
| OLD | NEW |