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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 db1.reset(CreateDB(kIdee1, false, false)); | 157 db1.reset(CreateDB(kIdee1, false, false)); |
158 ASSERT_TRUE(!!db1.get()); | 158 ASSERT_TRUE(!!db1.get()); |
159 | 159 |
160 // We should not be able to attach this random database for which no file | 160 // We should not be able to attach this random database for which no file |
161 // exists. | 161 // exists. |
162 const int kIdeeNoExisto = 999999999; | 162 const int kIdeeNoExisto = 999999999; |
163 scoped_ptr<TextDatabase> db3(CreateDB(kIdeeNoExisto, false, true)); | 163 scoped_ptr<TextDatabase> db3(CreateDB(kIdeeNoExisto, false, true)); |
164 EXPECT_FALSE(!!db3.get()); | 164 EXPECT_FALSE(!!db3.get()); |
165 } | 165 } |
166 | 166 |
| 167 // TODO(sqs): this test fails - fix it |
167 TEST_F(TextDatabaseTest, AddRemove) { | 168 TEST_F(TextDatabaseTest, AddRemove) { |
168 // Create a database and add some pages to it. | 169 // Create a database and add some pages to it. |
169 const int kIdee1 = 200801; | 170 const int kIdee1 = 200801; |
170 scoped_ptr<TextDatabase> db(CreateDB(kIdee1, true, true)); | 171 scoped_ptr<TextDatabase> db(CreateDB(kIdee1, true, true)); |
171 ASSERT_TRUE(!!db.get()); | 172 ASSERT_TRUE(!!db.get()); |
172 URLID id1 = db->AddPageData( | 173 URLID id1 = db->AddPageData( |
173 Time::FromInternalValue(kTime1), kURL1, kTitle1, kBody1); | 174 Time::FromInternalValue(kTime1), kURL1, kTitle1, kBody1); |
174 EXPECT_NE(0, id1); | 175 EXPECT_NE(0, id1); |
175 URLID id2 = db->AddPageData( | 176 URLID id2 = db->AddPageData( |
176 Time::FromInternalValue(kTime2), kURL2, kTitle2, kBody2); | 177 Time::FromInternalValue(kTime2), kURL2, kTitle2, kBody2); |
(...skipping 10 matching lines...) Expand all Loading... |
187 // Close and reopen. | 188 // Close and reopen. |
188 db.reset(new TextDatabase(temp_path_, kIdee1, false)); | 189 db.reset(new TextDatabase(temp_path_, kIdee1, false)); |
189 EXPECT_TRUE(db->Init()); | 190 EXPECT_TRUE(db->Init()); |
190 | 191 |
191 // Verify that the deleted ID is gone and try to delete another one. | 192 // Verify that the deleted ID is gone and try to delete another one. |
192 EXPECT_EQ(2, RowCount(db.get())); | 193 EXPECT_EQ(2, RowCount(db.get())); |
193 db->DeletePageData(Time::FromInternalValue(kTime2), kURL2); | 194 db->DeletePageData(Time::FromInternalValue(kTime2), kURL2); |
194 EXPECT_EQ(1, RowCount(db.get())); | 195 EXPECT_EQ(1, RowCount(db.get())); |
195 } | 196 } |
196 | 197 |
| 198 // TODO(sqs): this test fails - fix it |
197 TEST_F(TextDatabaseTest, Query) { | 199 TEST_F(TextDatabaseTest, Query) { |
198 // Make a database with some pages. | 200 // Make a database with some pages. |
199 const int kIdee1 = 200801; | 201 const int kIdee1 = 200801; |
200 scoped_ptr<TextDatabase> db(CreateDB(kIdee1, true, true)); | 202 scoped_ptr<TextDatabase> db(CreateDB(kIdee1, true, true)); |
201 EXPECT_TRUE(!!db.get()); | 203 EXPECT_TRUE(!!db.get()); |
202 AddAllTestData(db.get()); | 204 AddAllTestData(db.get()); |
203 | 205 |
204 // Get all the results. | 206 // Get all the results. |
205 QueryOptions options; | 207 QueryOptions options; |
206 options.begin_time = Time::FromInternalValue(0); | 208 options.begin_time = Time::FromInternalValue(0); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 325 |
324 // There should be one result, the most recent one. | 326 // There should be one result, the most recent one. |
325 EXPECT_EQ(1U, results.size()); | 327 EXPECT_EQ(1U, results.size()); |
326 EXPECT_TRUE(ResultsHaveURL(results, kURL2)); | 328 EXPECT_TRUE(ResultsHaveURL(results, kURL2)); |
327 | 329 |
328 // The max time considered should be the date of the returned item. | 330 // The max time considered should be the date of the returned item. |
329 EXPECT_EQ(kTime2, first_time_searched.ToInternalValue()); | 331 EXPECT_EQ(kTime2, first_time_searched.ToInternalValue()); |
330 } | 332 } |
331 | 333 |
332 } // namespace history | 334 } // namespace history |
OLD | NEW |