| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Returns true if the file exists and is read successfully, false otherwise. | 213 // Returns true if the file exists and is read successfully, false otherwise. |
| 214 bool GetWebDatabaseData(const base::FilePath& file, std::string* contents) { | 214 bool GetWebDatabaseData(const base::FilePath& file, std::string* contents) { |
| 215 base::FilePath source_path; | 215 base::FilePath source_path; |
| 216 PathService::Get(base::DIR_SOURCE_ROOT, &source_path); | 216 PathService::Get(base::DIR_SOURCE_ROOT, &source_path); |
| 217 source_path = source_path.AppendASCII("components"); | 217 source_path = source_path.AppendASCII("components"); |
| 218 source_path = source_path.AppendASCII("test"); | 218 source_path = source_path.AppendASCII("test"); |
| 219 source_path = source_path.AppendASCII("data"); | 219 source_path = source_path.AppendASCII("data"); |
| 220 source_path = source_path.AppendASCII("web_database"); | 220 source_path = source_path.AppendASCII("web_database"); |
| 221 source_path = source_path.Append(file); | 221 source_path = source_path.Append(file); |
| 222 return base::PathExists(source_path) && | 222 return base::PathExists(source_path) && |
| 223 file_util::ReadFileToString(source_path, contents); | 223 base::ReadFileToString(source_path, contents); |
| 224 } | 224 } |
| 225 | 225 |
| 226 static int VersionFromConnection(sql::Connection* connection) { | 226 static int VersionFromConnection(sql::Connection* connection) { |
| 227 // Get version. | 227 // Get version. |
| 228 sql::Statement s(connection->GetUniqueStatement( | 228 sql::Statement s(connection->GetUniqueStatement( |
| 229 "SELECT value FROM meta WHERE key='version'")); | 229 "SELECT value FROM meta WHERE key='version'")); |
| 230 if (!s.Step()) | 230 if (!s.Step()) |
| 231 return 0; | 231 return 0; |
| 232 return s.ColumnInt(0); | 232 return s.ColumnInt(0); |
| 233 } | 233 } |
| (...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2110 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2111 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 2111 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
| 2112 | 2112 |
| 2113 // Check version. | 2113 // Check version. |
| 2114 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 2114 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
| 2115 | 2115 |
| 2116 // New columns should have been created. | 2116 // New columns should have been created. |
| 2117 EXPECT_TRUE(connection.DoesColumnExist("keywords", "new_tab_url")); | 2117 EXPECT_TRUE(connection.DoesColumnExist("keywords", "new_tab_url")); |
| 2118 } | 2118 } |
| 2119 } | 2119 } |
| OLD | NEW |