OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/webui/history_ui.h" | 5 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 struct TestResult { | 12 struct TestResult { |
13 std::string url; | 13 std::string url; |
14 int64 hour_offset; // Visit time in hours past the baseline time. | 14 int64 hour_offset; // Visit time in hours past the baseline time. |
15 }; | 15 }; |
(...skipping 26 matching lines...) Expand all Loading... |
42 base::Time correct_time = | 42 base::Time correct_time = |
43 baseline_time + base::TimeDelta::FromHours(correct_result.hour_offset); | 43 baseline_time + base::TimeDelta::FromHours(correct_result.hour_offset); |
44 | 44 |
45 return result.time == correct_time && result.url == GURL(correct_result.url); | 45 return result.time == correct_time && result.url == GURL(correct_result.url); |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 // Tests that the MergeDuplicateResults method correctly removes duplicate | 50 // Tests that the MergeDuplicateResults method correctly removes duplicate |
51 // visits to the same URL on the same day. | 51 // visits to the same URL on the same day. |
52 TEST(HistoryUITest, MergeDuplicateResults) { | 52 TEST(BrowsingHistoryHandlerTest, MergeDuplicateResults) { |
53 { | 53 { |
54 // Basic test that duplicates on the same day are removed. | 54 // Basic test that duplicates on the same day are removed. |
55 TestResult test_data[] = { | 55 TestResult test_data[] = { |
56 { "http://google.com", 0 }, | 56 { "http://google.com", 0 }, |
57 { "http://google.de", 1 }, | 57 { "http://google.de", 1 }, |
58 { "http://google.com", 2 }, | 58 { "http://google.com", 2 }, |
59 { "http://google.com", 3 } // Most recent. | 59 { "http://google.com", 3 } // Most recent. |
60 }; | 60 }; |
61 std::vector<BrowsingHistoryHandler::HistoryEntry> results; | 61 std::vector<BrowsingHistoryHandler::HistoryEntry> results; |
62 AddQueryResults(test_data, arraysize(test_data), &results); | 62 AddQueryResults(test_data, arraysize(test_data), &results); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 AddQueryResults(test_data, arraysize(test_data), &results); | 121 AddQueryResults(test_data, arraysize(test_data), &results); |
122 BrowsingHistoryHandler::MergeDuplicateResults(&results); | 122 BrowsingHistoryHandler::MergeDuplicateResults(&results); |
123 | 123 |
124 ASSERT_EQ(2U, results.size()); | 124 ASSERT_EQ(2U, results.size()); |
125 EXPECT_TRUE(ResultEquals(results[0], test_data[3])); | 125 EXPECT_TRUE(ResultEquals(results[0], test_data[3])); |
126 EXPECT_TRUE(ResultEquals(results[1], test_data[1])); | 126 EXPECT_TRUE(ResultEquals(results[1], test_data[1])); |
127 EXPECT_EQ(3u, results[0].all_timestamps.size()); | 127 EXPECT_EQ(3u, results[0].all_timestamps.size()); |
128 EXPECT_EQ(1u, results[1].all_timestamps.size()); | 128 EXPECT_EQ(1u, results[1].all_timestamps.size()); |
129 } | 129 } |
130 } | 130 } |
OLD | NEW |