OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" |
| 7 #include "base/scoped_temp_dir.h" |
| 8 #include "chrome/browser/history/android/android_cache_database.h" |
| 9 #include "chrome/browser/history/history_database.h" |
| 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace history { |
| 14 |
| 15 class SimpleAndroidCacheDatabase : public AndroidCacheDatabase { |
| 16 public: |
| 17 explicit SimpleAndroidCacheDatabase(sql::Connection* connection) |
| 18 :db_(connection) { |
| 19 } |
| 20 |
| 21 protected: |
| 22 sql::Connection& GetDB() { |
| 23 return *db_; |
| 24 } |
| 25 |
| 26 private: |
| 27 sql::Connection* db_; |
| 28 }; |
| 29 |
| 30 class AndroidCacheDatabaseTest : public testing::Test { |
| 31 public: |
| 32 AndroidCacheDatabaseTest() { |
| 33 } |
| 34 ~AndroidCacheDatabaseTest() { |
| 35 } |
| 36 |
| 37 protected: |
| 38 virtual void SetUp() { |
| 39 // Get a temporary directory for the test DB files. |
| 40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 41 main_db_name_ = temp_dir_.path().AppendASCII("history.db"); |
| 42 android_cache_db_name_ = temp_dir_.path().AppendASCII( |
| 43 "TestAndroidCache.db"); |
| 44 } |
| 45 |
| 46 ScopedTempDir temp_dir_; |
| 47 FilePath android_cache_db_name_; |
| 48 FilePath main_db_name_; |
| 49 }; |
| 50 |
| 51 TEST_F(AndroidCacheDatabaseTest, InitAndroidCacheDatabase) { |
| 52 sql::Connection connection; |
| 53 ASSERT_TRUE(connection.Open(main_db_name_)); |
| 54 SimpleAndroidCacheDatabase android_cache_db(&connection); |
| 55 EXPECT_EQ(sql::INIT_OK, |
| 56 android_cache_db.InitAndroidCacheDatabase(android_cache_db_name_)); |
| 57 // Try to run a sql against the table to verify it exists. |
| 58 EXPECT_TRUE(connection.Execute( |
| 59 "DELETE FROM android_cache_db.bookmark_cache")); |
| 60 } |
| 61 |
| 62 } // namespace history |
OLD | NEW |