OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "chrome/browser/history/top_sites_database.h" | 8 #include "chrome/browser/history/top_sites_database.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace history { | 11 namespace history { |
12 | 12 |
13 class TopSitesDatabaseTest : public testing::Test { | 13 class TopSitesDatabaseTest : public testing::Test { |
14 protected: | 14 protected: |
15 virtual void SetUp() { | 15 virtual void SetUp() { |
16 // Get a temporary directory for the test DB files. | 16 // Get a temporary directory for the test DB files. |
17 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 17 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
18 file_name_ = temp_dir_.path().AppendASCII("TestTopSites.db"); | 18 file_name_ = temp_dir_.path().AppendASCII("TestTopSites.db"); |
19 } | 19 } |
20 | 20 |
21 ScopedTempDir temp_dir_; | 21 base::ScopedTempDir temp_dir_; |
22 FilePath file_name_; | 22 FilePath file_name_; |
23 }; | 23 }; |
24 | 24 |
25 TEST_F(TopSitesDatabaseTest, UpgradeToVersion2) { | 25 TEST_F(TopSitesDatabaseTest, UpgradeToVersion2) { |
26 TopSitesDatabase db; | 26 TopSitesDatabase db; |
27 ASSERT_TRUE(db.Init(file_name_)); | 27 ASSERT_TRUE(db.Init(file_name_)); |
28 | 28 |
29 // Create a version 1 table. SQLite doesn't support DROP COLUMN with | 29 // Create a version 1 table. SQLite doesn't support DROP COLUMN with |
30 // ALTER TABLE. Hence, we recreate a table here. | 30 // ALTER TABLE. Hence, we recreate a table here. |
31 ASSERT_TRUE(db.db_->Execute("DROP TABLE IF EXISTS thumbnails")); | 31 ASSERT_TRUE(db.db_->Execute("DROP TABLE IF EXISTS thumbnails")); |
(...skipping 15 matching lines...) Expand all Loading... |
47 | 47 |
48 // Upgrade to version 2. | 48 // Upgrade to version 2. |
49 ASSERT_TRUE(db.UpgradeToVersion2()); | 49 ASSERT_TRUE(db.UpgradeToVersion2()); |
50 | 50 |
51 // Make sure the table meets the version 2 criteria. | 51 // Make sure the table meets the version 2 criteria. |
52 ASSERT_EQ(2, db.meta_table_.GetVersionNumber()); | 52 ASSERT_EQ(2, db.meta_table_.GetVersionNumber()); |
53 ASSERT_TRUE(db.db_->DoesColumnExist("thumbnails", "load_completed")); | 53 ASSERT_TRUE(db.db_->DoesColumnExist("thumbnails", "load_completed")); |
54 } | 54 } |
55 | 55 |
56 } // namespace history | 56 } // namespace history |
OLD | NEW |