Chromium Code Reviews| 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/history_ui.h" |
| 6 | 6 |
| 7 #include <string> | |
| 8 | |
| 7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 11 |
| 10 namespace { | 12 namespace { |
| 11 | 13 |
| 12 struct TestResult { | 14 struct TestResult { |
| 13 std::string url; | 15 std::string url; |
| 14 int64 hour_offset; // Visit time in hours past the baseline time. | 16 int64 hour_offset; // Visit time in hours past the baseline time. |
| 15 }; | 17 }; |
| 16 | 18 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 AddQueryResults(test_data, arraysize(test_data), &results); | 123 AddQueryResults(test_data, arraysize(test_data), &results); |
| 122 BrowsingHistoryHandler::MergeDuplicateResults(&results); | 124 BrowsingHistoryHandler::MergeDuplicateResults(&results); |
| 123 | 125 |
| 124 ASSERT_EQ(2U, results.size()); | 126 ASSERT_EQ(2U, results.size()); |
| 125 EXPECT_TRUE(ResultEquals(results[0], test_data[3])); | 127 EXPECT_TRUE(ResultEquals(results[0], test_data[3])); |
| 126 EXPECT_TRUE(ResultEquals(results[1], test_data[1])); | 128 EXPECT_TRUE(ResultEquals(results[1], test_data[1])); |
| 127 EXPECT_EQ(3u, results[0].all_timestamps.size()); | 129 EXPECT_EQ(3u, results[0].all_timestamps.size()); |
| 128 EXPECT_EQ(1u, results[1].all_timestamps.size()); | 130 EXPECT_EQ(1u, results[1].all_timestamps.size()); |
| 129 } | 131 } |
| 130 } | 132 } |
| 133 | |
| 134 TEST(HistoryUITest, SetDisplayableDomain) { | |
|
Patrick Dubroy
2013/08/20 14:26:37
I think it would be much more valuable to add a te
| |
| 135 const std::string key = "displayableDomain"; | |
| 136 BrowsingHistoryHandler::HistoryEntry history_entry; | |
| 137 DictionaryValue dict_value; | |
| 138 history_entry.url = GURL("http://xn--d1abbgf6aiiy.xn--p1ai/"); | |
| 139 history_entry.SetDisplayableDomain(&dict_value); | |
| 140 EXPECT_TRUE(dict_value.HasKey(key)); | |
| 141 string16 str16; | |
| 142 dict_value.GetString(key, &str16); | |
| 143 const std::string str = base::UTF16ToUTF8(str16); | |
| 144 EXPECT_EQ(str, "\xD0\xBF\xD1\x80\xD0\xB5\xD0\xB7\xD0\xB8\xD0\xB4" | |
| 145 "\xD0\xB5\xD0\xBD\xD1\x82.\xD1\x80\xD1\x84"); | |
| 146 } | |
| 147 | |
| OLD | NEW |