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 // History unit tests come in two flavors: | 5 // History unit tests come in two flavors: |
6 // | 6 // |
7 // 1. The more complicated style is that the unit test creates a full history | 7 // 1. The more complicated style is that the unit test creates a full history |
8 // service. This spawns a background thread for the history backend, and | 8 // service. This spawns a background thread for the history backend, and |
9 // all communication is asynchronous. This is useful for testing more | 9 // all communication is asynchronous. This is useful for testing more |
10 // complicated things or end-to-end behavior. | 10 // complicated things or end-to-end behavior. |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 993 |
994 protected: | 994 protected: |
995 friend class BackendDelegate; | 995 friend class BackendDelegate; |
996 | 996 |
997 // testing::Test | 997 // testing::Test |
998 void SetUp() override { | 998 void SetUp() override { |
999 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 999 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
1000 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); | 1000 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); |
1001 ASSERT_TRUE(base::CreateDirectory(history_dir_)); | 1001 ASSERT_TRUE(base::CreateDirectory(history_dir_)); |
1002 history_service_.reset(new HistoryService); | 1002 history_service_.reset(new HistoryService); |
1003 if (!history_service_->Init(HistoryDatabaseParamsForPath(history_dir_))) { | 1003 if (!history_service_->Init(std::string(), |
| 1004 HistoryDatabaseParamsForPath(history_dir_))) { |
1004 history_service_.reset(); | 1005 history_service_.reset(); |
1005 ADD_FAILURE(); | 1006 ADD_FAILURE(); |
1006 } | 1007 } |
1007 } | 1008 } |
1008 | 1009 |
1009 void TearDown() override { | 1010 void TearDown() override { |
1010 if (history_service_) | 1011 if (history_service_) |
1011 CleanupHistoryService(); | 1012 CleanupHistoryService(); |
1012 | 1013 |
1013 // Make sure we don't have any event pending that could disrupt the next | 1014 // Make sure we don't have any event pending that could disrupt the next |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 std::vector<PageUsageData*> results; | 1866 std::vector<PageUsageData*> results; |
1866 db_->QuerySegmentUsage(segment_time, 10, &results); | 1867 db_->QuerySegmentUsage(segment_time, 10, &results); |
1867 ASSERT_EQ(1u, results.size()); | 1868 ASSERT_EQ(1u, results.size()); |
1868 EXPECT_EQ(url, results[0]->GetURL()); | 1869 EXPECT_EQ(url, results[0]->GetURL()); |
1869 EXPECT_EQ(segment_id, results[0]->GetID()); | 1870 EXPECT_EQ(segment_id, results[0]->GetID()); |
1870 EXPECT_EQ(title, results[0]->GetTitle()); | 1871 EXPECT_EQ(title, results[0]->GetTitle()); |
1871 STLDeleteElements(&results); | 1872 STLDeleteElements(&results); |
1872 } | 1873 } |
1873 | 1874 |
1874 } // namespace history | 1875 } // namespace history |
OLD | NEW |