| OLD | NEW | 
|     1 // Copyright 2012 The Chromium Authors. All rights reserved. |     1 // Copyright 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 "chrome/browser/autocomplete/search_provider.h" |     5 #include "chrome/browser/autocomplete/search_provider.h" | 
|     6  |     6  | 
|     7 #include "base/run_loop.h" |     7 #include "base/run_loop.h" | 
|     8 #include "base/string_util.h" |     8 #include "base/string_util.h" | 
|     9 #include "base/time.h" |     9 #include "base/time.h" | 
|    10 #include "base/utf_string_conversions.h" |    10 #include "base/utf_string_conversions.h" | 
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   201 #else |   201 #else | 
|   202   base::RunLoop run_loop; |   202   base::RunLoop run_loop; | 
|   203   run_loop.Run(); |   203   run_loop.Run(); | 
|   204 #endif |   204 #endif | 
|   205 } |   205 } | 
|   206  |   206  | 
|   207 void SearchProviderTest::QueryForInput(const string16& text, |   207 void SearchProviderTest::QueryForInput(const string16& text, | 
|   208                                        const string16& desired_tld, |   208                                        const string16& desired_tld, | 
|   209                                        bool prevent_inline_autocomplete) { |   209                                        bool prevent_inline_autocomplete) { | 
|   210   // Start a query. |   210   // Start a query. | 
|   211   AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, |   211   AutocompleteInput input(text, string16::npos, desired_tld, | 
 |   212                           prevent_inline_autocomplete, | 
|   212                           false, true, AutocompleteInput::ALL_MATCHES); |   213                           false, true, AutocompleteInput::ALL_MATCHES); | 
|   213   provider_->Start(input, false); |   214   provider_->Start(input, false); | 
|   214  |   215  | 
|   215   // RunUntilIdle so that the task scheduled by SearchProvider to create the |   216   // RunUntilIdle so that the task scheduled by SearchProvider to create the | 
|   216   // URLFetchers runs. |   217   // URLFetchers runs. | 
|   217   message_loop_.RunUntilIdle(); |   218   message_loop_.RunUntilIdle(); | 
|   218 } |   219 } | 
|   219  |   220  | 
|   220 void SearchProviderTest::QueryForInputAndSetWYTMatch( |   221 void SearchProviderTest::QueryForInputAndSetWYTMatch( | 
|   221     const string16& text, |   222     const string16& text, | 
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   683 } |   684 } | 
|   684  |   685  | 
|   685 // Verifies AutocompleteControllers sets descriptions for results correctly. |   686 // Verifies AutocompleteControllers sets descriptions for results correctly. | 
|   686 TEST_F(SearchProviderTest, UpdateKeywordDescriptions) { |   687 TEST_F(SearchProviderTest, UpdateKeywordDescriptions) { | 
|   687   // Add an entry that corresponds to a keyword search with 'term2'. |   688   // Add an entry that corresponds to a keyword search with 'term2'. | 
|   688   AddSearchToHistory(keyword_t_url_, ASCIIToUTF16("term2"), 1); |   689   AddSearchToHistory(keyword_t_url_, ASCIIToUTF16("term2"), 1); | 
|   689   profile_.BlockUntilHistoryProcessesPendingRequests(); |   690   profile_.BlockUntilHistoryProcessesPendingRequests(); | 
|   690  |   691  | 
|   691   AutocompleteController controller(&profile_, NULL, |   692   AutocompleteController controller(&profile_, NULL, | 
|   692       AutocompleteProvider::TYPE_SEARCH); |   693       AutocompleteProvider::TYPE_SEARCH); | 
|   693   controller.Start(ASCIIToUTF16("k t"), string16(), false, false, true, |   694   controller.Start(AutocompleteInput( | 
|   694                    AutocompleteInput::ALL_MATCHES); |   695       ASCIIToUTF16("k t"), string16::npos, string16(), false, false, true, | 
 |   696       AutocompleteInput::ALL_MATCHES)); | 
|   695   const AutocompleteResult& result = controller.result(); |   697   const AutocompleteResult& result = controller.result(); | 
|   696  |   698  | 
|   697   // There should be two matches, one for the keyword one for what you typed. |   699   // There should be two matches, one for the keyword one for what you typed. | 
|   698   ASSERT_EQ(2u, result.size()); |   700   ASSERT_EQ(2u, result.size()); | 
|   699  |   701  | 
|   700   EXPECT_FALSE(result.match_at(0).keyword.empty()); |   702   EXPECT_FALSE(result.match_at(0).keyword.empty()); | 
|   701   EXPECT_FALSE(result.match_at(1).keyword.empty()); |   703   EXPECT_FALSE(result.match_at(1).keyword.empty()); | 
|   702   EXPECT_NE(result.match_at(0).keyword, result.match_at(1).keyword); |   704   EXPECT_NE(result.match_at(0).keyword, result.match_at(1).keyword); | 
|   703  |   705  | 
|   704   EXPECT_FALSE(result.match_at(0).description.empty()); |   706   EXPECT_FALSE(result.match_at(0).description.empty()); | 
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1268   EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |  1270   EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 
|  1269             match.contents_class[0].style); |  1271             match.contents_class[0].style); | 
|  1270   EXPECT_EQ(4U, match.contents_class[1].offset); |  1272   EXPECT_EQ(4U, match.contents_class[1].offset); | 
|  1271   EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | |  1273   EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | | 
|  1272             AutocompleteMatch::ACMatchClassification::MATCH, |  1274             AutocompleteMatch::ACMatchClassification::MATCH, | 
|  1273             match.contents_class[1].style); |  1275             match.contents_class[1].style); | 
|  1274   EXPECT_EQ(5U, match.contents_class[2].offset); |  1276   EXPECT_EQ(5U, match.contents_class[2].offset); | 
|  1275   EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |  1277   EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 
|  1276             match.contents_class[2].style); |  1278             match.contents_class[2].style); | 
|  1277 } |  1279 } | 
| OLD | NEW |