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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 // testing::Test | 140 // testing::Test |
141 virtual void SetUp() { | 141 virtual void SetUp() { |
142 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 142 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
143 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); | 143 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); |
144 ASSERT_TRUE(file_util::CreateDirectory(history_dir_)); | 144 ASSERT_TRUE(file_util::CreateDirectory(history_dir_)); |
145 } | 145 } |
146 | 146 |
147 void DeleteBackend() { | 147 void DeleteBackend() { |
148 if (backend_) { | 148 if (backend_.get()) { |
149 backend_->Closing(); | 149 backend_->Closing(); |
150 backend_ = NULL; | 150 backend_ = NULL; |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 virtual void TearDown() { | 154 virtual void TearDown() { |
155 DeleteBackend(); | 155 DeleteBackend(); |
156 | 156 |
157 // Make sure we don't have any event pending that could disrupt the next | 157 // Make sure we don't have any event pending that could disrupt the next |
158 // test. | 158 // test. |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 std::vector<PageUsageData*> results; | 1658 std::vector<PageUsageData*> results; |
1659 db_->QuerySegmentUsage(segment_time, 10, &results); | 1659 db_->QuerySegmentUsage(segment_time, 10, &results); |
1660 ASSERT_EQ(1u, results.size()); | 1660 ASSERT_EQ(1u, results.size()); |
1661 EXPECT_EQ(url, results[0]->GetURL()); | 1661 EXPECT_EQ(url, results[0]->GetURL()); |
1662 EXPECT_EQ(segment_id, results[0]->GetID()); | 1662 EXPECT_EQ(segment_id, results[0]->GetID()); |
1663 EXPECT_EQ(title, results[0]->GetTitle()); | 1663 EXPECT_EQ(title, results[0]->GetTitle()); |
1664 STLDeleteElements(&results); | 1664 STLDeleteElements(&results); |
1665 } | 1665 } |
1666 | 1666 |
1667 } // namespace history | 1667 } // namespace history |
OLD | NEW |