| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 10 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // should be to search for what we typed. | 128 // should be to search for what we typed. |
| 129 const AutocompleteResult& result = autocomplete_controller->result(); | 129 const AutocompleteResult& result = autocomplete_controller->result(); |
| 130 ASSERT_EQ(5U, result.size()) << AutocompleteResultAsString(result); | 130 ASSERT_EQ(5U, result.size()) << AutocompleteResultAsString(result); |
| 131 | 131 |
| 132 ASSERT_TRUE(result.match_at(0).template_url); | 132 ASSERT_TRUE(result.match_at(0).template_url); |
| 133 EXPECT_EQ(L"keyword suggestio", result.match_at(0).fill_into_edit); | 133 EXPECT_EQ(L"keyword suggestio", result.match_at(0).fill_into_edit); |
| 134 EXPECT_EQ(L"keyword suggestion1", result.match_at(1).fill_into_edit); | 134 EXPECT_EQ(L"keyword suggestion1", result.match_at(1).fill_into_edit); |
| 135 EXPECT_EQ(L"keyword suggestion2", result.match_at(2).fill_into_edit); | 135 EXPECT_EQ(L"keyword suggestion2", result.match_at(2).fill_into_edit); |
| 136 EXPECT_EQ(L"keyword suggestion3", result.match_at(3).fill_into_edit); | 136 EXPECT_EQ(L"keyword suggestion3", result.match_at(3).fill_into_edit); |
| 137 | 137 |
| 138 std::wstring description = L"Description with style: <match> [dim], none"; | 138 std::wstring description = |
| 139 L"Description with style: <match>, [dim], (url till end)"; |
| 139 EXPECT_EQ(description, result.match_at(1).contents); | 140 EXPECT_EQ(description, result.match_at(1).contents); |
| 140 ASSERT_EQ(5u, result.match_at(1).contents_class.size()); | 141 ASSERT_EQ(6u, result.match_at(1).contents_class.size()); |
| 142 |
| 141 EXPECT_EQ(0u, | 143 EXPECT_EQ(0u, |
| 142 result.match_at(1).contents_class[0].offset); | 144 result.match_at(1).contents_class[0].offset); |
| 143 EXPECT_EQ(ACMatchClassification::NONE, | 145 EXPECT_EQ(ACMatchClassification::NONE, |
| 144 result.match_at(1).contents_class[0].style); | 146 result.match_at(1).contents_class[0].style); |
| 147 |
| 145 EXPECT_EQ(description.find('<'), | 148 EXPECT_EQ(description.find('<'), |
| 146 result.match_at(1).contents_class[1].offset); | 149 result.match_at(1).contents_class[1].offset); |
| 147 EXPECT_EQ(ACMatchClassification::MATCH, | 150 EXPECT_EQ(ACMatchClassification::MATCH, |
| 148 result.match_at(1).contents_class[1].style); | 151 result.match_at(1).contents_class[1].style); |
| 152 |
| 149 EXPECT_EQ(description.find('>'), | 153 EXPECT_EQ(description.find('>'), |
| 150 result.match_at(1).contents_class[2].offset); | 154 result.match_at(1).contents_class[2].offset); |
| 151 EXPECT_EQ(ACMatchClassification::NONE, | 155 EXPECT_EQ(ACMatchClassification::NONE, |
| 152 result.match_at(1).contents_class[2].style); | 156 result.match_at(1).contents_class[2].style); |
| 157 |
| 153 EXPECT_EQ(description.find('['), | 158 EXPECT_EQ(description.find('['), |
| 154 result.match_at(1).contents_class[3].offset); | 159 result.match_at(1).contents_class[3].offset); |
| 155 EXPECT_EQ(ACMatchClassification::DIM, | 160 EXPECT_EQ(ACMatchClassification::DIM, |
| 156 result.match_at(1).contents_class[3].style); | 161 result.match_at(1).contents_class[3].style); |
| 162 |
| 157 EXPECT_EQ(description.find(']'), | 163 EXPECT_EQ(description.find(']'), |
| 158 result.match_at(1).contents_class[4].offset); | 164 result.match_at(1).contents_class[4].offset); |
| 159 EXPECT_EQ(ACMatchClassification::NONE, | 165 EXPECT_EQ(ACMatchClassification::NONE, |
| 160 result.match_at(1).contents_class[4].style); | 166 result.match_at(1).contents_class[4].style); |
| 161 | 167 |
| 168 EXPECT_EQ(description.find('('), |
| 169 result.match_at(1).contents_class[5].offset); |
| 170 EXPECT_EQ(ACMatchClassification::URL, |
| 171 result.match_at(1).contents_class[5].style); |
| 172 |
| 162 AutocompleteMatch match = result.match_at(4); | 173 AutocompleteMatch match = result.match_at(4); |
| 163 EXPECT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, match.type); | 174 EXPECT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, match.type); |
| 164 EXPECT_FALSE(match.deletable); | 175 EXPECT_FALSE(match.deletable); |
| 165 } | 176 } |
| 166 | 177 |
| 167 { | 178 { |
| 168 ResultCatcher catcher; | 179 ResultCatcher catcher; |
| 169 autocomplete_controller->Start(L"keyword command", std::wstring(), | 180 autocomplete_controller->Start(L"keyword command", std::wstring(), |
| 170 true, false, true, false); | 181 true, false, true, false); |
| 171 location_bar->AcceptInput(); | 182 location_bar->AcceptInput(); |
| 172 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 183 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 173 } | 184 } |
| 174 } | 185 } |
| OLD | NEW |