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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/history/android/android_cache_database.h" | 9 #include "chrome/browser/history/android/android_cache_database.h" |
10 #include "chrome/browser/history/android/android_time.h" | 10 #include "chrome/browser/history/android/android_time.h" |
11 #include "chrome/browser/history/history_database.h" | 11 #include "chrome/browser/history/history_database.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using base::Time; | 15 using base::Time; |
16 using base::TimeDelta; | 16 using base::TimeDelta; |
17 | 17 |
18 namespace history { | 18 namespace history { |
19 | 19 |
20 class AndroidCacheDatabaseTest : public testing::Test { | 20 class AndroidCacheDatabaseTest : public testing::Test { |
21 public: | 21 public: |
22 AndroidCacheDatabaseTest() { | 22 AndroidCacheDatabaseTest() { |
23 } | 23 } |
24 ~AndroidCacheDatabaseTest() { | 24 virtual ~AndroidCacheDatabaseTest() {} |
25 } | |
26 | 25 |
27 protected: | 26 protected: |
28 virtual void SetUp() { | 27 virtual void SetUp() { |
29 // Get a temporary directory for the test DB files. | 28 // Get a temporary directory for the test DB files. |
30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
31 base::FilePath history_db_name_ = | 30 base::FilePath history_db_name_ = |
32 temp_dir_.path().AppendASCII("history.db"); | 31 temp_dir_.path().AppendASCII("history.db"); |
33 android_cache_db_name_ = temp_dir_.path().AppendASCII( | 32 android_cache_db_name_ = temp_dir_.path().AppendASCII( |
34 "TestAndroidCache.db"); | 33 "TestAndroidCache.db"); |
35 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, NULL)); | 34 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, NULL)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 EXPECT_FALSE(history_db_.GetSearchTerm(update_row1.term, NULL)); | 106 EXPECT_FALSE(history_db_.GetSearchTerm(update_row1.term, NULL)); |
108 // The search_term2 should still in the table. | 107 // The search_term2 should still in the table. |
109 ASSERT_EQ(id2, history_db_.GetSearchTerm(search_term2, &row1)); | 108 ASSERT_EQ(id2, history_db_.GetSearchTerm(search_term2, &row1)); |
110 EXPECT_EQ(id2, row1.id); | 109 EXPECT_EQ(id2, row1.id); |
111 EXPECT_EQ(ToDatabaseTime(search_time2), | 110 EXPECT_EQ(ToDatabaseTime(search_time2), |
112 ToDatabaseTime(row1.last_visit_time)); | 111 ToDatabaseTime(row1.last_visit_time)); |
113 EXPECT_EQ(search_term2, row1.term); | 112 EXPECT_EQ(search_term2, row1.term); |
114 } | 113 } |
115 | 114 |
116 } // namespace history | 115 } // namespace history |
OLD | NEW |