| 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/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/history/shortcuts_backend.h" | 10 #include "chrome/browser/history/shortcuts_backend.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 AutocompleteMatch::Type output_type; | 115 AutocompleteMatch::Type output_type; |
| 116 } type_cases[] = { | 116 } type_cases[] = { |
| 117 { AutocompleteMatchType::URL_WHAT_YOU_TYPED, | 117 { AutocompleteMatchType::URL_WHAT_YOU_TYPED, |
| 118 AutocompleteMatchType::HISTORY_URL }, | 118 AutocompleteMatchType::HISTORY_URL }, |
| 119 { AutocompleteMatchType::NAVSUGGEST, | 119 { AutocompleteMatchType::NAVSUGGEST, |
| 120 AutocompleteMatchType::HISTORY_URL }, | 120 AutocompleteMatchType::HISTORY_URL }, |
| 121 { AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 121 { AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
| 122 AutocompleteMatchType::SEARCH_HISTORY }, | 122 AutocompleteMatchType::SEARCH_HISTORY }, |
| 123 { AutocompleteMatchType::SEARCH_SUGGEST, | 123 { AutocompleteMatchType::SEARCH_SUGGEST, |
| 124 AutocompleteMatchType::SEARCH_HISTORY }, | 124 AutocompleteMatchType::SEARCH_HISTORY }, |
| 125 { AutocompleteMatchType::SEARCH_SUGGEST_ENTITY, |
| 126 AutocompleteMatchType::SEARCH_HISTORY }, |
| 127 { AutocompleteMatchType::SEARCH_SUGGEST_INFINITE, |
| 128 AutocompleteMatchType::SEARCH_HISTORY }, |
| 129 { AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED, |
| 130 AutocompleteMatchType::SEARCH_HISTORY }, |
| 131 { AutocompleteMatchType::SEARCH_SUGGEST_PROFILE, |
| 132 AutocompleteMatchType::SEARCH_HISTORY }, |
| 125 }; | 133 }; |
| 126 | 134 |
| 127 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(type_cases); ++i) { | 135 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(type_cases); ++i) { |
| 128 EXPECT_EQ(type_cases[i].output_type, | 136 EXPECT_EQ(type_cases[i].output_type, |
| 129 ConvertedMatchType(type_cases[i].input_type)); | 137 ConvertedMatchType(type_cases[i].input_type)); |
| 130 } | 138 } |
| 131 } | 139 } |
| 132 | 140 |
| 141 TEST_F(ShortcutsBackendTest, EntitySuggestionTest) { |
| 142 AutocompleteMatch match; |
| 143 match.fill_into_edit = base::UTF8ToUTF16("franklin d roosevelt"); |
| 144 match.type = AutocompleteMatchType::SEARCH_SUGGEST_ENTITY; |
| 145 match.contents = base::UTF8ToUTF16("roosevelt"); |
| 146 match.contents_class = |
| 147 AutocompleteMatch::ClassificationsFromString("0,0,5,2"); |
| 148 match.description = base::UTF8ToUTF16("Franklin D. Roosevelt"); |
| 149 match.description_class = AutocompleteMatch::ClassificationsFromString("0,4"); |
| 150 match.destination_url = GURL( |
| 151 "http://www.google.com/search?q=franklin+d+roosevelt&gs_ssp=1234"); |
| 152 match.stripped_destination_url = GURL( |
| 153 "http://www.google.com/search?q=franklin+d+roosevelt"); |
| 154 |
| 155 ShortcutsBackend::Shortcut::MatchCore match_core(match); |
| 156 |
| 157 EXPECT_EQ(match.stripped_destination_url, match_core.destination_url); |
| 158 EXPECT_EQ(match.fill_into_edit, match_core.contents); |
| 159 EXPECT_TRUE(match_core.contents_class.empty()); |
| 160 EXPECT_EQ(base::string16(), match_core.description); |
| 161 EXPECT_TRUE(match_core.description_class.empty()); |
| 162 } |
| 163 |
| 133 TEST_F(ShortcutsBackendTest, AddAndUpdateShortcut) { | 164 TEST_F(ShortcutsBackendTest, AddAndUpdateShortcut) { |
| 134 InitBackend(); | 165 InitBackend(); |
| 135 EXPECT_FALSE(changed_notified_); | 166 EXPECT_FALSE(changed_notified_); |
| 136 ShortcutsBackend::Shortcut shortcut( | 167 ShortcutsBackend::Shortcut shortcut( |
| 137 "BD85DBA2-8C29-49F9-84AE-48E1E90880DF", base::ASCIIToUTF16("goog"), | 168 "BD85DBA2-8C29-49F9-84AE-48E1E90880DF", base::ASCIIToUTF16("goog"), |
| 138 MatchCoreForTesting("http://www.google.com"), base::Time::Now(), 100); | 169 MatchCoreForTesting("http://www.google.com"), base::Time::Now(), 100); |
| 139 EXPECT_TRUE(backend_->AddShortcut(shortcut)); | 170 EXPECT_TRUE(backend_->AddShortcut(shortcut)); |
| 140 EXPECT_TRUE(changed_notified_); | 171 EXPECT_TRUE(changed_notified_); |
| 141 changed_notified_ = false; | 172 changed_notified_ = false; |
| 142 | 173 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 std::vector<std::string> deleted_ids; | 228 std::vector<std::string> deleted_ids; |
| 198 deleted_ids.push_back(shortcut3.id); | 229 deleted_ids.push_back(shortcut3.id); |
| 199 deleted_ids.push_back(shortcut4.id); | 230 deleted_ids.push_back(shortcut4.id); |
| 200 | 231 |
| 201 EXPECT_TRUE(backend_->DeleteShortcutsWithIds(deleted_ids)); | 232 EXPECT_TRUE(backend_->DeleteShortcutsWithIds(deleted_ids)); |
| 202 | 233 |
| 203 ASSERT_EQ(0U, shortcuts.size()); | 234 ASSERT_EQ(0U, shortcuts.size()); |
| 204 } | 235 } |
| 205 | 236 |
| 206 } // namespace history | 237 } // namespace history |
| OLD | NEW |