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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 | 910 |
911 protected: | 911 protected: |
912 friend class BackendDelegate; | 912 friend class BackendDelegate; |
913 | 913 |
914 // testing::Test | 914 // testing::Test |
915 virtual void SetUp() { | 915 virtual void SetUp() { |
916 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 916 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
917 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); | 917 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); |
918 ASSERT_TRUE(base::CreateDirectory(history_dir_)); | 918 ASSERT_TRUE(base::CreateDirectory(history_dir_)); |
919 history_service_.reset(new HistoryService); | 919 history_service_.reset(new HistoryService); |
920 if (!history_service_->Init(history_dir_, NULL)) { | 920 if (!history_service_->Init(history_dir_)) { |
921 history_service_.reset(); | 921 history_service_.reset(); |
922 ADD_FAILURE(); | 922 ADD_FAILURE(); |
923 } | 923 } |
924 } | 924 } |
925 | 925 |
926 virtual void TearDown() { | 926 virtual void TearDown() { |
927 if (history_service_) | 927 if (history_service_) |
928 CleanupHistoryService(); | 928 CleanupHistoryService(); |
929 | 929 |
930 // Make sure we don't have any event pending that could disrupt the next | 930 // Make sure we don't have any event pending that could disrupt the next |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 std::vector<PageUsageData*> results; | 1842 std::vector<PageUsageData*> results; |
1843 db_->QuerySegmentUsage(segment_time, 10, &results); | 1843 db_->QuerySegmentUsage(segment_time, 10, &results); |
1844 ASSERT_EQ(1u, results.size()); | 1844 ASSERT_EQ(1u, results.size()); |
1845 EXPECT_EQ(url, results[0]->GetURL()); | 1845 EXPECT_EQ(url, results[0]->GetURL()); |
1846 EXPECT_EQ(segment_id, results[0]->GetID()); | 1846 EXPECT_EQ(segment_id, results[0]->GetID()); |
1847 EXPECT_EQ(title, results[0]->GetTitle()); | 1847 EXPECT_EQ(title, results[0]->GetTitle()); |
1848 STLDeleteElements(&results); | 1848 STLDeleteElements(&results); |
1849 } | 1849 } |
1850 | 1850 |
1851 } // namespace history | 1851 } // namespace history |
OLD | NEW |